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