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  */
HWTEST_F(DSchedContinuationTest, StartContinuation_001, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, StartContinuation_002, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, StartContinuation_003, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, StartContinuation_004, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, NotifyCompleteContinuation_001, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, NotifyCompleteContinuation_002, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, NotifyContinuationResultFromRemote_001, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, NotifyContinuationResultFromRemote_002, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, SetWantForContinuation_001, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_001, TestSize.Level1)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  */
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_002, TestSize.Level1)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     int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(
427         deviceId, missionId, callback, wantParams);
428     EXPECT_EQ(CONTINUE_ALREADY_IN_PROGRESS, ret);
429     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_002 end" << std::endl;
430 }
431 
432 /**
433  * @tc.name: ContinueLocalMission_003
434  * @tc.desc: input invalid params.
435  * @tc.type: FUNC
436  * @tc.require: I5RWKZ
437  */
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_003, TestSize.Level1)438 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_003, TestSize.Level1)
439 {
440     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_003 start" << std::endl;
441     std::string deviceId = "123456";
442     int32_t missionId = -1;
443     auto callback = GetDSchedService();
444     WantParams wantParams;
445     DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
446     int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(
447         deviceId, missionId, callback, wantParams);
448     EXPECT_NE(ret, ERR_OK);
449     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_003 end" << std::endl;
450 }
451 
452 /**
453  * @tc.name: ContinueLocalMission_004
454  * @tc.desc: input invalid params.
455  * @tc.type: FUNC
456  * @tc.require: I5RWKZ
457  */
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_004, TestSize.Level1)458 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_004, TestSize.Level1)
459 {
460     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_004 start" << std::endl;
461     std::string deviceId;
462     int32_t missionId = -1;
463     auto callback = GetDSchedService();
464     WantParams wantParams;
465     DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
466     int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission(
467         deviceId, missionId, callback, wantParams);
468     EXPECT_NE(ret, ERR_OK);
469     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_004 end" << std::endl;
470 }
471 
472 /**
473  * @tc.name: ContinueLocalMission_005
474  * @tc.desc: input invalid params.
475  * @tc.type: FUNC
476  * @tc.require: I5RWKZ
477  */
HWTEST_F(DSchedContinuationTest, ContinueLocalMission_005, TestSize.Level1)478 HWTEST_F(DSchedContinuationTest, ContinueLocalMission_005, TestSize.Level1)
479 {
480     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_005 start" << std::endl;
481     /**
482      * @tc.steps: step1. input invalid mission.
483      * @tc.expected: step1. return err.
484      */
485     std::string deviceId = "123456";
486     int32_t missionId = 0;
487     auto callback = GetDSchedService();
488     WantParams wantParams;
489     ASSERT_NE(nullptr, DistributedSchedService::GetInstance().dschedContinuation_);
490     DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
491     ASSERT_NE(DistributedSchedService::GetInstance().dschedContinuation_, nullptr);
492     DistributedSchedService::GetInstance().dschedContinuation_->PushCallback(missionId, callback, deviceId, false);
493     int32_t ret = DistributedSchedService::GetInstance().ContinueAbilityWithTimeout(deviceId, missionId, callback);
494     EXPECT_EQ(CONTINUE_ALREADY_IN_PROGRESS, ret);
495     DTEST_LOG << "DSchedContinuationTest ContinueLocalMission_005 end" << std::endl;
496 }
497 
498 /**
499  * @tc.name: ContinueLocalMissionDealFreeInstall_001
500  * @tc.desc: input invalid params.
501  * @tc.type: FUNC
502  */
HWTEST_F(DSchedContinuationTest, ContinueLocalMissionDealFreeInstall_001, TestSize.Level1)503 HWTEST_F(DSchedContinuationTest, ContinueLocalMissionDealFreeInstall_001, TestSize.Level1)
504 {
505     DTEST_LOG << "DSchedContinuationTest ContinueLocalMissionDealFreeInstall_001 start" << std::endl;
506     std::string bundleName = "bundleName";
507     std::string abilityName = "abilityName";
508     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
509     spWant->SetParam("isFreeInstall", false);
510 
511     int32_t missionId = 0;
512     std::string deviceId = "123456";
513     auto callback = GetDSchedService();
514     int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMissionDealFreeInstall(*spWant,
515         missionId, deviceId, callback);
516     EXPECT_NE(ret, ERR_OK);
517     DTEST_LOG << "DSchedContinuationTest ContinueLocalMissionDealFreeInstall_001 end" << std::endl;
518 }
519 
520 /**
521  * @tc.name: ContinueRemoteMission_001
522  * @tc.desc: input invalid params.
523  * @tc.type: FUNC
524  */
HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_001, TestSize.Level1)525 HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_001, TestSize.Level1)
526 {
527     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_001 start" << std::endl;
528     /**
529      * @tc.steps: step1. input invalid deviceId.
530      * @tc.expected: step1. return err.
531      */
532     std::string srcDeviceId = "123456";
533     std::string dstDeviceid = "123456";
534     int32_t missionId = 0;
535     auto callback = GetDSchedService();
536     WantParams wantParams;
537     int32_t ret = DistributedSchedService::GetInstance().ContinueRemoteMission(
538         srcDeviceId, dstDeviceid, missionId, callback, wantParams);
539     EXPECT_TRUE(INVALID_REMOTE_PARAMETERS_ERR == ret);
540     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_001 end" << std::endl;
541 }
542 
543 /**
544  * @tc.name: ContinueRemoteMission_002
545  * @tc.desc: input invalid params.
546  * @tc.type: FUNC
547  */
HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_002, TestSize.Level1)548 HWTEST_F(DSchedContinuationTest, ContinueRemoteMission_002, TestSize.Level1)
549 {
550     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_002 start" << std::endl;
551     /**
552      * @tc.steps: step1. input invalid param.
553      * @tc.expected: step1. return err.
554      */
555     std::string srcDeviceId;
556     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
557     std::string dstDeviceid = "123456";
558     int32_t missionId = 0;
559     auto callback = GetDSchedService();
560     WantParams wantParams;
561     int32_t ret = DistributedSchedService::GetInstance().ContinueRemoteMission(
562         srcDeviceId, dstDeviceid, missionId, callback, wantParams);
563     EXPECT_TRUE(ERR_OK != ret);
564     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_002 end" << std::endl;
565 }
566 
567 /**
568  * @tc.name: PushAbilityToken_001
569  * @tc.desc: input invalid params.
570  * @tc.type: FUNC
571  */
HWTEST_F(DSchedContinuationTest, PushAbilityToken_001, TestSize.Level1)572 HWTEST_F(DSchedContinuationTest, PushAbilityToken_001, TestSize.Level1)
573 {
574     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_001 start" << std::endl;
575     /**
576      * @tc.steps: step1. input invalid abilityToken.
577      * @tc.expected: step1. return false.
578      */
579 
580     ASSERT_NE(dschedContinuation_, nullptr);
581     auto sessionId = dschedContinuation_->GenerateSessionId();
582     bool ret = dschedContinuation_->PushAbilityToken(sessionId, nullptr);
583     EXPECT_TRUE(!ret);
584     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_001 end" << std::endl;
585 }
586 
587 /**
588  * @tc.name: PushAbilityToken_002
589  * @tc.desc: input invalid params.
590  * @tc.type: FUNC
591  */
HWTEST_F(DSchedContinuationTest, PushAbilityToken_002, TestSize.Level1)592 HWTEST_F(DSchedContinuationTest, PushAbilityToken_002, TestSize.Level1)
593 {
594     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_002 start" << std::endl;
595     /**
596      * @tc.steps: step1. input invalid sessionId.
597      * @tc.expected: step1. return false.
598      */
599     ASSERT_NE(dschedContinuation_, nullptr);
600     bool ret = dschedContinuation_->PushAbilityToken(-1, GetDSchedService());
601     EXPECT_TRUE(!ret);
602     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_002 end" << std::endl;
603 }
604 
605 /**
606  * @tc.name: PushAbilityToken_003
607  * @tc.desc: init not call.
608  * @tc.type: FUNC
609  */
HWTEST_F(DSchedContinuationTest, PushAbilityToken_003, TestSize.Level1)610 HWTEST_F(DSchedContinuationTest, PushAbilityToken_003, TestSize.Level1)
611 {
612     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_003 start" << std::endl;
613     /**
614      * @tc.steps: step1. input valid abilityToken and valid sessionId.
615      * @tc.expected: step1. return false.
616      */
617     ASSERT_NE(dschedContinuation_, nullptr);
618     auto sessionId = dschedContinuation_->GenerateSessionId();
619     bool ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
620     EXPECT_TRUE(!ret);
621     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_003 end" << std::endl;
622 }
623 
624 /**
625  * @tc.name: PushAbilityToken_004
626  * @tc.desc: Push AbilityToken OK.
627  * @tc.type: FUNC
628  */
HWTEST_F(DSchedContinuationTest, PushAbilityToken_004, TestSize.Level1)629 HWTEST_F(DSchedContinuationTest, PushAbilityToken_004, TestSize.Level1)
630 {
631     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_004 start" << std::endl;
632     /**
633      * @tc.steps: step1. input valid params and init.
634      * @tc.expected: step1. return true.
635      */
636     ASSERT_NE(dschedContinuation_, nullptr);
637     dschedContinuation_->Init(nullptr);
638     auto sessionId = dschedContinuation_->GenerateSessionId();
639     bool ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
640     EXPECT_TRUE(ret);
641     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_004 end" << std::endl;
642 }
643 
644 /**
645  * @tc.name: PushAbilityToken_005
646  * @tc.desc: AbilityToken is exist.
647  * @tc.type: FUNC
648  * @tc.require: I60TOK
649  */
HWTEST_F(DSchedContinuationTest, PushAbilityToken_005, TestSize.Level1)650 HWTEST_F(DSchedContinuationTest, PushAbilityToken_005, TestSize.Level1)
651 {
652     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_005 start" << std::endl;
653     ASSERT_NE(dschedContinuation_, nullptr);
654     dschedContinuation_->Init(nullptr);
655     auto sessionId = 1;
656     bool ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
657     ret = dschedContinuation_->PushAbilityToken(sessionId, GetDSchedService());
658     EXPECT_EQ(ret, false);
659     DTEST_LOG << "DSchedContinuationTest PushAbilityToken_005 end" << std::endl;
660 }
661 
662 /**
663  * @tc.name: PopAbilityToken_001
664  * @tc.desc: input invalid params.
665  * @tc.type: FUNC
666  */
HWTEST_F(DSchedContinuationTest, PopAbilityToken_001, TestSize.Level1)667 HWTEST_F(DSchedContinuationTest, PopAbilityToken_001, TestSize.Level1)
668 {
669     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_001 start" << std::endl;
670     /**
671      * @tc.steps: step1. input invalid sessionId.
672      * @tc.expected: step1. return false.
673      */
674     ASSERT_NE(dschedContinuation_, nullptr);
675     sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(-1);
676     EXPECT_TRUE(abilityToken == nullptr);
677     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_001 end" << std::endl;
678 }
679 
680 /**
681  * @tc.name: PopAbilityToken_002
682  * @tc.desc: input invalid params.
683  * @tc.type: FUNC
684  */
HWTEST_F(DSchedContinuationTest, PopAbilityToken_002, TestSize.Level1)685 HWTEST_F(DSchedContinuationTest, PopAbilityToken_002, TestSize.Level1)
686 {
687     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_002 start" << std::endl;
688     /**
689      * @tc.steps: step1. pop not exist sessionId.
690      * @tc.expected: step1. return false.
691      */
692     ASSERT_NE(dschedContinuation_, nullptr);
693     int32_t sessionId = dschedContinuation_->GenerateSessionId() + 1;
694     sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
695     EXPECT_TRUE(abilityToken == nullptr);
696     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_002 end" << std::endl;
697 }
698 
699 /**
700  * @tc.name: PopAbilityToken_003
701  * @tc.desc: pop abilityToken success.
702  * @tc.type: FUNC
703  */
HWTEST_F(DSchedContinuationTest, PopAbilityToken_003, TestSize.Level1)704 HWTEST_F(DSchedContinuationTest, PopAbilityToken_003, TestSize.Level1)
705 {
706     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_003 start" << std::endl;
707     /**
708      * @tc.steps: step1. pop exist sessionId.
709      * @tc.expected: step1. return true.
710      */
711     ASSERT_NE(dschedContinuation_, nullptr);
712     int32_t sessionId = PushAbilityToken();
713     sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
714     EXPECT_TRUE(abilityToken != nullptr);
715 
716     /**
717      * @tc.steps: step2. duplicate pop abilityToken.
718      * @tc.expected: step1. return false.
719      */
720     abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
721     EXPECT_TRUE(abilityToken == nullptr);
722     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_003 end" << std::endl;
723 }
724 
725 /**
726  * @tc.name: PopAbilityToken_004
727  * @tc.desc: pop abilityToken success.
728  * @tc.type: FUNC
729  * @tc.require: I60TOK
730  */
HWTEST_F(DSchedContinuationTest, PopAbilityToken_004, TestSize.Level1)731 HWTEST_F(DSchedContinuationTest, PopAbilityToken_004, TestSize.Level1)
732 {
733     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_004 start" << std::endl;
734     ASSERT_NE(dschedContinuation_, nullptr);
735     dschedContinuation_->continuationHandler_ = nullptr;
736 
737     int32_t sessionId = PushAbilityToken();
738     sptr<IRemoteObject> abilityToken = dschedContinuation_->PopAbilityToken(sessionId);
739     EXPECT_TRUE(abilityToken != nullptr);
740     DTEST_LOG << "DSchedContinuationTest PopAbilityToken_004 end" << std::endl;
741 }
742 
743 /**
744  * @tc.name: GenerateSessionId_001
745  * @tc.desc: test GenerateSessionId when currSessionId is less than zero.
746  * @tc.type: FUNC
747  * @tc.require: I60TOK
748  */
HWTEST_F(DSchedContinuationTest, GenerateSessionId_001, TestSize.Level4)749 HWTEST_F(DSchedContinuationTest, GenerateSessionId_001, TestSize.Level4)
750 {
751     DTEST_LOG << "DSchedContinuationTest GenerateSessionId_001 start" << std::endl;
752     ASSERT_NE(dschedContinuation_, nullptr);
753     int32_t sessionId =  dschedContinuation_->currSessionId_;
754     dschedContinuation_->currSessionId_ = -100;
755     dschedContinuation_->GenerateSessionId();
756     EXPECT_EQ(dschedContinuation_->currSessionId_, 1);
757     dschedContinuation_->currSessionId_ = sessionId;
758     DTEST_LOG << "DSchedContinuationTest GenerateSessionId_001 end" << std::endl;
759 }
760 
761 /**
762  * @tc.name: SetTimeOut_001
763  * @tc.desc: test SetTimeOut.
764  * @tc.type: FUNC
765  * @tc.require: I60TOK
766  */
HWTEST_F(DSchedContinuationTest, SetTimeOut_001, TestSize.Level3)767 HWTEST_F(DSchedContinuationTest, SetTimeOut_001, TestSize.Level3)
768 {
769     DTEST_LOG << "DSchedContinuationTest SetTimeOut_001 start" << std::endl;
770     ASSERT_NE(dschedContinuation_, nullptr);
771     dschedContinuation_->Init(nullptr);
772 
773     int32_t missionId = 0;
774     int32_t timeout = 1000;
775     dschedContinuation_->SetTimeOut(missionId, timeout);
776     EXPECT_NE(dschedContinuation_->continuationHandler_, nullptr);
777     DTEST_LOG << "DSchedContinuationTest SetTimeOut_001 end" << std::endl;
778 }
779 
780 /**
781  * @tc.name: RemoveTimeOut_001
782  * @tc.desc: test RemoveTimeOut.
783  * @tc.type: FUNC
784  * @tc.require: I60TOK
785  */
HWTEST_F(DSchedContinuationTest, RemoveTimeOut_001, TestSize.Level3)786 HWTEST_F(DSchedContinuationTest, RemoveTimeOut_001, TestSize.Level3)
787 {
788     DTEST_LOG << "DSchedContinuationTest RemoveTimeOut_001 start" << std::endl;
789     ASSERT_NE(dschedContinuation_, nullptr);
790     dschedContinuation_->Init(nullptr);
791 
792     int32_t missionId = 0;
793     int32_t timeout = 1000;
794     dschedContinuation_->SetTimeOut(missionId, timeout);
795     EXPECT_NE(dschedContinuation_->continuationHandler_, nullptr);
796     DTEST_LOG << "DSchedContinuationTest RemoveTimeOut_001 end" << std::endl;
797 }
798 
799 /**
800  * @tc.name: GetTargetDevice_001
801  * @tc.desc: test GetTargetDevice.
802  * @tc.type: FUNC
803  * @tc.require: I60TOK
804  */
HWTEST_F(DSchedContinuationTest, GetTargetDevice_001, TestSize.Level3)805 HWTEST_F(DSchedContinuationTest, GetTargetDevice_001, TestSize.Level3)
806 {
807     DTEST_LOG << "DSchedContinuationTest GetTargetDevice_001 start" << std::endl;
808     ASSERT_NE(dschedContinuation_, nullptr);
809     dschedContinuation_->Init(nullptr);
810 
811     int32_t missionId = 0;
812     std::string mockDevice = "mockDevice";
813     dschedContinuation_->continuationDevices_[missionId] = mockDevice;
814     std::string result = dschedContinuation_->GetTargetDevice(missionId);
815     EXPECT_EQ(result, mockDevice);
816     DTEST_LOG << "DSchedContinuationTest GetTargetDevice_001 end" << std::endl;
817 }
818 
819 /**
820  * @tc.name: PushCallback_001
821  * @tc.desc: test PushCallback when callback is nullptr.
822  * @tc.type: FUNC
823  * @tc.require: I60TOK
824  */
HWTEST_F(DSchedContinuationTest, PushCallback_001, TestSize.Level3)825 HWTEST_F(DSchedContinuationTest, PushCallback_001, TestSize.Level3)
826 {
827     DTEST_LOG << "DSchedContinuationTest PushCallback_001 start" << std::endl;
828     ASSERT_NE(dschedContinuation_, nullptr);
829     dschedContinuation_->Init(nullptr);
830 
831     int32_t missionId = 0;
832     const sptr<IRemoteObject> callback = nullptr;
833     std::string deviceId = "";
834     bool isFreeInstall = true;
835     bool result = dschedContinuation_->PushCallback(missionId, callback, deviceId, isFreeInstall);
836     EXPECT_EQ(result, false);
837     DTEST_LOG << "DSchedContinuationTest PushCallback_001 end" << std::endl;
838 }
839 
840 /**
841  * @tc.name: PushCallback_002
842  * @tc.desc: test PushCallback when callback is exist.
843  * @tc.type: FUNC
844  * @tc.require: I60TOK
845  */
HWTEST_F(DSchedContinuationTest, PushCallback_002, TestSize.Level3)846 HWTEST_F(DSchedContinuationTest, PushCallback_002, TestSize.Level3)
847 {
848     DTEST_LOG << "DSchedContinuationTest PushCallback_002 start" << std::endl;
849     ASSERT_NE(dschedContinuation_, nullptr);
850     dschedContinuation_->Init(nullptr);
851 
852     int32_t missionId = 0;
853     const sptr<IRemoteObject> callback(new MockRemoteStub());
854     std::string deviceId = "";
855     bool isFreeInstall = true;
856     dschedContinuation_->callbackMap_[missionId] = callback;
857     bool result = dschedContinuation_->PushCallback(missionId, callback, deviceId, isFreeInstall);
858     EXPECT_EQ(result, false);
859     DTEST_LOG << "DSchedContinuationTest PushCallback_002 end" << std::endl;
860 }
861 
862 /**
863  * @tc.name: PushCallback_003
864  * @tc.desc: test PushCallback when isFreeInstall is true.
865  * @tc.type: FUNC
866  * @tc.require: I60TOK
867  */
HWTEST_F(DSchedContinuationTest, PushCallback_003, TestSize.Level3)868 HWTEST_F(DSchedContinuationTest, PushCallback_003, TestSize.Level3)
869 {
870     DTEST_LOG << "DSchedContinuationTest PushCallback_003 start" << std::endl;
871     ASSERT_NE(dschedContinuation_, nullptr);
872     dschedContinuation_->Init(nullptr);
873 
874     int32_t missionId = 0;
875     const sptr<IRemoteObject> callback(new MockRemoteStub());
876     std::string deviceId = "";
877     bool isFreeInstall = true;
878     dschedContinuation_->callbackMap_.clear();
879     bool result = dschedContinuation_->PushCallback(missionId, callback, deviceId, isFreeInstall);
880     EXPECT_EQ(result, true);
881     DTEST_LOG << "DSchedContinuationTest PushCallback_003 end" << std::endl;
882 }
883 
884 /**
885  * @tc.name: PushCallback_004
886  * @tc.desc: test PushCallback
887  * @tc.type: FUNC
888  * @tc.require: I60TOK
889  */
HWTEST_F(DSchedContinuationTest, PushCallback_004, TestSize.Level3)890 HWTEST_F(DSchedContinuationTest, PushCallback_004, TestSize.Level3)
891 {
892     DTEST_LOG << "DSchedContinuationTest PushCallback_004 start" << std::endl;
893     ASSERT_NE(dschedContinuation_, nullptr);
894     const sptr<IRemoteObject> callback = nullptr;
895     dschedContinuation_->PushCallback(callback);
896 
897     dschedContinuation_->Init(nullptr);
898     bool result = dschedContinuation_->PushCallback(callback);
899     EXPECT_EQ(result, false);
900     DTEST_LOG << "DSchedContinuationTest PushCallback_004 end" << std::endl;
901 }
902 
903 /**
904  * @tc.name: PushCallback_005
905  * @tc.desc: test PushCallback
906  * @tc.type: FUNC
907  * @tc.require: I60TOK
908  */
HWTEST_F(DSchedContinuationTest, PushCallback_005, TestSize.Level3)909 HWTEST_F(DSchedContinuationTest, PushCallback_005, TestSize.Level3)
910 {
911     DTEST_LOG << "DSchedContinuationTest PushCallback_005 start" << std::endl;
912     ASSERT_NE(dschedContinuation_, nullptr);
913     const sptr<IRemoteObject> callback(new MockRemoteStub());
914     dschedContinuation_->Init(nullptr);
915     dschedContinuation_->continuationCallbackArr_.clear();
916     dschedContinuation_->PushCallback(callback);
917 
918     dschedContinuation_->continuationCallbackArr_.push_back(callback);
919     bool result = dschedContinuation_->PushCallback(callback);
920     EXPECT_EQ(result, false);
921     DTEST_LOG << "DSchedContinuationTest PushCallback_005 end" << std::endl;
922 }
923 
924 /**
925  * @tc.name: CleanupCallback_001
926  * @tc.desc: test CleanupCallback
927  * @tc.type: FUNC
928  * @tc.require: I60TOK
929  */
HWTEST_F(DSchedContinuationTest, CleanupCallback_001, TestSize.Level3)930 HWTEST_F(DSchedContinuationTest, CleanupCallback_001, TestSize.Level3)
931 {
932     DTEST_LOG << "DSchedContinuationTest CleanupCallback_001 start" << std::endl;
933     ASSERT_NE(dschedContinuation_, nullptr);
934     const sptr<IRemoteObject> callback(new MockRemoteStub());
935 
936     dschedContinuation_->continuationCallbackArr_.push_back(callback);
937     dschedContinuation_->CleanupCallback(callback);
938 
939     dschedContinuation_->continuationCallbackArr_.clear();
940     bool result = dschedContinuation_->CleanupCallback(callback);
941     EXPECT_EQ(result, false);
942     DTEST_LOG << "DSchedContinuationTest CleanupCallback_001 end" << std::endl;
943 }
944 
945 /**
946  * @tc.name: NotifyDSchedEventForOneCB_001
947  * @tc.desc: test NotifyDSchedEventForOneCB
948  * @tc.type: FUNC
949  * @tc.require: I60TOK
950  */
HWTEST_F(DSchedContinuationTest, NotifyDSchedEventForOneCB_001, TestSize.Level3)951 HWTEST_F(DSchedContinuationTest, NotifyDSchedEventForOneCB_001, TestSize.Level3)
952 {
953     DTEST_LOG << "DSchedContinuationTest NotifyDSchedEventForOneCB_001 start" << std::endl;
954     ASSERT_NE(dschedContinuation_, nullptr);
955     const sptr<IRemoteObject> cb(new MockRemoteStub());
956     int32_t resultCode = 0;
957     dschedContinuation_->NotifyDSchedEventForOneCB(cb, resultCode);
958     int32_t result = dschedContinuation_->NotifyDSchedEventForOneCB(nullptr, resultCode);
959     EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
960     DTEST_LOG << "DSchedContinuationTest NotifyDSchedEventForOneCB_001 end" << std::endl;
961 }
962 
963 /**
964  * @tc.name: NotifyDSchedEventResult_001
965  * @tc.desc: test NotifyDSchedEventResult
966  * @tc.type: FUNC
967  * @tc.require: I60TOK
968  */
HWTEST_F(DSchedContinuationTest, NotifyDSchedEventResult_001, TestSize.Level3)969 HWTEST_F(DSchedContinuationTest, NotifyDSchedEventResult_001, TestSize.Level3)
970 {
971     DTEST_LOG << "DSchedContinuationTest NotifyDSchedEventResult_001 start" << std::endl;
972     ASSERT_NE(dschedContinuation_, nullptr);
973     const sptr<IRemoteObject> callback(new MockRemoteStub());
974     int32_t resultCode = 0;
975     dschedContinuation_->continuationCallbackArr_.push_back(callback);
976     dschedContinuation_->NotifyDSchedEventResult(resultCode);
977 
978     dschedContinuation_->continuationCallbackArr_.clear();
979     int32_t result = dschedContinuation_->NotifyDSchedEventResult(resultCode);
980     EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
981     DTEST_LOG << "DSchedContinuationTest NotifyDSchedEventResult_001 end" << std::endl;
982 }
983 
984 /**
985  * @tc.name: IsCleanMission_001
986  * @tc.desc: test IsCleanMission
987  * @tc.type: FUNC
988  * @tc.require: I60TOK
989  */
HWTEST_F(DSchedContinuationTest, IsCleanMission_001, TestSize.Level3)990 HWTEST_F(DSchedContinuationTest, IsCleanMission_001, TestSize.Level3)
991 {
992     DTEST_LOG << "DSchedContinuationTest IsCleanMission_001 start" << std::endl;
993     ASSERT_NE(dschedContinuation_, nullptr);
994     int32_t missionId = 0;
995     dschedContinuation_->SetCleanMissionFlag(1, true);
996     dschedContinuation_->IsCleanMission(missionId);
997 
998     dschedContinuation_->SetCleanMissionFlag(missionId, false);
999     bool result = dschedContinuation_->IsCleanMission(missionId);
1000     EXPECT_EQ(result, false);
1001     DTEST_LOG << "DSchedContinuationTest IsCleanMission_001 end" << std::endl;
1002 }
1003 
1004 /**
1005  * @tc.name: ContinueMission_001
1006  * @tc.desc: test ContinueMission when srcDeviceId is empty.
1007  * @tc.type: FUNC
1008  */
HWTEST_F(DSchedContinuationTest, ContinueMission_001, TestSize.Level1)1009 HWTEST_F(DSchedContinuationTest, ContinueMission_001, TestSize.Level1)
1010 {
1011     DTEST_LOG << "DSchedContinuationTest ContinueMission_001 start" << std::endl;
1012     WantParams wantParams;
1013     int32_t ret = DistributedSchedService::GetInstance().ContinueMission("",
1014         "string", 1, GetDSchedService(), wantParams);
1015     EXPECT_TRUE(ret != ERR_OK);
1016     DTEST_LOG << "DSchedContinuationTest ContinueMission_001 end" << std::endl;
1017 }
1018 
1019 /**
1020  * @tc.name: ContinueMission_002
1021  * @tc.desc: test ContinueMission when dstDeviceId is empty.
1022  * @tc.type: FUNC
1023  */
HWTEST_F(DSchedContinuationTest, ContinueMission_002, TestSize.Level1)1024 HWTEST_F(DSchedContinuationTest, ContinueMission_002, TestSize.Level1)
1025 {
1026     DTEST_LOG << "DSchedContinuationTest ContinueMission_002 start" << std::endl;
1027     WantParams wantParams;
1028     int32_t ret = DistributedSchedService::GetInstance().ContinueMission("string",
1029         "", 1, GetDSchedService(), wantParams);
1030     EXPECT_TRUE(ret != ERR_OK);
1031     DTEST_LOG << "DSchedContinuationTest ContinueMission_002 end" << std::endl;
1032 }
1033 
1034 /**
1035  * @tc.name: ContinueMission_003
1036  * @tc.desc: test ContinueMission when callback is nullptr.
1037  * @tc.type: FUNC
1038  */
HWTEST_F(DSchedContinuationTest, ContinueMission_003, TestSize.Level1)1039 HWTEST_F(DSchedContinuationTest, ContinueMission_003, TestSize.Level1)
1040 {
1041     DTEST_LOG << "DSchedContinuationTest ContinueMission_003 start" << std::endl;
1042     WantParams wantParams;
1043     int32_t ret = DistributedSchedService::GetInstance().ContinueMission("string", "string", 1, nullptr, wantParams);
1044     EXPECT_TRUE(ret != ERR_OK);
1045     DTEST_LOG << "DSchedContinuationTest ContinueMission_003 end" << std::endl;
1046 }
1047 
1048 /**
1049  * @tc.name: ContinueMission_004
1050  * @tc.desc: test ContinueMission when srcDeviceId == localDevId.
1051  * @tc.type: FUNC
1052  */
HWTEST_F(DSchedContinuationTest, ContinueMission_004, TestSize.Level1)1053 HWTEST_F(DSchedContinuationTest, ContinueMission_004, TestSize.Level1)
1054 {
1055     DTEST_LOG << "DSchedContinuationTest ContinueMission_004 start" << std::endl;
1056     WantParams wantParams;
1057 
1058     std::string srcDeviceId;
1059     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1060     int32_t ret = DistributedSchedService::GetInstance().ContinueMission(srcDeviceId,
1061         "string", -1, GetDSchedService(), wantParams);
1062     EXPECT_TRUE(ret != ERR_OK);
1063     DTEST_LOG << "DSchedContinuationTest ContinueMission_004 end" << std::endl;
1064 }
1065 
1066 /**
1067  * @tc.name: StartRemoteFreeInstall_001
1068  * @tc.desc: input invalid params.
1069  * @tc.type: FUNC
1070  */
HWTEST_F(DSchedContinuationTest, StartRemoteFreeInstall_001, TestSize.Level1)1071 HWTEST_F(DSchedContinuationTest, StartRemoteFreeInstall_001, TestSize.Level1)
1072 {
1073     DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_001 start" << std::endl;
1074     /**
1075      * @tc.steps: step1. want not set continuation flags.
1076      * @tc.expected: step1. return false.
1077      */
1078     int32_t ret = StartRemoteFreeInstall(0, GetDSchedService());
1079     EXPECT_TRUE(ret != ERR_OK);
1080     DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_001 end" << std::endl;
1081 }
1082 
1083 /**
1084  * @tc.name: StartRemoteFreeInstall_002
1085  * @tc.desc: get remote dms failed.
1086  * @tc.type: FUNC
1087  */
HWTEST_F(DSchedContinuationTest, StartRemoteFreeInstall_002, TestSize.Level1)1088 HWTEST_F(DSchedContinuationTest, StartRemoteFreeInstall_002, TestSize.Level1)
1089 {
1090     DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_002 start" << std::endl;
1091     /**
1092      * @tc.steps: step1. get remote dms failed.
1093      * @tc.expected: step1. return false.
1094      */
1095     int32_t ret = StartRemoteFreeInstall(Want::FLAG_ABILITY_CONTINUATION, GetDSchedService());
1096     EXPECT_TRUE(ret != ERR_OK);
1097     DTEST_LOG << "DSchedContinuationTest StartRemoteFreeInstall_002 end" << std::endl;
1098 }
1099 
1100 /**
1101  * @tc.name: StartFreeInstallFromRemote_001
1102  * @tc.desc: call StartFreeInstallFromRemote with illegal param
1103  * @tc.type: FUNC
1104  */
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_001, TestSize.Level0)1105 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_001, TestSize.Level0)
1106 {
1107     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_001 start" << std::endl;
1108     sptr<IDistributedSched> proxy = GetDms();
1109     ASSERT_NE(nullptr, proxy);
1110     AAFwk::Want want;
1111     CallerInfo callerInfo;
1112     callerInfo.uid = 0;
1113     callerInfo.sourceDeviceId = "255.255.255.255";
1114     IDistributedSched::AccountInfo accountInfo;
1115     IDistributedSched::FreeInstallInfo info = {.want = want,
1116         .requestCode = 0,
1117         .callerInfo = callerInfo,
1118         .accountInfo = accountInfo
1119     };
1120     /**
1121      * @tc.steps: step1. StartFreeInstallFromRemote with uninitialized params
1122      * @tc.expected: step1. StartFreeInstallFromRemote return INVALID_REMOTE_PARAMETERS_ERR
1123      */
1124     int result1 = proxy->StartFreeInstallFromRemote(info, 0);
1125     DTEST_LOG << "result1:" << result1 << std::endl;
1126     /**
1127      * @tc.steps: step1. StartFreeInstallFromRemote with with empty deviceId
1128      * @tc.expected: step1. StartFreeInstallFromRemote return INVALID_REMOTE_PARAMETERS_ERR
1129      */
1130     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1131         "com.ohos.distributedmusicplayer.MainAbility");
1132     want.SetElement(element);
1133     int result2 = proxy->StartFreeInstallFromRemote(info, 0);
1134     DTEST_LOG << "result2:" << result2 << std::endl;
1135     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_001 end" << std::endl;
1136 }
1137 
1138 /**
1139  * @tc.name: StartFreeInstallFromRemote_002
1140  * @tc.desc: call StartFreeInstallFromRemote
1141  * @tc.type: FUNC
1142  */
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_002, TestSize.Level1)1143 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_002, TestSize.Level1)
1144 {
1145     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_002 start" << std::endl;
1146     sptr<IDistributedSched> proxy = GetDms();
1147     ASSERT_NE(nullptr, proxy);
1148 
1149     AAFwk::Want want;
1150     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1151         "com.ohos.distributedmusicplayer.MainAbility");
1152     want.SetElement(element);
1153     CallerInfo callerInfo;
1154     callerInfo.uid = 0;
1155     callerInfo.sourceDeviceId = "255.255.255.255";
1156     IDistributedSched::AccountInfo accountInfo;
1157     IDistributedSched::FreeInstallInfo info = {.want = want,
1158         .requestCode = 0,
1159         .callerInfo = callerInfo,
1160         .accountInfo = accountInfo
1161     };
1162 
1163     int result1 = proxy->StartFreeInstallFromRemote(info, 0);
1164     DTEST_LOG << "result1 is" << result1 << std::endl;
1165 
1166     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
1167         "com.ohos.distributedmusicplayer.MainAbilityService");
1168     want.SetElement(element2);
1169     int result2 = proxy->StartFreeInstallFromRemote(info, 0);
1170     DTEST_LOG << "result2:" << result2 << std::endl;
1171     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_002 end" << std::endl;
1172 }
1173 
1174 /**
1175  * @tc.name: StartFreeInstallFromRemote_003
1176  * @tc.desc: call StartFreeInstallFromRemote for pressure test
1177  * @tc.type: FUNC
1178  */
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_003, TestSize.Level1)1179 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_003, TestSize.Level1)
1180 {
1181     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_003 start" << std::endl;
1182     sptr<IDistributedSched> proxy = GetDms();
1183     ASSERT_NE(nullptr, proxy);
1184     /**
1185      * @tc.steps: step1. set want and abilityInfo
1186      */
1187     AAFwk::Want want;
1188     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1189         "com.ohos.distributedmusicplayer.MainAbility");
1190     want.SetElement(element);
1191     CallerInfo callerInfo;
1192     callerInfo.uid = 0;
1193     callerInfo.sourceDeviceId = "255.255.255.255";
1194     IDistributedSched::AccountInfo accountInfo;
1195     IDistributedSched::FreeInstallInfo info = {.want = want,
1196         .requestCode = 0,
1197         .callerInfo = callerInfo,
1198         .accountInfo = accountInfo
1199     };
1200     /**
1201      * @tc.steps: step2. StartFreeInstallFromRemote for pressure test
1202      * @tc.expected: step2. StartFreeInstallFromRemote for result
1203      */
1204     for (int index = 0; index < static_cast<int32_t>(LoopTime::LOOP_TIME); index++) {
1205         int result = proxy->StartFreeInstallFromRemote(info, 0);
1206         DTEST_LOG << "pressure" + std::to_string(index) + " result is " << result << std::endl;
1207     }
1208     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_003 end" << std::endl;
1209 }
1210 
1211 /**
1212  * @tc.name: StartFreeInstallFromRemote_004
1213  * @tc.desc: call StartFreeInstallFromRemote with dms
1214  * @tc.type: FUNC
1215  */
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_004, TestSize.Level0)1216 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_004, TestSize.Level0)
1217 {
1218     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_004 start" << std::endl;
1219     sptr<IDistributedSched> proxy = GetDms();
1220 
1221     AAFwk::Want want;
1222     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1223         "com.ohos.distributedmusicplayer.MainAbility");
1224     want.SetElement(element);
1225     CallerInfo callerInfo;
1226     callerInfo.uid = 0;
1227     callerInfo.sourceDeviceId = "255.255.255.255";
1228     IDistributedSched::AccountInfo accountInfo;
1229     IDistributedSched::FreeInstallInfo info = {.want = want,
1230         .requestCode = 0,
1231         .callerInfo = callerInfo,
1232         .accountInfo = accountInfo
1233     };
1234 
1235     int result1 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1236     DTEST_LOG << "result1:" << result1 << std::endl;
1237 
1238     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
1239         "com.ohos.distributedmusicplayer.MainAbilityService");
1240     want.SetElement(element2);
1241     int result2 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1242     DTEST_LOG << "result2:" << result2 << std::endl;
1243     EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result1);
1244     EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result2);
1245     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_004 end" << std::endl;
1246 }
1247 
1248 /**
1249  * @tc.name: StartFreeInstallFromRemote_005
1250  * @tc.desc: call StartFreeInstallFromRemote with dms
1251  * @tc.type: FUNC
1252  */
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_005, TestSize.Level1)1253 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_005, TestSize.Level1)
1254 {
1255     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_005 start" << std::endl;
1256     sptr<IDistributedSched> proxy = GetDms();
1257 
1258     AAFwk::Want want;
1259     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1260         "com.ohos.distributedmusicplayer.MainAbility");
1261     want.SetElement(element);
1262     CallerInfo callerInfo;
1263     callerInfo.uid = 0;
1264     callerInfo.sourceDeviceId = "255.255.255.255";
1265     IDistributedSched::AccountInfo accountInfo;
1266     accountInfo.accountType = 1;
1267     accountInfo.groupIdList.push_back("123456");
1268     IDistributedSched::FreeInstallInfo info = {.want = want,
1269         .requestCode = 0,
1270         .callerInfo = callerInfo,
1271         .accountInfo = accountInfo
1272     };
1273 
1274     int result1 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1275     DTEST_LOG << "result1:" << result1 << std::endl;
1276 
1277     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
1278         "com.ohos.distributedmusicplayer.MainAbilityService");
1279     want.SetElement(element2);
1280     int result2 = DistributedSchedService::GetInstance().StartFreeInstallFromRemote(info, 0);
1281     DTEST_LOG << "result2:" << result2 << std::endl;
1282     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_005 end" << std::endl;
1283 }
1284 
1285 /**
1286  * @tc.name: StartFreeInstallFromRemote_006
1287  * @tc.desc: call StartFreeInstallFromRemote
1288  * @tc.type: FUNC
1289  */
HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_006, TestSize.Level1)1290 HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_006, TestSize.Level1)
1291 {
1292     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_006 start" << std::endl;
1293     sptr<IDistributedSched> proxy = GetDms();
1294     ASSERT_NE(nullptr, proxy);
1295 
1296     AAFwk::Want want;
1297     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1298         "com.ohos.distributedmusicplayer.MainAbility");
1299     want.SetElement(element);
1300     CallerInfo callerInfo;
1301     callerInfo.uid = 0;
1302     callerInfo.sourceDeviceId = "255.255.255.255";
1303     callerInfo.extraInfoJson[DMS_VERSION_ID] = DMS_VERSION;
1304     IDistributedSched::AccountInfo accountInfo;
1305     IDistributedSched::FreeInstallInfo info = {.want = want,
1306         .requestCode = 0,
1307         .callerInfo = callerInfo,
1308         .accountInfo = accountInfo
1309     };
1310 
1311     int result1 = proxy->StartFreeInstallFromRemote(info, 0);
1312     DTEST_LOG << "result1 is" << result1 << std::endl;
1313 
1314     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
1315         "com.ohos.distributedmusicplayer.MainAbilityService");
1316     want.SetElement(element2);
1317     int result2 = proxy->StartFreeInstallFromRemote(info, 0);
1318     DTEST_LOG << "result2:" << result2 << std::endl;
1319     DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_006 end" << std::endl;
1320 }
1321 
1322 /**
1323  * @tc.name: NotifyCompleteFreeInstall_001
1324  * @tc.desc: input invalid taskId.
1325  * @tc.type: FUNC
1326  */
HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstall_001, TestSize.Level1)1327 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstall_001, TestSize.Level1)
1328 {
1329     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_001 start" << std::endl;
1330     /**
1331      * @tc.steps: step1. input invalid taskId.
1332      * @tc.expected: step1. return false.
1333      */
1334     IDistributedSched::FreeInstallInfo info;
1335     DistributedSchedService::GetInstance().NotifyCompleteFreeInstall(info, -1, 0);
1336     EXPECT_TRUE(!freeInstallTimeoutFlag_);
1337     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_001 end" << std::endl;
1338 }
1339 
1340 /**
1341  * @tc.name: NotifyCompleteFreeInstall_002
1342  * @tc.desc: get remote dms failed.
1343  * @tc.type: FUNC
1344  */
HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstall_002, TestSize.Level1)1345 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstall_002, TestSize.Level1)
1346 {
1347     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_002 start" << std::endl;
1348     /**
1349      * @tc.steps: step1. get remote dms failed.
1350      * @tc.expected: step1. return false.
1351      */
1352     IDistributedSched::FreeInstallInfo info;
1353     DistributedSchedService::GetInstance().NotifyCompleteFreeInstall(info, MOCK_TASK_ID, 0);
1354     EXPECT_TRUE(!freeInstallTimeoutFlag_);
1355     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstall_002 end" << std::endl;
1356 }
1357 
1358 /**
1359  * @tc.name: NotifyCompleteFreeInstallFromRemote_001
1360  * @tc.desc: input invalid taskId.
1361  * @tc.type: FUNC
1362  */
HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstallFromRemote_001, TestSize.Level1)1363 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstallFromRemote_001, TestSize.Level1)
1364 {
1365     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_001 start" << std::endl;
1366     /**
1367      * @tc.steps: step1. input invalid taskId.
1368      * @tc.expected: step1. return false.
1369      */
1370     DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemote(-1, 0);
1371     EXPECT_TRUE(!freeInstallTimeoutFlag_);
1372     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_001 end" << std::endl;
1373 }
1374 
1375 /**
1376  * @tc.name: NotifyCompleteFreeInstallFromRemote_002
1377  * @tc.desc: dmsCallbackTask_ or dschedContinuation_ is nullptr.
1378  * @tc.type: FUNC
1379  */
HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstallFromRemote_002, TestSize.Level1)1380 HWTEST_F(DSchedContinuationTest, NotifyCompleteFreeInstallFromRemote_002, TestSize.Level1)
1381 {
1382     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_002 start" << std::endl;
1383     /**
1384      * @tc.steps: step1. dmsCallbackTask_ or dschedContinuation_ is nullptr.
1385      * @tc.expected: step1. return false.
1386      */
1387     DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemote(MOCK_TASK_ID, 0);
1388     EXPECT_TRUE(!freeInstallTimeoutFlag_);
1389     DTEST_LOG << "DSchedContinuationTest NotifyCompleteFreeInstallFromRemote_002 end" << std::endl;
1390 }
1391 
1392 /**
1393  * @tc.name: IsFreeInstall_001
1394  * @tc.desc: missionId is not exist.
1395  * @tc.type: FUNC
1396  * @tc.require: I5WKCK
1397  */
HWTEST_F(DSchedContinuationTest, IsFreeInstall_001, TestSize.Level1)1398 HWTEST_F(DSchedContinuationTest, IsFreeInstall_001, TestSize.Level1)
1399 {
1400     DTEST_LOG << "DSchedContinuationTest IsFreeInstall_001 start" << std::endl;
1401     ASSERT_NE(dschedContinuation_, nullptr);
1402     int32_t missionId = -1;
1403     bool result = dschedContinuation_->IsFreeInstall(missionId);
1404     EXPECT_EQ(result, false);
1405     DTEST_LOG << "DSchedContinuationTest IsFreeInstall_001 end" << std::endl;
1406 }
1407 
1408 /**
1409  * @tc.name: IsFreeInstall_002
1410  * @tc.desc: missionId is exist.
1411  * @tc.type: FUNC
1412  * @tc.require: I5WKCK
1413  */
HWTEST_F(DSchedContinuationTest, IsFreeInstall_002, TestSize.Level1)1414 HWTEST_F(DSchedContinuationTest, IsFreeInstall_002, TestSize.Level1)
1415 {
1416     DTEST_LOG << "DSchedContinuationTest IsFreeInstall_002 start" << std::endl;
1417     ASSERT_NE(dschedContinuation_, nullptr);
1418     int32_t missionId = 1;
1419     dschedContinuation_->freeInstall_[missionId] = true;
1420     bool result = dschedContinuation_->IsFreeInstall(missionId);
1421     EXPECT_EQ(result, true);
1422     DTEST_LOG << "DSchedContinuationTest IsFreeInstall_002 end" << std::endl;
1423 }
1424 
1425 /**
1426  * @tc.name: IsFreeInstall_003
1427  * @tc.desc: missionId is exist.
1428  * @tc.type: FUNC
1429  * @tc.require: I5WKCK
1430  */
HWTEST_F(DSchedContinuationTest, IsFreeInstall_003, TestSize.Level1)1431 HWTEST_F(DSchedContinuationTest, IsFreeInstall_003, TestSize.Level1)
1432 {
1433     DTEST_LOG << "DSchedContinuationTest IsFreeInstall_003 start" << std::endl;
1434     ASSERT_NE(dschedContinuation_, nullptr);
1435     int32_t missionId = 1;
1436     dschedContinuation_->freeInstall_[missionId] = false;
1437     bool result = dschedContinuation_->IsFreeInstall(missionId);
1438     EXPECT_EQ(result, false);
1439     DTEST_LOG << "DSchedContinuationTest IsFreeInstall_003 end" << std::endl;
1440 }
1441 
1442 /**
1443  * @tc.name: PopCallback_001
1444  * @tc.desc: missionId is not exist in callbackMap_.
1445  * @tc.type: FUNC
1446  * @tc.require: I5WKCK
1447  */
HWTEST_F(DSchedContinuationTest, PopCallback_001, TestSize.Level1)1448 HWTEST_F(DSchedContinuationTest, PopCallback_001, TestSize.Level1)
1449 {
1450     DTEST_LOG << "DSchedContinuationTest PopCallback_001 start" << std::endl;
1451     ASSERT_NE(dschedContinuation_, nullptr);
1452     int32_t missionId = -1;
1453     dschedContinuation_->callbackMap_.erase(missionId);
1454     sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1455     EXPECT_EQ(result, nullptr);
1456     DTEST_LOG << "DSchedContinuationTest PopCallback_001 end" << std::endl;
1457 }
1458 
1459 /**
1460  * @tc.name: PopCallback_002
1461  * @tc.desc: missionId is not exist in continuationDevices_.
1462  * @tc.type: FUNC
1463  * @tc.require: I5WKCK
1464  */
HWTEST_F(DSchedContinuationTest, PopCallback_002, TestSize.Level1)1465 HWTEST_F(DSchedContinuationTest, PopCallback_002, TestSize.Level1)
1466 {
1467     DTEST_LOG << "DSchedContinuationTest PopCallback_002 start" << std::endl;
1468     ASSERT_NE(dschedContinuation_, nullptr);
1469     int32_t missionId = -1;
1470     dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1471     dschedContinuation_->continuationDevices_.erase(missionId);
1472     sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1473     EXPECT_NE(result, nullptr);
1474     DTEST_LOG << "DSchedContinuationTest PopCallback_002 end" << std::endl;
1475 }
1476 
1477 /**
1478  * @tc.name: PopCallback_003
1479  * @tc.desc: missionId is not exist in freeInstall_.
1480  * @tc.type: FUNC
1481  * @tc.require: I5WKCK
1482  */
HWTEST_F(DSchedContinuationTest, PopCallback_003, TestSize.Level1)1483 HWTEST_F(DSchedContinuationTest, PopCallback_003, TestSize.Level1)
1484 {
1485     DTEST_LOG << "DSchedContinuationTest PopCallback_003 start" << std::endl;
1486     ASSERT_NE(dschedContinuation_, nullptr);
1487     int32_t missionId = -1;
1488     dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1489     dschedContinuation_->continuationDevices_[missionId] = "mockDevices";
1490     dschedContinuation_->freeInstall_.erase(missionId);
1491     sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1492     EXPECT_NE(result, nullptr);
1493     DTEST_LOG << "DSchedContinuationTest PopCallback_003 end" << std::endl;
1494 }
1495 
1496 /**
1497  * @tc.name: PopCallback_004
1498  * @tc.desc: missionId is exist.
1499  * @tc.type: FUNC
1500  * @tc.require: I5WKCK
1501  */
HWTEST_F(DSchedContinuationTest, PopCallback_004, TestSize.Level1)1502 HWTEST_F(DSchedContinuationTest, PopCallback_004, TestSize.Level1)
1503 {
1504     DTEST_LOG << "DSchedContinuationTest PopCallback_004 start" << std::endl;
1505     ASSERT_NE(dschedContinuation_, nullptr);
1506     int32_t missionId = -1;
1507     dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1508     dschedContinuation_->continuationDevices_[missionId] = "mockDevices";
1509     dschedContinuation_->freeInstall_[missionId] = true;
1510     sptr<IRemoteObject> result = dschedContinuation_->PopCallback(missionId);
1511     EXPECT_NE(result, nullptr);
1512     DTEST_LOG << "DSchedContinuationTest PopCallback_004 end" << std::endl;
1513 }
1514 
1515 /**
1516  * @tc.name: NotifyMissionCenterResult_001
1517  * @tc.desc: missionId is not exist in callbackMap_.
1518  * @tc.type: FUNC
1519  * @tc.require: I5WKCK
1520  */
HWTEST_F(DSchedContinuationTest, NotifyMissionCenterResult_001, TestSize.Level1)1521 HWTEST_F(DSchedContinuationTest, NotifyMissionCenterResult_001, TestSize.Level1)
1522 {
1523     DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_001 start" << std::endl;
1524     ASSERT_NE(dschedContinuation_, nullptr);
1525     int32_t missionId = -1;
1526     int32_t resultCode = 0;
1527     dschedContinuation_->callbackMap_[missionId] = nullptr;
1528     int32_t result = dschedContinuation_->NotifyMissionCenterResult(missionId, resultCode);
1529     EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1530     DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_001 end" << std::endl;
1531 }
1532 
1533 /**
1534  * @tc.name: NotifyMissionCenterResult_002
1535  * @tc.desc: missionId is exist.
1536  * @tc.type: FUNC
1537  * @tc.require: I5WKCK
1538  */
HWTEST_F(DSchedContinuationTest, NotifyMissionCenterResult_002, TestSize.Level1)1539 HWTEST_F(DSchedContinuationTest, NotifyMissionCenterResult_002, TestSize.Level1)
1540 {
1541     DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_002 start" << std::endl;
1542     ASSERT_NE(dschedContinuation_, nullptr);
1543     int32_t missionId = -1;
1544     int32_t resultCode = 0;
1545     dschedContinuation_->callbackMap_[missionId] = GetDSchedService();
1546     dschedContinuation_->NotifyMissionCenterResult(missionId, resultCode);
1547     EXPECT_EQ(dschedContinuation_->callbackMap_.size(), 0);
1548     DTEST_LOG << "DSchedContinuationTest NotifyMissionCenterResult_002 end" << std::endl;
1549 }
1550 
1551 /**
1552  * @tc.name: ProxyCallContinueMission001
1553  * @tc.desc: call dms proxy ContinueMission
1554  * @tc.type: FUNC
1555  * @tc.require: I5X9O4
1556  */
HWTEST_F(DSchedContinuationTest, ProxyCallContinueMission001, TestSize.Level3)1557 HWTEST_F(DSchedContinuationTest, ProxyCallContinueMission001, TestSize.Level3)
1558 {
1559     DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission001 start" << std::endl;
1560     sptr<IDistributedSched> proxy = GetDms();
1561     EXPECT_NE(proxy, nullptr);
1562     std::string srcDeviceId;
1563     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1564     WantParams wantParams;
1565     int32_t ret = proxy->ContinueMission(srcDeviceId, "MockdevId", 0, GetDSchedService(), wantParams);
1566     EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
1567     DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission001 end" << std::endl;
1568 }
1569 
1570 /**
1571  * @tc.name: ProxyCallContinueMission002
1572  * @tc.desc: call dms proxy ContinueMission
1573  * @tc.type: FUNC
1574  * @tc.require: I5X9O4
1575  */
HWTEST_F(DSchedContinuationTest, ProxyCallContinueMission002, TestSize.Level3)1576 HWTEST_F(DSchedContinuationTest, ProxyCallContinueMission002, TestSize.Level3)
1577 {
1578     DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission002 start" << std::endl;
1579     sptr<IDistributedSched> proxy = GetDms();
1580     EXPECT_NE(proxy, nullptr);
1581     std::string srcDeviceId;
1582     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1583     WantParams wantParams;
1584     int32_t ret = proxy->ContinueMission(srcDeviceId, "MockdevId", 0, nullptr, wantParams);
1585     EXPECT_EQ(ret, ERR_NULL_OBJECT);
1586     DTEST_LOG << "DistributedSchedServiceTest ProxyCallContinueMission002 end" << std::endl;
1587 }
1588 
1589 /**
1590  * @tc.name: ProxyCallStartContinuation001
1591  * @tc.desc: call dms proxy StartContinuation
1592  * @tc.type: FUNC
1593  * @tc.require: I5X9O4
1594  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartContinuation001, TestSize.Level3)1595 HWTEST_F(DSchedContinuationTest, ProxyCallStartContinuation001, TestSize.Level3)
1596 {
1597     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartContinuation001 start" << std::endl;
1598     sptr<IDistributedSched> proxy = GetDms();
1599     EXPECT_NE(proxy, nullptr);
1600     OHOS::AAFwk::Want want;
1601     want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName");
1602     int32_t ret = proxy->StartContinuation(want, 0, 0, 0, 0);
1603     EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
1604     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartContinuation001 end" << std::endl;
1605 }
1606 
1607 /**
1608  * @tc.name: ProxyCallNotifyContinuationResultFromRemote001
1609  * @tc.desc: call dms proxy NotifyContinuationResultFromRemote
1610  * @tc.type: FUNC
1611  * @tc.require: I5X9O4
1612  */
HWTEST_F(DSchedContinuationTest, ProxyCallNotifyContinuationResultFromRemote001, TestSize.Level3)1613 HWTEST_F(DSchedContinuationTest, ProxyCallNotifyContinuationResultFromRemote001, TestSize.Level3)
1614 {
1615     DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyContinuationResultFromRemote001 start" << std::endl;
1616     sptr<IDistributedSched> proxy = GetDms();
1617     EXPECT_NE(proxy, nullptr);
1618     std::string srcDeviceId;
1619     std::string info;
1620     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(srcDeviceId);
1621     proxy->NotifyCompleteContinuation(Str8ToStr16(srcDeviceId), 0, true);
1622     int32_t ret = proxy->NotifyContinuationResultFromRemote(0, true, info);
1623     EXPECT_EQ(ret, REQUEST_CODE_ERR);
1624     DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyContinuationResultFromRemote001 end" << std::endl;
1625 }
1626 
1627 /**
1628  * @tc.name: NotifyProcessDiedFromRemote001
1629  * @tc.desc: call dms proxy NotifyProcessDiedFromRemote
1630  * @tc.type: FUNC
1631  * @tc.require: I5X9O4
1632  */
HWTEST_F(DSchedContinuationTest, ProxyCallNotifyProcessDiedFromRemote001, TestSize.Level3)1633 HWTEST_F(DSchedContinuationTest, ProxyCallNotifyProcessDiedFromRemote001, TestSize.Level3)
1634 {
1635     DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyProcessDiedFromRemote001 start" << std::endl;
1636     sptr<IDistributedSched> proxy = GetDms();
1637     ASSERT_NE(nullptr, proxy);
1638     CallerInfo callerInfo;
1639     callerInfo.sourceDeviceId = "255.255.255.255";
1640     callerInfo.uid = 0;
1641     callerInfo.sourceDeviceId = "123456";
1642     int32_t ret = proxy->NotifyProcessDiedFromRemote(callerInfo);
1643     EXPECT_NE(ret, ERR_NULL_OBJECT);
1644     DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyProcessDiedFromRemote001 end" << std::endl;
1645 }
1646 
1647 /**
1648  * @tc.name: StartRemoteAbilityByCall001
1649  * @tc.desc: call dms proxy StartRemoteAbilityByCall
1650  * @tc.type: FUNC
1651  * @tc.require: I5X9O4
1652  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall001, TestSize.Level3)1653 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall001, TestSize.Level3)
1654 {
1655     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall001 start" << std::endl;
1656     sptr<IDistributedSched> proxy = GetDms();
1657     EXPECT_NE(proxy, nullptr);
1658     std::string bundleName = "bundleName";
1659     std::string abilityName = "abilityName";
1660     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1661     int32_t ret = proxy->StartRemoteAbilityByCall(*spWant, nullptr, 0, 0, 1);
1662     EXPECT_EQ(ret, ERR_NULL_OBJECT);
1663     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall001 end" << std::endl;
1664 }
1665 
1666 /**
1667  * @tc.name: StartRemoteAbilityByCall001
1668  * @tc.desc: call dms proxy StartRemoteAbilityByCall
1669  * @tc.type: FUNC
1670  * @tc.require: I5X9O4
1671  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall002, TestSize.Level3)1672 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall002, TestSize.Level3)
1673 {
1674     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall002 start" << std::endl;
1675     sptr<IDistributedSched> proxy = GetDms();
1676     ASSERT_NE(nullptr, proxy);
1677     std::string bundleName = "bundleName";
1678     std::string abilityName = "abilityName";
1679     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1680     int32_t ret = proxy->StartRemoteAbilityByCall(*spWant, GetDSchedService(), 0, 0, 1);
1681     EXPECT_NE(ret, ERR_NULL_OBJECT);
1682     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall002 end" << std::endl;
1683 }
1684 
1685 /**
1686  * @tc.name: ReleaseRemoteAbility001
1687  * @tc.desc: call dms proxy ReleaseRemoteAbility
1688  * @tc.type: FUNC
1689  * @tc.require: I5X9O4
1690  */
HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility001, TestSize.Level3)1691 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility001, TestSize.Level3)
1692 {
1693     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 start" << std::endl;
1694     sptr<IDistributedSched> proxy = GetDms();
1695     EXPECT_NE(proxy, nullptr);
1696     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1697         "com.ohos.distributedmusicplayer.MainAbility");
1698     int32_t ret = proxy->ReleaseRemoteAbility(nullptr, element);
1699     EXPECT_EQ(ret, ERR_NULL_OBJECT);
1700     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 end" << std::endl;
1701 }
1702 
1703 /**
1704  * @tc.name: ReleaseRemoteAbility002
1705  * @tc.desc: call dms proxy ReleaseRemoteAbility
1706  * @tc.type: FUNC
1707  * @tc.require: I5X9O4
1708  */
HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility002, TestSize.Level3)1709 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility002, TestSize.Level3)
1710 {
1711     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 start" << std::endl;
1712     sptr<IDistributedSched> proxy = GetDms();
1713     ASSERT_NE(nullptr, proxy);
1714     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1715         "com.ohos.distributedmusicplayer.MainAbility");
1716     int32_t ret = proxy->ReleaseRemoteAbility(GetDSchedService(), element);
1717     EXPECT_NE(ret, ERR_NULL_OBJECT);
1718     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 end" << std::endl;
1719 }
1720 
1721 /**
1722  * @tc.name: ProxyCallStartAbilityByCallFromRemote001
1723  * @tc.desc: call dms proxy StartAbilityByCallFromRemote
1724  * @tc.type: FUNC
1725  * @tc.require: I5X9O4
1726  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote001, TestSize.Level3)1727 HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote001, TestSize.Level3)
1728 {
1729     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 start" << std::endl;
1730     sptr<IDistributedSched> proxy = GetDms();
1731     EXPECT_NE(proxy, nullptr);
1732     // mock want
1733     std::string bundleName = "bundleName";
1734     std::string abilityName = "abilityName";
1735     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1736     // mock callerinfo
1737     CallerInfo callerInfo;
1738     callerInfo.sourceDeviceId = "255.255.255.255";
1739     callerInfo.uid = 0;
1740     callerInfo.sourceDeviceId = "123456";
1741     // mock accountInfo
1742     IDistributedSched::AccountInfo accountInfo;
1743     accountInfo.accountType = 1;
1744     accountInfo.groupIdList.push_back("123456");
1745 
1746     int32_t ret = proxy->StartAbilityByCallFromRemote(*spWant, nullptr, callerInfo, accountInfo);
1747     EXPECT_EQ(ret, ERR_NULL_OBJECT);
1748     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility001 end" << std::endl;
1749 }
1750 
1751 /**
1752  * @tc.name: StartAbilityByCallFromRemote002
1753  * @tc.desc: call dms proxy StartAbilityByCallFromRemote
1754  * @tc.type: FUNC
1755  * @tc.require: I5X9O4
1756  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote002, TestSize.Level3)1757 HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote002, TestSize.Level3)
1758 {
1759     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 start" << std::endl;
1760     sptr<IDistributedSched> proxy = GetDms();
1761     ASSERT_NE(nullptr, proxy);
1762     // mock want
1763     std::string bundleName = "bundleName";
1764     std::string abilityName = "abilityName";
1765     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1766     // mock callerinfo
1767     CallerInfo callerInfo;
1768     callerInfo.sourceDeviceId = "255.255.255.255";
1769     callerInfo.uid = 0;
1770     callerInfo.sourceDeviceId = "123456";
1771     // mock accountInfo
1772     IDistributedSched::AccountInfo accountInfo;
1773     accountInfo.accountType = 1;
1774     accountInfo.groupIdList.push_back("123456");
1775 
1776     int32_t ret = proxy->StartAbilityByCallFromRemote(*spWant, GetDSchedService(), callerInfo, accountInfo);
1777     EXPECT_NE(ret, ERR_NULL_OBJECT);
1778     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 end" << std::endl;
1779 }
1780 
1781 /**
1782  * @tc.name: ReleaseAbilityFromRemote001
1783  * @tc.desc: call dms proxy ReleaseAbilityFromRemote
1784  * @tc.type: FUNC
1785  * @tc.require: I5X9O4
1786  */
HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote001, TestSize.Level3)1787 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote001, TestSize.Level3)
1788 {
1789     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote001 start" << std::endl;
1790     sptr<IDistributedSched> proxy = GetDms();
1791     EXPECT_NE(proxy, nullptr);
1792     // mock callerinfo
1793     CallerInfo callerInfo;
1794     callerInfo.sourceDeviceId = "255.255.255.255";
1795     callerInfo.uid = 0;
1796     callerInfo.sourceDeviceId = "123456";
1797 
1798     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1799         "com.ohos.distributedmusicplayer.MainAbility");
1800     int32_t ret = proxy->ReleaseAbilityFromRemote(nullptr, element, callerInfo);
1801     EXPECT_EQ(ret, ERR_NULL_OBJECT);
1802     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote001 end" << std::endl;
1803 }
1804 
1805 /**
1806  * @tc.name: ReleaseAbilityFromRemote002
1807  * @tc.desc: call dms proxy ReleaseAbilityFromRemote
1808  * @tc.type: FUNC
1809  * @tc.require: I5X9O4
1810  */
HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote002, TestSize.Level3)1811 HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote002, TestSize.Level3)
1812 {
1813     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote002 start" << std::endl;
1814     sptr<IDistributedSched> proxy = GetDms();
1815     ASSERT_NE(nullptr, proxy);
1816     // mock callerinfo
1817     CallerInfo callerInfo;
1818     callerInfo.sourceDeviceId = "255.255.255.255";
1819     callerInfo.uid = 0;
1820     callerInfo.sourceDeviceId = "123456";
1821 
1822     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
1823         "com.ohos.distributedmusicplayer.MainAbility");
1824     int32_t ret = proxy->ReleaseAbilityFromRemote(GetDSchedService(), element, callerInfo);
1825     EXPECT_NE(ret, ERR_NULL_OBJECT);
1826     DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote002 end" << std::endl;
1827 }
1828 
1829 /**
1830  * @tc.name: StartRemoteFreeInstall001
1831  * @tc.desc: call dms proxy StartRemoteFreeInstall
1832  * @tc.type: FUNC
1833  * @tc.require: I5X9O4
1834  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall001, TestSize.Level3)1835 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall001, TestSize.Level3)
1836 {
1837     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall001 start" << std::endl;
1838     sptr<IDistributedSched> proxy = GetDms();
1839     ASSERT_NE(nullptr, proxy);
1840     // mock want
1841     std::string bundleName = "bundleName";
1842     std::string abilityName = "abilityName";
1843     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1844 
1845     int32_t ret = proxy->StartRemoteFreeInstall(*spWant, 0, 1, 1, GetDSchedService());
1846     EXPECT_NE(ret, ERR_NULL_OBJECT);
1847     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall001 end" << std::endl;
1848 }
1849 
1850 /**
1851  * @tc.name: StartRemoteFreeInstall002
1852  * @tc.desc: call dms proxy StartRemoteFreeInstall
1853  * @tc.type: FUNC
1854  * @tc.require: I5X9O4
1855  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall002, TestSize.Level3)1856 HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall002, TestSize.Level3)
1857 {
1858     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall002 start" << std::endl;
1859     sptr<IDistributedSched> proxy = GetDms();
1860     EXPECT_NE(proxy, nullptr);
1861     // mock want
1862     std::string bundleName = "bundleName";
1863     std::string abilityName = "abilityName";
1864     std::shared_ptr<Want> spWant = MockWant(bundleName, abilityName, 0);
1865 
1866     int32_t ret = proxy->StartRemoteFreeInstall(*spWant, 0, 1, 1, nullptr);
1867     EXPECT_EQ(ret, ERR_NULL_OBJECT);
1868     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall002 end" << std::endl;
1869 }
1870 
1871 /**
1872  * @tc.name: NotifyCompleteFreeInstallFromRemote001
1873  * @tc.desc: call dms proxy NotifyCompleteFreeInstallFromRemote
1874  * @tc.type: FUNC
1875  * @tc.require: I5X9O4
1876  */
HWTEST_F(DSchedContinuationTest, ProxyCallNotifyCompleteFreeInstallFromRemote001, TestSize.Level3)1877 HWTEST_F(DSchedContinuationTest, ProxyCallNotifyCompleteFreeInstallFromRemote001, TestSize.Level3)
1878 {
1879     DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyCompleteFreeInstallFromRemote001 start" << std::endl;
1880     sptr<IDistributedSched> proxy = GetDms();
1881     ASSERT_NE(nullptr, proxy);
1882     int32_t ret = proxy->NotifyCompleteFreeInstallFromRemote(1, 1);
1883     EXPECT_NE(ret, ERR_NULL_OBJECT);
1884     DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyCompleteFreeInstallFromRemote001 end" << std::endl;
1885 }
1886 
1887 /**
1888  * @tc.name: GetDistributedComponentList001
1889  * @tc.desc: call dms proxy GetDistributedComponentList
1890  * @tc.type: FUNC
1891  * @tc.require: I5X9O4
1892  */
HWTEST_F(DSchedContinuationTest, ProxyCallGetDistributedComponentList001, TestSize.Level3)1893 HWTEST_F(DSchedContinuationTest, ProxyCallGetDistributedComponentList001, TestSize.Level3)
1894 {
1895     DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetDistributedComponentList001 start" << std::endl;
1896     sptr<IDistributedSched> proxy = GetDms();
1897     ASSERT_NE(nullptr, proxy);
1898     vector<string> distributedComponents = { "test "};
1899     int32_t ret = proxy->GetDistributedComponentList(distributedComponents);
1900     EXPECT_NE(ret, ERR_NULL_OBJECT);
1901     DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetDistributedComponentList001 end" << std::endl;
1902 }
1903 
1904 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
1905 /**
1906  * @tc.name: StartShareFormFromRemote001
1907  * @tc.desc: call dms proxy StartShareFormFromRemote
1908  * @tc.type: FUNC
1909  * @tc.require: I5X9O4
1910  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote001, TestSize.Level3)1911 HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote001, TestSize.Level3)
1912 {
1913     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote001 start" << std::endl;
1914     sptr<IDistributedSched> proxy = GetDms();
1915     EXPECT_NE(proxy, nullptr);
1916     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
1917     int32_t ret = proxy->StartShareFormFromRemote("", formShareInfo);
1918     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1919     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote001 end" << std::endl;
1920 }
1921 
1922 /**
1923  * @tc.name: StartShareFormFromRemote002
1924  * @tc.desc: call dms proxy StartShareFormFromRemote
1925  * @tc.type: FUNC
1926  * @tc.require: I5X9O4
1927  */
HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote002, TestSize.Level3)1928 HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote002, TestSize.Level3)
1929 {
1930     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote002 start" << std::endl;
1931     sptr<IDistributedSched> proxy = GetDms();
1932     ASSERT_NE(nullptr, proxy);
1933     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
1934     int32_t ret = proxy->StartShareFormFromRemote("111", formShareInfo);
1935     EXPECT_NE(ret, ERR_NULL_OBJECT);
1936     DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote002 end" << std::endl;
1937 }
1938 #endif
1939 } // DistributedSchedule
1940 } // namespace OHOS
1941