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