1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "distributed_sched_continuation_test.h"
17 #include "distributed_sched_util.h"
18 #include "dtbschedmgr_device_info_storage.h"
19 #include "ipc_skeleton.h"
20 #include "mock_distributed_sched.h"
21 #include "mock_remote_stub.h"
22
23 using namespace testing;
24 using namespace testing::ext;
25 using namespace OHOS::AAFwk;
26 using namespace OHOS::AppExecFwk;
27 using namespace OHOS::DistributedHardware;
28 using string = std::string;
29
30 namespace OHOS {
31 namespace DistributedSchedule {
32 namespace {
33 const std::u16string MOCK_DEVICE_ID = u"MOCK_DEVICE_ID";
34 constexpr int32_t MOCK_SESSION_ID = 123;
35 constexpr int32_t MOCK_TASK_ID = 456;
36 const string LOCAL_DEVICE_ID = "192.168.43.100";
37 constexpr int32_t REQUEST_CODE_ERR = 305;
38 }
39
SetUpTestCase()40 void DSchedContinuationTest::SetUpTestCase()
41 {
42 const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
43 std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
44 DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
45 }
46
TearDownTestCase()47 void DSchedContinuationTest::TearDownTestCase()
48 {
49 }
50
SetUp()51 void DSchedContinuationTest::SetUp()
52 {
53 DistributedSchedUtil::MockPermission();
54 dschedContinuation_ = std::make_shared<DSchedContinuation>();
55 }
56
TearDown()57 void DSchedContinuationTest::TearDown()
58 {
59 dschedContinuation_ = nullptr;
60 }
61
OnRemoteDied()62 void DSchedContinuationTest::DeviceInitCallBack::OnRemoteDied()
63 {
64 }
65
GetDSchedService() const66 sptr<IRemoteObject> DSchedContinuationTest::GetDSchedService() const
67 {
68 sptr<IRemoteObject> dsched = new MockDistributedSched();
69 return dsched;
70 }
71
PushAbilityToken()72 int32_t DSchedContinuationTest::PushAbilityToken()
73 {
74 FuncContinuationCallback continuationCallback = [this] (int32_t missionId) {
75 timeoutFlag_ = true;
76 };
77 dschedContinuation_->Init(continuationCallback);
78 int32_t sessionId = dschedContinuation_->GenerateSessionId();
79 dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
80 return sessionId;
81 }
82
MockWant(const string & bundleName,const string & ability,int32_t flags)83 std::shared_ptr<Want> DSchedContinuationTest::MockWant(const string& bundleName, const string& ability, int32_t flags)
84 {
85 ElementName element("", bundleName, ability);
86 std::shared_ptr<Want> spWant = std::make_shared<Want>();
87 spWant->SetElement(element);
88 spWant->SetFlags(flags);
89 return spWant;
90 }
91
GetDms()92 sptr<IDistributedSched> DSchedContinuationTest::GetDms()
93 {
94 if (proxy_ != nullptr) {
95 return proxy_;
96 }
97 auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
98 EXPECT_TRUE(sm != nullptr);
99 if (sm == nullptr) {
100 DTEST_LOG << "DSchedContinuationTest sm is nullptr" << std::endl;
101 return nullptr;
102 }
103 DTEST_LOG << "DSchedContinuationTest sm is not nullptr" << std::endl;
104 auto distributedObject = sm->GetSystemAbility(DISTRIBUTED_SCHED_SA_ID);
105 EXPECT_TRUE(distributedObject != nullptr);
106 proxy_ = iface_cast<IDistributedSched>(distributedObject);
107 if (proxy_ == nullptr) {
108 DTEST_LOG << "DSchedContinuationTest DistributedSched is nullptr" << std::endl;
109 }
110 DTEST_LOG << "DSchedContinuationTest DistributedSched is not nullptr" << std::endl;
111 return proxy_;
112 }
113
StartContinuation(int32_t missionId,int32_t flags)114 int32_t DSchedContinuationTest::StartContinuation(int32_t missionId, int32_t flags)
115 {
116 string bundleName = "bundleName";
117 string abilityName = "abilityName";
118 string devId = "devId";
119 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, flags);
120 int callerUid = 0;
121 return DistributedSchedService::GetInstance().StartContinuation(*spWant, missionId, callerUid, 0, 0);
122 }
123
StartRemoteFreeInstall(int32_t flags,const sptr<IRemoteObject> & callback)124 int32_t DSchedContinuationTest::StartRemoteFreeInstall(int32_t flags, const sptr<IRemoteObject>& callback)
125 {
126 string bundleName = "bundleName";
127 string abilityName = "abilityName";
128 string devId = "devId";
129 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, flags);
130 int callerUid = 0;
131 return DistributedSchedService::GetInstance().StartRemoteFreeInstall(*spWant, callerUid, 0, 0, callback);
132 }
133
134 /**
135 * @tc.name: StartContinuation_001
136 * @tc.desc: input invalid params.
137 * @tc.type: FUNC
138 */
139 HWTEST_F(DSchedContinuationTest, StartContinuation_001, TestSize.Level1)
140 {
141 DTEST_LOG << "DSchedContinuationTest StartContinuation_001 start" << std::endl;
142 /**
143 * @tc.steps: step1. want not set continuation flags.
144 * @tc.expected: step1. return false.
145 */
146 int32_t ret = StartContinuation(0, 0);
147 EXPECT_TRUE(ret != ERR_OK);
148 DTEST_LOG << "DSchedContinuationTest StartContinuation002 end" << std::endl;
149 }
150
151 /**
152 * @tc.name: StartContinuation_002
153 * @tc.desc: get remote dms failed.
154 * @tc.type: FUNC
155 */
156 HWTEST_F(DSchedContinuationTest, StartContinuation_002, TestSize.Level1)
157 {
158 DTEST_LOG << "DSchedContinuationTest StartContinuation_002 start" << std::endl;
159 /**
160 * @tc.steps: step1. get remote dms failed.
161 * @tc.expected: step1. return false.
162 */
163 int32_t ret = StartContinuation(0, Want::FLAG_ABILITY_CONTINUATION);
164 EXPECT_TRUE(ret != ERR_OK);
165 DTEST_LOG << "DSchedContinuationTest StartContinuation003 end" << std::endl;
166 }
167
168 /**
169 * @tc.name: StartContinuation_003
170 * @tc.desc: call StartContinuation
171 * @tc.type: FUNC
172 */
173 HWTEST_F(DSchedContinuationTest, StartContinuation_003, TestSize.Level1)
174 {
175 DTEST_LOG << "DSchedContinuationTest StartContinuation_003 start" << std::endl;
176 if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) {
177 DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
178 }
179 std::string bundleName = "bundleName";
180 std::string abilityName = "abilityName";
181 int32_t flags = Want::FLAG_ABILITY_CONTINUATION;
182 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, flags);
183 int32_t missionId = 0;
184 auto callback = GetDSchedService();
185 std::string deviceId = "123456";
186 DistributedSchedService::GetInstance().dschedContinuation_->PushCallback(missionId, callback, deviceId, false);
187 int32_t status = ERR_OK;
188 int32_t uid = IPCSkeleton::GetCallingUid();
189 int32_t accessToken = IPCSkeleton::GetCallingTokenID();
190 int32_t ret = DistributedSchedService::GetInstance().StartContinuation(*spWant,
191 missionId, uid, status, accessToken);
192 EXPECT_TRUE(ret != ERR_OK);
193 DTEST_LOG << "DSchedContinuationTest StartContinuation_003 end" << std::endl;
194 }
195
196 /**
197 * @tc.name: StartContinuation_004
198 * @tc.desc: call StartContinuation
199 * @tc.type: FUNC
200 */
201 HWTEST_F(DSchedContinuationTest, StartContinuation_004, TestSize.Level1)
202 {
203 DTEST_LOG << "DSchedContinuationTest StartContinuation_004 start" << std::endl;
204 if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) {
205 DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
206 }
207 std::string bundleName = "bundleName";
208 std::string abilityName = "abilityName";
209 int32_t flags = Want::FLAG_ABILITY_CONTINUATION;
210 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, flags);
211 int32_t missionId = 0;
212 auto callback = GetDSchedService();
213 std::string deviceId = "123456";
214 DistributedSchedService::GetInstance().dschedContinuation_->PushCallback(missionId, callback, deviceId, true);
215 int32_t status = ERR_OK;
216 int32_t uid = IPCSkeleton::GetCallingUid();
217 int32_t accessToken = IPCSkeleton::GetCallingTokenID();
218 int32_t ret = DistributedSchedService::GetInstance().StartContinuation(*spWant,
219 missionId, uid, status, accessToken);
220 EXPECT_TRUE(ret != ERR_OK);
221 DTEST_LOG << "DSchedContinuationTest StartContinuation_004 end" << std::endl;
222 }
223
224 /**
225 * @tc.name: NotifyCompleteContinuation_001
226 * @tc.desc: input invalid session.
227 * @tc.type: FUNC
228 */
229 HWTEST_F(DSchedContinuationTest, NotifyCompleteContinuation_001, TestSize.Level1)
230 {
231 DTEST_LOG << "DSchedContinuationTest NotifyCompleteContinuation_001 start" << std::endl;
232 /**
233 * @tc.steps: step1. input invalid session.
234 * @tc.expected: step1. return false.
235 */
236 DistributedSchedService::GetInstance().NotifyCompleteContinuation(MOCK_DEVICE_ID, -1, true);
237 EXPECT_TRUE(!timeoutFlag_);
238 DTEST_LOG << "DSchedContinuationTest NotifyCompleteContinuation_001 end" << std::endl;
239 }
240
241 /**
242 * @tc.name: NotifyCompleteContinuation_002
243 * @tc.desc: get remote dms failed.
244 * @tc.type: FUNC
245 */
246 HWTEST_F(DSchedContinuationTest, NotifyCompleteContinuation_002, TestSize.Level1)
247 {
248 DTEST_LOG << "DSchedContinuationTest NotifyCompleteContinuation_002 start" << std::endl;
249 /**
250 * @tc.steps: step1. get remote dms failed.
251 * @tc.expected: step1. return false.
252 */
253 DistributedSchedService::GetInstance().NotifyCompleteContinuation(MOCK_DEVICE_ID, MOCK_SESSION_ID, true);
254 EXPECT_TRUE(!timeoutFlag_);
255 DTEST_LOG << "DSchedContinuationTest NotifyCompleteContinuation_002 end" << std::endl;
256 }
257
258 /**
259 * @tc.name: NotifyContinuationResultFromRemote_001
260 * @tc.desc: input invalid session.
261 * @tc.type: FUNC
262 */
263 HWTEST_F(DSchedContinuationTest, NotifyContinuationResultFromRemote_001, TestSize.Level1)
264 {
265 DTEST_LOG << "DSchedContinuationTest NotifyContinuationResultFromRemote_001 start" << std::endl;
266 /**
267 * @tc.steps: step1. input invalid session.
268 * @tc.expected: step1. return false.
269 */
270 DistributedSchedService::GetInstance().NotifyContinuationResultFromRemote(-1, true);
271 EXPECT_TRUE(!timeoutFlag_);
272 DTEST_LOG << "DSchedContinuationTest NotifyContinuationResultFromRemote_001 end" << std::endl;
273 }
274
275 /**
276 * @tc.name: NotifyContinuationResultFromRemote_002
277 * @tc.desc: get remote dms failed.
278 * @tc.type: FUNC
279 */
280 HWTEST_F(DSchedContinuationTest, NotifyContinuationResultFromRemote_002, TestSize.Level1)
281 {
282 DTEST_LOG << "DSchedContinuationTest NotifyContinuationResultFromRemote_002 start" << std::endl;
283 /**
284 * @tc.steps: step1. get remote dms failed.
285 * @tc.expected: step1. return false.
286 */
287 DistributedSchedService::GetInstance().NotifyContinuationResultFromRemote(MOCK_SESSION_ID, true);
288 EXPECT_TRUE(!timeoutFlag_);
289 DTEST_LOG << "DSchedContinuationTest NotifyContinuationResultFromRemote_002 end" << std::endl;
290 }
291
292 /**
293 * @tc.name: SetWantForContinuation_001
294 * @tc.desc: input invalid params.
295 * @tc.type: FUNC
296 */
297 HWTEST_F(DSchedContinuationTest, SetWantForContinuation_001, TestSize.Level1)
298 {
299 DTEST_LOG << "DSchedContinuationTest SetWantForContinuation_001 start" << std::endl;
300 /**
301 * @tc.steps: step1. input invalid bundleName.
302 * @tc.expected: step1. return err.
303 */
304 string bundleName = "bundleName";
305 string abilityName = "abilityName";
306 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
307 int32_t missionId = 0;
308 int32_t ret = DistributedSchedService::GetInstance().SetWantForContinuation(*spWant, missionId);
309 EXPECT_TRUE(INVALID_PARAMETERS_ERR == ret);
310 DTEST_LOG << "DSchedContinuationTest SetWantForContinuation_001 end" << std::endl;
311 }
312
313 /**
314 * @tc.name: SetWantForContinuation_002
315 * @tc.desc: input valid params.
316 * @tc.type: FUNC
317 */
318 HWTEST_F(DSchedContinuationTest, SetWantForContinuation_002, TestSize.Level1)
319 {
320 DTEST_LOG << "DSchedContinuationTest SetWantForContinuation_002 start" << std::endl;
321 /**
322 * @tc.steps: step1. input valid bundleName.
323 * @tc.expected: step1. return OK.
324 */
325 string bundleName = "ohos.samples.distributedcalc";
326 string abilityName = "MainAbility";
327 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
328 int32_t missionId = 0;
329 int32_t ret = DistributedSchedService::GetInstance().SetWantForContinuation(*spWant, missionId);
330 EXPECT_TRUE(ERR_OK == ret);
331 DTEST_LOG << "DSchedContinuationTest SetWantForContinuation_002 end" << std::endl;
332 }
333
334 /**
335 * @tc.name: ContinueLocalMission_001
336 * @tc.desc: input invalid params.
337 * @tc.type: FUNC
338 */
339 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_001, TestSize.Level1)
340 {
341 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_001 start" << std::endl;
342 /**
343 * @tc.steps: step1. input invalid missionId.
344 * @tc.expected: step1. return err.
345 */
346 string deviceId = "123456";
347 int32_t missionId = 0;
348 auto callback = GetDSchedService();
349 WantParams wantParams;
350 int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(deviceId,
351 missionId, callback, wantParams);
352 EXPECT_NE(ret, ERR_OK);
353 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_001 end" << std::endl;
354 }
355
356 /**
357 * @tc.name: ContinueLocalMission_002
358 * @tc.desc: input invalid params.
359 * @tc.type: FUNC
360 */
361 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_002, TestSize.Level1)
362 {
363 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_002 start" << std::endl;
364 /**
365 * @tc.steps: step1. input invalid mission.
366 * @tc.expected: step1. return err.
367 */
368 string deviceId = "123456";
369 int32_t missionId = 0;
370 auto callback = GetDSchedService();
371 WantParams wantParams;
372 DistributedSchedService::GetInstance().OnStart();
373 if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) {
374 return;
375 }
376 DistributedSchedService::GetInstance().dschedContinuation_->PushCallback(missionId, callback, deviceId, false);
377 int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(
378 deviceId, missionId, callback, wantParams);
379 EXPECT_EQ(CONTINUE_ALREADY_IN_PROGRESS, ret);
380 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_002 end" << std::endl;
381 }
382
383 /**
384 * @tc.name: ContinueLocalMission_003
385 * @tc.desc: input invalid params.
386 * @tc.type: FUNC
387 * @tc.require: I5RWKZ
388 */
389 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_003, TestSize.Level1)
390 {
391 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_003 start" << std::endl;
392 string deviceId = "123456";
393 int32_t missionId = -1;
394 auto callback = GetDSchedService();
395 WantParams wantParams;
396 DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
397 int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(
398 deviceId, missionId, callback, wantParams);
399 EXPECT_NE(ret, ERR_OK);
400 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_003 end" << std::endl;
401 }
402
403 /**
404 * @tc.name: ContinueLocalMission_004
405 * @tc.desc: input invalid params.
406 * @tc.type: FUNC
407 * @tc.require: I5RWKZ
408 */
409 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_004, TestSize.Level1)
410 {
411 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_004 start" << std::endl;
412 string deviceId;
413 int32_t missionId = -1;
414 auto callback = GetDSchedService();
415 WantParams wantParams;
416 DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
417 int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(
418 deviceId, missionId, callback, wantParams);
419 EXPECT_NE(ret, ERR_OK);
420 DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_004 end" << std::endl;
421 }
422
423 /**
424 * @tc.name: ContinueRemoteMission_001
425 * @tc.desc: input invalid params.
426 * @tc.type: FUNC
427 */
428 HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_001, TestSize.Level1)
429 {
430 DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_001 start" << std::endl;
431 /**
432 * @tc.steps: step1. input invalid deviceId.
433 * @tc.expected: step1. return err.
434 */
435 string srcDeviceId = "123456";
436 string dstDeviceid = "123456";
437 int32_t missionId = 0;
438 auto callback = GetDSchedService();
439 WantParams wantParams;
440 int32_t ret = DistributedSchedService::GetInstance().ContinueRemoteMission(
441 srcDeviceId, dstDeviceid, missionId, callback, wantParams);
442 EXPECT_TRUE(INVALID_REMOTE_PARAMETERS_ERR == ret);
443 DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_001 end" << std::endl;
444 }
445
446 /**
447 * @tc.name: ContinueRemoteMission_002
448 * @tc.desc: input invalid params.
449 * @tc.type: FUNC
450 */
451 HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_002, TestSize.Level1)
452 {
453 DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_002 start" << std::endl;
454 /**
455 * @tc.steps: step1. input invalid param.
456 * @tc.expected: step1. return err.
457 */
458 string srcDeviceId;
459 DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
460 string dstDeviceid = "123456";
461 int32_t missionId = 0;
462 auto callback = GetDSchedService();
463 WantParams wantParams;
464 int32_t ret = DistributedSchedService::GetInstance().ContinueRemoteMission(
465 srcDeviceId, dstDeviceid, missionId, callback, wantParams);
466 EXPECT_TRUE(ERR_OK != ret);
467 DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_002 end" << std::endl;
468 }
469
470 /**
471 * @tc.name: PushAbilityToken_001
472 * @tc.desc: input invalid params.
473 * @tc.type: FUNC
474 */
475 HWTEST_F(DSchedContinuationTest, PushAbilityToken_001, TestSize.Level1)
476 {
477 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_001 start" << std::endl;
478 /**
479 * @tc.steps: step1. input invalid abilityToken.
480 * @tc.expected: step1. return false.
481 */
482 auto sessionId = dschedContinuation_->GenerateSessionId();
483 bool ret = dschedContinuation_->PushAbilityToken(sessionId, nullptr);
484 EXPECT_TRUE(!ret);
485 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_001 end" << std::endl;
486 }
487
488 /**
489 * @tc.name: PushAbilityToken_002
490 * @tc.desc: input invalid params.
491 * @tc.type: FUNC
492 */
493 HWTEST_F(DSchedContinuationTest, PushAbilityToken_002, TestSize.Level1)
494 {
495 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_002 start" << std::endl;
496 /**
497 * @tc.steps: step1. input invalid sessionId.
498 * @tc.expected: step1. return false.
499 */
500 bool ret = dschedContinuation_->PushAbilityToken(-1, GetDSchedService());
501 EXPECT_TRUE(!ret);
502 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_002 end" << std::endl;
503 }
504
505 /**
506 * @tc.name: PushAbilityToken_003
507 * @tc.desc: init not call.
508 * @tc.type: FUNC
509 */
510 HWTEST_F(DSchedContinuationTest, PushAbilityToken_003, TestSize.Level1)
511 {
512 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_003 start" << std::endl;
513 /**
514 * @tc.steps: step1. input valid abilityToken and valid sessionId.
515 * @tc.expected: step1. return false.
516 */
517 auto sessionId = dschedContinuation_->GenerateSessionId();
518 bool ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
519 EXPECT_TRUE(!ret);
520 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_003 end" << std::endl;
521 }
522
523 /**
524 * @tc.name: PushAbilityToken_004
525 * @tc.desc: Push AbilityToken OK.
526 * @tc.type: FUNC
527 */
528 HWTEST_F(DSchedContinuationTest, PushAbilityToken_004, TestSize.Level1)
529 {
530 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_004 start" << std::endl;
531 /**
532 * @tc.steps: step1. input valid params and init.
533 * @tc.expected: step1. return true.
534 */
535 dschedContinuation_->Init(nullptr);
536 auto sessionId = dschedContinuation_->GenerateSessionId();
537 bool ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
538 EXPECT_TRUE(ret);
539 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_004 end" << std::endl;
540 }
541
542 /**
543 * @tc.name: PushAbilityToken_005
544 * @tc.desc: AbilityToken is exist.
545 * @tc.type: FUNC
546 * @tc.require: I60TOK
547 */
548 HWTEST_F(DSchedContinuationTest, PushAbilityToken_005, TestSize.Level1)
549 {
550 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_005 start" << std::endl;
551 dschedContinuation_->Init(nullptr);
552 auto sessionId = 1;
553 bool ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
554 ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
555 EXPECT_EQ(ret, false);
556 DTEST_LOG << "DSchedContinuationTest PushAbilityToken_005 end" << std::endl;
557 }
558
559 /**
560 * @tc.name: PopAbilityToken_001
561 * @tc.desc: input invalid params.
562 * @tc.type: FUNC
563 */
564 HWTEST_F(DSchedContinuationTest, PopAbilityToken_001, TestSize.Level1)
565 {
566 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_001 start" << std::endl;
567 /**
568 * @tc.steps: step1. input invalid sessionId.
569 * @tc.expected: step1. return false.
570 */
571 sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(-1);
572 EXPECT_TRUE(abilityToken == nullptr);
573 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_001 end" << std::endl;
574 }
575
576 /**
577 * @tc.name: PopAbilityToken_002
578 * @tc.desc: input invalid params.
579 * @tc.type: FUNC
580 */
581 HWTEST_F(DSchedContinuationTest, PopAbilityToken_002, TestSize.Level1)
582 {
583 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_002 start" << std::endl;
584 /**
585 * @tc.steps: step1. pop not exist sessionId.
586 * @tc.expected: step1. return false.
587 */
588 int32_t sessionId = dschedContinuation_->GenerateSessionId() + 1;
589 sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
590 EXPECT_TRUE(abilityToken == nullptr);
591 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_002 end" << std::endl;
592 }
593
594 /**
595 * @tc.name: PopAbilityToken_003
596 * @tc.desc: pop abilityToken success.
597 * @tc.type: FUNC
598 */
599 HWTEST_F(DSchedContinuationTest, PopAbilityToken_003, TestSize.Level1)
600 {
601 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_003 start" << std::endl;
602 /**
603 * @tc.steps: step1. pop exist sessionId.
604 * @tc.expected: step1. return true.
605 */
606 int32_t sessionId = PushAbilityToken();
607 sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
608 EXPECT_TRUE(abilityToken != nullptr);
609
610 /**
611 * @tc.steps: step2. duplicate pop abilityToken.
612 * @tc.expected: step1. return false.
613 */
614 abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
615 EXPECT_TRUE(abilityToken == nullptr);
616 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_003 end" << std::endl;
617 }
618
619 /**
620 * @tc.name: PopAbilityToken_004
621 * @tc.desc: pop abilityToken success.
622 * @tc.type: FUNC
623 * @tc.require: I60TOK
624 */
625 HWTEST_F(DSchedContinuationTest, PopAbilityToken_004, TestSize.Level1)
626 {
627 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_004 start" << std::endl;
628 dschedContinuation_->continuationHandler_ = nullptr;
629
630 int32_t sessionId = PushAbilityToken();
631 sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
632 EXPECT_TRUE(abilityToken != nullptr);
633 DTEST_LOG << "DSchedContinuationTest PopAbilityToken_004 end" << std::endl;
634 }
635
636 /**
637 * @tc.name: GenerateSessionId_001
638 * @tc.desc: test GenerateSessionId when currSessionId is less than zero.
639 * @tc.type: FUNC
640 * @tc.require: I60TOK
641 */
642 HWTEST_F(DSchedContinuationTest, GenerateSessionId_001, TestSize.Level4)
643 {
644 DTEST_LOG << "DSchedContinuationTest GenerateSessionId_001 start" << std::endl;
645 int32_t sessionId = dschedContinuation_->currSessionId_;
646 dschedContinuation_->currSessionId_ = -100;
647 dschedContinuation_->GenerateSessionId();
648 EXPECT_EQ(dschedContinuation_->currSessionId_, 1);
649 dschedContinuation_->currSessionId_ = sessionId;
650 DTEST_LOG << "DSchedContinuationTest GenerateSessionId_001 end" << std::endl;
651 }
652
653 /**
654 * @tc.name: SetTimeOut_001
655 * @tc.desc: test SetTimeOut.
656 * @tc.type: FUNC
657 * @tc.require: I60TOK
658 */
659 HWTEST_F(DSchedContinuationTest, SetTimeOut_001, TestSize.Level3)
660 {
661 DTEST_LOG << "DSchedContinuationTest SetTimeOut_001 start" << std::endl;
662 dschedContinuation_->Init(nullptr);
663
664 int32_t missionId = 0;
665 int32_t timeout = 1000;
666 dschedContinuation_->SetTimeOut(missionId, timeout);
667 EXPECT_NE(dschedContinuation_->continuationHandler_, nullptr);
668 DTEST_LOG << "DSchedContinuationTest SetTimeOut_001 end" << std::endl;
669 }
670
671 /**
672 * @tc.name: RemoveTimeOut_001
673 * @tc.desc: test RemoveTimeOut.
674 * @tc.type: FUNC
675 * @tc.require: I60TOK
676 */
677 HWTEST_F(DSchedContinuationTest, RemoveTimeOut_001, TestSize.Level3)
678 {
679 DTEST_LOG << "DSchedContinuationTest RemoveTimeOut_001 start" << std::endl;
680 dschedContinuation_->Init(nullptr);
681
682 int32_t missionId = 0;
683 int32_t timeout = 1000;
684 dschedContinuation_->SetTimeOut(missionId, timeout);
685 EXPECT_NE(dschedContinuation_->continuationHandler_, nullptr);
686 DTEST_LOG << "DSchedContinuationTest RemoveTimeOut_001 end" << std::endl;
687 }
688
689 /**
690 * @tc.name: GetTargetDevice_001
691 * @tc.desc: test GetTargetDevice.
692 * @tc.type: FUNC
693 * @tc.require: I60TOK
694 */
695 HWTEST_F(DSchedContinuationTest, GetTargetDevice_001, TestSize.Level3)
696 {
697 DTEST_LOG << "DSchedContinuationTest GetTargetDevice_001 start" << std::endl;
698 dschedContinuation_->Init(nullptr);
699
700 int32_t missionId = 0;
701 std::string mockDevice = "mockDevice";
702 dschedContinuation_->continuationDevices_[missionId] = mockDevice;
703 std::string result = dschedContinuation_->GetTargetDevice(missionId);
704 EXPECT_EQ(result, mockDevice);
705 DTEST_LOG << "DSchedContinuationTest GetTargetDevice_001 end" << std::endl;
706 }
707
708 /**
709 * @tc.name: PushCallback_001
710 * @tc.desc: test PushCallback when callback is nullptr.
711 * @tc.type: FUNC
712 * @tc.require: I60TOK
713 */
714 HWTEST_F(DSchedContinuationTest, PushCallback_001, TestSize.Level3)
715 {
716 DTEST_LOG << "DSchedContinuationTest PushCallback_001 start" << std::endl;
717 dschedContinuation_->Init(nullptr);
718
719 int32_t missionId = 0;
720 const sptr<IRemoteObject> callback = nullptr;
721 std::string deviceId = "";
722 bool isFreeInstall = true;
723 bool result = dschedContinuation_->PushCallback(missionId, callback, deviceId, isFreeInstall);
724 EXPECT_EQ(result, false);
725 DTEST_LOG << "DSchedContinuationTest PushCallback_001 end" << std::endl;
726 }
727
728 /**
729 * @tc.name: PushCallback_002
730 * @tc.desc: test PushCallback when callback is exist.
731 * @tc.type: FUNC
732 * @tc.require: I60TOK
733 */
734 HWTEST_F(DSchedContinuationTest, PushCallback_002, TestSize.Level3)
735 {
736 DTEST_LOG << "DSchedContinuationTest PushCallback_002 start" << std::endl;
737 dschedContinuation_->Init(nullptr);
738
739 int32_t missionId = 0;
740 const sptr<IRemoteObject> callback = new MockRemoteStub();
741 std::string deviceId = "";
742 bool isFreeInstall = true;
743 dschedContinuation_->callbackMap_[missionId] = callback;
744 bool result = dschedContinuation_->PushCallback(missionId, callback, deviceId, isFreeInstall);
745 EXPECT_EQ(result, false);
746 DTEST_LOG << "DSchedContinuationTest PushCallback_002 end" << std::endl;
747 }
748
749 /**
750 * @tc.name: PushCallback_003
751 * @tc.desc: test PushCallback when isFreeInstall is true.
752 * @tc.type: FUNC
753 * @tc.require: I60TOK
754 */
755 HWTEST_F(DSchedContinuationTest, PushCallback_003, TestSize.Level3)
756 {
757 DTEST_LOG << "DSchedContinuationTest PushCallback_003 start" << std::endl;
758 dschedContinuation_->Init(nullptr);
759
760 int32_t missionId = 0;
761 const sptr<IRemoteObject> callback = new MockRemoteStub();
762 std::string deviceId = "";
763 bool isFreeInstall = true;
764 dschedContinuation_->callbackMap_.clear();
765 bool result = dschedContinuation_->PushCallback(missionId, callback, deviceId, isFreeInstall);
766 EXPECT_EQ(result, true);
767 DTEST_LOG << "DSchedContinuationTest PushCallback_003 end" << std::endl;
768 }
769
770 /**
771 * @tc.name: ContinueMission_001
772 * @tc.desc: test ContinueMission when srcDeviceId is empty.
773 * @tc.type: FUNC
774 */
775 HWTEST_F(DSchedContinuationTest, ContinueMission_001, TestSize.Level1)
776 {
777 DTEST_LOG << "DSchedContinuationTest ContinueMission_001 start" << std::endl;
778 WantParams wantParams;
779 int32_t ret = DistributedSchedService::GetInstance().ContinueMission("",
780 "string", 1, GetDSchedService(), wantParams);
781 EXPECT_TRUE(ret != ERR_OK);
782 DTEST_LOG << "DSchedContinuationTest ContinueMission_001 end" << std::endl;
783 }
784
785 /**
786 * @tc.name: ContinueMission_002
787 * @tc.desc: test ContinueMission when dstDeviceId is empty.
788 * @tc.type: FUNC
789 */
790 HWTEST_F(DSchedContinuationTest, ContinueMission_002, TestSize.Level1)
791 {
792 DTEST_LOG << "DSchedContinuationTest ContinueMission_002 start" << std::endl;
793 WantParams wantParams;
794 int32_t ret = DistributedSchedService::GetInstance().ContinueMission("string",
795 "", 1, GetDSchedService(), wantParams);
796 EXPECT_TRUE(ret != ERR_OK);
797 DTEST_LOG << "DSchedContinuationTest ContinueMission_002 end" << std::endl;
798 }
799
800 /**
801 * @tc.name: ContinueMission_003
802 * @tc.desc: test ContinueMission when callback is nullptr.
803 * @tc.type: FUNC
804 */
805 HWTEST_F(DSchedContinuationTest, ContinueMission_003, TestSize.Level1)
806 {
807 DTEST_LOG << "DSchedContinuationTest ContinueMission_003 start" << std::endl;
808 WantParams wantParams;
809 int32_t ret = DistributedSchedService::GetInstance().ContinueMission("string", "string", 1, nullptr, wantParams);
810 EXPECT_TRUE(ret != ERR_OK);
811 DTEST_LOG << "DSchedContinuationTest ContinueMission_003 end" << std::endl;
812 }
813
814 /**
815 * @tc.name: ContinueMission_004
816 * @tc.desc: test ContinueMission when srcDeviceId == localDevId.
817 * @tc.type: FUNC
818 */
819 HWTEST_F(DSchedContinuationTest, ContinueMission_004, TestSize.Level1)
820 {
821 DTEST_LOG << "DSchedContinuationTest ContinueMission_004 start" << std::endl;
822 WantParams wantParams;
823
824 std::string srcDeviceId;
825 DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
826 int32_t ret = DistributedSchedService::GetInstance().ContinueMission(srcDeviceId,
827 "string", -1, GetDSchedService(), wantParams);
828 EXPECT_TRUE(ret != ERR_OK);
829 DTEST_LOG << "DSchedContinuationTest ContinueMission_004 end" << std::endl;
830 }
831
832 /**
833 * @tc.name: StartRemoteFreeInstall_001
834 * @tc.desc: input invalid params.
835 * @tc.type: FUNC
836 */
837 HWTEST_F(DSchedContinuationTest, StartRemoteFreeInstall_001, TestSize.Level1)
838 {
839 DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_001 start" << std::endl;
840 /**
841 * @tc.steps: step1. want not set continuation flags.
842 * @tc.expected: step1. return false.
843 */
844 int32_t ret = StartRemoteFreeInstall(0, GetDSchedService());
845 EXPECT_TRUE(ret != ERR_OK);
846 DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_001 end" << std::endl;
847 }
848
849 /**
850 * @tc.name: StartRemoteFreeInstall_002
851 * @tc.desc: get remote dms failed.
852 * @tc.type: FUNC
853 */
854 HWTEST_F(DSchedContinuationTest, StartRemoteFreeInstall_002, TestSize.Level1)
855 {
856 DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_002 start" << std::endl;
857 /**
858 * @tc.steps: step1. get remote dms failed.
859 * @tc.expected: step1. return false.
860 */
861 int32_t ret = StartRemoteFreeInstall(Want::FLAG_ABILITY_CONTINUATION, GetDSchedService());
862 EXPECT_TRUE(ret != ERR_OK);
863 DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_002 end" << std::endl;
864 }
865
866 /**
867 * @tc.name: StartFreeInstallFromRemote_001
868 * @tc.desc: call StartFreeInstallFromRemote with illegal param
869 * @tc.type: FUNC
870 */
871 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_001, TestSize.Level0)
872 {
873 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_001 start" << std::endl;
874 sptr<IDistributedSched> proxy = GetDms();
875 if (proxy == nullptr) {
876 return;
877 }
878 AAFwk::Want want;
879 CallerInfo callerInfo;
880 callerInfo.uid = 0;
881 callerInfo.sourceDeviceId = "255.255.255.255";
882 IDistributedSched::AccountInfo accountInfo;
883 IDistributedSched::FreeInstallInfo info = {.want = want,
884 .requestCode = 0,
885 .callerInfo = callerInfo,
886 .accountInfo = accountInfo
887 };
888 /**
889 * @tc.steps: step1. StartFreeInstallFromRemote with uninitialized params
890 * @tc.expected: step1. StartFreeInstallFromRemote return INVALID_REMOTE_PARAMETERS_ERR
891 */
892 int result1 = proxy->StartFreeInstallFromRemote(info, 0);
893 DTEST_LOG << "result1:" << result1 << std::endl;
894 /**
895 * @tc.steps: step1. StartFreeInstallFromRemote with with empty deviceId
896 * @tc.expected: step1. StartFreeInstallFromRemote return INVALID_REMOTE_PARAMETERS_ERR
897 */
898 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
899 "com.ohos.distributedmusicplayer.MainAbility");
900 want.SetElement(element);
901 int result2 = proxy->StartFreeInstallFromRemote(info, 0);
902 DTEST_LOG << "result2:" << result2 << std::endl;
903 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_001 end" << std::endl;
904 }
905
906 /**
907 * @tc.name: StartFreeInstallFromRemote_002
908 * @tc.desc: call StartFreeInstallFromRemote
909 * @tc.type: FUNC
910 */
911 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_002, TestSize.Level1)
912 {
913 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_002 start" << std::endl;
914 sptr<IDistributedSched> proxy = GetDms();
915 if (proxy == nullptr) {
916 return;
917 }
918
919 AAFwk::Want want;
920 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
921 "com.ohos.distributedmusicplayer.MainAbility");
922 want.SetElement(element);
923 CallerInfo callerInfo;
924 callerInfo.uid = 0;
925 callerInfo.sourceDeviceId = "255.255.255.255";
926 IDistributedSched::AccountInfo accountInfo;
927 IDistributedSched::FreeInstallInfo info = {.want = want,
928 .requestCode = 0,
929 .callerInfo = callerInfo,
930 .accountInfo = accountInfo
931 };
932
933 int result1 = proxy->StartFreeInstallFromRemote(info, 0);
934 DTEST_LOG << "result1 is" << result1 << std::endl;
935
936 AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
937 "com.ohos.distributedmusicplayer.MainAbilityService");
938 want.SetElement(element2);
939 int result2 = proxy->StartFreeInstallFromRemote(info, 0);
940 DTEST_LOG << "result2:" << result2 << std::endl;
941 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_002 end" << std::endl;
942 }
943
944 /**
945 * @tc.name: StartFreeInstallFromRemote_003
946 * @tc.desc: call StartFreeInstallFromRemote for pressure test
947 * @tc.type: FUNC
948 */
949 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_003, TestSize.Level1)
950 {
951 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_003 start" << std::endl;
952 sptr<IDistributedSched> proxy = GetDms();
953 if (proxy == nullptr) {
954 return;
955 }
956 /**
957 * @tc.steps: step1. set want and abilityInfo
958 */
959 AAFwk::Want want;
960 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
961 "com.ohos.distributedmusicplayer.MainAbility");
962 want.SetElement(element);
963 CallerInfo callerInfo;
964 callerInfo.uid = 0;
965 callerInfo.sourceDeviceId = "255.255.255.255";
966 IDistributedSched::AccountInfo accountInfo;
967 IDistributedSched::FreeInstallInfo info = {.want = want,
968 .requestCode = 0,
969 .callerInfo = callerInfo,
970 .accountInfo = accountInfo
971 };
972 /**
973 * @tc.steps: step2. StartFreeInstallFromRemote for pressure test
974 * @tc.expected: step2. StartFreeInstallFromRemote for result
975 */
976 for (int index = 0; index < static_cast<int32_t>(LoopTime::LOOP_TIME); index++) {
977 int result = proxy->StartFreeInstallFromRemote(info, 0);
978 DTEST_LOG << "pressure" + std::to_string(index) + " result is " << result << std::endl;
979 }
980 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_003 end" << std::endl;
981 }
982
983 /**
984 * @tc.name: StartFreeInstallFromRemote_004
985 * @tc.desc: call StartFreeInstallFromRemote with dms
986 * @tc.type: FUNC
987 */
988 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_004, TestSize.Level0)
989 {
990 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_004 start" << std::endl;
991 sptr<IDistributedSched> proxy = GetDms();
992
993 AAFwk::Want want;
994 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
995 "com.ohos.distributedmusicplayer.MainAbility");
996 want.SetElement(element);
997 CallerInfo callerInfo;
998 callerInfo.uid = 0;
999 callerInfo.sourceDeviceId = "255.255.255.255";
1000 IDistributedSched::AccountInfo accountInfo;
1001 IDistributedSched::FreeInstallInfo info = {.want = want,
1002 .requestCode = 0,
1003 .callerInfo = callerInfo,
1004 .accountInfo = accountInfo
1005 };
1006
1007 int result1 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1008 DTEST_LOG << "result1:" << result1 << std::endl;
1009
1010 AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
1011 "com.ohos.distributedmusicplayer.MainAbilityService");
1012 want.SetElement(element2);
1013 int result2 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1014 DTEST_LOG << "result2:" << result2 << std::endl;
1015 EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result1);
1016 EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result2);
1017 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_004 end" << std::endl;
1018 }
1019
1020 /**
1021 * @tc.name: StartFreeInstallFromRemote_005
1022 * @tc.desc: call StartFreeInstallFromRemote with dms
1023 * @tc.type: FUNC
1024 */
1025 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_005, TestSize.Level1)
1026 {
1027 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_005 start" << std::endl;
1028 sptr<IDistributedSched> proxy = GetDms();
1029
1030 AAFwk::Want want;
1031 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1032 "com.ohos.distributedmusicplayer.MainAbility");
1033 want.SetElement(element);
1034 CallerInfo callerInfo;
1035 callerInfo.uid = 0;
1036 callerInfo.sourceDeviceId = "255.255.255.255";
1037 IDistributedSched::AccountInfo accountInfo;
1038 accountInfo.accountType = 1;
1039 accountInfo.groupIdList.push_back("123456");
1040 IDistributedSched::FreeInstallInfo info = {.want = want,
1041 .requestCode = 0,
1042 .callerInfo = callerInfo,
1043 .accountInfo = accountInfo
1044 };
1045
1046 int result1 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1047 DTEST_LOG << "result1:" << result1 << std::endl;
1048
1049 AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
1050 "com.ohos.distributedmusicplayer.MainAbilityService");
1051 want.SetElement(element2);
1052 int result2 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1053 DTEST_LOG << "result2:" << result2 << std::endl;
1054 DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_005 end" << std::endl;
1055 }
1056
1057 /**
1058 * @tc.name: NotifyCompleteFreeInstall_001
1059 * @tc.desc: input invalid taskId.
1060 * @tc.type: FUNC
1061 */
1062 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstall_001, TestSize.Level1)
1063 {
1064 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_001 start" << std::endl;
1065 /**
1066 * @tc.steps: step1. input invalid taskId.
1067 * @tc.expected: step1. return false.
1068 */
1069 IDistributedSched::FreeInstallInfo info;
1070 DistributedSchedService::GetInstance().NotifyCompleteFreeInstall(info, -1, 0);
1071 EXPECT_TRUE(!freeInstallTimeoutFlag_);
1072 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_001 end" << std::endl;
1073 }
1074
1075 /**
1076 * @tc.name: NotifyCompleteFreeInstall_002
1077 * @tc.desc: get remote dms failed.
1078 * @tc.type: FUNC
1079 */
1080 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstall_002, TestSize.Level1)
1081 {
1082 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_002 start" << std::endl;
1083 /**
1084 * @tc.steps: step1. get remote dms failed.
1085 * @tc.expected: step1. return false.
1086 */
1087 IDistributedSched::FreeInstallInfo info;
1088 DistributedSchedService::GetInstance().NotifyCompleteFreeInstall(info, MOCK_TASK_ID, 0);
1089 EXPECT_TRUE(!freeInstallTimeoutFlag_);
1090 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_002 end" << std::endl;
1091 }
1092
1093 /**
1094 * @tc.name: NotifyCompleteFreeInstallFromRemote_001
1095 * @tc.desc: input invalid taskId.
1096 * @tc.type: FUNC
1097 */
1098 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstallFromRemote_001, TestSize.Level1)
1099 {
1100 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_001 start" << std::endl;
1101 /**
1102 * @tc.steps: step1. input invalid taskId.
1103 * @tc.expected: step1. return false.
1104 */
1105 DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemote(-1, 0);
1106 EXPECT_TRUE(!freeInstallTimeoutFlag_);
1107 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_001 end" << std::endl;
1108 }
1109
1110 /**
1111 * @tc.name: NotifyCompleteFreeInstallFromRemote_002
1112 * @tc.desc: dmsCallbackTask_ or dschedContinuation_ is nullptr.
1113 * @tc.type: FUNC
1114 */
1115 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstallFromRemote_002, TestSize.Level1)
1116 {
1117 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_002 start" << std::endl;
1118 /**
1119 * @tc.steps: step1. dmsCallbackTask_ or dschedContinuation_ is nullptr.
1120 * @tc.expected: step1. return false.
1121 */
1122 DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemote(MOCK_TASK_ID, 0);
1123 EXPECT_TRUE(!freeInstallTimeoutFlag_);
1124 DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_002 end" << std::endl;
1125 }
1126
1127 /**
1128 * @tc.name: IsFreeInstall_001
1129 * @tc.desc: missionId is not exist.
1130 * @tc.type: FUNC
1131 * @tc.require: I5WKCK
1132 */
1133 HWTEST_F(DSchedContinuationTest, IsFreeInstall_001, TestSize.Level1)
1134 {
1135 DTEST_LOG << "DSchedContinuationTest IsFreeInstall_001 start" << std::endl;
1136 int32_t missionId = -1;
1137 bool result = dschedContinuation_->IsFreeInstall(missionId);
1138 EXPECT_EQ(result, false);
1139 DTEST_LOG << "DSchedContinuationTest IsFreeInstall_001 end" << std::endl;
1140 }
1141
1142 /**
1143 * @tc.name: IsFreeInstall_002
1144 * @tc.desc: missionId is exist.
1145 * @tc.type: FUNC
1146 * @tc.require: I5WKCK
1147 */
1148 HWTEST_F(DSchedContinuationTest, IsFreeInstall_002, TestSize.Level1)
1149 {
1150 DTEST_LOG << "DSchedContinuationTest IsFreeInstall_002 start" << std::endl;
1151 int32_t missionId = 1;
1152 dschedContinuation_->freeInstall_[missionId] = true;
1153 bool result = dschedContinuation_->IsFreeInstall(missionId);
1154 EXPECT_EQ(result, true);
1155 DTEST_LOG << "DSchedContinuationTest IsFreeInstall_002 end" << std::endl;
1156 }
1157
1158 /**
1159 * @tc.name: IsFreeInstall_003
1160 * @tc.desc: missionId is exist.
1161 * @tc.type: FUNC
1162 * @tc.require: I5WKCK
1163 */
1164 HWTEST_F(DSchedContinuationTest, IsFreeInstall_003, TestSize.Level1)
1165 {
1166 DTEST_LOG << "DSchedContinuationTest IsFreeInstall_003 start" << std::endl;
1167 int32_t missionId = 1;
1168 dschedContinuation_->freeInstall_[missionId] = false;
1169 bool result = dschedContinuation_->IsFreeInstall(missionId);
1170 EXPECT_EQ(result, false);
1171 DTEST_LOG << "DSchedContinuationTest IsFreeInstall_003 end" << std::endl;
1172 }
1173
1174 /**
1175 * @tc.name: PopCallback_001
1176 * @tc.desc: missionId is not exist in callbackMap_.
1177 * @tc.type: FUNC
1178 * @tc.require: I5WKCK
1179 */
1180 HWTEST_F(DSchedContinuationTest, PopCallback_001, TestSize.Level1)
1181 {
1182 DTEST_LOG << "DSchedContinuationTest PopCallback_001 start" << std::endl;
1183 int32_t missionId = -1;
1184 dschedContinuation_->callbackMap_.erase(missionId);
1185 sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1186 EXPECT_EQ(result, nullptr);
1187 DTEST_LOG << "DSchedContinuationTest PopCallback_001 end" << std::endl;
1188 }
1189
1190 /**
1191 * @tc.name: PopCallback_002
1192 * @tc.desc: missionId is not exist in continuationDevices_.
1193 * @tc.type: FUNC
1194 * @tc.require: I5WKCK
1195 */
1196 HWTEST_F(DSchedContinuationTest, PopCallback_002, TestSize.Level1)
1197 {
1198 DTEST_LOG << "DSchedContinuationTest PopCallback_002 start" << std::endl;
1199 int32_t missionId = -1;
1200 dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1201 dschedContinuation_->continuationDevices_.erase(missionId);
1202 sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1203 EXPECT_NE(result, nullptr);
1204 DTEST_LOG << "DSchedContinuationTest PopCallback_002 end" << std::endl;
1205 }
1206
1207 /**
1208 * @tc.name: PopCallback_003
1209 * @tc.desc: missionId is not exist in freeInstall_.
1210 * @tc.type: FUNC
1211 * @tc.require: I5WKCK
1212 */
1213 HWTEST_F(DSchedContinuationTest, PopCallback_003, TestSize.Level1)
1214 {
1215 DTEST_LOG << "DSchedContinuationTest PopCallback_003 start" << std::endl;
1216 int32_t missionId = -1;
1217 dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1218 dschedContinuation_->continuationDevices_[missionId] = "mockDevices";
1219 dschedContinuation_->freeInstall_.erase(missionId);
1220 sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1221 EXPECT_NE(result, nullptr);
1222 DTEST_LOG << "DSchedContinuationTest PopCallback_003 end" << std::endl;
1223 }
1224
1225 /**
1226 * @tc.name: PopCallback_004
1227 * @tc.desc: missionId is exist.
1228 * @tc.type: FUNC
1229 * @tc.require: I5WKCK
1230 */
1231 HWTEST_F(DSchedContinuationTest, PopCallback_004, TestSize.Level1)
1232 {
1233 DTEST_LOG << "DSchedContinuationTest PopCallback_004 start" << std::endl;
1234 int32_t missionId = -1;
1235 dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1236 dschedContinuation_->continuationDevices_[missionId] = "mockDevices";
1237 dschedContinuation_->freeInstall_[missionId] = true;
1238 sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1239 EXPECT_NE(result, nullptr);
1240 DTEST_LOG << "DSchedContinuationTest PopCallback_004 end" << std::endl;
1241 }
1242
1243 /**
1244 * @tc.name: NotifyMissionCenterResult_001
1245 * @tc.desc: missionId is not exist in callbackMap_.
1246 * @tc.type: FUNC
1247 * @tc.require: I5WKCK
1248 */
1249 HWTEST_F(DSchedContinuationTest, NotifyMissionCenterResult_001, TestSize.Level1)
1250 {
1251 DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_001 start" << std::endl;
1252 int32_t missionId = -1;
1253 int32_t resultCode = 0;
1254 dschedContinuation_->callbackMap_[missionId] = nullptr;
1255 int32_t result = dschedContinuation_->NotifyMissionCenterResult(missionId, resultCode);
1256 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1257 DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_001 end" << std::endl;
1258 }
1259
1260 /**
1261 * @tc.name: NotifyMissionCenterResult_002
1262 * @tc.desc: missionId is exist.
1263 * @tc.type: FUNC
1264 * @tc.require: I5WKCK
1265 */
1266 HWTEST_F(DSchedContinuationTest, NotifyMissionCenterResult_002, TestSize.Level1)
1267 {
1268 DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_002 start" << std::endl;
1269 int32_t missionId = -1;
1270 int32_t resultCode = 0;
1271 dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1272 dschedContinuation_->NotifyMissionCenterResult(missionId, resultCode);
1273 EXPECT_EQ(dschedContinuation_->callbackMap_.size(), 0);
1274 DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_002 end" << std::endl;
1275 }
1276
1277 /**
1278 * @tc.name: ProxyCallContinueMission001
1279 * @tc.desc: call dms proxy ContinueMission
1280 * @tc.type: FUNC
1281 * @tc.require: I5X9O4
1282 */
1283 HWTEST_F(DSchedContinuationTest, ProxyCallContinueMission001, TestSize.Level3)
1284 {
1285 DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission001 start" << std::endl;
1286 sptr<IDistributedSched> proxy = GetDms();
1287 if (proxy == nullptr) {
1288 return;
1289 }
1290 std::string srcDeviceId;
1291 DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1292 WantParams wantParams;
1293 int32_t ret = proxy->ContinueMission(srcDeviceId, "MockdevId", 0, GetDSchedService(), wantParams);
1294 EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
1295 DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission001 end" << std::endl;
1296 }
1297
1298 /**
1299 * @tc.name: ProxyCallContinueMission002
1300 * @tc.desc: call dms proxy ContinueMission
1301 * @tc.type: FUNC
1302 * @tc.require: I5X9O4
1303 */
1304 HWTEST_F(DSchedContinuationTest, ProxyCallContinueMission002, TestSize.Level3)
1305 {
1306 DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission002 start" << std::endl;
1307 sptr<IDistributedSched> proxy = GetDms();
1308 if (proxy == nullptr) {
1309 return;
1310 }
1311 std::string srcDeviceId;
1312 DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1313 WantParams wantParams;
1314 int32_t ret = proxy->ContinueMission(srcDeviceId, "MockdevId", 0, nullptr, wantParams);
1315 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1316 DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission002 end" << std::endl;
1317 }
1318
1319 /**
1320 * @tc.name: ProxyCallStartContinuation001
1321 * @tc.desc: call dms proxy StartContinuation
1322 * @tc.type: FUNC
1323 * @tc.require: I5X9O4
1324 */
1325 HWTEST_F(DSchedContinuationTest, ProxyCallStartContinuation001, TestSize.Level3)
1326 {
1327 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartContinuation001 start" << std::endl;
1328 sptr<IDistributedSched> proxy = GetDms();
1329 if (proxy == nullptr) {
1330 return;
1331 }
1332 OHOS::AAFwk::Want want;
1333 want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName");
1334 int32_t ret = proxy->StartContinuation(want, 0, 0, 0, 0);
1335 EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
1336 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartContinuation001 end" << std::endl;
1337 }
1338
1339 /**
1340 * @tc.name: ProxyCallNotifyContinuationResultFromRemote001
1341 * @tc.desc: call dms proxy NotifyContinuationResultFromRemote
1342 * @tc.type: FUNC
1343 * @tc.require: I5X9O4
1344 */
1345 HWTEST_F(DSchedContinuationTest, ProxyCallNotifyContinuationResultFromRemote001, TestSize.Level3)
1346 {
1347 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyContinuationResultFromRemote001 start" << std::endl;
1348 sptr<IDistributedSched> proxy = GetDms();
1349 if (proxy == nullptr) {
1350 return;
1351 }
1352 std::string srcDeviceId;
1353 DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1354 proxy->NotifyCompleteContinuation(Str8ToStr16(srcDeviceId), 0, true);
1355 int32_t ret = proxy->NotifyContinuationResultFromRemote(0, true);
1356 EXPECT_EQ(ret, REQUEST_CODE_ERR);
1357 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyContinuationResultFromRemote001 end" << std::endl;
1358 }
1359
1360 /**
1361 * @tc.name: NotifyProcessDiedFromRemote001
1362 * @tc.desc: call dms proxy NotifyProcessDiedFromRemote
1363 * @tc.type: FUNC
1364 * @tc.require: I5X9O4
1365 */
1366 HWTEST_F(DSchedContinuationTest, ProxyCallNotifyProcessDiedFromRemote001, TestSize.Level3)
1367 {
1368 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyProcessDiedFromRemote001 start" << std::endl;
1369 sptr<IDistributedSched> proxy = GetDms();
1370 if (proxy == nullptr) {
1371 return;
1372 }
1373 CallerInfo callerInfo;
1374 callerInfo.sourceDeviceId = "255.255.255.255";
1375 callerInfo.uid = 0;
1376 callerInfo.sourceDeviceId = "123456";
1377 int32_t ret = proxy->NotifyProcessDiedFromRemote(callerInfo);
1378 EXPECT_NE(ret, ERR_NULL_OBJECT);
1379 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyProcessDiedFromRemote001 end" << std::endl;
1380 }
1381
1382 /**
1383 * @tc.name: StartRemoteAbilityByCall001
1384 * @tc.desc: call dms proxy StartRemoteAbilityByCall
1385 * @tc.type: FUNC
1386 * @tc.require: I5X9O4
1387 */
1388 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall001, TestSize.Level3)
1389 {
1390 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall001 start" << std::endl;
1391 sptr<IDistributedSched> proxy = GetDms();
1392 if (proxy == nullptr) {
1393 return;
1394 }
1395 string bundleName = "bundleName";
1396 string abilityName = "abilityName";
1397 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1398 int32_t ret = proxy->StartRemoteAbilityByCall(*spWant, nullptr, 0, 0, 1);
1399 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1400 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall001 end" << std::endl;
1401 }
1402
1403 /**
1404 * @tc.name: StartRemoteAbilityByCall001
1405 * @tc.desc: call dms proxy StartRemoteAbilityByCall
1406 * @tc.type: FUNC
1407 * @tc.require: I5X9O4
1408 */
1409 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall002, TestSize.Level3)
1410 {
1411 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall002 start" << std::endl;
1412 sptr<IDistributedSched> proxy = GetDms();
1413 if (proxy == nullptr) {
1414 return;
1415 }
1416 string bundleName = "bundleName";
1417 string abilityName = "abilityName";
1418 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1419 int32_t ret = proxy->StartRemoteAbilityByCall(*spWant, GetDSchedService(), 0, 0, 1);
1420 EXPECT_NE(ret, ERR_NULL_OBJECT);
1421 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall002 end" << std::endl;
1422 }
1423
1424 /**
1425 * @tc.name: ReleaseRemoteAbility001
1426 * @tc.desc: call dms proxy ReleaseRemoteAbility
1427 * @tc.type: FUNC
1428 * @tc.require: I5X9O4
1429 */
1430 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility001, TestSize.Level3)
1431 {
1432 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 start" << std::endl;
1433 sptr<IDistributedSched> proxy = GetDms();
1434 if (proxy == nullptr) {
1435 return;
1436 }
1437 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1438 "com.ohos.distributedmusicplayer.MainAbility");
1439 int32_t ret = proxy->ReleaseRemoteAbility(nullptr, element);
1440 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1441 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 end" << std::endl;
1442 }
1443
1444 /**
1445 * @tc.name: ReleaseRemoteAbility002
1446 * @tc.desc: call dms proxy ReleaseRemoteAbility
1447 * @tc.type: FUNC
1448 * @tc.require: I5X9O4
1449 */
1450 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility002, TestSize.Level3)
1451 {
1452 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 start" << std::endl;
1453 sptr<IDistributedSched> proxy = GetDms();
1454 if (proxy == nullptr) {
1455 return;
1456 }
1457 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1458 "com.ohos.distributedmusicplayer.MainAbility");
1459 int32_t ret = proxy->ReleaseRemoteAbility(GetDSchedService(), element);
1460 EXPECT_NE(ret, ERR_NULL_OBJECT);
1461 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 end" << std::endl;
1462 }
1463
1464 /**
1465 * @tc.name: ProxyCallStartAbilityByCallFromRemote001
1466 * @tc.desc: call dms proxy StartAbilityByCallFromRemote
1467 * @tc.type: FUNC
1468 * @tc.require: I5X9O4
1469 */
1470 HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote001, TestSize.Level3)
1471 {
1472 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 start" << std::endl;
1473 sptr<IDistributedSched> proxy = GetDms();
1474 if (proxy == nullptr) {
1475 return;
1476 }
1477 // mock want
1478 string bundleName = "bundleName";
1479 string abilityName = "abilityName";
1480 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1481 // mock callerinfo
1482 CallerInfo callerInfo;
1483 callerInfo.sourceDeviceId = "255.255.255.255";
1484 callerInfo.uid = 0;
1485 callerInfo.sourceDeviceId = "123456";
1486 // mock accountInfo
1487 IDistributedSched::AccountInfo accountInfo;
1488 accountInfo.accountType = 1;
1489 accountInfo.groupIdList.push_back("123456");
1490
1491 int32_t ret = proxy->StartAbilityByCallFromRemote(*spWant, nullptr, callerInfo, accountInfo);
1492 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1493 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 end" << std::endl;
1494 }
1495
1496 /**
1497 * @tc.name: StartAbilityByCallFromRemote002
1498 * @tc.desc: call dms proxy StartAbilityByCallFromRemote
1499 * @tc.type: FUNC
1500 * @tc.require: I5X9O4
1501 */
1502 HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote002, TestSize.Level3)
1503 {
1504 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 start" << std::endl;
1505 sptr<IDistributedSched> proxy = GetDms();
1506 if (proxy == nullptr) {
1507 return;
1508 }
1509 // mock want
1510 string bundleName = "bundleName";
1511 string abilityName = "abilityName";
1512 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1513 // mock callerinfo
1514 CallerInfo callerInfo;
1515 callerInfo.sourceDeviceId = "255.255.255.255";
1516 callerInfo.uid = 0;
1517 callerInfo.sourceDeviceId = "123456";
1518 // mock accountInfo
1519 IDistributedSched::AccountInfo accountInfo;
1520 accountInfo.accountType = 1;
1521 accountInfo.groupIdList.push_back("123456");
1522
1523 int32_t ret = proxy->StartAbilityByCallFromRemote(*spWant, GetDSchedService(), callerInfo, accountInfo);
1524 EXPECT_NE(ret, ERR_NULL_OBJECT);
1525 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 end" << std::endl;
1526 }
1527
1528 /**
1529 * @tc.name: ReleaseAbilityFromRemote001
1530 * @tc.desc: call dms proxy ReleaseAbilityFromRemote
1531 * @tc.type: FUNC
1532 * @tc.require: I5X9O4
1533 */
1534 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote001, TestSize.Level3)
1535 {
1536 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote001 start" << std::endl;
1537 sptr<IDistributedSched> proxy = GetDms();
1538 if (proxy == nullptr) {
1539 return;
1540 }
1541 // mock callerinfo
1542 CallerInfo callerInfo;
1543 callerInfo.sourceDeviceId = "255.255.255.255";
1544 callerInfo.uid = 0;
1545 callerInfo.sourceDeviceId = "123456";
1546
1547 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1548 "com.ohos.distributedmusicplayer.MainAbility");
1549 int32_t ret = proxy->ReleaseAbilityFromRemote(nullptr, element, callerInfo);
1550 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1551 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote001 end" << std::endl;
1552 }
1553
1554 /**
1555 * @tc.name: ReleaseAbilityFromRemote002
1556 * @tc.desc: call dms proxy ReleaseAbilityFromRemote
1557 * @tc.type: FUNC
1558 * @tc.require: I5X9O4
1559 */
1560 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote002, TestSize.Level3)
1561 {
1562 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote002 start" << std::endl;
1563 sptr<IDistributedSched> proxy = GetDms();
1564 if (proxy == nullptr) {
1565 return;
1566 }
1567 // mock callerinfo
1568 CallerInfo callerInfo;
1569 callerInfo.sourceDeviceId = "255.255.255.255";
1570 callerInfo.uid = 0;
1571 callerInfo.sourceDeviceId = "123456";
1572
1573 AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1574 "com.ohos.distributedmusicplayer.MainAbility");
1575 int32_t ret = proxy->ReleaseAbilityFromRemote(GetDSchedService(), element, callerInfo);
1576 EXPECT_NE(ret, ERR_NULL_OBJECT);
1577 DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote002 end" << std::endl;
1578 }
1579
1580 /**
1581 * @tc.name: StartRemoteFreeInstall001
1582 * @tc.desc: call dms proxy StartRemoteFreeInstall
1583 * @tc.type: FUNC
1584 * @tc.require: I5X9O4
1585 */
1586 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall001, TestSize.Level3)
1587 {
1588 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall001 start" << std::endl;
1589 sptr<IDistributedSched> proxy = GetDms();
1590 if (proxy == nullptr) {
1591 return;
1592 }
1593 // mock want
1594 string bundleName = "bundleName";
1595 string abilityName = "abilityName";
1596 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1597
1598 int32_t ret = proxy->StartRemoteFreeInstall(*spWant, 0, 1, 1, GetDSchedService());
1599 EXPECT_NE(ret, ERR_NULL_OBJECT);
1600 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall001 end" << std::endl;
1601 }
1602
1603 /**
1604 * @tc.name: StartRemoteFreeInstall002
1605 * @tc.desc: call dms proxy StartRemoteFreeInstall
1606 * @tc.type: FUNC
1607 * @tc.require: I5X9O4
1608 */
1609 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall002, TestSize.Level3)
1610 {
1611 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall002 start" << std::endl;
1612 sptr<IDistributedSched> proxy = GetDms();
1613 if (proxy == nullptr) {
1614 return;
1615 }
1616 // mock want
1617 string bundleName = "bundleName";
1618 string abilityName = "abilityName";
1619 std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1620
1621 int32_t ret = proxy->StartRemoteFreeInstall(*spWant, 0, 1, 1, nullptr);
1622 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1623 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall002 end" << std::endl;
1624 }
1625
1626 /**
1627 * @tc.name: NotifyCompleteFreeInstallFromRemote001
1628 * @tc.desc: call dms proxy NotifyCompleteFreeInstallFromRemote
1629 * @tc.type: FUNC
1630 * @tc.require: I5X9O4
1631 */
1632 HWTEST_F(DSchedContinuationTest, ProxyCallNotifyCompleteFreeInstallFromRemote001, TestSize.Level3)
1633 {
1634 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyCompleteFreeInstallFromRemote001 start" << std::endl;
1635 sptr<IDistributedSched> proxy = GetDms();
1636 if (proxy == nullptr) {
1637 return;
1638 }
1639 int32_t ret = proxy->NotifyCompleteFreeInstallFromRemote(1, 1);
1640 EXPECT_NE(ret, ERR_NULL_OBJECT);
1641 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyCompleteFreeInstallFromRemote001 end" << std::endl;
1642 }
1643
1644 /**
1645 * @tc.name: GetDistributedComponentList001
1646 * @tc.desc: call dms proxy GetDistributedComponentList
1647 * @tc.type: FUNC
1648 * @tc.require: I5X9O4
1649 */
1650 HWTEST_F(DSchedContinuationTest, ProxyCallGetDistributedComponentList001, TestSize.Level3)
1651 {
1652 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetDistributedComponentList001 start" << std::endl;
1653 sptr<IDistributedSched> proxy = GetDms();
1654 if (proxy == nullptr) {
1655 return;
1656 }
1657 vector<string> distributedComponents = { "test "};
1658 int32_t ret = proxy->GetDistributedComponentList(distributedComponents);
1659 EXPECT_NE(ret, ERR_NULL_OBJECT);
1660 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetDistributedComponentList001 end" << std::endl;
1661 }
1662
1663 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
1664 /**
1665 * @tc.name: StartShareFormFromRemote001
1666 * @tc.desc: call dms proxy StartShareFormFromRemote
1667 * @tc.type: FUNC
1668 * @tc.require: I5X9O4
1669 */
1670 HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote001, TestSize.Level3)
1671 {
1672 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote001 start" << std::endl;
1673 sptr<IDistributedSched> proxy = GetDms();
1674 if (proxy == nullptr) {
1675 return;
1676 }
1677 const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
1678 int32_t ret = proxy->StartShareFormFromRemote("", formShareInfo);
1679 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1680 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote001 end" << std::endl;
1681 }
1682
1683 /**
1684 * @tc.name: StartShareFormFromRemote002
1685 * @tc.desc: call dms proxy StartShareFormFromRemote
1686 * @tc.type: FUNC
1687 * @tc.require: I5X9O4
1688 */
1689 HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote002, TestSize.Level3)
1690 {
1691 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote002 start" << std::endl;
1692 sptr<IDistributedSched> proxy = GetDms();
1693 if (proxy == nullptr) {
1694 return;
1695 }
1696 const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
1697 int32_t ret = proxy->StartShareFormFromRemote("111", formShareInfo);
1698 EXPECT_NE(ret, ERR_NULL_OBJECT);
1699 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote002 end" << std::endl;
1700 }
1701 #endif
1702 } // DistributedSchedule
1703 } // namespace OHOS
1704