1 /*
2 * Copyright (c) 2024-2025 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_manager_test.h"
17
18 #include "datetime_ex.h"
19
20 #include "dtbschedmgr_device_info_storage.h"
21 #include "distributed_sched_test_util.h"
22 #include "test_log.h"
23 #include "mock_distributed_sched.h"
24
25 using namespace testing;
26 using namespace testing::ext;
27 using namespace OHOS::DistributedHardware;
28
29 namespace OHOS {
30 namespace DistributedSchedule {
31
32 static std::shared_ptr<DmsDeviceInfo> g_mockDeviceInfoPtr = nullptr;
33 static bool g_mockDbs = false;
34
35 namespace {
36 const std::string LOCAL_DEVICEID = "localdeviceid";
37 const std::string REMOTE_DEVICEID = "remotedeviceid";
38 const std::string CONTINUETYPE = "continueType";
39 const std::string BASEDIR = "/data/service/el1/public/database/DistributedSchedule";
40 constexpr int32_t MISSION_ID = 1;
41 constexpr size_t SIZE = 10;
42 const int32_t WAITTIME = 2000;
43 const std::string BUNDLE_NAME = "com.ohos.permissionmanager";
44 }
45
GetDeviceInfoById(const std::string & networkId)46 std::shared_ptr<DmsDeviceInfo> DtbschedmgrDeviceInfoStorage::GetDeviceInfoById(const std::string& networkId)
47 {
48 return g_mockDeviceInfoPtr;
49 }
50
GetDistributedBundleInfo(const std::string & networkId,const uint16_t & bundleNameId,DmsBundleInfo & distributeBundleInfo)51 bool DmsBmStorage::GetDistributedBundleInfo(const std::string &networkId,
52 const uint16_t &bundleNameId, DmsBundleInfo &distributeBundleInfo)
53 {
54 return g_mockDbs;
55 }
56
SetUpTestCase()57 void DSchedContinueManagerTest::SetUpTestCase()
58 {
59 mkdir(BASEDIR.c_str(), (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
60 const std::string pkgName = "DBinderBus_PermissionTest" + std::to_string(getprocpid());
61 std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
62 DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
63 dmsStoreMock = std::make_shared<MockDmsMgrDeviceInfoStore>();
64 DmsMgrDeviceInfoStore::dmsStore = dmsStoreMock;
65 DTEST_LOG << "DSchedContinueManagerTest::SetUpTestCase" << std::endl;
66 }
67
TearDownTestCase()68 void DSchedContinueManagerTest::TearDownTestCase()
69 {
70 (void)remove(BASEDIR.c_str());
71 DmsMgrDeviceInfoStore::dmsStore = nullptr;
72 dmsStoreMock = nullptr;
73 DTEST_LOG << "DSchedContinueManagerTest::TearDownTestCase" << std::endl;
74 }
75
TearDown()76 void DSchedContinueManagerTest::TearDown()
77 {
78 usleep(WAITTIME);
79 DTEST_LOG << "DSchedContinueManagerTest::TearDown" << std::endl;
80 }
81
SetUp()82 void DSchedContinueManagerTest::SetUp()
83 {
84 usleep(WAITTIME);
85 g_mockDeviceInfoPtr = nullptr;
86 g_mockDbs = false;
87 DTEST_LOG << "DSchedContinueManagerTest::SetUp" << std::endl;
88 }
89
OnRemoteDied()90 void DSchedContinueManagerTest::DeviceInitCallBack::OnRemoteDied()
91 {
92 }
93
GetDSchedService() const94 sptr<IRemoteObject> DSchedContinueManagerTest::GetDSchedService() const
95 {
96 sptr<IRemoteObject> dsched(new MockDistributedSched());
97 return dsched;
98 }
99
CreateObject()100 std::shared_ptr<DSchedContinue> DSchedContinueManagerTest::CreateObject()
101 {
102 int32_t subServiceType = 0;
103 int32_t direction = 0;
104 sptr<IRemoteObject> callback = nullptr;
105 DSchedContinueInfo continueInfo;
106 std::shared_ptr<DSchedContinue> dContinue = std::make_shared<DSchedContinue>(subServiceType, direction,
107 callback, continueInfo);
108 dContinue->Init();
109 return dContinue;
110 }
111
112 /**
113 * @tc.name: Init_001
114 * @tc.desc: test Init func
115 * @tc.type: FUNC
116 */
117 HWTEST_F(DSchedContinueManagerTest, Init_001, TestSize.Level3)
118 {
119 DTEST_LOG << "DSchedContinueManagerTest Init_001 begin" << std::endl;
120 DSchedContinueManager::GetInstance().Init();
121 std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler =
122 DSchedContinueManager::GetInstance().eventHandler_;
123 EXPECT_NE(eventHandler, nullptr);
124 DTEST_LOG << "DSchedContinueManagerTest Init_001 end" << std::endl;
125 }
126
127 /**
128 * @tc.name: Init_002
129 * @tc.desc: test Init func
130 * @tc.type: FUNC
131 */
132 HWTEST_F(DSchedContinueManagerTest, Init_002, TestSize.Level3)
133 {
134 DTEST_LOG << "DSchedContinueManagerTest Init_002 begin" << std::endl;
135 std::vector<std::thread> threads;
136 for (int i = 0; i < 10; ++i) {
__anon31547d9b0202() 137 threads.emplace_back(std::thread([]() {
138 DSchedContinueManager::GetInstance().Init();
139 }));
140 }
141 for (auto &item: threads) {
142 if (item.joinable()) {
143 item.join();
144 }
145 }
146 std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler =
147 DSchedContinueManager::GetInstance().eventHandler_;
148 EXPECT_NE(eventHandler, nullptr);
149 DTEST_LOG << "DSchedContinueManagerTest Init_002 end" << std::endl;
150 }
151
152 /**
153 * @tc.name: ContinueMission_001
154 * @tc.desc: test ContinueMission func
155 * @tc.type: FUNC
156 */
157 HWTEST_F(DSchedContinueManagerTest, ContinueMission_001, TestSize.Level3)
158 {
159 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_001 begin" << std::endl;
160 auto callback = GetDSchedService();
161 OHOS::AAFwk::WantParams wantParams;
162 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
163 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
164 callback, wantParams);
165 EXPECT_EQ(ret, OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET);
166 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_001 end" << std::endl;
167 }
168
169 /**
170 * @tc.name: ContinueMission_002
171 * @tc.desc: test ContinueMission func
172 * @tc.type: FUNC
173 */
174 HWTEST_F(DSchedContinueManagerTest, ContinueMission_002, TestSize.Level3)
175 {
176 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_002 begin" << std::endl;
177 OHOS::AAFwk::WantParams wantParams;
178 auto callback = GetDSchedService();
179 DSchedContinueManager::GetInstance().HandleContinueMission("", REMOTE_DEVICEID, MISSION_ID, callback, wantParams);
180 DSchedContinueManager::GetInstance().HandleContinueMission(LOCAL_DEVICEID, "", MISSION_ID, callback, wantParams);
181 DSchedContinueManager::GetInstance().HandleContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
182 nullptr, wantParams);
183
184 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true)).WillOnce(Return(true));
185 DSchedContinueManager::GetInstance().HandleContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
186 callback, wantParams);
187
188 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
189 DSchedContinueManager::GetInstance().HandleContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
190 callback, wantParams);
191
192 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission("", REMOTE_DEVICEID, MISSION_ID,
193 callback, wantParams);
194 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
195
196 ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, "", MISSION_ID,
197 nullptr, wantParams);
198 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
199
200 ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
201 nullptr, wantParams);
202 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
203 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_002 end" << std::endl;
204 }
205
206 /**
207 * @tc.name: ContinueMission_003
208 * @tc.desc: test ContinueMission func
209 * @tc.type: FUNC
210 */
211 HWTEST_F(DSchedContinueManagerTest, ContinueMission_003, TestSize.Level3)
212 {
213 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_003 begin" << std::endl;
214 DistributedSchedUtil::MockPermission();
215 OHOS::AAFwk::WantParams wantParams;
216 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(
217 DSchedContinueInfo("", BUNDLE_NAME, "", BUNDLE_NAME, CONTINUETYPE),
218 nullptr, wantParams);
219 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
220
221 ret = DSchedContinueManager::GetInstance().ContinueMission(
222 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, "", BUNDLE_NAME, CONTINUETYPE),
223 nullptr, wantParams);
224 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
225
226 ret = DSchedContinueManager::GetInstance().ContinueMission(
227 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
228 nullptr, wantParams);
229 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
230
231 auto callback = GetDSchedService();
232 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
233 ret = DSchedContinueManager::GetInstance().ContinueMission(
234 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
235 callback, wantParams);
236 EXPECT_EQ(ret, OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET);
237
238 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(LOCAL_DEVICEID), Return(true)));
239 ret = DSchedContinueManager::GetInstance().ContinueMission(
240 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
241 callback, wantParams);
242 EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
243
244 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
245 ret = DSchedContinueManager::GetInstance().ContinueMission(
246 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
247 callback, wantParams);
248 EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
249 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_003 end" << std::endl;
250 }
251
252 /**
253 * @tc.name: HandleContinueMission_001
254 * @tc.desc: test HandleContinueMission func
255 * @tc.type: FUNC
256 */
257 HWTEST_F(DSchedContinueManagerTest, HandleContinueMission_001, TestSize.Level3)
258 {
259 DTEST_LOG << "DSchedContinueManagerTest HandleContinueMission_001 begin" << std::endl;
260 OHOS::AAFwk::WantParams wantParams;
261 auto callback = GetDSchedService();
262 DSchedContinueManager::GetInstance().HandleContinueMission(
263 DSchedContinueInfo("", BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
264 callback, wantParams);
265 DSchedContinueManager::GetInstance().HandleContinueMission(
266 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, "", BUNDLE_NAME, CONTINUETYPE),
267 callback, wantParams);
268 DSchedContinueManager::GetInstance().HandleContinueMission(
269 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
270 nullptr, wantParams);
271
272 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
273 DSchedContinueManager::GetInstance().HandleContinueMission(
274 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
275 callback, wantParams);
276 DTEST_LOG << "DSchedContinueManagerTest HandleContinueMission_001 end" << std::endl;
277 }
278
279 /**
280 * @tc.name: SetTimeOut_001
281 * @tc.desc: test SetTimeOut func
282 * @tc.type: FUNC
283 */
284 HWTEST_F(DSchedContinueManagerTest, SetTimeOut_001, TestSize.Level3)
285 {
286 DTEST_LOG << "DSchedContinueManagerTest SetTimeOut_001 begin" << std::endl;
287 DSchedContinueInfo info;
288 int32_t timeout = 0;
289 DSchedContinueManager::GetInstance().continues_.clear();
290 DSchedContinueManager::GetInstance().SetTimeOut(info, timeout);
291 EXPECT_EQ(DSchedContinueManager::GetInstance().continues_.empty(), true);
292 DTEST_LOG << "DSchedContinueManagerTest SetTimeOut_001 end" << std::endl;
293 }
294
295 /**
296 * @tc.name: StartContinuation_001
297 * @tc.desc: test StartContinuation func
298 * @tc.type: FUNC
299 */
300 HWTEST_F(DSchedContinueManagerTest, StartContinuation_001, TestSize.Level3)
301 {
302 DTEST_LOG << "DSchedContinueManagerTest StartContinuation_001 begin" << std::endl;
303 OHOS::AAFwk::Want want;
304 int32_t missionId = 0;
305 int32_t callerUid = 0;
306 int32_t status = 0;
307 uint32_t accessToken = 0;
308 int32_t ret1 = DSchedContinueManager::GetInstance().StartContinuation(want, missionId,
309 callerUid, status, accessToken);
310 EXPECT_EQ(ret1, INVALID_REMOTE_PARAMETERS_ERR);
311 DTEST_LOG << "DSchedContinueManagerTest StartContinuation_001 end" << std::endl;
312 }
313
314 /**
315 * @tc.name: CheckContinuationLimit_001
316 * @tc.desc: test CheckContinuationLimit func
317 * @tc.type: FUNC
318 */
319 HWTEST_F(DSchedContinueManagerTest, CheckContinuationLimit_001, TestSize.Level3)
320 {
321 DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_001 begin" << std::endl;
322 int32_t direction = 0;
323 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
324 int32_t ret = DSchedContinueManager::GetInstance().CheckContinuationLimit(LOCAL_DEVICEID, REMOTE_DEVICEID,
325 direction);
326 EXPECT_EQ(ret, OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET);
327 DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_001 end" << std::endl;
328 }
329
330 /**
331 * @tc.name: GetContinueInfo_001
332 * @tc.desc: test GetContinueInfo func
333 * @tc.type: FUNC
334 */
335 HWTEST_F(DSchedContinueManagerTest, GetContinueInfo_001, TestSize.Level3)
336 {
337 DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_001 begin" << std::endl;
338 std::string localDeviceId = "localdeviceid";
339 std::string remoteDeviceId = "remotedeviceid";
340 int32_t ret = DSchedContinueManager::GetInstance().GetContinueInfo(localDeviceId, remoteDeviceId);
341 EXPECT_EQ(ret, ERR_OK);
342 DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_001 end" << std::endl;
343 }
344
345 /**
346 * @tc.name: GetContinueInfo_002
347 * @tc.desc: test GetContinueInfo func
348 * @tc.type: FUNC
349 */
350 HWTEST_F(DSchedContinueManagerTest, GetContinueInfo_002, TestSize.Level3)
351 {
352 DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_002 begin" << std::endl;
353 DSchedContinueManager::GetInstance().OnShutdown(1, true);
354
355 DSchedContinueManager::GetInstance().OnShutdown(1, false);
356
357 DSchedContinueManager::GetInstance().OnShutdown(1, false);
358
359 DSchedContinueInfo info;
360 std::shared_ptr<DSchedContinue> dContinue = CreateObject();
361 usleep(WAITTIME);
362 std::string localDeviceId = "localdeviceid";
363 std::string remoteDeviceId = "remotedeviceid";
364 DSchedContinueManager::GetInstance().continues_[info] = dContinue;
365 int32_t ret = DSchedContinueManager::GetInstance().GetContinueInfo(localDeviceId, remoteDeviceId);
366 EXPECT_EQ(ret, ERR_OK);
367
368 DSchedContinueManager::GetInstance().continues_.clear();
369 DSchedContinueManager::GetInstance().continues_[info] = nullptr;
370 ret = DSchedContinueManager::GetInstance().GetContinueInfo(localDeviceId, remoteDeviceId);
371 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
372 DTEST_LOG << "DSchedContinueManagerTest GetContinueInfo_002 end" << std::endl;
373 }
374
375 /**
376 * @tc.name: HandleNotifyCompleteContinuation_001
377 * @tc.desc: test HandleNotifyCompleteContinuation func
378 * @tc.type: FUNC
379 */
380 HWTEST_F(DSchedContinueManagerTest, HandleNotifyCompleteContinuation_001, TestSize.Level3)
381 {
382 DTEST_LOG << "DSchedContinueManagerTest HandleNotifyCompleteContinuation_001 begin" << std::endl;
383 std::u16string devId;
384 int32_t missionId = 0;
385 std::string callerBundleName;
386 DSchedContinueManager::GetInstance().continues_.clear();
387 DSchedContinueManager::GetInstance().HandleNotifyCompleteContinuation(devId, missionId, false, callerBundleName);
388
389 DSchedContinueInfo info;
390 DSchedContinueManager::GetInstance().continues_[info] = nullptr;
391 DSchedContinueManager::GetInstance().HandleNotifyCompleteContinuation(devId, missionId, false, callerBundleName);
392 bool ret = DSchedContinueManager::GetInstance().continues_.empty();
393 EXPECT_EQ(ret, false);
394 DTEST_LOG << "DSchedContinueManagerTest HandleNotifyCompleteContinuation_001 end" << std::endl;
395 }
396
397 /**
398 * @tc.name: NotifyCompleteContinuation_001
399 * @tc.desc: test NotifyCompleteContinuation func
400 * @tc.type: FUNC
401 */
402 HWTEST_F(DSchedContinueManagerTest, NotifyCompleteContinuation_001, TestSize.Level3)
403 {
404 DTEST_LOG << "DSchedContinueManagerTest NotifyCompleteContinuation_001 begin" << std::endl;
405 std::u16string devId;
406 int32_t sessionId = 0;
407 bool isSuccess = false;
408 std::string callerBundleName;
409 DSchedContinueManager::GetInstance().Init();
410 int32_t ret = DSchedContinueManager::GetInstance().NotifyCompleteContinuation(devId,
411 sessionId, isSuccess, callerBundleName);
412 EXPECT_EQ(ret, ERR_OK);
413 DTEST_LOG << "DSchedContinueManagerTest NotifyCompleteContinuation_001 end" << std::endl;
414 }
415
416 /**
417 * @tc.name: OnContinueEnd_001
418 * @tc.desc: test OnContinueEnd func
419 * @tc.type: FUNC
420 */
421 HWTEST_F(DSchedContinueManagerTest, OnContinueEnd_001, TestSize.Level3)
422 {
423 DTEST_LOG << "DSchedContinueManagerTest OnContinueEnd_001 begin" << std::endl;
424 DSchedContinueInfo info(LOCAL_DEVICEID, "sourceBundleName", REMOTE_DEVICEID, "sinkBundleName",
425 "continueType");
426 DSchedContinueManager::GetInstance().UnInit();
427 int32_t ret = DSchedContinueManager::GetInstance().OnContinueEnd(info);
428 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
429
430 DSchedContinueManager::GetInstance().Init();
431
432 ret = DSchedContinueManager::GetInstance().OnContinueEnd(info);
433 EXPECT_EQ(ret, ERR_OK);
434 DTEST_LOG << "DSchedContinueManagerTest OnContinueEnd_001 end" << std::endl;
435 }
436
437 /**
438 * @tc.name: HandleContinueEnd_001
439 * @tc.desc: test HandleContinueEnd func
440 * @tc.type: FUNC
441 */
442 HWTEST_F(DSchedContinueManagerTest, HandleContinueEnd_001, TestSize.Level3)
443 {
444 DTEST_LOG << "DSchedContinueManagerTest HandleContinueEnd_001 begin" << std::endl;
445 DSchedContinueInfo info(LOCAL_DEVICEID, "sourceBundleName", REMOTE_DEVICEID, "sinkBundleName",
446 "continueType");
447 DSchedContinueManager::GetInstance().RemoveTimeout(info);
448
449 DSchedContinueManager::GetInstance().Init();
450 DSchedContinueManager::GetInstance().RemoveTimeout(info);
451
452 DSchedContinueManager::GetInstance().continues_.clear();
453 DSchedContinueManager::GetInstance().HandleContinueEnd(info);
454 int32_t ret = DSchedContinueManager::GetInstance().continues_.empty();
455 EXPECT_EQ(ret, true);
456
457 std::shared_ptr<DSchedContinue> ptr = nullptr;
458 DSchedContinueManager::GetInstance().continues_[info] = ptr;
459 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
460 DSchedContinueManager::GetInstance().HandleContinueEnd(info);
461
462 DSchedContinueManager::GetInstance().continues_[info] = ptr;
463 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
464 DSchedContinueManager::GetInstance().HandleContinueEnd(info);
465 EXPECT_EQ(DSchedContinueManager::GetInstance().cntSource_, 0);
466 DTEST_LOG << "DSchedContinueManagerTest HandleContinueEnd_001 end" << std::endl;
467 }
468
469 /**
470 * @tc.name: GetDSchedContinueByWant_001
471 * @tc.desc: test GetDSchedContinueByWant func
472 * @tc.type: FUNC
473 */
474 HWTEST_F(DSchedContinueManagerTest, GetDSchedContinueByWant_001, TestSize.Level3)
475 {
476 DTEST_LOG << "DSchedContinueManagerTest GetDSchedContinueByWant_001 begin" << std::endl;
477 OHOS::AAFwk::Want want;
478 int32_t missionId = 0;
479 DSchedContinueManager::GetInstance().continues_.clear();
480 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
481 auto ret = DSchedContinueManager::GetInstance().GetDSchedContinueByWant(want, missionId);
482 EXPECT_EQ(ret, nullptr);
483 DTEST_LOG << "DSchedContinueManagerTest GetDSchedContinueByWant_001 end" << std::endl;
484 }
485
486 /**
487 * @tc.name: NotifyTerminateContinuation_001
488 * @tc.desc: test NotifyTerminateContinuation func
489 * @tc.type: FUNC
490 */
491 HWTEST_F(DSchedContinueManagerTest, NotifyTerminateContinuation_001, TestSize.Level3)
492 {
493 DTEST_LOG << "DSchedContinueManagerTest NotifyTerminateContinuation_001 begin" << std::endl;
494 int32_t missionId = 0;
495 int32_t sessionId = 0;
496 DSchedContinueManager::GetInstance().continues_.clear();
497 DSchedContinueManager::GetInstance().HandleDataRecv(sessionId, nullptr);
498 DSchedContinueManager::GetInstance().NotifyTerminateContinuation(missionId);
499 EXPECT_EQ(DSchedContinueManager::GetInstance().continues_.empty(), true);
500 DTEST_LOG << "DSchedContinueManagerTest NotifyTerminateContinuation_001 end" << std::endl;
501 }
502
503 /**
504 * @tc.name: GetFirstBundleName_001
505 * @tc.desc: test GetFirstBundleName func
506 * @tc.type: FUNC
507 */
508 HWTEST_F(DSchedContinueManagerTest, GetFirstBundleName_001, TestSize.Level3)
509 {
510 DTEST_LOG << "DSchedContinueManagerTest GetFirstBundleName_001 begin" << std::endl;
511 DSchedContinueInfo info;
512 std::string firstBundleName;
513 std::string bundleName;
514 std::string deviceId;
515 bool ret = DSchedContinueManager::GetInstance().GetFirstBundleName(info, firstBundleName, bundleName, deviceId);
516 EXPECT_EQ(ret, false);
517 DTEST_LOG << "DSchedContinueManagerTest GetFirstBundleName_001 end" << std::endl;
518 }
519
520 /**
521 * @tc.name: ContinueMission_004
522 * @tc.desc: test ContinueMission func
523 * @tc.type: FUNC
524 */
525 HWTEST_F(DSchedContinueManagerTest, ContinueMission_004, TestSize.Level3)
526 {
527 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_004 begin" << std::endl;
528 auto callback = GetDSchedService();
529 OHOS::AAFwk::WantParams wantParams;
530 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
531 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
532 callback, wantParams);
533 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
534
535 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(LOCAL_DEVICEID), Return(true)));
536 ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
537 callback, wantParams);
538 EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
539
540 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
541 ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
542 callback, wantParams);
543 EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
544 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_004 end" << std::endl;
545 }
546
547 /**
548 * @tc.name: ContinueMission_005
549 * @tc.desc: test ContinueMission func
550 * @tc.type: FUNC
551 */
552 HWTEST_F(DSchedContinueManagerTest, ContinueMission_005, TestSize.Level3)
553 {
554 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_005 begin" << std::endl;
555 auto callback = GetDSchedService();
556 OHOS::AAFwk::WantParams wantParams;
557 int32_t timeout = 0;
558 DSchedContinueManager::GetInstance().WaitAllConnectDecision(CONTINUE_SOURCE,
559 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE), timeout);
560
561 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
562 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(
563 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
564 callback, wantParams);
565 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
566 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_005 end" << std::endl;
567 }
568
569 /**
570 * @tc.name: GetDSchedContinueByWant_002
571 * @tc.desc: test GetDSchedContinueByWant func
572 * @tc.type: FUNC
573 */
574 HWTEST_F(DSchedContinueManagerTest, GetDSchedContinueByWant_002, TestSize.Level3)
575 {
576 DTEST_LOG << "DSchedContinueManagerTest GetDSchedContinueByWant_002 begin" << std::endl;
577 OHOS::AAFwk::Want want;
578 int32_t missionId = 0;
579 int32_t callerUid = 0;
580 int32_t status = 0;
581 uint32_t accessToken = 0;
582 DSchedContinueInfo info(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE);
583 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
584 DSchedContinueManager::GetInstance().HandleStartContinuation(want, missionId, callerUid, status, accessToken);
585
586 DSchedContinueManager::GetInstance().continues_.clear();
587 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
588 auto ret = DSchedContinueManager::GetInstance().GetDSchedContinueByWant(want, missionId);
589 EXPECT_EQ(ret, nullptr);
590
591 std::shared_ptr<DSchedContinue> dContinue = CreateObject();
592 usleep(WAITTIME);
593 DSchedContinueManager::GetInstance().continues_[info] = nullptr;
594 DSchedContinueManager::GetInstance().continues_[info] = dContinue;
595
596 DSchedContinueManager::GetInstance().NotifyTerminateContinuation(missionId);
597 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
598 ret = DSchedContinueManager::GetInstance().GetDSchedContinueByWant(want, missionId);
599 EXPECT_NE(ret, nullptr);
600 DTEST_LOG << "DSchedContinueManagerTest GetDSchedContinueByWant_002 end" << std::endl;
601 }
602
603 /**
604 * @tc.name: CheckContinuationLimit_002
605 * @tc.desc: test CheckContinuationLimit func
606 * @tc.type: FUNC
607 */
608 HWTEST_F(DSchedContinueManagerTest, CheckContinuationLimit_002, TestSize.Level3)
609 {
610 DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_002 begin" << std::endl;
611 int32_t direction = 0;
612 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
613 int32_t ret = DSchedContinueManager::GetInstance().CheckContinuationLimit(LOCAL_DEVICEID, REMOTE_DEVICEID,
614 direction);
615 EXPECT_EQ(ret, GET_LOCAL_DEVICE_ERR);
616
617 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(LOCAL_DEVICEID), Return(true)));
618 DSchedContinueManager::GetInstance().cntSink_.store(MAX_CONCURRENT_SINK);
619 ret = DSchedContinueManager::GetInstance().CheckContinuationLimit(LOCAL_DEVICEID, REMOTE_DEVICEID,
620 direction);
621 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
622
623 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
624 DSchedContinueManager::GetInstance().cntSink_.store(0);
625 ret = DSchedContinueManager::GetInstance().CheckContinuationLimit(LOCAL_DEVICEID, REMOTE_DEVICEID,
626 direction);
627 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
628 DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_002 end" << std::endl;
629 }
630
631 /**
632 * @tc.name: NotifyContinueDataRecv_001
633 * @tc.desc: test NotifyContinueDataRecv func
634 * @tc.type: FUNC
635 */
636 HWTEST_F(DSchedContinueManagerTest, NotifyContinueDataRecv_001, TestSize.Level3)
637 {
638 DTEST_LOG << "DSchedContinueManagerTest NotifyContinueDataRecv_001 begin" << std::endl;
639 int32_t sessionId = 0;
640 int32_t command = 0;
641 std::string jsonStr = "jsonStr";
642 std::shared_ptr<DSchedDataBuffer> dataBuffer = nullptr;
643 DSchedContinueManager::GetInstance().continues_.clear();
644 DSchedContinueManager::GetInstance().NotifyContinueDataRecv(sessionId, command, jsonStr, dataBuffer);
645 EXPECT_EQ(DSchedContinueManager::GetInstance().continues_.empty(), true);
646 DTEST_LOG << "DSchedContinueManagerTest NotifyContinueDataRecv_001 end" << std::endl;
647 }
648
649 /**
650 * @tc.name: ContinueMission_006
651 * @tc.desc: test ContinueMission func
652 * @tc.type: FUNC
653 */
654 HWTEST_F(DSchedContinueManagerTest, ContinueMission_006, TestSize.Level3)
655 {
656 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_006 begin" << std::endl;
657 DSchedContinueManager::GetInstance(). eventHandler_ = nullptr;
658 auto callback = GetDSchedService();
659 OHOS::AAFwk::WantParams wantParams;
660 g_mockDeviceInfoPtr = std::make_shared<DmsDeviceInfo>("", 0, "");
661 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
662 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
663 callback, wantParams);
664 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
665
666 g_mockDeviceInfoPtr = std::make_shared<DmsDeviceInfo>("", 0, "");
667 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
668 ret = DSchedContinueManager::GetInstance().ContinueMission(
669 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
670 callback, wantParams);
671 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
672 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_006 end" << std::endl;
673 }
674
675 /**
676 * @tc.name: ContinueMission_007
677 * @tc.desc: test ContinueMission func
678 * @tc.type: FUNC
679 */
680 HWTEST_F(DSchedContinueManagerTest, ContinueMission_007, TestSize.Level3)
681 {
682 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_007 begin" << std::endl;
683 auto runner = AppExecFwk::EventRunner::Create(false);
684 DSchedContinueManager::GetInstance().eventHandler_ = std::make_shared<OHOS::AppExecFwk::EventHandler>(runner);
685 auto callback = GetDSchedService();
686 OHOS::AAFwk::WantParams wantParams;
687 g_mockDeviceInfoPtr = std::make_shared<DmsDeviceInfo>("", 0, "");
688 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
689 int32_t ret = DSchedContinueManager::GetInstance().ContinueMission(LOCAL_DEVICEID, REMOTE_DEVICEID, MISSION_ID,
690 callback, wantParams);
691 EXPECT_EQ(ret, ERR_OK);
692
693 g_mockDeviceInfoPtr = std::make_shared<DmsDeviceInfo>("", 0, "");
694 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
695 ret = DSchedContinueManager::GetInstance().ContinueMission(
696 DSchedContinueInfo(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE),
697 callback, wantParams);
698 EXPECT_EQ(ret, ERR_OK);
699 DTEST_LOG << "DSchedContinueManagerTest ContinueMission_007 end" << std::endl;
700 }
701
702 /**
703 * @tc.name: StartContinuation_002
704 * @tc.desc: test StartContinuation func
705 * @tc.type: FUNC
706 */
707 HWTEST_F(DSchedContinueManagerTest, StartContinuation_002, TestSize.Level3)
708 {
709 DTEST_LOG << "DSchedContinueManagerTest StartContinuation_002 begin" << std::endl;
710 OHOS::AAFwk::Want want;
711 int32_t missionId = 0;
712 int32_t callerUid = 0;
713 int32_t status = 0;
714 uint32_t accessToken = 0;
715 DSchedContinueInfo info(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE);
716 std::shared_ptr<DSchedContinue> dContinue = CreateObject();
717 g_mockDeviceInfoPtr = std::make_shared<DmsDeviceInfo>("", 0, "");
718 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
719 int32_t ret = DSchedContinueManager::GetInstance().StartContinuation(want, missionId,
720 callerUid, status, accessToken);
721 EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
722 DTEST_LOG << "DSchedContinueManagerTest StartContinuation_002 end" << std::endl;
723 }
724
725 /**
726 * @tc.name: HandleDataRecv_001
727 * @tc.desc: test HandleDataRecv func
728 * @tc.type: FUNC
729 */
730 HWTEST_F(DSchedContinueManagerTest, HandleDataRecv_001, TestSize.Level3)
731 {
732 DTEST_LOG << "DSchedContinueManagerTest HandleDataRecv_001 begin" << std::endl;
733 std::shared_ptr<DSchedDataBuffer> dataBuffer = std::make_shared<DSchedDataBuffer>(SIZE);
734 EXPECT_NO_FATAL_FAILURE(DSchedContinueManager::GetInstance().HandleDataRecv(1, dataBuffer));
735 DTEST_LOG << "DSchedContinueManagerTest HandleDataRecv_001 end" << std::endl;
736 }
737
738 /**
739 * @tc.name: NotifyContinueDataRecv_002
740 * @tc.desc: test NotifyContinueDataRecv func
741 * @tc.type: FUNC
742 */
743 HWTEST_F(DSchedContinueManagerTest, NotifyContinueDataRecv_002, TestSize.Level3)
744 {
745 DTEST_LOG << "DSchedContinueManagerTest NotifyContinueDataRecv_002 begin" << std::endl;
746 int32_t sessionId = -1;
747 int32_t command = 0;
748 std::string jsonStr = "jsonStr";
749 DSchedContinueInfo info(LOCAL_DEVICEID, BUNDLE_NAME, REMOTE_DEVICEID, BUNDLE_NAME, CONTINUETYPE);
750 std::shared_ptr<DSchedContinue> dContinue = CreateObject();
751 DSchedContinueManager::GetInstance().continues_.clear();
752 DSchedContinueManager::GetInstance().continues_[info] = nullptr;
753 DSchedContinueManager::GetInstance().continues_[info] = dContinue;
754 std::shared_ptr<DSchedDataBuffer> dataBuffer = nullptr;
755 DSchedContinueManager::GetInstance().NotifyContinueDataRecv(sessionId, command, jsonStr, dataBuffer);
756 EXPECT_NE(DSchedContinueManager::GetInstance().continues_.empty(), true);
757
758 EXPECT_NO_FATAL_FAILURE(DSchedContinueManager::GetInstance().OnShutdown(1, false));
759 DTEST_LOG << "DSchedContinueManagerTest NotifyContinueDataRecv_002 end" << std::endl;
760 }
761
762 /**
763 * @tc.name: CheckContinuationLimit_003
764 * @tc.desc: test CheckContinuationLimit func
765 * @tc.type: FUNC
766 */
767 HWTEST_F(DSchedContinueManagerTest, CheckContinuationLimit_003, TestSize.Level3)
768 {
769 DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_003 begin" << std::endl;
770 int32_t direction = 0;
771 g_mockDeviceInfoPtr = std::make_shared<DmsDeviceInfo>("", 0, "");
772 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(LOCAL_DEVICEID), Return(true)));
773 DSchedContinueManager::GetInstance().cntSink_.store(MAX_CONCURRENT_SINK);
774 int32_t ret = DSchedContinueManager::GetInstance().CheckContinuationLimit(LOCAL_DEVICEID, REMOTE_DEVICEID,
775 direction);
776 EXPECT_EQ(ret, ERR_OK);
777
778 EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(DoAll(SetArgReferee<0>(REMOTE_DEVICEID), Return(true)));
779 DSchedContinueManager::GetInstance().cntSink_.store(0);
780 ret = DSchedContinueManager::GetInstance().CheckContinuationLimit(LOCAL_DEVICEID, REMOTE_DEVICEID,
781 direction);
782 EXPECT_EQ(ret, ERR_OK);
783 DTEST_LOG << "DSchedContinueManagerTest CheckContinuationLimit_003 end" << std::endl;
784 }
785
786 /**
787 * @tc.name: NotifyCompleteContinuation_002
788 * @tc.desc: test NotifyCompleteContinuation func
789 * @tc.type: FUNC
790 */
791 HWTEST_F(DSchedContinueManagerTest, NotifyCompleteContinuation_002, TestSize.Level3)
792 {
793 DTEST_LOG << "DSchedContinueManagerTest NotifyCompleteContinuation_002 begin" << std::endl;
794 DSchedContinueManager::GetInstance(). eventHandler_ = nullptr;
795 DSchedContinueInfo info;
796 DSchedContinueManager::GetInstance().SetTimeOut(info, 0);
797 DSchedContinueManager::GetInstance().RemoveTimeout(info);
798 DSchedContinueManager::GetInstance().OnDataRecv(0, nullptr);
799 DSchedContinueManager::GetInstance().OnShutdown(1, false);
800
801 std::u16string devId = u"testDevId";
802 int32_t ret = DSchedContinueManager::GetInstance().NotifyCompleteContinuation(devId, 0, false, "");
803 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
804 DTEST_LOG << "DSchedContinueManagerTest NotifyCompleteContinuation_002 end" << std::endl;
805 }
806
807 /**
808 * @tc.name: GetFirstBundleName_002
809 * @tc.desc: test GetFirstBundleName func
810 * @tc.type: FUNC
811 */
812 HWTEST_F(DSchedContinueManagerTest, GetFirstBundleName_002, TestSize.Level3)
813 {
814 DTEST_LOG << "DSchedContinueManagerTest GetFirstBundleName_002 begin" << std::endl;
815 DSchedContinueInfo info;
816 std::string firstBundleName;
817 std::string bundleName;
818 std::string deviceId;
819 g_mockDbs = true;
820 bool ret = DSchedContinueManager::GetInstance().GetFirstBundleName(info, firstBundleName, bundleName, deviceId);
821 EXPECT_EQ(ret, false);
822 DTEST_LOG << "DSchedContinueManagerTest GetFirstBundleName_002 end" << std::endl;
823 }
824
825 /**
826 * @tc.name: ContinueStateCallbackRegister_001
827 * @tc.desc: test ContinueStateCallbackRegister func
828 * @tc.type: FUNC
829 */
830 HWTEST_F(DSchedContinueManagerTest, ContinueStateCallbackRegister_001, TestSize.Level3)
831 {
832 DTEST_LOG << "DSchedContinueManagerTest ContinueStateCallbackRegister_001 begin" << std::endl;
833 StateCallbackInfo stateCallbackInfo;
834 stateCallbackInfo.missionId = 1;
835 stateCallbackInfo.bundleName = "bundleName";
836 stateCallbackInfo.moduleName = "moduleName";
837 stateCallbackInfo.abilityName = "abilityName";
838
839 auto callback = GetDSchedService();
840
841 int32_t ret = DSchedContinueManager::GetInstance().ContinueStateCallbackRegister(
842 stateCallbackInfo, callback);
843 EXPECT_EQ(ret, ERR_OK);
844
845 DSchedContinueManager::GetInstance().stateCallbackCache_[stateCallbackInfo].state = 1;
846 ret = DSchedContinueManager::GetInstance().ContinueStateCallbackRegister(
847 stateCallbackInfo, callback);
848 EXPECT_EQ(ret, ERR_OK);
849 DTEST_LOG << "DSchedContinueManagerTest ContinueStateCallbackRegister_001 end" << std::endl;
850 }
851
852 /**
853 * @tc.name: ContinueStateCallbackUnRegister_001
854 * @tc.desc: test ContinueStateCallbackUnRegister func
855 * @tc.type: FUNC
856 */
857 HWTEST_F(DSchedContinueManagerTest, ContinueStateCallbackUnRegister_001, TestSize.Level3)
858 {
859 DTEST_LOG << "DSchedContinueManagerTest ContinueStateCallbackUnRegister_001 begin" << std::endl;
860 StateCallbackInfo stateCallbackInfo;
861 stateCallbackInfo.missionId = 1;
862 stateCallbackInfo.bundleName = "bundleName";
863 stateCallbackInfo.moduleName = "moduleName";
864 stateCallbackInfo.abilityName = "abilityName";
865
866 int32_t ret = DSchedContinueManager::GetInstance().ContinueStateCallbackUnRegister(
867 stateCallbackInfo);
868 EXPECT_EQ(ret, ERR_OK);
869 DTEST_LOG << "DSchedContinueManagerTest ContinueStateCallbackUnRegister_001 end" << std::endl;
870 }
871
872 /**
873 * @tc.name: NotifyQuickStartState_001
874 * @tc.desc: test NotifyQuickStartState func
875 * @tc.type: FUNC
876 */
877 HWTEST_F(DSchedContinueManagerTest, NotifyQuickStartState_001, TestSize.Level3)
878 {
879 DTEST_LOG << "DSchedContinueManagerTest NotifyQuickStartState_001 begin" << std::endl;
880 StateCallbackInfo stateCallbackInfo;
881 stateCallbackInfo.missionId = 2;
882 stateCallbackInfo.bundleName = "bundleName";
883 stateCallbackInfo.moduleName = "moduleName";
884 stateCallbackInfo.abilityName = "abilityName";
885
886 std::string testMessage = "testMessage";
887
888 int32_t ret = DSchedContinueManager::GetInstance().NotifyQuickStartState(
889 stateCallbackInfo, 0, testMessage);
890 EXPECT_EQ(ret, ERR_OK);
891
892 ret = DSchedContinueManager::GetInstance().NotifyQuickStartState(
893 stateCallbackInfo, 0, testMessage);
894 EXPECT_EQ(ret, ERR_OK);
895
896 DSchedContinueManager::GetInstance().stateCallbackCache_[stateCallbackInfo].remoteObject = GetDSchedService();
897 ret = DSchedContinueManager::GetInstance().NotifyQuickStartState(
898 stateCallbackInfo, 0, testMessage);
899 EXPECT_EQ(ret, ERR_OK);
900
901 DTEST_LOG << "DSchedContinueManagerTest NotifyQuickStartState_001 end" << std::endl;
902 }
903 }
904 }
905