1 /*
2  * Copyright (c) 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 
16 #include "dsched_continue_test.h"
17 
18 #include "distributed_sched_service.h"
19 #include "dsched_continue.h"
20 #include "dtbschedmgr_log.h"
21 #include "softbus_error_code.h"
22 #include "test_log.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace DistributedSchedule {
29 
30 namespace {
31     const std::string BASEDIR = "/data/service/el1/public/database/DistributedSchedule";
32     const std::string BUNDLEMAME_1 = "bundleName";
33     const int32_t WAITTIME = 2000;
34     const uint32_t DSCHED_BUFFER_SIZE = 1024;
35 }
SetUpTestCase()36 void DSchedContinueTest::SetUpTestCase()
37 {
38     mkdir(BASEDIR.c_str(), (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
39     dmsStoreMock = std::make_shared<MockDmsMgrDeviceInfoStore>();
40     DmsMgrDeviceInfoStore::dmsStore = dmsStoreMock;
41     DTEST_LOG << "DSchedContinueTest::SetUpTestCase" << std::endl;
42     DistributedSchedService::GetInstance().Init();
43 }
44 
TearDownTestCase()45 void DSchedContinueTest::TearDownTestCase()
46 {
47     (void)remove(BASEDIR.c_str());
48     DmsMgrDeviceInfoStore::dmsStore = nullptr;
49     dmsStoreMock = nullptr;
50     DTEST_LOG << "DSchedContinueTest::TearDownTestCase" << std::endl;
51 }
52 
TearDown()53 void DSchedContinueTest::TearDown()
54 {
55     usleep(WAITTIME);
56     DTEST_LOG << "DSchedContinueTest::TearDown" << std::endl;
57 }
58 
SetUp()59 void DSchedContinueTest::SetUp()
60 {
61     usleep(WAITTIME);
62     DTEST_LOG << "DSchedContinueTest::SetUp" << std::endl;
63 }
64 
65 /**
66  * @tc.name: DSchedContinueTest_001_1
67  * @tc.desc: OnContinueMission and PostStartTask
68  * @tc.type: FUNC
69  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_001_1, TestSize.Level0)70 HWTEST_F(DSchedContinueTest, DSchedContinueTest_001_1, TestSize.Level0)
71 {
72     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_001_1 begin" << std::endl;
73     std::string deviceId = "123";
74     std::string bundleName = "test";
75     int32_t subType = CONTINUE_PULL;
76     int32_t direction = CONTINUE_SINK;
77     sptr<IRemoteObject> callback = nullptr;
78     OHOS::AAFwk::WantParams wantParams;
79     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
80     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
81 
82     // eventHandler_ is null
83     int32_t ret = conti->OnContinueMission(wantParams);
84     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
85 
86     ret = conti->PostStartTask(wantParams);
87     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
88 
89     // eventHandler_ not null
90     conti->Init();
91     ret = conti->PostStartTask(wantParams);
92     EXPECT_EQ(ret, ERR_OK);
93     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_001_1 end ret:" << ret << std::endl;
94     usleep(WAITTIME);
95 }
96 
97 /**
98  * @tc.name: DSchedContinueTest_002_1
99  * @tc.desc: OnStartCmd and PostCotinueAbilityTask
100  * @tc.type: FUNC
101  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_002_1, TestSize.Level0)102 HWTEST_F(DSchedContinueTest, DSchedContinueTest_002_1, TestSize.Level0)
103 {
104     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_002_1 begin" << std::endl;
105     std::string deviceId = "123";
106     std::string bundleName = "test";
107     int32_t subType = CONTINUE_PULL;
108     int32_t direction = CONTINUE_SINK;
109     sptr<IRemoteObject> callback = nullptr;
110     int32_t appVersion = 0;
111     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
112     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
113 
114     // eventHandler_ is null
115     int32_t ret = conti->OnStartCmd(appVersion);
116     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
117 
118     ret = conti->PostCotinueAbilityTask(appVersion);
119     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
120 
121     // eventHandler_ not null
122     conti->Init();
123     ret = conti->PostCotinueAbilityTask(appVersion);
124     EXPECT_EQ(ret, ERR_OK);
125     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_002_1 end ret:" << ret << std::endl;
126     usleep(WAITTIME);
127 }
128 
129 /**
130  * @tc.name: DSchedContinueTest_003
131  * @tc.desc: OnReplyCmd and PostReplyTask
132  * @tc.type: FUNC
133  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_003_1, TestSize.Level0)134 HWTEST_F(DSchedContinueTest, DSchedContinueTest_003_1, TestSize.Level0)
135 {
136     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_003_1 begin" << std::endl;
137     std::string deviceId = "123";
138     std::string bundleName = "test";
139     int32_t subType = CONTINUE_PULL;
140     int32_t direction = CONTINUE_SINK;
141     sptr<IRemoteObject> callback = nullptr;
142     auto cmd = std::make_shared<DSchedContinueReplyCmd>();
143     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
144     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
145 
146     // eventHandler_ is null
147     cmd->replyCmd_ = DSCHED_CONTINUE_CMD_START;
148     int32_t ret = conti->OnReplyCmd(cmd);
149     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
150 
151     ret = conti->PostReplyTask(cmd);
152     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
153 
154     // eventHandler_ not null
155     conti->Init();
156 
157     cmd->replyCmd_ = DSCHED_CONTINUE_END_EVENT;
158     ret = conti->OnReplyCmd(cmd);
159     EXPECT_EQ(ret, ERR_OK);
160 
161     ret = conti->PostReplyTask(cmd);
162     EXPECT_EQ(ret, ERR_OK);
163 
164     cmd->replyCmd_ = DSCHED_CONTINUE_INVALID_EVENT;
165     ret = conti->PostReplyTask(cmd);
166     EXPECT_EQ(ret, ERR_OK);
167 
168     cmd = nullptr;
169     ret = conti->PostReplyTask(cmd);
170     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
171     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_003_1 end ret:" << ret << std::endl;
172     usleep(WAITTIME);
173 }
174 
175 /**
176  * @tc.name: DSchedContinueTest_004_1
177  * @tc.desc: OnStartContinuation and PostContinueSendTask
178  * @tc.type: FUNC
179  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_004_1, TestSize.Level0)180 HWTEST_F(DSchedContinueTest, DSchedContinueTest_004_1, TestSize.Level0)
181 {
182     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_004_1 begin" << std::endl;
183     std::string deviceId = "123";
184     std::string bundleName = "test";
185     int32_t subType = CONTINUE_PULL;
186     int32_t direction = CONTINUE_SINK;
187     sptr<IRemoteObject> callback = nullptr;
188     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
189     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
190 
191     OHOS::AAFwk::Want want;
192     int32_t callerUid = 0;
193     int32_t status = ERR_OK;
194     uint32_t accessToken = 0;
195 
196     // eventHandler_ is null
197     int32_t ret = conti->OnStartContinuation(want, callerUid, status, accessToken);
198     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
199 
200     ret = conti->PostContinueSendTask(want, callerUid, status, accessToken);
201     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
202 
203     // eventHandler_ not null
204     conti->Init();
205 
206     ret = conti->OnStartContinuation(want, callerUid, status, accessToken);
207     EXPECT_EQ(ret, ERR_OK);
208 
209     ret = conti->PostContinueSendTask(want, callerUid, status, accessToken);
210     EXPECT_EQ(ret, ERR_OK);
211 
212     status = ERR_NONE;
213     ret = conti->PostContinueSendTask(want, callerUid, status, accessToken);
214     EXPECT_EQ(ret, ERR_OK);
215     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_004_1 end ret:" << ret << std::endl;
216     usleep(WAITTIME);
217 }
218 
219 /**
220  * @tc.name: DSchedContinueTest_005
221  * @tc.desc: OnContinueDataCmd and PostContinueDataTask
222  * @tc.type: FUNC
223  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_005_1, TestSize.Level0)224 HWTEST_F(DSchedContinueTest, DSchedContinueTest_005_1, TestSize.Level0)
225 {
226     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_005_1 begin" << std::endl;
227     std::string deviceId = "123";
228     std::string bundleName = "test";
229     int32_t subType = CONTINUE_PULL;
230     int32_t direction = CONTINUE_SINK;
231     sptr<IRemoteObject> callback = nullptr;
232     auto cmd = std::make_shared<DSchedContinueDataCmd>();
233     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
234     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
235 
236     // eventHandler_ is null
237     int32_t ret = conti->OnContinueDataCmd(cmd);
238     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
239 
240     ret = conti->PostContinueDataTask(cmd);
241     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
242 
243     // eventHandler_ not null
244     conti->Init();
245 
246     ret = conti->OnContinueDataCmd(cmd);
247     EXPECT_EQ(ret, ERR_OK);
248 
249     ret = conti->PostContinueDataTask(cmd);
250     EXPECT_EQ(ret, ERR_OK);
251     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_005_1 end ret:" << ret << std::endl;
252     usleep(WAITTIME);
253 }
254 
255 /**
256  * @tc.name: DSchedContinueTest_006_1
257  * @tc.desc: OnNotifyComplete, OnContinueEndCmd and PostNotifyCompleteTask
258  * @tc.type: FUNC
259  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_006_1, TestSize.Level0)260 HWTEST_F(DSchedContinueTest, DSchedContinueTest_006_1, TestSize.Level0)
261 {
262     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_006_1 begin" << std::endl;
263     std::string deviceId = "123";
264     std::string bundleName = "test";
265     int32_t subType = CONTINUE_PULL;
266     int32_t direction = CONTINUE_SINK;
267     sptr<IRemoteObject> callback = nullptr;
268     int32_t missionId = 1;
269     bool isSuccess = true;
270     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
271     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
272 
273     // OnNotifyComplete
274     int32_t ret = conti->OnNotifyComplete(missionId, isSuccess);
275     EXPECT_EQ(ret, ERR_OK);
276 
277     missionId = 0;
278     ret = conti->OnNotifyComplete(missionId, isSuccess);
279     EXPECT_EQ(ret, ERR_OK);
280 
281     isSuccess = false;
282     ret = conti->OnNotifyComplete(missionId, isSuccess);
283     EXPECT_EQ(ret, ERR_OK);
284 
285     // eventHandler_ is null
286     auto cmd = std::make_shared<DSchedContinueEndCmd>();
287     ret = conti->OnContinueEndCmd(cmd);
288     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
289 
290     ret = conti->PostNotifyCompleteTask(ERR_OK);
291     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
292 
293     // eventHandler_ not null
294     conti->Init();
295     ret = conti->PostNotifyCompleteTask(ERR_OK);
296     EXPECT_EQ(ret, ERR_OK);
297 
298     cmd = nullptr;
299     ret = conti->OnContinueEndCmd(cmd);
300     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
301     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_006_1 end ret:" << ret << std::endl;
302     usleep(WAITTIME);
303 }
304 
305 /**
306  * @tc.name: DSchedContinueTest_007_1
307  * @tc.desc: OnContinueEnd and PostContinueEndTask
308  * @tc.type: FUNC
309  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_007_1, TestSize.Level0)310 HWTEST_F(DSchedContinueTest, DSchedContinueTest_007_1, TestSize.Level0)
311 {
312     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_007_1 begin" << std::endl;
313     std::string deviceId = "123";
314     std::string bundleName = "test";
315     int32_t subType = CONTINUE_PULL;
316     int32_t direction = CONTINUE_SINK;
317     sptr<IRemoteObject> callback = nullptr;
318     int32_t result = ERR_OK;
319     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
320     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
321 
322     // eventHandler_ is null
323     int32_t ret = conti->OnContinueEnd(result);
324     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
325 
326     ret = conti->PostContinueEndTask(result);
327     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
328 
329     // eventHandler_ not null
330     conti->Init();
331     ret = conti->PostContinueEndTask(result);
332     EXPECT_EQ(ret, ERR_OK);
333     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_007_1 end ret:" << ret << std::endl;
334     usleep(WAITTIME);
335 }
336 
337 /**
338  * @tc.name: DSchedContinueTest_008_1
339  * @tc.desc: ExecuteContinueReq
340  * @tc.type: FUNC
341  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_008_1, TestSize.Level0)342 HWTEST_F(DSchedContinueTest, DSchedContinueTest_008_1, TestSize.Level0)
343 {
344     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_008_1 begin" << std::endl;
345     std::string deviceId = "123";
346     std::string bundleName = "test";
347     int32_t subType = CONTINUE_PULL;
348     int32_t direction = CONTINUE_SINK;
349     sptr<IRemoteObject> callback = nullptr;
350     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
351     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
352     conti->Init();
353 
354     auto wantParams = std::make_shared<DistributedWantParams>();
355     int32_t ret = conti->ExecuteContinueReq(wantParams);
356     EXPECT_NE(ret, ERR_OK);
357 
358     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_008_1 end ret:" << ret << std::endl;
359     usleep(WAITTIME);
360 }
361 
362 /**
363  * @tc.name: DSchedContinueTest_009_1
364  * @tc.desc: PackStartCmd
365  * @tc.type: FUNC
366  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_009_1, TestSize.Level0)367 HWTEST_F(DSchedContinueTest, DSchedContinueTest_009_1, TestSize.Level0)
368 {
369     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_009_1 begin" << std::endl;
370     std::string deviceId = "123";
371     std::string bundleName = "test";
372     int32_t subType = CONTINUE_PUSH;
373     int32_t direction = CONTINUE_SINK;
374     sptr<IRemoteObject> callback = nullptr;
375     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
376     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
377     conti->Init();
378 
379     auto cmd = std::make_shared<DSchedContinueStartCmd>();
380     auto wantParams = std::make_shared<DistributedWantParams>();
381 
382     int32_t ret = conti->PackStartCmd(cmd, wantParams);
383     EXPECT_EQ(ret, ERR_OK);
384 
385     wantParams = nullptr;
386     ret = conti->PackStartCmd(cmd, wantParams);
387     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
388 
389     wantParams = std::make_shared<DistributedWantParams>();
390     conti->continueInfo_.missionId_ = 0;
391     EXPECT_NE(ret, ERR_OK);
392     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_009_1 end ret:" << ret << std::endl;
393     usleep(WAITTIME);
394 }
395 
396 /**
397  * @tc.name: DSchedContinueTest_0010_1
398  * @tc.desc: ExecuteContinueAbility
399  * @tc.type: FUNC
400  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0010_1, TestSize.Level0)401 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0010_1, TestSize.Level0)
402 {
403     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0010_1 begin" << std::endl;
404     std::string deviceId = "123";
405     std::string bundleName = "test";
406     int32_t subType = CONTINUE_PULL;
407     int32_t direction = CONTINUE_SINK;
408     int32_t missionId = 1;
409     sptr<IRemoteObject> callback = nullptr;
410     auto info = DSchedContinueInfo(deviceId, deviceId, missionId);
411     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
412     conti->Init();
413 
414     int32_t appVersion = 0;
415     int32_t ret = conti->ExecuteContinueAbility(appVersion);
416     EXPECT_NE(ret, ERR_OK);
417     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0010_1 end ret:" << ret << std::endl;
418     usleep(WAITTIME);
419 }
420 
421 /**
422  * @tc.name: DSchedContinueTest_0011_1
423  * @tc.desc: GetMissionIdByBundleName
424  * @tc.type: FUNC
425  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0011_1, TestSize.Level0)426 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0011_1, TestSize.Level0)
427 {
428     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0011_1 begin" << std::endl;
429     std::string deviceId = "123";
430     int32_t subType = CONTINUE_PULL;
431     int32_t direction = CONTINUE_SINK;
432     int32_t missionId = 1;
433     sptr<IRemoteObject> callback = nullptr;
434     auto info = DSchedContinueInfo(deviceId, deviceId, missionId);
435     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
436     conti->Init();
437 
438     int32_t ret = conti->GetMissionIdByBundleName();
439     EXPECT_EQ(ret, ERR_OK);
440     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0011_1 end ret:" << ret << std::endl;
441     usleep(WAITTIME);
442 }
443 
444 /**
445  * @tc.name: DSchedContinueTest_0012_1
446  * @tc.desc: CheckContinueAbilityPermission
447  * @tc.type: FUNC
448  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0012_1, TestSize.Level0)449 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0012_1, TestSize.Level0)
450 {
451     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0012_1 begin" << std::endl;
452     std::string deviceId = "123";
453     std::string bundleName = "test";
454     int32_t subType = CONTINUE_PULL;
455     int32_t direction = CONTINUE_SINK;
456     sptr<IRemoteObject> callback = nullptr;
457     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
458     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
459     conti->Init();
460 
461     int32_t ret = conti->CheckContinueAbilityPermission();
462     EXPECT_EQ(ret, NO_MISSION_INFO_FOR_MISSION_ID);
463     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0012_1 end ret:" << ret << std::endl;
464     usleep(WAITTIME);
465 }
466 
467 /**
468  * @tc.name: DSchedContinueTest_0013_1
469  * @tc.desc: ExecuteContinueReply
470  * @tc.type: FUNC
471  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0013_1, TestSize.Level0)472 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0013_1, TestSize.Level0)
473 {
474     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0013_1 begin" << std::endl;
475     std::string deviceId = "123";
476     std::string bundleName = "test";
477     int32_t subType = CONTINUE_PULL;
478     int32_t direction = CONTINUE_SINK;
479     sptr<IRemoteObject> callback = nullptr;
480     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
481     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
482     conti->Init();
483 
484     int32_t ret = conti->ExecuteContinueReply();
485     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
486     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0013_1 end ret:" << ret << std::endl;
487     usleep(WAITTIME);
488 }
489 
490 /**
491  * @tc.name: DSchedContinueTest_0014_1
492  * @tc.desc: ExecuteContinueSend
493  * @tc.type: FUNC
494  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0014_1, TestSize.Level0)495 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0014_1, TestSize.Level0)
496 {
497     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0014_1 begin" << std::endl;
498     std::string deviceId = "123";
499     std::string bundleName = "test";
500     int32_t subType = CONTINUE_PULL;
501     int32_t direction = CONTINUE_SINK;
502     sptr<IRemoteObject> callback = nullptr;
503     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
504     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
505     conti->Init();
506 
507     auto data = std::make_shared<ContinueAbilityData>();
508     int32_t ret = conti->ExecuteContinueSend(data);
509     EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
510 
511     data = nullptr;
512     ret = conti->ExecuteContinueSend(data);
513     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
514     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0014_1 end ret:" << ret << std::endl;
515     usleep(WAITTIME);
516 }
517 
518 /**
519  * @tc.name: DSchedContinueTest_0015_1
520  * @tc.desc: SetWantForContinuation
521  * @tc.type: FUNC
522  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0015_1, TestSize.Level0)523 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0015_1, TestSize.Level0)
524 {
525     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0015_1 begin" << std::endl;
526     std::string deviceId = "123";
527     std::string bundleName = "test";
528     int32_t subType = CONTINUE_PULL;
529     int32_t direction = CONTINUE_SINK;
530     sptr<IRemoteObject> callback = nullptr;
531     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
532     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
533     conti->Init();
534 
535     AAFwk::Want want;
536     int32_t ret = conti->SetWantForContinuation(want);
537     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
538     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0015_1 end ret:" << ret << std::endl;
539     usleep(WAITTIME);
540 }
541 
542 /**
543  * @tc.name: DSchedContinueTest_0016_1
544  * @tc.desc: PackDataCmd
545  * @tc.type: FUNC
546  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0016_1, TestSize.Level0)547 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0016_1, TestSize.Level0)
548 {
549     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0016_1 begin" << std::endl;
550     std::string deviceId = "123";
551     std::string bundleName = "test";
552     int32_t subType = CONTINUE_PULL;
553     int32_t direction = CONTINUE_SINK;
554     sptr<IRemoteObject> callback = nullptr;
555     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
556     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
557     conti->Init();
558 
559     auto cmd = std::make_shared<DSchedContinueDataCmd>();
560     OHOS::AAFwk::Want want;
561     AppExecFwk::AbilityInfo abilityInfo;
562     CallerInfo callerInfo;
563     AccountInfo accountInfo;
564 
565     int32_t ret = conti->PackDataCmd(cmd, want, abilityInfo, callerInfo, accountInfo);
566     EXPECT_EQ(ret, ERR_OK);
567 
568     cmd = nullptr;
569     ret = conti->PackDataCmd(cmd, want, abilityInfo, callerInfo, accountInfo);
570     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
571     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0016_1 end ret:" << ret << std::endl;
572     usleep(WAITTIME);
573 }
574 
575 /**
576  * @tc.name: DSchedContinueTest_0017_1
577  * @tc.desc: ExecuteContinueData
578  * @tc.type: FUNC
579  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0017_1, TestSize.Level0)580 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0017_1, TestSize.Level0)
581 {
582     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0017_1 begin" << std::endl;
583     std::string deviceId = "123";
584     std::string bundleName = "test";
585     int32_t subType = CONTINUE_PULL;
586     int32_t direction = CONTINUE_SINK;
587     sptr<IRemoteObject> callback = nullptr;
588     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
589     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
590     conti->Init();
591 
592     auto cmd = std::make_shared<DSchedContinueDataCmd>();
593 
594     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
595     int32_t ret = conti->ExecuteContinueData(cmd);
596     EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
597 
598     cmd = nullptr;
599     ret = conti->ExecuteContinueData(cmd);
600     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
601     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0017_1 end ret:" << ret << std::endl;
602     usleep(WAITTIME);
603 }
604 
605 /**
606  * @tc.name: DSchedContinueTest_0018_1
607  * @tc.desc: ExecuteNotifyComplete
608  * @tc.type: FUNC
609  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0018_1, TestSize.Level0)610 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0018_1, TestSize.Level0)
611 {
612     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0018_1 begin" << std::endl;
613     std::string deviceId = "123";
614     std::string bundleName = "test";
615     int32_t subType = CONTINUE_PULL;
616     int32_t direction = CONTINUE_SINK;
617     sptr<IRemoteObject> callback = nullptr;
618     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
619     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
620     conti->Init();
621 
622     int32_t result = ERR_OK;
623     int32_t ret = conti->ExecuteNotifyComplete(result);
624     EXPECT_NE(ret, ERR_OK);
625 
626     direction = CONTINUE_SOURCE;
627     ret = conti->ExecuteNotifyComplete(result);
628     EXPECT_NE(ret, ERR_OK);
629     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0018_1 end ret:" << ret << std::endl;
630     usleep(WAITTIME);
631 }
632 
633 /**
634  * @tc.name: DSchedContinueTest_0019_1
635  * @tc.desc: PackReplyCmd
636  * @tc.type: FUNC
637  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0019_1, TestSize.Level0)638 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0019_1, TestSize.Level0)
639 {
640     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0019_1 begin" << std::endl;
641     std::string deviceId = "123";
642     std::string bundleName = "test";
643     int32_t subType = CONTINUE_PULL;
644     int32_t direction = CONTINUE_SINK;
645     sptr<IRemoteObject> callback = nullptr;
646     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
647     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
648     conti->Init();
649 
650     auto cmd = std::make_shared<DSchedContinueReplyCmd>();
651     int32_t replyCmd = 0;
652     int32_t appVersion = 0;
653     int32_t result = 0;
654 
655     int32_t ret = conti->PackReplyCmd(cmd, replyCmd, appVersion, result, "");
656     EXPECT_EQ(ret, ERR_OK);
657 
658     cmd = nullptr;
659     ret = conti->PackReplyCmd(cmd, replyCmd, appVersion, result, "");
660     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
661     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0019_1 end ret:" << ret << std::endl;
662     usleep(WAITTIME);
663 }
664 
665 /**
666  * @tc.name: DSchedContinueTest_0020_1
667  * @tc.desc: ExecuteContinueEnd
668  * @tc.type: FUNC
669  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0020_1, TestSize.Level0)670 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0020_1, TestSize.Level0)
671 {
672     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0020_1 begin" << std::endl;
673     std::string deviceId = "123";
674     std::string bundleName = "test";
675     int32_t subType = CONTINUE_PULL;
676     int32_t direction = CONTINUE_SINK;
677     sptr<IRemoteObject> callback = nullptr;
678     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
679     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
680     conti->Init();
681 
682     int32_t result = 0;
683 
684     int32_t ret = conti->ExecuteContinueEnd(result);
685     EXPECT_EQ(ret, ERR_OK);
686     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0020_1 end ret:" << ret << std::endl;
687     usleep(WAITTIME);
688 }
689 
690 /**
691  * @tc.name: DSchedContinueTest_0021_1
692  * @tc.desc: ExecuteContinueError
693  * @tc.type: FUNC
694  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0021_1, TestSize.Level0)695 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0021_1, TestSize.Level0)
696 {
697     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0021_1 begin" << std::endl;
698     std::string deviceId = "123";
699     std::string bundleName = "test";
700     int32_t subType = CONTINUE_PULL;
701     int32_t direction = CONTINUE_SINK;
702     sptr<IRemoteObject> callback = nullptr;
703     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
704     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
705     conti->Init();
706 
707     int32_t result = 0;
708     int32_t ret = conti->ExecuteContinueError(result);
709     EXPECT_EQ(ret, ERR_OK);
710 
711     direction = CONTINUE_SOURCE;
712     ret = conti->ExecuteContinueError(result);
713     EXPECT_EQ(ret, ERR_OK);
714     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0021_1 end ret:" << ret << std::endl;
715     usleep(WAITTIME);
716 }
717 
718 /**
719  * @tc.name: DSchedContinueTest_0022_1
720  * @tc.desc: PackEndCmd
721  * @tc.type: FUNC
722  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0022_1, TestSize.Level0)723 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0022_1, TestSize.Level0)
724 {
725     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0022_1 begin" << std::endl;
726     std::string deviceId = "123";
727     std::string bundleName = "test";
728     int32_t subType = CONTINUE_PULL;
729     int32_t direction = CONTINUE_SINK;
730     sptr<IRemoteObject> callback = nullptr;
731     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
732     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
733     conti->Init();
734 
735     auto cmd = std::make_shared<DSchedContinueEndCmd>();
736     int32_t result = 0;
737 
738     int32_t ret = conti->PackEndCmd(cmd, result);
739     EXPECT_EQ(ret, ERR_OK);
740 
741     cmd = nullptr;
742     ret = conti->PackEndCmd(cmd, result);
743     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
744     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0022_1 end ret:" << ret << std::endl;
745     usleep(WAITTIME);
746 }
747 
748 /**
749  * @tc.name: DSchedContinueTest_0023_1
750  * @tc.desc: SendCommand
751  * @tc.type: FUNC
752  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0023_1, TestSize.Level0)753 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0023_1, TestSize.Level0)
754 {
755     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0023_1 begin" << std::endl;
756     std::string deviceId = "123";
757     std::string bundleName = "test";
758     int32_t subType = CONTINUE_PULL;
759     int32_t direction = CONTINUE_SINK;
760     sptr<IRemoteObject> callback = nullptr;
761     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
762     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
763     conti->Init();
764 
765     auto cmd = std::make_shared<DSchedContinueCmdBase>();
766     int32_t ret = conti->SendCommand(cmd);
767     EXPECT_NE(ret, ERR_OK);
768     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0023_1 end ret:" << ret << std::endl;
769     usleep(WAITTIME);
770 }
771 
772 /**
773  * @tc.name: DSchedContinueTest_0024_1
774  * @tc.desc: GetLocalDeviceId
775  * @tc.type: FUNC
776  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0024_1, TestSize.Level0)777 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0024_1, TestSize.Level0)
778 {
779     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0024_1 begin" << std::endl;
780     std::string deviceId = "123";
781     std::string bundleName = "test";
782     int32_t subType = CONTINUE_PULL;
783     int32_t direction = CONTINUE_SINK;
784     sptr<IRemoteObject> callback = nullptr;
785     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
786     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
787     conti->Init();
788 
789     std::string localDeviceId;
790     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
791     bool ret = conti->GetLocalDeviceId(localDeviceId);
792     EXPECT_EQ(ret, true);
793     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0024_1 end ret:" << ret << std::endl;
794     usleep(WAITTIME);
795 }
796 
797 /**
798  * @tc.name: DSchedContinueTest_0025_1
799  * @tc.desc: CheckDeviceIdFromRemote
800  * @tc.type: FUNC
801  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_0025_1, TestSize.Level0)802 HWTEST_F(DSchedContinueTest, DSchedContinueTest_0025_1, TestSize.Level0)
803 {
804     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0025_1 begin" << std::endl;
805     std::string deviceId = "123";
806     std::string bundleName = "test";
807     int32_t subType = CONTINUE_PULL;
808     int32_t direction = CONTINUE_SINK;
809     sptr<IRemoteObject> callback = nullptr;
810     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
811     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
812     conti->Init();
813 
814     bool ret = conti->CheckDeviceIdFromRemote("", "", "");
815     EXPECT_FALSE(ret);
816 
817     std::string localDevId = "localDevId";
818     std::string destDevId = "destDevId";
819     std::string srcDevId = "srcDevId";
820     ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
821     EXPECT_FALSE(ret);
822 
823     destDevId = "localDevId";
824     srcDevId = "localDevId";
825     ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
826     EXPECT_FALSE(ret);
827 
828     conti->continueInfo_.sourceDeviceId_ = "localDevId";
829     ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
830     EXPECT_FALSE(ret);
831 
832     srcDevId = "srcDevId";
833     conti->continueInfo_.sourceDeviceId_ = "srcDevId";
834     ret = conti->CheckDeviceIdFromRemote(localDevId, destDevId, srcDevId);
835     EXPECT_TRUE(ret);
836     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_0025_1 end ret:" << ret << std::endl;
837     usleep(WAITTIME);
838 }
839 
840 /**
841  * @tc.name: WaitAbilityStateInitialTest_0026_1
842  * @tc.desc: WaitAbilityStateInitialTest
843  * @tc.type: FUNC
844  */
HWTEST_F(DSchedContinueTest, WaitAbilityStateInitialTest_0026_1, TestSize.Level0)845 HWTEST_F(DSchedContinueTest, WaitAbilityStateInitialTest_0026_1, TestSize.Level0)
846 {
847     DTEST_LOG << "DSchedContinueTest WaitAbilityStateInitialTest_0026_1 begin" << std::endl;
848     std::string deviceId = "123";
849     std::string bundleName = "test";
850     int32_t subType = CONTINUE_PULL;
851     int32_t direction = CONTINUE_SINK;
852     sptr<IRemoteObject> callback = nullptr;
853     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
854     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
855     conti->Init();
856 
857     int32_t persistentId = 100;
858     bool ret = conti->WaitAbilityStateInitial(persistentId);
859     EXPECT_FALSE(ret);
860     DTEST_LOG << "DSchedContinueTest WaitAbilityStateInitialTest_0026_1 end ret:" << ret << std::endl;
861     usleep(WAITTIME);
862 }
863 
864 /**
865  * @tc.name: StartAbilityTest_0027_1
866  * @tc.desc: StartAbilityTest
867  * @tc.type: FUNC
868  */
HWTEST_F(DSchedContinueTest, StartAbilityTest_0027_1, TestSize.Level0)869 HWTEST_F(DSchedContinueTest, StartAbilityTest_0027_1, TestSize.Level0)
870 {
871     DTEST_LOG << "DSchedContinueTest StartAbilityTest_0027_1 begin" << std::endl;
872     std::string deviceId = "123";
873     std::string bundleName = "test";
874     int32_t subType = CONTINUE_PULL;
875     int32_t direction = CONTINUE_SINK;
876     sptr<IRemoteObject> callback = nullptr;
877     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
878     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
879     conti->Init();
880 
881     AAFwk::Want want;
882     AppExecFwk::ElementName element("devicdId", "com.ohos.distributedmusicplayer",
883         "com.ohos.distributedmusicplayer.MainAbility");
884     want.SetElement(element);
885     int32_t ret = conti->StartAbility(want, 0);
886     EXPECT_NE(ret, ERR_OK);
887     DTEST_LOG << "DSchedContinueTest StartAbilityTest_0027_1 end ret:" << ret << std::endl;
888     usleep(WAITTIME);
889 }
890 
891 /**
892  * @tc.name: QuerySinkAbilityNameTest_0028_1
893  * @tc.desc: QuerySinkAbilityNameTest
894  * @tc.type: FUNC
895  */
HWTEST_F(DSchedContinueTest, QuerySinkAbilityNameTest_0028_1, TestSize.Level0)896 HWTEST_F(DSchedContinueTest, QuerySinkAbilityNameTest_0028_1, TestSize.Level0)
897 {
898     DTEST_LOG << "DSchedContinueTest QuerySinkAbilityNameTest_0028_1 begin" << std::endl;
899     std::string deviceId = "123";
900     std::string bundleName = "test";
901     int32_t subType = CONTINUE_PULL;
902     int32_t direction = CONTINUE_SINK;
903     std::string continueType = "test";
904     sptr<IRemoteObject> callback = nullptr;
905     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, continueType);
906     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
907     conti->Init();
908 
909     std::string sinkBundleName = conti->QuerySinkAbilityName();
910     EXPECT_TRUE(sinkBundleName.empty());
911     DTEST_LOG << "DSchedContinueTest QuerySinkAbilityNameTest_0028_1 end" << std::endl;
912     usleep(WAITTIME);
913 }
914 
915 /**
916  * @tc.name: QuickStartAbilityTest_0029_1
917  * @tc.desc: QuickStartAbilityTest
918  * @tc.type: FUNC
919  */
HWTEST_F(DSchedContinueTest, QuickStartAbilityTest_0029_1, TestSize.Level0)920 HWTEST_F(DSchedContinueTest, QuickStartAbilityTest_0029_1, TestSize.Level0)
921 {
922     DTEST_LOG << "DSchedContinueTest QuickStartAbilityTest_0029_1 begin" << std::endl;
923     std::string deviceId = "123";
924     std::string bundleName = "test";
925     int32_t subType = CONTINUE_PULL;
926     int32_t direction = CONTINUE_SINK;
927     sptr<IRemoteObject> callback = nullptr;
928     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
929     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
930     conti->Init();
931 
932     int32_t ret = conti->QuickStartAbility();
933     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
934     DTEST_LOG << "DSchedContinueTest QuickStartAbilityTest_0029_1 end ret:" << ret << std::endl;
935     usleep(WAITTIME);
936 }
937 
938 /**
939  * @tc.name: UpdateWantForContinueTypeTest_0030_1
940  * @tc.desc: UpdateWantForContinueTypeTest
941  * @tc.type: FUNC
942  */
HWTEST_F(DSchedContinueTest, UpdateWantForContinueTypeTest_0030_1, TestSize.Level0)943 HWTEST_F(DSchedContinueTest, UpdateWantForContinueTypeTest_0030_1, TestSize.Level0)
944 {
945     DTEST_LOG << "DSchedContinueTest UpdateWantForContinueTypeTest_0030_1 begin" << std::endl;
946     std::string deviceId = "123";
947     std::string bundleName = "test";
948     int32_t subType = CONTINUE_PULL;
949     int32_t direction = CONTINUE_SINK;
950     sptr<IRemoteObject> callback = nullptr;
951     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
952     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
953     conti->Init();
954 
955     AAFwk::Want want;
956     AppExecFwk::ElementName element("devicdId", "com.ohos.distributedmusicplayer",
957         "com.ohos.distributedmusicplayer.MainAbility");
958     want.SetElement(element);
959     int32_t ret = conti->UpdateWantForContinueType(want);
960     EXPECT_EQ(ret, ERR_OK);
961     DTEST_LOG << "DSchedContinueTest UpdateWantForContinueTypeTest_0030_1 end ret:" << ret << std::endl;
962     usleep(WAITTIME);
963 }
964 
965 /**
966  * @tc.name: DSchedContinueTest_031_1
967  * @tc.desc: DSchedContinue
968  * @tc.type: FUNC
969  */
HWTEST_F(DSchedContinueTest, DSchedContinueTest_031_1, TestSize.Level0)970 HWTEST_F(DSchedContinueTest, DSchedContinueTest_031_1, TestSize.Level0)
971 {
972     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_031_1 begin" << std::endl;
973     std::string deviceId = "123";
974     std::string bundleName = "test";
975     int32_t subType = CONTINUE_PULL;
976     int32_t direction = CONTINUE_SINK;
977     sptr<IRemoteObject> callback = nullptr;
978     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
979     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
980     conti->Init();
981 
982     AppExecFwk::InnerEvent *event = nullptr;
983     auto destructor = [](AppExecFwk::InnerEvent *event) {
984         if (event != nullptr) {
985             delete event;
986         }
987     };
988     conti->ProcessEvent(AppExecFwk::InnerEvent::Pointer(event, destructor));
989     conti->continueInfo_.continueType_ = "";
990     conti->CheckQuickStartConfiguration();
991     conti->GetSessionId();
992     conti->GetAbilityNameByContinueType();
993     EXPECT_NE(nullptr, conti->stateMachine_);
994     DTEST_LOG << "DSchedContinueTest DSchedContinueTest_031_1 end" << std::endl;
995     usleep(WAITTIME);
996 }
997 
998 /**
999  * @tc.name: OnDataRecvTest_032_1
1000  * @tc.desc: OnDataRecv
1001  * @tc.type: FUNC
1002  */
HWTEST_F(DSchedContinueTest, OnDataRecvTest_032_1, TestSize.Level0)1003 HWTEST_F(DSchedContinueTest, OnDataRecvTest_032_1, TestSize.Level0)
1004 {
1005     DTEST_LOG << "DSchedContinueTest OnDataRecvTest_032_1 begin" << std::endl;
1006     std::string deviceId = "123";
1007     std::string bundleName = "test";
1008     int32_t subType = CONTINUE_PULL;
1009     int32_t direction = CONTINUE_SINK;
1010     sptr<IRemoteObject> callback = nullptr;
1011     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
1012     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
1013     conti->Init();
1014 
1015     int32_t command = 0;
1016     std::shared_ptr<DSchedDataBuffer> dataBuffer = nullptr;
1017     conti->OnDataRecv(command, dataBuffer);
1018     EXPECT_EQ(nullptr, dataBuffer);
1019     command = DSCHED_CONTINUE_CMD_START;
1020     dataBuffer = std::make_shared<DSchedDataBuffer>(DSCHED_BUFFER_SIZE);
1021     conti->OnDataRecv(command, dataBuffer);
1022     EXPECT_NE(nullptr, dataBuffer);
1023     command = DSCHED_CONTINUE_CMD_DATA;
1024     conti->OnDataRecv(command, dataBuffer);
1025     EXPECT_NE(nullptr, dataBuffer);
1026     command = DSCHED_CONTINUE_CMD_REPLY;
1027     conti->OnDataRecv(command, dataBuffer);
1028     EXPECT_NE(nullptr, dataBuffer);
1029     command = DSCHED_CONTINUE_CMD_END;
1030     conti->OnDataRecv(command, dataBuffer);
1031     EXPECT_NE(nullptr, dataBuffer);
1032     command = DSCHED_CONTINUE_CMD_MIN;
1033     conti->OnDataRecv(command, dataBuffer);
1034     EXPECT_NE(nullptr, dataBuffer);
1035     DTEST_LOG << "DSchedContinueTest OnDataRecvTest_032_1 end" << std::endl;
1036     usleep(WAITTIME);
1037 }
1038 
1039 /**
1040  * @tc.name: UpdateStateTest_033_1
1041  * @tc.desc: UpdateState
1042  * @tc.type: FUNC
1043  */
HWTEST_F(DSchedContinueTest, UpdateStateTest_033_1, TestSize.Level0)1044 HWTEST_F(DSchedContinueTest, UpdateStateTest_033_1, TestSize.Level0)
1045 {
1046     DTEST_LOG << "DSchedContinueTest UpdateStateTest_033_1 begin" << std::endl;
1047     std::string deviceId = "123";
1048     std::string bundleName = "test";
1049     int32_t subType = CONTINUE_PULL;
1050     int32_t direction = CONTINUE_SINK;
1051     sptr<IRemoteObject> callback = nullptr;
1052     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
1053     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
1054     conti->Init();
1055 
1056     DSchedContinueStateType stateType = DSCHED_CONTINUE_SINK_START_STATE;
1057     conti->UpdateState(stateType);
1058     EXPECT_NE(nullptr, conti->stateMachine_);
1059     DTEST_LOG << "DSchedContinueTest UpdateStateTest_033_1 end" << std::endl;
1060 }
1061 
1062 /**
1063  * @tc.name: CheckStartPermission_034_1
1064  * @tc.desc: CheckStartPermission
1065  * @tc.type: FUNC
1066  */
HWTEST_F(DSchedContinueTest, CheckStartPermission_034_1, TestSize.Level0)1067 HWTEST_F(DSchedContinueTest, CheckStartPermission_034_1, TestSize.Level0)
1068 {
1069     DTEST_LOG << "DSchedContinueTest CheckStartPermission_034_1 begin" << std::endl;
1070     auto cmd = std::make_shared<DSchedContinueDataCmd>();
1071     ASSERT_NE(nullptr, cmd);
1072     cmd->srcBundleName_ = BUNDLEMAME_1;
1073     cmd->dstBundleName_ = BUNDLEMAME_1;
1074     std::string deviceId = "123";
1075     std::string bundleName = "test";
1076     int32_t subType = CONTINUE_PULL;
1077     int32_t direction = CONTINUE_SINK;
1078     sptr<IRemoteObject> callback = nullptr;
1079     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
1080     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
1081     conti->Init();
1082 
1083     int32_t ret = conti->CheckStartPermission(cmd);
1084     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1085     cmd->srcBundleName_.clear();
1086     ret = conti->CheckStartPermission(cmd);
1087     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1088     DTEST_LOG << "DSchedContinueTest CheckStartPermission_034_1 end" << std::endl;
1089 }
1090 
1091 /**
1092  * @tc.name: ConvertToDmsSdkErr_035_1
1093  * @tc.desc: ConvertToDmsSdkErr
1094  * @tc.type: FUNC
1095  */
HWTEST_F(DSchedContinueTest, ConvertToDmsSdkErr_035_1, TestSize.Level0)1096 HWTEST_F(DSchedContinueTest, ConvertToDmsSdkErr_035_1, TestSize.Level0)
1097 {
1098     DTEST_LOG << "DSchedContinueTest ConvertToDmsSdkErr_035_1 begin" << std::endl;
1099     auto cmd = std::make_shared<DSchedContinueDataCmd>();
1100     ASSERT_NE(nullptr, cmd);
1101     cmd->srcBundleName_ = BUNDLEMAME_1;
1102     cmd->dstBundleName_ = BUNDLEMAME_1;
1103     std::string deviceId = "123";
1104     std::string bundleName = "test";
1105     int32_t subType = CONTINUE_PULL;
1106     int32_t direction = CONTINUE_SINK;
1107     sptr<IRemoteObject> callback = nullptr;
1108     auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
1109     auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
1110     conti->Init();
1111 
1112     int32_t ret = conti->ConvertToDmsSdkErr(0);
1113     EXPECT_EQ(ret, ERR_OK);
1114     ret = conti->ConvertToDmsSdkErr(SoftBusErrNo::SOFTBUS_CONN_PASSIVE_TYPE_AP_STA_CHIP_CONFLICT);
1115     EXPECT_EQ(ret,  DmsInterfaceSdkErr::ERR_BIND_REMOTE_HOTSPOT_ENABLE_STATE);
1116     ret = conti->ConvertToDmsSdkErr(-1);
1117     EXPECT_EQ(ret, DmsInterfaceSdkErr::ERR_DMS_WORK_ABNORMALLY);
1118     DTEST_LOG << "DSchedContinueTest ConvertToDmsSdkErr_035_1 end" << std::endl;
1119 }
1120 }
1121 }
1122