1 /*
2 * Copyright (c) 2021-2022 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 #define private public
17 #define protected public
18 #include "dms_mission_manager_test.h"
19 #include "distributed_sched_proxy.h"
20 #include "distributed_sched_service.h"
21 #include "distributed_sched_util.h"
22 #include "dtbschedmgr_device_info_storage.h"
23 #include "if_system_ability_manager.h"
24 #include "ipc_skeleton.h"
25 #include "iservice_registry.h"
26 #include "mission/distributed_sched_mission_manager.h"
27 #include "mission/mission_constant.h"
28 #include "mission/snapshot_converter.h"
29 #include "string_ex.h"
30 #include "system_ability_definition.h"
31 #include "test_log.h"
32 #undef private
33 #undef protected
34
35 #include <thread>
36 using namespace std;
37 using namespace testing;
38 using namespace testing::ext;
39 using namespace OHOS::DistributedHardware;
40
41 namespace OHOS {
42 namespace DistributedSchedule {
43 namespace {
44 const std::string DEVICE_NAME = "DEVICE_PHONE_001";
45 const std::string DEVICE_ID = "123456789ABCD";
46 const std::u16string U16DEVICE_ID = u"123456789ABCD";
47 const std::string BUNDLE_NAME = "ohos.test.test";
48 constexpr int32_t TASK_ID = 11;
49 constexpr size_t BYTESTREAM_LENGTH = 100;
50 constexpr uint8_t ONE_BYTE = '6';
51 const int32_t NUM_MISSIONS = 100;
52 const int32_t NORMAL_NUM_MISSIONS = 10;
53 constexpr int32_t REQUEST_CODE_ERR = 305;
54 constexpr int32_t MAX_WAIT_TIME = 1000;
55 }
56
57 bool DMSMissionManagerTest::isCaseDone_ = false;
58 std::mutex DMSMissionManagerTest::caseDoneLock_;
59 std::condition_variable DMSMissionManagerTest::caseDoneCondition_;
60
SetUpTestCase()61 void DMSMissionManagerTest::SetUpTestCase()
62 {
63 const std::string pkgName = "DBinderBus_" + std::to_string(getpid());
64 std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
65 DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
66 }
67
TearDownTestCase()68 void DMSMissionManagerTest::TearDownTestCase()
69 {
70 }
71
SetUp()72 void DMSMissionManagerTest::SetUp()
73 {
74 DistributedSchedUtil::MockPermission();
75 string localDeviceId;
76 if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId)) {
77 DTEST_LOG << "getLocalDevicesId failed!" << std::endl;
78 return;
79 }
80 localDeviceId_ = localDeviceId;
81 u16localDeviceId_ = Str8ToStr16(localDeviceId);
82 }
83
TearDown()84 void DMSMissionManagerTest::TearDown()
85 {
86 }
87
OnRemoteDied()88 void DMSMissionManagerTest::DeviceInitCallBack::OnRemoteDied()
89 {
90 }
91
GetDms()92 sptr<IDistributedSched> DMSMissionManagerTest::GetDms()
93 {
94 if (proxy_ != nullptr) {
95 return proxy_;
96 }
97 auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
98 EXPECT_TRUE(sm != nullptr);
99 if (sm == nullptr) {
100 DTEST_LOG << "DMSMissionManagerTest sm is nullptr" << std::endl;
101 return nullptr;
102 }
103 DTEST_LOG << "DMSMissionManagerTest sm is not nullptr" << std::endl;
104 auto distributedObject = sm->GetSystemAbility(DISTRIBUTED_SCHED_SA_ID);
105 EXPECT_TRUE(distributedObject != nullptr);
106 proxy_ = iface_cast<IDistributedSched>(distributedObject);
107 if (proxy_ == nullptr) {
108 DTEST_LOG << "DMSMissionManagerTest DistributedSched is nullptr" << std::endl;
109 }
110 DTEST_LOG << "DMSMissionManagerTest DistributedSched is not nullptr" << std::endl;
111 return proxy_;
112 }
113
NotifyMissionsChanged(const std::string & deviceId)114 void RemoteMissionListenerTest::NotifyMissionsChanged(const std::string& deviceId)
115 {
116 DTEST_LOG << "NotifyMissionsChanged" << std::endl;
117 }
118
NotifySnapshot(const std::string & deviceId,int32_t missionId)119 void RemoteMissionListenerTest::NotifySnapshot(const std::string& deviceId, int32_t missionId)
120 {
121 DTEST_LOG << "NotifySnapshot" << std::endl;
122 }
123
NotifyNetDisconnect(const std::string & deviceId,int32_t state)124 void RemoteMissionListenerTest::NotifyNetDisconnect(const std::string& deviceId, int32_t state)
125 {
126 DTEST_LOG << "NotifyNetDisconnect" << std::endl;
127 }
128
129 /**
130 * @tc.name: testGetRemoteMissionInfo001
131 * @tc.desc: get remote mission info
132 * @tc.type: FUNC
133 */
134 HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo001, TestSize.Level1)
135 {
136 std::vector<AAFwk::MissionInfo> infos;
137 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(DEVICE_ID, 0, infos);
138 EXPECT_TRUE(ret != ERR_NONE);
139
140 ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(localDeviceId_, 0, infos);
141 EXPECT_TRUE(ret != ERR_NONE);
142
143 ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos("", 0, infos);
144 EXPECT_TRUE(ret != ERR_NONE);
145
146 ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(DEVICE_ID, -1, infos);
147 EXPECT_TRUE(ret != ERR_NONE);
148
149 ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(localDeviceId_, -1, infos);
150 EXPECT_TRUE(ret != ERR_NONE);
151 }
152
153 /**
154 * @tc.name: testGetRemoteMissionInfo002
155 * @tc.desc: get remote mission info
156 * @tc.type: FUNC
157 */
158 HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo002, TestSize.Level1)
159 {
160 sptr<IDistributedSched> proxy = GetDms();
161 if (proxy == nullptr) {
162 return;
163 }
164 std::vector<AAFwk::MissionInfo> infos;
165 auto ret = proxy->GetMissionInfos(DEVICE_ID, 0, infos);
166 EXPECT_TRUE(ret != ERR_NONE);
167
168 ret = proxy->GetMissionInfos(localDeviceId_, 0, infos);
169 EXPECT_TRUE(ret != ERR_NONE);
170
171 ret = proxy->GetMissionInfos("", 0, infos);
172 EXPECT_TRUE(ret != ERR_NONE);
173
174 ret = proxy->GetMissionInfos(DEVICE_ID, -1, infos);
175 EXPECT_TRUE(ret != ERR_NONE);
176
177 ret = proxy->GetMissionInfos(localDeviceId_, -1, infos);
178 EXPECT_TRUE(ret != ERR_NONE);
179 }
180
181 /**
182 * @tc.name: testStartSyncRemoteMissions001
183 * @tc.desc: prepare and sync missions from remote
184 * @tc.type: FUNC
185 */
186 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions001, TestSize.Level1)
187 {
188 sptr<IDistributedSched> proxy = GetDms();
189 if (proxy == nullptr) {
190 return;
191 }
192 auto ret = proxy->StartSyncRemoteMissions(DEVICE_ID, false, 0);
193 EXPECT_NE(ret, ERR_NONE);
194 }
195
196 /**
197 * @tc.name: testStartSyncRemoteMissions002
198 * @tc.desc: prepare and sync missions from remote
199 * @tc.type: FUNC
200 */
201 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions002, TestSize.Level1)
202 {
203 sptr<IDistributedSched> proxy = GetDms();
204 if (proxy == nullptr) {
205 return;
206 }
207 auto ret = proxy->StartSyncRemoteMissions("", false, 0);
208 EXPECT_NE(ret, ERR_NONE);
209 }
210
211 /**
212 * @tc.name: testStartSyncRemoteMissions003
213 * @tc.desc: prepare and sync missions from remote
214 * @tc.type: FUNC
215 */
216 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions003, TestSize.Level1)
217 {
218 sptr<IDistributedSched> proxy = GetDms();
219 if (proxy == nullptr) {
220 return;
221 }
222 auto ret = proxy->StartSyncRemoteMissions(localDeviceId_, false, 0);
223 EXPECT_NE(ret, ERR_NONE);
224 }
225
226 /**
227 * @tc.name: testStartSyncRemoteMissions004
228 * @tc.desc: prepare and sync missions from remote
229 * @tc.type: FUNC
230 */
231 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions004, TestSize.Level3)
232 {
233 DTEST_LOG << "testStartSyncRemoteMissions004 begin" << std::endl;
234 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, false, 0);
235 EXPECT_EQ(ret, ERR_NONE);
236 DTEST_LOG << "testStartSyncRemoteMissions004 end" << std::endl;
237 }
238
239 /**
240 * @tc.name: testStartSyncRemoteMissions005
241 * @tc.desc: prepare and sync missions from remote
242 * @tc.type: FUNC
243 */
244 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions005, TestSize.Level3)
245 {
246 DTEST_LOG << "testStartSyncRemoteMissions005 begin" << std::endl;
247 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions("", false, 0);
248 EXPECT_EQ(ret, ERR_NONE);
249 DTEST_LOG << "testStartSyncRemoteMissions005 end" << std::endl;
250 }
251
252 /**
253 * @tc.name: testStartSyncRemoteMissions006
254 * @tc.desc: prepare and sync missions from remote
255 * @tc.type: FUNC
256 */
257 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions006, TestSize.Level3)
258 {
259 DTEST_LOG << "testStartSyncRemoteMissions006 begin" << std::endl;
260 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(localDeviceId_, false, 0);
261 EXPECT_NE(ret, ERR_NONE);
262 DTEST_LOG << "testStartSyncRemoteMissions006 end" << std::endl;
263 }
264
265 /**
266 * @tc.name: testStartSyncRemoteMissions007
267 * @tc.desc: prepare and sync missions from remote
268 * @tc.type: FUNC
269 */
270 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions007, TestSize.Level3)
271 {
272 DTEST_LOG << "testStartSyncRemoteMissions007 begin" << std::endl;
273 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, true, 0);
274 EXPECT_EQ(ret, ERR_NONE);
275 DTEST_LOG << "testStartSyncRemoteMissions007 end" << std::endl;
276 }
277
278 /**
279 * @tc.name: testStartSyncRemoteMissions008
280 * @tc.desc: prepare and sync missions from remote
281 * @tc.type: FUNC
282 */
283 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions008, TestSize.Level3)
284 {
285 DTEST_LOG << "testStartSyncRemoteMissions008 begin" << std::endl;
286 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions("", true, 0);
287 EXPECT_EQ(ret, ERR_NONE);
288 DTEST_LOG << "testStartSyncRemoteMissions008 end" << std::endl;
289 }
290
291 /**
292 * @tc.name: testStartSyncRemoteMissions009
293 * @tc.desc: prepare and sync missions from remote
294 * @tc.type: FUNC
295 */
296 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions009, TestSize.Level3)
297 {
298 DTEST_LOG << "testStartSyncRemoteMissions009 begin" << std::endl;
299 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(localDeviceId_, true, 0);
300 EXPECT_NE(ret, ERR_NONE);
301 DTEST_LOG << "testStartSyncRemoteMissions009 end" << std::endl;
302 }
303
304 /**
305 * @tc.name: testStartSyncRemoteMissions010
306 * @tc.desc: prepare and sync missions from remote
307 * @tc.type: FUNC
308 */
309 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions010, TestSize.Level3)
310 {
311 DTEST_LOG << "testStartSyncRemoteMissions010 begin" << std::endl;
312 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, true, 1);
313 EXPECT_EQ(ret, ERR_NONE);
314 DTEST_LOG << "testStartSyncRemoteMissions010 end" << std::endl;
315 }
316
317 /**
318 * @tc.name: testStartSyncRemoteMissions011
319 * @tc.desc: prepare and sync missions from remote
320 * @tc.type: FUNC
321 */
322 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions011, TestSize.Level3)
323 {
324 DTEST_LOG << "testStartSyncRemoteMissions011 begin" << std::endl;
325 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions("", true, 1);
326 EXPECT_EQ(ret, ERR_NONE);
327 DTEST_LOG << "testStartSyncRemoteMissions011 end" << std::endl;
328 }
329
330 /**
331 * @tc.name: testStartSyncRemoteMissions012
332 * @tc.desc: prepare and sync missions from remote
333 * @tc.type: FUNC
334 */
335 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions012, TestSize.Level3)
336 {
337 DTEST_LOG << "testStartSyncRemoteMissions012 begin" << std::endl;
338 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(localDeviceId_, true, 1);
339 EXPECT_NE(ret, ERR_NONE);
340 DTEST_LOG << "testStartSyncRemoteMissions012 end" << std::endl;
341 }
342
343 /**
344 * @tc.name: testStartSyncRemoteMissions013
345 * @tc.desc: prepare and sync missions from remote
346 * @tc.type: FUNC
347 */
348 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions013, TestSize.Level3)
349 {
350 DTEST_LOG << "testStartSyncRemoteMissions013 begin" << std::endl;
351 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, localDeviceId_);
352 EXPECT_EQ(ret, ERR_NONE);
353 DTEST_LOG << "testStartSyncRemoteMissions013 end" << std::endl;
354 }
355
356 /**
357 * @tc.name: testStartSyncRemoteMissions014
358 * @tc.desc: prepare and sync missions from remote
359 * @tc.type: FUNC
360 */
361 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions014, TestSize.Level3)
362 {
363 DTEST_LOG << "testStartSyncRemoteMissions014 begin" << std::endl;
364 sptr<IDistributedSched> proxy = GetDms();
365 if (proxy == nullptr) {
366 return;
367 }
368 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, proxy);
369 EXPECT_NE(ret, ERR_NONE);
370 DTEST_LOG << "testStartSyncRemoteMissions014 end" << std::endl;
371 }
372
373 /**
374 * @tc.name: testNeedSyncDevice001
375 * @tc.desc: need sync device
376 * @tc.type: FUNC
377 */
378 HWTEST_F(DMSMissionManagerTest, testNeedSyncDevice001, TestSize.Level3)
379 {
380 DTEST_LOG << "testCleanMissionResources001 begin" << std::endl;
381 bool ret = DistributedSchedMissionManager::GetInstance().NeedSyncDevice(DEVICE_ID);
382 EXPECT_FALSE(ret);
383 DTEST_LOG << "testNeedSyncDevice001 end" << std::endl;
384 }
385
386 /**
387 * @tc.name: testNeedSyncDevice002
388 * @tc.desc: need sync device
389 * @tc.type: FUNC
390 */
391 HWTEST_F(DMSMissionManagerTest, testNeedSyncDevice002, TestSize.Level3)
392 {
393 DTEST_LOG << "testNeedSyncDevice002 begin" << std::endl;
394 remoteSyncDeviceSet_.emplace(DEVICE_ID);
395 bool ret = DistributedSchedMissionManager::GetInstance().NeedSyncDevice(DEVICE_ID);
396 EXPECT_FALSE(ret);
397 DTEST_LOG << "testNeedSyncDevice002 end" << std::endl;
398 }
399
400 /**
401 * @tc.name: testHasSyncListener001
402 * @tc.desc: need sync device
403 * @tc.type: FUNC
404 */
405 HWTEST_F(DMSMissionManagerTest, testHasSyncListener001, TestSize.Level3)
406 {
407 DTEST_LOG << "testHasSyncListener001 begin" << std::endl;
408 bool ret = DistributedSchedMissionManager::GetInstance().HasSyncListener(DEVICE_ID);
409 EXPECT_FALSE(ret);
410 DTEST_LOG << "testHasSyncListener001 end" << std::endl;
411 }
412
413 /**
414 * @tc.name: testCleanMissionResources001
415 * @tc.desc: prepare and sync missions from remote
416 * @tc.type: FUNC
417 */
418 HWTEST_F(DMSMissionManagerTest, testCleanMissionResources001, TestSize.Level3)
419 {
420 DTEST_LOG << "testCleanMissionResources001 begin" << std::endl;
421 DistributedSchedMissionManager::GetInstance().CleanMissionResources(DEVICE_ID);
422 DTEST_LOG << "testCleanMissionResources001 end" << std::endl;
423 }
424
425 /**
426 * @tc.name: testStopSyncRemoteMissions001
427 * @tc.desc: stop sync missions from remote with fake deviceId
428 * @tc.type: FUNC
429 */
430 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions001, TestSize.Level1)
431 {
432 sptr<IDistributedSched> proxy = GetDms();
433 if (proxy == nullptr) {
434 return;
435 }
436 auto ret = proxy->StopSyncRemoteMissions(DEVICE_ID);
437 EXPECT_NE(ret, ERR_NONE);
438 }
439
440 /**
441 * @tc.name: testStopSyncRemoteMissions002
442 * @tc.desc: stop sync missions from remote with local deviceId
443 * @tc.type: FUNC
444 */
445 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions002, TestSize.Level1)
446 {
447 sptr<IDistributedSched> proxy = GetDms();
448 if (proxy == nullptr) {
449 return;
450 }
451 auto ret = proxy->StopSyncRemoteMissions(localDeviceId_);
452 EXPECT_NE(ret, ERR_NONE);
453 }
454
455 /**
456 * @tc.name: testStopSyncRemoteMissions003
457 * @tc.desc: stop sync missions from remote with empty deviceId
458 * @tc.type: FUNC
459 */
460 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions003, TestSize.Level1)
461 {
462 sptr<IDistributedSched> proxy = GetDms();
463 if (proxy == nullptr) {
464 return;
465 }
466 auto ret = proxy->StopSyncRemoteMissions("");
467 EXPECT_NE(ret, ERR_NONE);
468 }
469
470 /**
471 * @tc.name: testStopSyncRemoteMissions004
472 * @tc.desc: stop sync missions from remote with empty deviceId
473 * @tc.type: FUNC
474 */
475 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions004, TestSize.Level3)
476 {
477 DTEST_LOG << "testStopSyncRemoteMissions004 begin" << std::endl;
478 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions("", false, true);
479 EXPECT_NE(ret, ERR_NONE);
480 DTEST_LOG << "testStopSyncRemoteMissions004 end" << std::endl;
481 }
482
483 /**
484 * @tc.name: testStopSyncRemoteMissions005
485 * @tc.desc: stop sync missions from remote with local deviceId
486 * @tc.type: FUNC
487 */
488 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions005, TestSize.Level3)
489 {
490 DTEST_LOG << "testStopSyncRemoteMissions005 begin" << std::endl;
491 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(localDeviceId_, false, true);
492 EXPECT_NE(ret, ERR_NONE);
493 DTEST_LOG << "testStopSyncRemoteMissions005 end" << std::endl;
494 }
495
496 /**
497 * @tc.name: testStopSyncRemoteMissions006
498 * @tc.desc: stop sync missions from remote with deviceId
499 * @tc.type: FUNC
500 */
501 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions006, TestSize.Level3)
502 {
503 DTEST_LOG << "testStopSyncRemoteMissions006 begin" << std::endl;
504 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(DEVICE_ID, false, true);
505 EXPECT_NE(ret, ERR_NONE);
506 DTEST_LOG << "testStopSyncRemoteMissions006 end" << std::endl;
507 }
508
509 /**
510 * @tc.name: testStopSyncRemoteMissions007
511 * @tc.desc: stop sync missions from remote with empty deviceId
512 * @tc.type: FUNC
513 */
514 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions007, TestSize.Level3)
515 {
516 DTEST_LOG << "testStopSyncRemoteMissions007 begin" << std::endl;
517 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions("", true, true);
518 EXPECT_EQ(ret, ERR_NONE);
519 DTEST_LOG << "testStopSyncRemoteMissions007 end" << std::endl;
520 }
521
522 /**
523 * @tc.name: testStopSyncRemoteMissions008
524 * @tc.desc: stop sync missions from remote with local deviceId
525 * @tc.type: FUNC
526 */
527 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions008, TestSize.Level3)
528 {
529 DTEST_LOG << "testStopSyncRemoteMissions008 begin" << std::endl;
530 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(localDeviceId_, true, true);
531 EXPECT_EQ(ret, ERR_NONE);
532 DTEST_LOG << "testStopSyncRemoteMissions008 end" << std::endl;
533 }
534
535 /**
536 * @tc.name: testStopSyncRemoteMissions009
537 * @tc.desc: stop sync missions from remote with deviceId
538 * @tc.type: FUNC
539 */
540 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions009, TestSize.Level3)
541 {
542 DTEST_LOG << "testStopSyncRemoteMissions009 begin" << std::endl;
543 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(DEVICE_ID, true, true);
544 EXPECT_EQ(ret, ERR_NONE);
545 DTEST_LOG << "testStopSyncRemoteMissions009 end" << std::endl;
546 }
547
548 /**
549 * @tc.name: testStopSyncRemoteMissions010
550 * @tc.desc: stop sync missions from remote with empty deviceId
551 * @tc.type: FUNC
552 */
553 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions010, TestSize.Level3)
554 {
555 DTEST_LOG << "testStopSyncRemoteMissions010 begin" << std::endl;
556 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions("", true, false);
557 EXPECT_EQ(ret, ERR_NONE);
558 DTEST_LOG << "testStopSyncRemoteMissions010 end" << std::endl;
559 }
560
561 /**
562 * @tc.name: testStopSyncRemoteMissions011
563 * @tc.desc: stop sync missions from remote with local deviceId
564 * @tc.type: FUNC
565 */
566 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions011, TestSize.Level3)
567 {
568 DTEST_LOG << "testStopSyncRemoteMissions011 begin" << std::endl;
569 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(localDeviceId_, true, false);
570 EXPECT_EQ(ret, ERR_NONE);
571 DTEST_LOG << "testStopSyncRemoteMissions011 end" << std::endl;
572 }
573
574 /**
575 * @tc.name: testStopSyncRemoteMissions012
576 * @tc.desc: stop sync missions from remote with deviceId
577 * @tc.type: FUNC
578 */
579 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions012, TestSize.Level3)
580 {
581 DTEST_LOG << "testStopSyncRemoteMissions012 begin" << std::endl;
582 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(DEVICE_ID, true, false);
583 EXPECT_EQ(ret, ERR_NONE);
584 DTEST_LOG << "testStopSyncRemoteMissions012 end" << std::endl;
585 }
586
587 /**
588 * @tc.name: testRegisterMissionListener001
589 * @tc.desc: register mission listener
590 * @tc.type: FUNC
591 */
592 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener001, TestSize.Level1)
593 {
594 sptr<IDistributedSched> proxy = GetDms();
595 if (proxy == nullptr) {
596 return;
597 }
598 auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, nullptr);
599 EXPECT_TRUE(ret != ERR_NONE);
600
601 ret = proxy->RegisterMissionListener(u16localDeviceId_, nullptr);
602 EXPECT_TRUE(ret != ERR_NONE);
603
604 ret = proxy->RegisterMissionListener(u"", nullptr);
605 EXPECT_TRUE(ret != ERR_NONE);
606 }
607
608 /**
609 * @tc.name: testRegisterMissionListener002
610 * @tc.desc: register mission listener
611 * @tc.type: FUNC
612 */
613 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1)
614 {
615 sptr<IDistributedSched> proxy = GetDms();
616 if (proxy == nullptr) {
617 return;
618 }
619 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
620 auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, listener);
621 EXPECT_TRUE(ret != ERR_NONE);
622
623 ret = proxy->RegisterMissionListener(u16localDeviceId_, listener);
624 EXPECT_TRUE(ret != ERR_NONE);
625
626 ret = proxy->RegisterMissionListener(u"", listener);
627 EXPECT_TRUE(ret != ERR_NONE);
628
629 ret = proxy->UnRegisterMissionListener(U16DEVICE_ID, listener);
630 EXPECT_TRUE(ret != ERR_NONE);
631
632 ret = proxy->UnRegisterMissionListener(u16localDeviceId_, listener);
633 EXPECT_TRUE(ret != ERR_NONE);
634
635 ret = proxy->UnRegisterMissionListener(u"", listener);
636 EXPECT_TRUE(ret != ERR_NONE);
637 }
638
639 /**
640 * @tc.name: testRegisterMissionListener003
641 * @tc.desc: test register mission listener
642 * @tc.type: FUNC
643 */
644 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener003, TestSize.Level3)
645 {
646 DTEST_LOG << "testRegisterMissionListener003 begin" << std::endl;
647 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
648 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(u"", listener);
649 EXPECT_EQ(ret, ERR_NONE);
650 DTEST_LOG << "testRegisterMissionListener003 end" << std::endl;
651 }
652
653 /**
654 * @tc.name: testRegisterMissionListener004
655 * @tc.desc: test register mission listener
656 * @tc.type: FUNC
657 */
658 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener004, TestSize.Level3)
659 {
660 DTEST_LOG << "testRegisterMissionListener004 begin" << std::endl;
661 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
662 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(U16DEVICE_ID, listener);
663 EXPECT_EQ(ret, ERR_NONE);
664 DTEST_LOG << "testRegisterMissionListener004 end" << std::endl;
665 }
666
667 /**
668 * @tc.name: testRegisterMissionListener005
669 * @tc.desc: test register mission listener
670 * @tc.type: FUNC
671 */
672 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener005, TestSize.Level3)
673 {
674 DTEST_LOG << "testRegisterMissionListener005 begin" << std::endl;
675 sptr<IRemoteObject> listener = nullptr;
676 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(u"", listener);
677 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
678 DTEST_LOG << "testRegisterMissionListener005 end" << std::endl;
679 }
680
681 /**
682 * @tc.name: testRegisterMissionListener006
683 * @tc.desc: test register mission listener
684 * @tc.type: FUNC
685 */
686 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener006, TestSize.Level3)
687 {
688 DTEST_LOG << "testRegisterMissionListener006 begin" << std::endl;
689 sptr<IRemoteObject> listener = nullptr;
690 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(U16DEVICE_ID, listener);
691 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
692 DTEST_LOG << "testRegisterMissionListener006 end" << std::endl;
693 }
694
695 /**
696 * @tc.name: testRegisterMissionListener007
697 * @tc.desc: test register mission listener
698 * @tc.type: FUNC
699 */
700 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener007, TestSize.Level3)
701 {
702 DTEST_LOG << "testRegisterMissionListener007 begin" << std::endl;
703 u16string deviceId = Str8ToStr16(localDeviceId_);
704 sptr<IRemoteObject> listener = nullptr;
705 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(deviceId, listener);
706 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
707 DTEST_LOG << "testRegisterMissionListener007 end" << std::endl;
708 }
709
710 /**
711 * @tc.name: testRegisterMissionListener008
712 * @tc.desc: test register mission listener
713 * @tc.type: FUNC
714 */
715 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener008, TestSize.Level3)
716 {
717 DTEST_LOG << "testRegisterMissionListener008 begin" << std::endl;
718 u16string deviceId = Str8ToStr16(localDeviceId_);
719 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
720 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(deviceId, listener);
721 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
722 DTEST_LOG << "testRegisterMissionListener008 end" << std::endl;
723 }
724
725 /**
726 * @tc.name: testUnRegisterMissionListener001
727 * @tc.desc: register mission listener
728 * @tc.type: FUNC
729 */
730 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener001, TestSize.Level1)
731 {
732 sptr<IDistributedSched> proxy = GetDms();
733 if (proxy == nullptr) {
734 return;
735 }
736 auto ret = proxy->UnRegisterMissionListener(U16DEVICE_ID, nullptr);
737 EXPECT_TRUE(ret != ERR_NONE);
738
739 ret = proxy->UnRegisterMissionListener(u16localDeviceId_, nullptr);
740 EXPECT_TRUE(ret != ERR_NONE);
741
742 ret = proxy->UnRegisterMissionListener(u"", nullptr);
743 EXPECT_TRUE(ret != ERR_NONE);
744 }
745
746 /**
747 * @tc.name: testUnRegisterMissionListener002
748 * @tc.desc: register mission listener
749 * @tc.type: FUNC
750 */
751 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener002, TestSize.Level3)
752 {
753 DTEST_LOG << "testUnRegisterMissionListener002 begin" << std::endl;
754 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
755 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(U16DEVICE_ID, listener);
756 EXPECT_EQ(ret, ERR_NONE);
757 DTEST_LOG << "testUnRegisterMissionListener002 end" << std::endl;
758 }
759
760 /**
761 * @tc.name: testUnRegisterMissionListener003
762 * @tc.desc: register mission listener
763 * @tc.type: FUNC
764 */
765 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener003, TestSize.Level3)
766 {
767 DTEST_LOG << "testUnRegisterMissionListener003 begin" << std::endl;
768 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(U16DEVICE_ID, nullptr);
769 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
770 DTEST_LOG << "testUnRegisterMissionListener003 end" << std::endl;
771 }
772
773 /**
774 * @tc.name: testUnRegisterMissionListener004
775 * @tc.desc: register mission listener
776 * @tc.type: FUNC
777 */
778 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener004, TestSize.Level3)
779 {
780 DTEST_LOG << "testUnRegisterMissionListener004 begin" << std::endl;
781 u16string deviceId = Str8ToStr16(localDeviceId_);
782 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, nullptr);
783 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
784 DTEST_LOG << "testUnRegisterMissionListener004 end" << std::endl;
785 }
786
787 /**
788 * @tc.name: testUnRegisterMissionListener005
789 * @tc.desc: register mission listener
790 * @tc.type: FUNC
791 */
792 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener005, TestSize.Level3)
793 {
794 DTEST_LOG << "testUnRegisterMissionListener005 begin" << std::endl;
795 u16string deviceId = Str8ToStr16(localDeviceId_);
796 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
797 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, listener);
798 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
799 DTEST_LOG << "testUnRegisterMissionListener005 end" << std::endl;
800 }
801
802 /**
803 * @tc.name: testIsDeviceIdValidated001
804 * @tc.desc: judging whether the deviceId is valid
805 * @tc.type: FUNC
806 */
807 HWTEST_F(DMSMissionManagerTest, testIsDeviceIdValidated001, TestSize.Level1)
808 {
809 std::string emptyDeviceId = "";
810 auto ret = DistributedSchedMissionManager::GetInstance().IsDeviceIdValidated(emptyDeviceId);
811 EXPECT_FALSE(ret);
812
813 ret = DistributedSchedMissionManager::GetInstance().IsDeviceIdValidated(DEVICE_ID);
814 EXPECT_FALSE(ret);
815
816 ret = DistributedSchedMissionManager::GetInstance().IsDeviceIdValidated(localDeviceId_);
817 EXPECT_FALSE(ret);
818 }
819
820 /**
821 * @tc.name: testGetMissionInfos001
822 * @tc.desc: get missions
823 * @tc.type: FUNC
824 */
825 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos001, TestSize.Level1)
826 {
827 std::string deviceid = DEVICE_ID;
828 int32_t numMissions = NUM_MISSIONS;
829 std::vector<AAFwk::MissionInfo> missionInfos;
830
831 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos);
832 EXPECT_TRUE(ret != ERR_NONE);
833 }
834
835 /**
836 * @tc.name: testGetMissionInfos002
837 * @tc.desc: get missions
838 * @tc.type: FUNC
839 */
840 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos002, TestSize.Level3)
841 {
842 DTEST_LOG << "testGetMissionInfos002 begin" << std::endl;
843 std::string deviceid = localDeviceId_;
844 int32_t numMissions = NUM_MISSIONS;
845 std::vector<AAFwk::MissionInfo> missionInfos;
846
847 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos);
848 EXPECT_TRUE(ret != ERR_NONE);
849 DTEST_LOG << "testGetMissionInfos002 end" << std::endl;
850 }
851
852 /**
853 * @tc.name: testGetMissionInfos003
854 * @tc.desc: get missions
855 * @tc.type: FUNC
856 */
857 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos003, TestSize.Level3)
858 {
859 DTEST_LOG << "testGetMissionInfos003 begin" << std::endl;
860 std::string deviceid = "";
861 int32_t numMissions = NUM_MISSIONS;
862 std::vector<AAFwk::MissionInfo> missionInfos;
863
864 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos);
865 EXPECT_TRUE(ret != ERR_NONE);
866 DTEST_LOG << "testGetMissionInfos003 end" << std::endl;
867 }
868
869 /**
870 * @tc.name: testGetMissionInfos004
871 * @tc.desc: get missions
872 * @tc.type: FUNC
873 */
874 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos004, TestSize.Level3)
875 {
876 DTEST_LOG << "testGetMissionInfos004 begin" << std::endl;
877 std::string deviceid = DEVICE_ID;
878 int32_t numMissions = -1;
879 std::vector<AAFwk::MissionInfo> missionInfos;
880 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos);
881 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
882 DTEST_LOG << "testGetMissionInfos004 end" << std::endl;
883 }
884
885 /**
886 * @tc.name: testGetMissionInfos005
887 * @tc.desc: get missions
888 * @tc.type: FUNC
889 */
890 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos005, TestSize.Level3)
891 {
892 DTEST_LOG << "testGetMissionInfos005 begin" << std::endl;
893 std::string deviceid = "";
894 int32_t numMissions = NUM_MISSIONS;
895 std::vector<AAFwk::MissionInfo> missionInfos;
896 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos);
897 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
898 DTEST_LOG << "testGetMissionInfos005 end" << std::endl;
899 }
900
901 /**
902 * @tc.name: testGetMissionInfos006
903 * @tc.desc: get missions
904 * @tc.type: FUNC
905 */
906 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos006, TestSize.Level3)
907 {
908 DTEST_LOG << "testGetMissionInfos006 begin" << std::endl;
909 std::string deviceid = "";
910 int32_t numMissions = 0;
911 std::vector<AAFwk::MissionInfo> missionInfos;
912 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(deviceid, numMissions, missionInfos);
913 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
914 DTEST_LOG << "testGetMissionInfos006 end" << std::endl;
915 }
916
917 /**
918 * @tc.name: testFetchCachedRemoteMissions001
919 * @tc.desc: test stop fake device, return error code
920 * @tc.type: FUNC
921 */
922 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions001, TestSize.Level1)
923 {
924 std::vector<DstbMissionInfo> infos;
925 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(DEVICE_ID, 0, infos);
926 EXPECT_TRUE(ret != ERR_NONE);
927 }
928
929 /**
930 * @tc.name: testFetchCachedRemoteMissions002
931 * @tc.desc: test empty deviceId, return error code
932 * @tc.type: FUNC
933 */
934 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions002, TestSize.Level3)
935 {
936 DTEST_LOG << "testFetchCachedRemoteMissions002 begin" << std::endl;
937 std::vector<DstbMissionInfo> infos;
938 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions("", 0, infos);
939 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
940 DTEST_LOG << "testFetchCachedRemoteMissions002 end" << std::endl;
941 }
942
943 /**
944 * @tc.name: testFetchCachedRemoteMissions003
945 * @tc.desc: test local deviceId, return error code
946 * @tc.type: FUNC
947 */
948 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions003, TestSize.Level3)
949 {
950 DTEST_LOG << "testFetchCachedRemoteMissions003 begin" << std::endl;
951 std::vector<DstbMissionInfo> infos;
952 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(localDeviceId_, 0, infos);
953 EXPECT_TRUE(ret == ERR_NULL_OBJECT);
954 DTEST_LOG << "testFetchCachedRemoteMissions003 end" << std::endl;
955 }
956
957 /**
958 * @tc.name: testFetchCachedRemoteMissions004
959 * @tc.desc: test stop fake device, return error code
960 * @tc.type: FUNC
961 */
962 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions004, TestSize.Level3)
963 {
964 DTEST_LOG << "testFetchCachedRemoteMissions004 begin" << std::endl;
965 std::vector<DstbMissionInfo> infos;
966 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(DEVICE_ID, NUM_MISSIONS, infos);
967 EXPECT_TRUE(ret != ERR_NONE);
968 DTEST_LOG << "testFetchCachedRemoteMissions004 end" << std::endl;
969 }
970
971 /**
972 * @tc.name: testFetchCachedRemoteMissions005
973 * @tc.desc: test empty deviceId, return error code
974 * @tc.type: FUNC
975 */
976 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions005, TestSize.Level3)
977 {
978 DTEST_LOG << "testFetchCachedRemoteMissions005 begin" << std::endl;
979 std::vector<DstbMissionInfo> infos;
980 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions("", NUM_MISSIONS, infos);
981 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
982 DTEST_LOG << "testFetchCachedRemoteMissions005 end" << std::endl;
983 }
984
985 /**
986 * @tc.name: testFetchCachedRemoteMissions006
987 * @tc.desc: test local deviceId, return error code
988 * @tc.type: FUNC
989 */
990 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions006, TestSize.Level3)
991 {
992 DTEST_LOG << "testFetchCachedRemoteMissions006 begin" << std::endl;
993 std::vector<DstbMissionInfo> infos;
994 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(localDeviceId_,
995 NUM_MISSIONS, infos);
996 EXPECT_TRUE(ret == ERR_NULL_OBJECT);
997 DTEST_LOG << "testFetchCachedRemoteMissions006 end" << std::endl;
998 }
999
1000 /**
1001 * @tc.name: testFetchCachedRemoteMissions007
1002 * @tc.desc: test stop fake device, return error code
1003 * @tc.type: FUNC
1004 */
1005 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions007, TestSize.Level3)
1006 {
1007 DTEST_LOG << "testFetchCachedRemoteMissions007 begin" << std::endl;
1008 std::vector<DstbMissionInfo> infos;
1009 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(DEVICE_ID,
1010 NORMAL_NUM_MISSIONS, infos);
1011 EXPECT_TRUE(ret != ERR_NONE);
1012 DTEST_LOG << "testFetchCachedRemoteMissions007 end" << std::endl;
1013 }
1014
1015 /**
1016 * @tc.name: testFetchCachedRemoteMissions008
1017 * @tc.desc: test empty deviceId, return error code
1018 * @tc.type: FUNC
1019 */
1020 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions008, TestSize.Level3)
1021 {
1022 DTEST_LOG << "testFetchCachedRemoteMissions008 begin" << std::endl;
1023 std::vector<DstbMissionInfo> infos;
1024 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions("", NORMAL_NUM_MISSIONS, infos);
1025 EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
1026 DTEST_LOG << "testFetchCachedRemoteMissions008 end" << std::endl;
1027 }
1028
1029 /**
1030 * @tc.name: testFetchCachedRemoteMissions009
1031 * @tc.desc: test local deviceId, return error code
1032 * @tc.type: FUNC
1033 */
1034 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions009, TestSize.Level3)
1035 {
1036 DTEST_LOG << "testFetchCachedRemoteMissions009 begin" << std::endl;
1037 std::vector<DstbMissionInfo> infos;
1038 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(localDeviceId_,
1039 NORMAL_NUM_MISSIONS, infos);
1040 EXPECT_TRUE(ret == ERR_NULL_OBJECT);
1041 DTEST_LOG << "testFetchCachedRemoteMissions009 end" << std::endl;
1042 }
1043
1044 /**
1045 * @tc.name: testNotifyRemoteDied001
1046 * @tc.desc: test notify remote died
1047 * @tc.type: FUNC
1048 */
1049 HWTEST_F(DMSMissionManagerTest, testNotifyRemoteDied001, TestSize.Level3)
1050 {
1051 DTEST_LOG << "testNotifyRemoteDied001 begin" << std::endl;
1052 wptr<IRemoteObject> remote = nullptr;
1053 DistributedSchedMissionManager::GetInstance().NotifyRemoteDied(remote);
1054 DTEST_LOG << "testNotifyRemoteDied001 end" << std::endl;
1055 }
1056
1057 /**
1058 * @tc.name: testStopDataStorage001
1059 * @tc.desc: test stop data storage
1060 * @tc.type: FUNC
1061 */
1062 HWTEST_F(DMSMissionManagerTest, testStopDataStorage001, TestSize.Level3)
1063 {
1064 DTEST_LOG << "testStopDataStorage001 begin" << std::endl;
1065 auto ret = DistributedSchedMissionManager::GetInstance().StopDataStorage();
1066 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1067 DTEST_LOG << "testStopDataStorage001 end" << std::endl;
1068 }
1069
1070 /**
1071 * @tc.name: testStoreSnapshotInfo001
1072 * @tc.desc: test store snapshot info
1073 * @tc.type: FUNC
1074 */
1075 HWTEST_F(DMSMissionManagerTest, testStoreSnapshotInfo001, TestSize.Level3)
1076 {
1077 DTEST_LOG << "testStoreSnapshotInfo001 begin" << std::endl;
1078 auto ret = DistributedSchedMissionManager::GetInstance().StoreSnapshotInfo(DEVICE_ID, 0, 0, 0);
1079 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1080 DTEST_LOG << "testStoreSnapshotInfo001 end" << std::endl;
1081 }
1082
1083 /**
1084 * @tc.name: testRemoveSnapshotInfo001
1085 * @tc.desc: test remove snapshot info
1086 * @tc.type: FUNC
1087 */
1088 HWTEST_F(DMSMissionManagerTest, testRemoveSnapshotInfo001, TestSize.Level3)
1089 {
1090 DTEST_LOG << "testRemoveSnapshotInfo001 begin" << std::endl;
1091 auto ret = DistributedSchedMissionManager::GetInstance().RemoveSnapshotInfo(DEVICE_ID, 0);
1092 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1093 DTEST_LOG << "testRemoveSnapshotInfo001 end" << std::endl;
1094 }
1095
1096 /**
1097 * @tc.name: testInitDataStorage001
1098 * @tc.desc: test init data storage
1099 * @tc.type: FUNC
1100 */
1101 HWTEST_F(DMSMissionManagerTest, testInitDataStorage001, TestSize.Level3)
1102 {
1103 DTEST_LOG << "testInitDataStorage001 begin" << std::endl;
1104 auto ret = DistributedSchedMissionManager::GetInstance().InitDataStorage();
1105 EXPECT_EQ(ret, ERR_NONE);
1106 DTEST_LOG << "testInitDataStorage001 end" << std::endl;
1107 }
1108
1109 /**
1110 * @tc.name: testInitDataStorage002
1111 * @tc.desc: test init data storage
1112 * @tc.type: FUNC
1113 */
1114 HWTEST_F(DMSMissionManagerTest, testInitDataStorage002, TestSize.Level3)
1115 {
1116 DTEST_LOG << "testInitDataStorage002 begin" << std::endl;
1117 auto ret = DistributedSchedMissionManager::GetInstance().InitDataStorage();
1118 EXPECT_EQ(ret, ERR_NONE);
1119 DTEST_LOG << "testInitDataStorage002 end" << std::endl;
1120 }
1121
1122 /**
1123 * @tc.name: testStoreSnapshotInfo002
1124 * @tc.desc: test store snapshot info
1125 * @tc.type: FUNC
1126 */
1127 HWTEST_F(DMSMissionManagerTest, testStoreSnapshotInfo002, TestSize.Level3)
1128 {
1129 DTEST_LOG << "testStoreSnapshotInfo002 begin" << std::endl;
1130 auto ret = DistributedSchedMissionManager::GetInstance().StoreSnapshotInfo(DEVICE_ID, 0, 0, 0);
1131 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1132 DTEST_LOG << "testStoreSnapshotInfo002 end" << std::endl;
1133 }
1134
1135 /**
1136 * @tc.name: testRemoveSnapshotInfo002
1137 * @tc.desc: test remove snapshot info
1138 * @tc.type: FUNC
1139 */
1140 HWTEST_F(DMSMissionManagerTest, testRemoveSnapshotInfo002, TestSize.Level3)
1141 {
1142 DTEST_LOG << "testRemoveSnapshotInfo002 begin" << std::endl;
1143 auto ret = DistributedSchedMissionManager::GetInstance().RemoveSnapshotInfo(DEVICE_ID, 0);
1144 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1145 DTEST_LOG << "testRemoveSnapshotInfo002 end" << std::endl;
1146 }
1147
1148 /**
1149 * @tc.name: testGetRemoteMissionSnapshotInfo001
1150 * @tc.desc: test get remote mission snapshot info
1151 * @tc.type: FUNC
1152 */
1153 HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionSnapshotInfo001, TestSize.Level3)
1154 {
1155 DTEST_LOG << "testGetRemoteMissionSnapshotInfo001 begin" << std::endl;
1156 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
1157 auto ret = DistributedSchedMissionManager::GetInstance().GetRemoteMissionSnapshotInfo("", 0, missionSnapshot);
1158 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1159 DTEST_LOG << "testGetRemoteMissionSnapshotInfo001 end" << std::endl;
1160 }
1161
1162 /**
1163 * @tc.name: testDeviceOnlineNotify001
1164 * @tc.desc: test device online notify
1165 * @tc.type: FUNC
1166 */
1167 HWTEST_F(DMSMissionManagerTest, testDeviceOnlineNotify001, TestSize.Level3)
1168 {
1169 DTEST_LOG << "testDeviceOnlineNotify001 begin" << std::endl;
1170 DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify("");
1171 DTEST_LOG << "testDeviceOnlineNotify001 end" << std::endl;
1172 }
1173
1174 /**
1175 * @tc.name: testDeviceOnlineNotify002
1176 * @tc.desc: test device online notify
1177 * @tc.type: FUNC
1178 */
1179 HWTEST_F(DMSMissionManagerTest, testDeviceOnlineNotify002, TestSize.Level3)
1180 {
1181 DTEST_LOG << "testDeviceOnlineNotify002 begin" << std::endl;
1182 DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify(DEVICE_ID);
1183 DTEST_LOG << "testDeviceOnlineNotify002 end" << std::endl;
1184 }
1185
1186 /**
1187 * @tc.name: testDeviceOnlineNotify003
1188 * @tc.desc: test device online notify
1189 * @tc.type: FUNC
1190 */
1191 HWTEST_F(DMSMissionManagerTest, testDeviceOnlineNotify003, TestSize.Level3)
1192 {
1193 DTEST_LOG << "testDeviceOnlineNotify003 begin" << std::endl;
1194 DistributedSchedMissionManager::GetInstance().Init();
1195 DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify(DEVICE_ID);
1196 DTEST_LOG << "testDeviceOnlineNotify003 end" << std::endl;
1197 }
1198
1199 /**
1200 * @tc.name: testDeviceOfflineNotify001
1201 * @tc.desc: test device offline notify
1202 * @tc.type: FUNC
1203 */
1204 HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify001, TestSize.Level3)
1205 {
1206 DTEST_LOG << "testDeviceOfflineNotify001 begin" << std::endl;
1207 DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify("");
1208 DTEST_LOG << "testDeviceOfflineNotify001 end" << std::endl;
1209 }
1210
1211 /**
1212 * @tc.name: testDeviceOfflineNotify002
1213 * @tc.desc: test device offline notify
1214 * @tc.type: FUNC
1215 */
1216 HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify002, TestSize.Level3)
1217 {
1218 DTEST_LOG << "testDeviceOfflineNotify002 begin" << std::endl;
1219 std::set<std::string> remoteSyncDeviceSet_ = set<std::string>();
1220 DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify(DEVICE_ID);
1221 DTEST_LOG << "testDeviceOfflineNotify002 end" << std::endl;
1222 }
1223
1224 /**
1225 * @tc.name: testDeleteDataStorage001
1226 * @tc.desc: test delete data storage
1227 * @tc.type: FUNC
1228 */
1229 HWTEST_F(DMSMissionManagerTest, testDeleteDataStorage001, TestSize.Level3)
1230 {
1231 DTEST_LOG << "testDeleteDataStorage001 begin" << std::endl;
1232 DistributedSchedMissionManager::GetInstance().DeleteDataStorage("", false);
1233 DTEST_LOG << "testDeleteDataStorage001 end" << std::endl;
1234 }
1235
1236 /**
1237 * @tc.name: testDeleteDataStorage002
1238 * @tc.desc: test delete data storage
1239 * @tc.type: FUNC
1240 */
1241 HWTEST_F(DMSMissionManagerTest, testDeleteDataStorage002, TestSize.Level3)
1242 {
1243 DTEST_LOG << "testDeleteDataStorage002 begin" << std::endl;
1244 DistributedSchedMissionManager::GetInstance().DeleteDataStorage(DEVICE_ID, false);
1245 DTEST_LOG << "testDeleteDataStorage002 end" << std::endl;
1246 }
1247
1248 /**
1249 * @tc.name: testDeleteDataStorage003
1250 * @tc.desc: test delete data storage
1251 * @tc.type: FUNC
1252 */
1253 HWTEST_F(DMSMissionManagerTest, testDeleteDataStorage003, TestSize.Level3)
1254 {
1255 DTEST_LOG << "testDeleteDataStorage003 begin" << std::endl;
1256 DistributedSchedMissionManager::GetInstance().DeleteDataStorage("", true);
1257 DTEST_LOG << "testDeleteDataStorage003 end" << std::endl;
1258 }
1259
1260 /**
1261 * @tc.name: testDeleteDataStorage004
1262 * @tc.desc: test delete data storage
1263 * @tc.type: FUNC
1264 */
1265 HWTEST_F(DMSMissionManagerTest, testDeleteDataStorage004, TestSize.Level3)
1266 {
1267 DTEST_LOG << "testDeleteDataStorage004 begin" << std::endl;
1268 DistributedSchedMissionManager::GetInstance().DeleteDataStorage(DEVICE_ID, true);
1269 DTEST_LOG << "testDeleteDataStorage004 end" << std::endl;
1270 }
1271
1272 /**
1273 * @tc.name: testNotifySnapshotChanged001
1274 * @tc.desc: test notify snapshot changed
1275 * @tc.type: FUNC
1276 */
1277 HWTEST_F(DMSMissionManagerTest, testNotifySnapshotChanged001, TestSize.Level3)
1278 {
1279 DTEST_LOG << "testNotifySnapshotChanged001 begin" << std::endl;
1280 DistributedSchedMissionManager::GetInstance().NotifySnapshotChanged(DEVICE_ID, 0);
1281 DTEST_LOG << "testNotifySnapshotChanged001 end" << std::endl;
1282 }
1283
1284 /**
1285 * @tc.name: testOnRemoteDied001
1286 * @tc.desc: test on remote died
1287 * @tc.type: FUNC
1288 */
1289 HWTEST_F(DMSMissionManagerTest, testOnRemoteDied001, TestSize.Level3)
1290 {
1291 DTEST_LOG << "testOnRemoteDied001 begin" << std::endl;
1292 wptr<IRemoteObject> remote = nullptr;
1293 DistributedSchedMissionManager::GetInstance().OnRemoteDied(remote);
1294 DTEST_LOG << "testOnRemoteDied001 end" << std::endl;
1295 }
1296
1297 /**
1298 * @tc.name: testOnRemoteDied002
1299 * @tc.desc: test on remote died
1300 * @tc.type: FUNC
1301 */
1302 HWTEST_F(DMSMissionManagerTest, testOnRemoteDied002, TestSize.Level3)
1303 {
1304 DTEST_LOG << "testOnRemoteDied002 begin" << std::endl;
1305 wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
1306 DistributedSchedMissionManager::GetInstance().OnRemoteDied(remote);
1307 DTEST_LOG << "testOnRemoteDied002 end" << std::endl;
1308 }
1309
1310 /**
1311 * @tc.name: testStartSyncMissionsFromRemote001
1312 * @tc.desc: prepare and sync missions from remote
1313 * @tc.type: FUNC
1314 */
1315 HWTEST_F(DMSMissionManagerTest, testStartSyncMissionsFromRemote001, TestSize.Level3)
1316 {
1317 DTEST_LOG << "testStartSyncMissionsFromRemote001 begin" << std::endl;
1318 std::vector<DstbMissionInfo> missionInfos;
1319 CallerInfo callerInfo;
1320 DistributedSchedMissionManager::GetInstance().Init();
1321 DistributedSchedMissionManager::GetInstance().GenerateCallerInfo(callerInfo);
1322 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncMissionsFromRemote(callerInfo, missionInfos);
1323 EXPECT_EQ(ret, ERR_NONE);
1324 DTEST_LOG << "testStartSyncMissionsFromRemote001 end" << std::endl;
1325 }
1326
1327 /**
1328 * @tc.name: testStopSyncMissionsFromRemote001
1329 * @tc.desc: stop sync missions from remote
1330 * @tc.type: FUNC
1331 */
1332 HWTEST_F(DMSMissionManagerTest, testStopSyncMissionsFromRemote001, TestSize.Level3)
1333 {
1334 DTEST_LOG << "testStopSyncMissionsFromRemote001 begin" << std::endl;
1335 std::vector<DstbMissionInfo> missionInfos;
1336 CallerInfo callerInfo;
1337 DistributedSchedMissionManager::GetInstance().Init();
1338 DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote("");
1339 DTEST_LOG << "testStopSyncMissionsFromRemote001 end" << std::endl;
1340 }
1341
1342 /**
1343 * @tc.name: testStopSyncMissionsFromRemote002
1344 * @tc.desc: stop sync missions from remote
1345 * @tc.type: FUNC
1346 */
1347 HWTEST_F(DMSMissionManagerTest, testStopSyncMissionsFromRemote002, TestSize.Level3)
1348 {
1349 DTEST_LOG << "testStopSyncMissionsFromRemote002 begin" << std::endl;
1350 std::vector<DstbMissionInfo> missionInfos;
1351 CallerInfo callerInfo;
1352 DistributedSchedMissionManager::GetInstance().Init();
1353 DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(DEVICE_ID);
1354 DTEST_LOG << "testStopSyncMissionsFromRemote002 end" << std::endl;
1355 }
1356
1357 /**
1358 * @tc.name: testEnqueueCachedSnapshotInfo001
1359 * @tc.desc: enqueue cached snapshot info
1360 * @tc.type: FUNC
1361 */
1362 HWTEST_F(DMSMissionManagerTest, testEnqueueCachedSnapshotInfo001, TestSize.Level3)
1363 {
1364 DTEST_LOG << "testEnqueueCachedSnapshotInfo001 begin" << std::endl;
1365 DistributedSchedMissionManager::GetInstance().EnqueueCachedSnapshotInfo("", 1, nullptr);
1366 DTEST_LOG << "testEnqueueCachedSnapshotInfo001 end" << std::endl;
1367 }
1368
1369 /**
1370 * @tc.name: testEnqueueCachedSnapshotInfo002
1371 * @tc.desc: enqueue cached snapshot info
1372 * @tc.type: FUNC
1373 */
1374 HWTEST_F(DMSMissionManagerTest, testEnqueueCachedSnapshotInfo002, TestSize.Level3)
1375 {
1376 DTEST_LOG << "testEnqueueCachedSnapshotInfo002 begin" << std::endl;
1377 DistributedSchedMissionManager::GetInstance().EnqueueCachedSnapshotInfo(DEVICE_ID, 1, nullptr);
1378 DTEST_LOG << "testEnqueueCachedSnapshotInfo002 end" << std::endl;
1379 }
1380
1381 /**
1382 * @tc.name: testEnqueueCachedSnapshotInfo003
1383 * @tc.desc: enqueue cached snapshot info
1384 * @tc.type: FUNC
1385 */
1386 HWTEST_F(DMSMissionManagerTest, testEnqueueCachedSnapshotInfo003, TestSize.Level3)
1387 {
1388 DTEST_LOG << "testEnqueueCachedSnapshotInfo003 begin" << std::endl;
1389 unique_ptr<Snapshot> snapshot = make_unique<Snapshot>();
1390 DistributedSchedMissionManager::GetInstance().EnqueueCachedSnapshotInfo("", 1, std::move(snapshot));
1391 DTEST_LOG << "testEnqueueCachedSnapshotInfo003 end" << std::endl;
1392 }
1393
1394 /**
1395 * @tc.name: testDequeueCachedSnapshotInfo001
1396 * @tc.desc: enqueue cached snapshot info
1397 * @tc.type: FUNC
1398 */
1399 HWTEST_F(DMSMissionManagerTest, testDequeueCachedSnapshotInfo001, TestSize.Level3)
1400 {
1401 DTEST_LOG << "testDequeueCachedSnapshotInfo001 begin" << std::endl;
1402 DistributedSchedMissionManager::GetInstance().DequeueCachedSnapshotInfo("", 1);
1403 DTEST_LOG << "testDequeueCachedSnapshotInfo001 end" << std::endl;
1404 }
1405
1406 /**
1407 * @tc.name: testDequeueCachedSnapshotInfo002
1408 * @tc.desc: enqueue cached snapshot info
1409 * @tc.type: FUNC
1410 */
1411 HWTEST_F(DMSMissionManagerTest, testDequeueCachedSnapshotInfo002, TestSize.Level3)
1412 {
1413 DTEST_LOG << "testDequeueCachedSnapshotInfo002 begin" << std::endl;
1414 DistributedSchedMissionManager::GetInstance().DequeueCachedSnapshotInfo(DEVICE_ID, 1);
1415 DTEST_LOG << "testDequeueCachedSnapshotInfo002 end" << std::endl;
1416 }
1417
1418 /**
1419 * @tc.name: testRebornMissionCache001
1420 * @tc.desc: reborn mission cache
1421 * @tc.type: FUNC
1422 */
1423 HWTEST_F(DMSMissionManagerTest, testRebornMissionCache001, TestSize.Level3)
1424 {
1425 DTEST_LOG << "testRebornMissionCache001 begin" << std::endl;
1426 std::vector<DstbMissionInfo> missionInfos;
1427 DistributedSchedMissionManager::GetInstance().RebornMissionCache("", missionInfos);
1428 DTEST_LOG << "testRebornMissionCache001 end" << std::endl;
1429 }
1430
1431 /**
1432 * @tc.name: testRebornMissionCache002
1433 * @tc.desc: reborn mission cache
1434 * @tc.type: FUNC
1435 */
1436 HWTEST_F(DMSMissionManagerTest, testRebornMissionCache002, TestSize.Level3)
1437 {
1438 DTEST_LOG << "testRebornMissionCache002 begin" << std::endl;
1439 std::vector<DstbMissionInfo> missionInfos;
1440 DistributedSchedMissionManager::GetInstance().RebornMissionCache(DEVICE_ID, missionInfos);
1441 DTEST_LOG << "testRebornMissionCache002 end" << std::endl;
1442 }
1443
1444 /**
1445 * @tc.name: testNotifyMissionsChangedFromRemote001
1446 * @tc.desc: notify missions changed from remote
1447 * @tc.type: FUNC
1448 */
1449 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedFromRemote001, TestSize.Level3)
1450 {
1451 DTEST_LOG << "testNotifyMissionsChangedFromRemote001 begin" << std::endl;
1452 CallerInfo callerInfo;
1453 callerInfo.sourceDeviceId = "";
1454 callerInfo.uid = 0;
1455 callerInfo.pid = 0;
1456 callerInfo.dmsVersion = 0;
1457 std::vector<DstbMissionInfo> missionInfos;
1458 DistributedSchedMissionManager::GetInstance().Init();
1459 auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedFromRemote(callerInfo, missionInfos);
1460 EXPECT_EQ(ret, ERR_NONE);
1461 DTEST_LOG << "testNotifyMissionsChangedFromRemote001 end" << std::endl;
1462 }
1463
1464 /**
1465 * @tc.name: testNotifyMissionsChangedFromRemote002
1466 * @tc.desc: notify missions changed from remote
1467 * @tc.type: FUNC
1468 */
1469 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedFromRemote002, TestSize.Level3)
1470 {
1471 DTEST_LOG << "testNotifyMissionsChangedFromRemote002 begin" << std::endl;
1472 CallerInfo callerInfo;
1473 callerInfo.sourceDeviceId = DEVICE_ID;
1474 callerInfo.uid = 0;
1475 callerInfo.pid = 0;
1476 callerInfo.dmsVersion = 0;
1477 std::vector<DstbMissionInfo> missionInfos;
1478 DistributedSchedMissionManager::GetInstance().Init();
1479 auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedFromRemote(callerInfo, missionInfos);
1480 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1481 DTEST_LOG << "testNotifyMissionsChangedFromRemote002 end" << std::endl;
1482 }
1483
1484 /**
1485 * @tc.name: testNotifyLocalMissionsChanged001
1486 * @tc.desc: notify local missions changed
1487 * @tc.type: FUNC
1488 */
1489 HWTEST_F(DMSMissionManagerTest, testNotifyLocalMissionsChanged001, TestSize.Level3)
1490 {
1491 DTEST_LOG << "testNotifyLocalMissionsChanged001 begin" << std::endl;
1492 DistributedSchedMissionManager::GetInstance().Init();
1493 DistributedSchedMissionManager::GetInstance().NotifyLocalMissionsChanged();
1494 DTEST_LOG << "testNotifyLocalMissionsChanged001 end" << std::endl;
1495 }
1496
1497 /**
1498 * @tc.name: testNotifyMissionSnapshotCreated001
1499 * @tc.desc: notify mission snapshot created
1500 * @tc.type: FUNC
1501 */
1502 HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotCreated001, TestSize.Level3)
1503 {
1504 DTEST_LOG << "testNotifyMissionSnapshotCreated001 begin" << std::endl;
1505 DistributedSchedMissionManager::GetInstance().Init();
1506 DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
1507 DTEST_LOG << "testNotifyMissionSnapshotCreated001 end" << std::endl;
1508 }
1509
1510 /**
1511 * @tc.name: testNotifyMissionSnapshotChanged001
1512 * @tc.desc: notify mission snapshot changed
1513 * @tc.type: FUNC
1514 */
1515 HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotChanged001, TestSize.Level3)
1516 {
1517 DTEST_LOG << "testNotifyMissionSnapshotChanged001 begin" << std::endl;
1518 DistributedSchedMissionManager::GetInstance().Init();
1519 DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotChanged(1);
1520 DTEST_LOG << "testNotifyMissionSnapshotChanged001 end" << std::endl;
1521 }
1522
1523 /**
1524 * @tc.name: testNotifyMissionSnapshotDestroyed001
1525 * @tc.desc: notify mission snapshot destroyed
1526 * @tc.type: FUNC
1527 */
1528 HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotDestroyed001, TestSize.Level3)
1529 {
1530 DTEST_LOG << "testNotifyMissionSnapshotDestroyed001 begin" << std::endl;
1531 DistributedSchedMissionManager::GetInstance().Init();
1532 DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotDestroyed(1);
1533 DTEST_LOG << "testNotifyMissionSnapshotDestroyed001 end" << std::endl;
1534 }
1535
1536 /**
1537 * @tc.name: testNotifyMissionsChangedToRemote001
1538 * @tc.desc: notify missions changed to remote
1539 * @tc.type: FUNC
1540 */
1541 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemote001, TestSize.Level3)
1542 {
1543 DTEST_LOG << "testNotifyMissionsChangedToRemote001 begin" << std::endl;
1544 std::vector<DstbMissionInfo> missionInfos;
1545 auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemote(missionInfos);
1546 EXPECT_EQ(ret, ERR_NONE);
1547 DTEST_LOG << "testNotifyMissionsChangedToRemote001 end" << std::endl;
1548 }
1549
1550 /**
1551 * @tc.name: testNotifyMissionsChangedToRemoteInner001
1552 * @tc.desc: notify missions changed to remote inner
1553 * @tc.type: FUNC
1554 */
1555 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner001, TestSize.Level3)
1556 {
1557 DTEST_LOG << "testNotifyMissionsChangedToRemoteInner001 begin" << std::endl;
1558 CallerInfo callerInfo;
1559 std::vector<DstbMissionInfo> missionInfos;
1560 DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner("", missionInfos, callerInfo);
1561 DTEST_LOG << "testNotifyMissionsChangedToRemoteInner001 end" << std::endl;
1562 }
1563
1564 /**
1565 * @tc.name: testNotifyMissionsChangedToRemoteInner002
1566 * @tc.desc: notify missions changed to remote inner
1567 * @tc.type: FUNC
1568 */
1569 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner002, TestSize.Level3)
1570 {
1571 DTEST_LOG << "testNotifyMissionsChangedToRemoteInner002 begin" << std::endl;
1572 CallerInfo callerInfo;
1573 std::vector<DstbMissionInfo> missionInfos;
1574 DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner(
1575 DEVICE_ID, missionInfos, callerInfo);
1576 DTEST_LOG << "testNotifyMissionsChangedToRemoteInner002 end" << std::endl;
1577 }
1578
1579 /**
1580 * @tc.name: testFetchDeviceHandler001
1581 * @tc.desc: fetch device handler
1582 * @tc.type: FUNC
1583 */
1584 HWTEST_F(DMSMissionManagerTest, testFetchDeviceHandler001, TestSize.Level3)
1585 {
1586 DTEST_LOG << "testFetchDeviceHandler001 begin" << std::endl;
1587 DistributedSchedMissionManager::GetInstance().FetchDeviceHandler("");
1588 DTEST_LOG << "testFetchDeviceHandler001 end" << std::endl;
1589 }
1590
1591 /**
1592 * @tc.name: testFetchDeviceHandler002
1593 * @tc.desc: fetch device handler
1594 * @tc.type: FUNC
1595 */
1596 HWTEST_F(DMSMissionManagerTest, testFetchDeviceHandler002, TestSize.Level3)
1597 {
1598 DTEST_LOG << "testFetchDeviceHandler002 begin" << std::endl;
1599 DistributedSchedMissionManager::GetInstance().FetchDeviceHandler(DEVICE_ID);
1600 DTEST_LOG << "testFetchDeviceHandler002 end" << std::endl;
1601 }
1602
1603 /**
1604 * @tc.name: testOnRemoteDmsDied001
1605 * @tc.desc: on remote dms died
1606 * @tc.type: FUNC
1607 */
1608 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied001, TestSize.Level3)
1609 {
1610 DTEST_LOG << "testOnRemoteDmsDied001 begin" << std::endl;
1611 wptr<IRemoteObject> remote = nullptr;
1612 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
1613 DTEST_LOG << "testOnRemoteDmsDied001 end" << std::endl;
1614 }
1615
1616 /**
1617 * @tc.name: testOnRemoteDmsDied002
1618 * @tc.desc: on remote dms died
1619 * @tc.type: FUNC
1620 */
1621 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied002, TestSize.Level3)
1622 {
1623 DTEST_LOG << "testOnRemoteDmsDied002 begin" << std::endl;
1624 wptr<IRemoteObject> remote = wptr<IRemoteObject>();
1625 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
1626 DTEST_LOG << "testOnRemoteDmsDied002 end" << std::endl;
1627 }
1628
1629 /**
1630 * @tc.name: testRetryStartSyncRemoteMissions001
1631 * @tc.desc: retry start sync remote missions
1632 * @tc.type: FUNC
1633 */
1634 HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions001, TestSize.Level3)
1635 {
1636 DTEST_LOG << "testRetryStartSyncRemoteMissions001 begin" << std::endl;
1637 DistributedSchedMissionManager::GetInstance().Init();
1638 DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions("", localDeviceId_, 1);
1639 DTEST_LOG << "testRetryStartSyncRemoteMissions001 end" << std::endl;
1640 }
1641
1642 /**
1643 * @tc.name: testRetryStartSyncRemoteMissions002
1644 * @tc.desc: retry start sync remote missions
1645 * @tc.type: FUNC
1646 */
1647 HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions002, TestSize.Level3)
1648 {
1649 DTEST_LOG << "testRetryStartSyncRemoteMissions002 begin" << std::endl;
1650 DistributedSchedMissionManager::GetInstance().Init();
1651 DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
1652 DTEST_LOG << "testRetryStartSyncRemoteMissions002 end" << std::endl;
1653 }
1654
1655 /**
1656 * @tc.name: testOnMissionListenerDied001
1657 * @tc.desc: on mission listener died
1658 * @tc.type: FUNC
1659 */
1660 HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied001, TestSize.Level3)
1661 {
1662 DTEST_LOG << "testOnMissionListenerDied001 begin" << std::endl;
1663 sptr<IRemoteObject> remote = nullptr;
1664 DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(remote);
1665 DTEST_LOG << "testOnMissionListenerDied001 end" << std::endl;
1666 }
1667
1668 /**
1669 * @tc.name: testOnMissionListenerDied002
1670 * @tc.desc: on mission listener died
1671 * @tc.type: FUNC
1672 */
1673 HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied002, TestSize.Level3)
1674 {
1675 DTEST_LOG << "testOnMissionListenerDied002 begin" << std::endl;
1676 sptr<IRemoteObject> remote = sptr<IRemoteObject>();
1677 DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(remote);
1678 DTEST_LOG << "testOnMissionListenerDied002 end" << std::endl;
1679 }
1680
1681 /**
1682 * @tc.name: testOnRemoteDmsDied003
1683 * @tc.desc: on remote dms died
1684 * @tc.type: FUNC
1685 */
1686 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied003, TestSize.Level3)
1687 {
1688 DTEST_LOG << "testOnRemoteDmsDied003 begin" << std::endl;
1689 sptr<IRemoteObject> remote = nullptr;
1690 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
1691 DTEST_LOG << "testOnRemoteDmsDied003 end" << std::endl;
1692 }
1693
1694 /**
1695 * @tc.name: testOnRemoteDmsDied004
1696 * @tc.desc: on remote dms died
1697 * @tc.type: FUNC
1698 */
1699 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied004, TestSize.Level3)
1700 {
1701 DTEST_LOG << "testOnRemoteDmsDied004 begin" << std::endl;
1702 sptr<IRemoteObject> remote = sptr<IRemoteObject>();
1703 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
1704 DTEST_LOG << "testOnRemoteDmsDied004 end" << std::endl;
1705 }
1706
1707 /**
1708 * @tc.name: testNotifyDmsProxyProcessDied001
1709 * @tc.desc: notify dms proxy process died
1710 * @tc.type: FUNC
1711 */
1712 HWTEST_F(DMSMissionManagerTest, testNotifyDmsProxyProcessDied001, TestSize.Level3)
1713 {
1714 DTEST_LOG << "testNotifyDmsProxyProcessDied001 begin" << std::endl;
1715 DistributedSchedMissionManager::GetInstance().NotifyDmsProxyProcessDied();
1716 DTEST_LOG << "testNotifyDmsProxyProcessDied001 end" << std::endl;
1717 }
1718
1719 /**
1720 * @tc.name: testRetryRegisterMissionChange001
1721 * @tc.desc: retry register mission change
1722 * @tc.type: FUNC
1723 */
1724 HWTEST_F(DMSMissionManagerTest, testRetryRegisterMissionChange001, TestSize.Level3)
1725 {
1726 DTEST_LOG << "testRetryRegisterMissionChange001 begin" << std::endl;
1727 DistributedSchedMissionManager::GetInstance().Init();
1728 DistributedSchedMissionManager::GetInstance().RetryRegisterMissionChange(1);
1729 DTEST_LOG << "testRetryRegisterMissionChange001 end" << std::endl;
1730 }
1731
1732 /**
1733 * @tc.name: testInitAllSnapshots001
1734 * @tc.desc: init all snapshots
1735 * @tc.type: FUNC
1736 */
1737 HWTEST_F(DMSMissionManagerTest, testInitAllSnapshots001, TestSize.Level3)
1738 {
1739 DTEST_LOG << "testInitAllSnapshots001 begin" << std::endl;
1740 std::vector<DstbMissionInfo> missionInfos;
1741 DistributedSchedMissionManager::GetInstance().InitAllSnapshots(missionInfos);
1742 DTEST_LOG << "testInitAllSnapshots001 end" << std::endl;
1743 }
1744
1745 /**
1746 * @tc.name: testMissionSnapshotChanged001
1747 * @tc.desc: mission snapshot changed
1748 * @tc.type: FUNC
1749 */
1750 HWTEST_F(DMSMissionManagerTest, testMissionSnapshotChanged001, TestSize.Level3)
1751 {
1752 DTEST_LOG << "testMissionSnapshotChanged001 begin" << std::endl;
1753 auto ret = DistributedSchedMissionManager::GetInstance().MissionSnapshotChanged(NUM_MISSIONS);
1754 EXPECT_NE(ret, ERR_NONE);
1755 DTEST_LOG << "testMissionSnapshotChanged001 end" << std::endl;
1756 }
1757
1758 /**
1759 * @tc.name: testOnDnetDied001
1760 * @tc.desc: on dnet died
1761 * @tc.type: FUNC
1762 */
1763 HWTEST_F(DMSMissionManagerTest, testOnDnetDied001, TestSize.Level3)
1764 {
1765 DTEST_LOG << "testOnDnetDied001 begin" << std::endl;
1766 DistributedSchedMissionManager::GetInstance().Init();
1767 DistributedSchedMissionManager::GetInstance().OnDnetDied();
1768 DTEST_LOG << "testOnDnetDied001 end" << std::endl;
1769 }
1770
1771 /**
1772 * @tc.name: ProxyCallStopSyncMissionsFromRemote001
1773 * @tc.desc: call dms proxy StopSyncMissionsFromRemote
1774 * @tc.type: FUNC
1775 * @tc.require: I5XDDS
1776 */
1777 HWTEST_F(DMSMissionManagerTest, ProxyCallStopSyncMissionsFromRemote001, TestSize.Level3)
1778 {
1779 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStopSyncMissionsFromRemote001 start" << std::endl;
1780 sptr<IDistributedSched> proxy = GetDms();
1781 if (proxy == nullptr) {
1782 return;
1783 }
1784 CallerInfo callerInfo;
1785 int32_t ret = proxy->StopSyncMissionsFromRemote(callerInfo);
1786 EXPECT_EQ(ret, REQUEST_CODE_ERR);
1787 DTEST_LOG << "DistributedSchedServiceTest ProxyCallStopSyncMissionsFromRemote001 end" << std::endl;
1788 }
1789
1790 /**
1791 * @tc.name: ProxyCallNotifyMissionsChangedFromRemote001
1792 * @tc.desc: call dms proxy NotifyMissionsChangedFromRemote
1793 * @tc.type: FUNC
1794 * @tc.require: I5XDDS
1795 */
1796 HWTEST_F(DMSMissionManagerTest, ProxyCallNotifyMissionsChangedFromRemote001, TestSize.Level3)
1797 {
1798 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyMissionsChangedFromRemote001 start" << std::endl;
1799 sptr<IDistributedSched> proxy = GetDms();
1800 if (proxy == nullptr) {
1801 return;
1802 }
1803 CallerInfo callerInfo;
1804 std::vector<DstbMissionInfo> missionInfos;
1805 int32_t ret = proxy->NotifyMissionsChangedFromRemote(missionInfos, callerInfo);
1806 EXPECT_EQ(ret, REQUEST_CODE_ERR);
1807 DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyMissionsChangedFromRemote001 end" << std::endl;
1808 }
1809
1810 /**
1811 * @tc.name: ProxyCallGetRemoteMissionSnapshotInfo001
1812 * @tc.desc: call dms proxy GetRemoteMissionSnapshotInfo
1813 * @tc.type: FUNC
1814 * @tc.require: I5XDDS
1815 */
1816 HWTEST_F(DMSMissionManagerTest, ProxyCallGetRemoteMissionSnapshotInfo001, TestSize.Level3)
1817 {
1818 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo001 start" << std::endl;
1819 sptr<IDistributedSched> proxy = GetDms();
1820 if (proxy == nullptr) {
1821 return;
1822 }
1823 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
1824 int32_t ret = proxy->GetRemoteMissionSnapshotInfo("MockDevId", 1, missionSnapshot);
1825 EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
1826 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo001 end" << std::endl;
1827 }
1828
1829 /**
1830 * @tc.name: ProxyCallGetRemoteMissionSnapshotInfo002
1831 * @tc.desc: call dms proxy GetRemoteMissionSnapshotInfo
1832 * @tc.type: FUNC
1833 * @tc.require: I5XDDS
1834 */
1835 HWTEST_F(DMSMissionManagerTest, ProxyCallGetRemoteMissionSnapshotInfo002, TestSize.Level3)
1836 {
1837 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo002 start" << std::endl;
1838 sptr<IDistributedSched> proxy = GetDms();
1839 if (proxy == nullptr) {
1840 return;
1841 }
1842 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
1843 int32_t ret = proxy->GetRemoteMissionSnapshotInfo("", 1, missionSnapshot);
1844 EXPECT_EQ(ret, ERR_NULL_OBJECT);
1845 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo002 end" << std::endl;
1846 }
1847
1848 /**
1849 * @tc.name: ProxyCallGetRemoteMissionSnapshotInfo003
1850 * @tc.desc: call dms proxy GetRemoteMissionSnapshotInfo
1851 * @tc.type: FUNC
1852 * @tc.require: I5XDDS
1853 */
1854 HWTEST_F(DMSMissionManagerTest, ProxyCallGetRemoteMissionSnapshotInfo003, TestSize.Level3)
1855 {
1856 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo003 start" << std::endl;
1857 sptr<IDistributedSched> proxy = GetDms();
1858 if (proxy == nullptr) {
1859 return;
1860 }
1861 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
1862 int32_t ret = proxy->GetRemoteMissionSnapshotInfo("MockDevId", -1, missionSnapshot);
1863 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1864 DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo003 end" << std::endl;
1865 }
1866
1867 /**
1868 * @tc.name: testDeleteDataStorage005
1869 * @tc.desc: test DeleteDataStorage
1870 * @tc.type: FUNC
1871 */
1872 HWTEST_F(DMSMissionManagerTest, testDeleteDataStorage005, TestSize.Level3)
1873 {
1874 DTEST_LOG << "testDeleteDataStorage005 begin" << std::endl;
1875 std::string uuid = "uuid for GetUuidByNetworkId";
1876 {
1877 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
1878 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
1879 }
1880 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
1881 std::make_shared<DistributedDataStorage>();
1882 auto result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Init();
__anoneafaeaae0202() 1883 auto initDoneTask = []() {
1884 std::lock_guard<std::mutex> autoLock(caseDoneLock_);
1885 isCaseDone_ = true;
1886 caseDoneCondition_.notify_all();
1887 };
1888 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ != nullptr) {
1889 std::shared_ptr<AppExecFwk::EventHandler> dmsDataStorageHandler =
1890 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->dmsDataStorageHandler_;
1891 if (dmsDataStorageHandler != nullptr) {
1892 dmsDataStorageHandler->PostTask(initDoneTask);
1893 }
1894 }
1895 std::unique_lock<std::mutex> lock(caseDoneLock_);
1896 caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
__anoneafaeaae0302() 1897 [&] () { return isCaseDone_; });
1898 EXPECT_TRUE(result);
1899 isCaseDone_ = false;
1900 uint8_t* byteStream = new uint8_t[BYTESTREAM_LENGTH];
1901 for (size_t i = 0; i < BYTESTREAM_LENGTH; ++i) {
1902 byteStream[i] = ONE_BYTE;
1903 }
1904 result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Insert(localDeviceId_,
1905 TASK_ID, byteStream, BYTESTREAM_LENGTH);
1906 EXPECT_TRUE(result);
1907 DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
1908 DistributedSchedMissionManager::GetInstance().DeleteDataStorage(localDeviceId_, false);
1909 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Stop();
1910 DTEST_LOG << "testDeleteDataStorage005 end" << std::endl;
1911 }
1912
1913 /**
1914 * @tc.name: testDeleteDataStorage006
1915 * @tc.desc: test DeleteDataStorage
1916 * @tc.type: FUNC
1917 */
1918 HWTEST_F(DMSMissionManagerTest, testDeleteDataStorage006, TestSize.Level3)
1919 {
1920 DTEST_LOG << "testDeleteDataStorage006 begin" << std::endl;
1921 std::string uuid = "uuid for GetUuidByNetworkId";
1922 {
1923 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
1924 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
1925 }
1926 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
1927 std::make_shared<DistributedDataStorage>();
1928 auto result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Init();
__anoneafaeaae0402() 1929 auto initDoneTask = []() {
1930 std::lock_guard<std::mutex> autoLock(caseDoneLock_);
1931 isCaseDone_ = true;
1932 caseDoneCondition_.notify_all();
1933 };
1934 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ != nullptr) {
1935 std::shared_ptr<AppExecFwk::EventHandler> dmsDataStorageHandler =
1936 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->dmsDataStorageHandler_;
1937 if (dmsDataStorageHandler != nullptr) {
1938 dmsDataStorageHandler->PostTask(initDoneTask);
1939 }
1940 }
1941 std::unique_lock<std::mutex> lock(caseDoneLock_);
1942 caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
__anoneafaeaae0502() 1943 [&] () { return isCaseDone_; });
1944 EXPECT_TRUE(result);
1945 isCaseDone_ = false;
1946 uint8_t* byteStream = new uint8_t[BYTESTREAM_LENGTH];
1947 for (size_t i = 0; i < BYTESTREAM_LENGTH; ++i) {
1948 byteStream[i] = ONE_BYTE;
1949 }
1950 result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Insert(localDeviceId_,
1951 TASK_ID, byteStream, BYTESTREAM_LENGTH);
1952 EXPECT_TRUE(result);
1953 DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
1954 DistributedSchedMissionManager::GetInstance().DeleteDataStorage(localDeviceId_, true);
1955 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Stop();
1956 DTEST_LOG << "testDeleteDataStorage006 end" << std::endl;
1957 }
1958
1959 /**
1960 * @tc.name: testRegisterMissionListener009
1961 * @tc.desc: test register mission listener
1962 * @tc.type: FUNC
1963 */
1964 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener009, TestSize.Level3)
1965 {
1966 DTEST_LOG << "testRegisterMissionListener009 begin" << std::endl;
1967 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
1968 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
1969 u16string deviceId = Str8ToStr16(localDeviceId_);
1970 std::string uuid = "uuid for GetUuidByNetworkId";
1971 {
1972 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
1973 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
1974 }
1975 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
1976 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(deviceId, listener);
1977 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1978 DTEST_LOG << "testRegisterMissionListener009 end" << std::endl;
1979 }
1980
1981 /**
1982 * @tc.name: testRegisterMissionListener010
1983 * @tc.desc: test register mission listener
1984 * @tc.type: FUNC
1985 */
1986 HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener010, TestSize.Level3)
1987 {
1988 DTEST_LOG << "testRegisterMissionListener010 begin" << std::endl;
1989 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
1990 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
1991 u16string deviceId = Str8ToStr16(DEVICE_ID);
1992 std::string uuid = "uuid for GetUuidByNetworkId";
1993 {
1994 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
1995 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
1996 }
1997 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
1998 {
1999 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2000 ListenerInfo listenerInfo;
2001 listenerInfo.Emplace(listener);
2002 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2003 }
2004 auto ret = DistributedSchedMissionManager::GetInstance().RegisterMissionListener(deviceId, listener);
2005 EXPECT_EQ(ret, ERR_NONE);
2006 DTEST_LOG << "testRegisterMissionListener010 end" << std::endl;
2007 }
2008
2009 /**
2010 * @tc.name: testGetRemoteDms001
2011 * @tc.desc: test GetRemoteDms
2012 * @tc.type: FUNC
2013 */
2014 HWTEST_F(DMSMissionManagerTest, testGetRemoteDms001, TestSize.Level1)
2015 {
2016 DTEST_LOG << "testGetRemoteDms001 begin" << std::endl;
2017 sptr<IDistributedSched> proxy = GetDms();
2018 if (proxy == nullptr) {
2019 return;
2020 }
2021 {
2022 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2023 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
2024 }
2025 {
2026 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2027 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[localDeviceId_] = proxy;
2028 }
2029
2030 auto ret = DistributedSchedMissionManager::GetInstance().GetRemoteDms(localDeviceId_);
2031 DTEST_LOG << "testGetRemoteDms001 end" << std::endl;
2032 }
2033
2034 /**
2035 * @tc.name: testGetRemoteDms002
2036 * @tc.desc: test GetRemoteDms
2037 * @tc.type: FUNC
2038 */
2039 HWTEST_F(DMSMissionManagerTest, testGetRemoteDms002, TestSize.Level1)
2040 {
2041 DTEST_LOG << "testGetRemoteDms002 begin" << std::endl;
2042 {
2043 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2044 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
2045 }
2046 {
2047 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2048 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[localDeviceId_] = nullptr;
2049 }
2050
2051 auto ret = DistributedSchedMissionManager::GetInstance().GetRemoteDms(localDeviceId_);
2052 DTEST_LOG << "testGetRemoteDms002 end" << std::endl;
2053 }
2054
2055 /**
2056 * @tc.name: testIsDeviceIdValidated002
2057 * @tc.desc: test IsDeviceIdValidated
2058 * @tc.type: FUNC
2059 */
2060 HWTEST_F(DMSMissionManagerTest, testIsDeviceIdValidated002, TestSize.Level1)
2061 {
2062 DTEST_LOG << "testIsDeviceIdValidated002 begin" << std::endl;
2063 {
2064 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2065 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
2066 }
2067
2068 int32_t deviceType = 0;
2069 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, localDeviceId_);
2070 {
2071 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2072 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[localDeviceId_] = dmsDeviceInfo;
2073 }
2074 auto ret = DistributedSchedMissionManager::GetInstance().IsDeviceIdValidated(localDeviceId_);
2075 EXPECT_TRUE(ret);
2076 DTEST_LOG << "testIsDeviceIdValidated002 end" << std::endl;
2077 }
2078
2079
2080 /**
2081 * @tc.name: testGetMissionInfos007
2082 * @tc.desc: get missions
2083 * @tc.type: FUNC
2084 */
2085 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos007, TestSize.Level3)
2086 {
2087 DTEST_LOG << "testGetMissionInfos007 begin" << std::endl;
2088 {
2089 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2090 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
2091 }
2092
2093 int32_t deviceType = 0;
2094 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, DEVICE_ID);
2095 {
2096 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2097 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[DEVICE_ID] = dmsDeviceInfo;
2098 }
2099 int32_t numMissions = 0;
2100 std::vector<AAFwk::MissionInfo> missionInfos;
2101 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(DEVICE_ID, numMissions, missionInfos);
2102 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
2103 DTEST_LOG << "testGetMissionInfos007 end" << std::endl;
2104 }
2105
2106 /**
2107 * @tc.name: testGetMissionInfos008
2108 * @tc.desc: get missions
2109 * @tc.type: FUNC
2110 */
2111 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos008, TestSize.Level3)
2112 {
2113 DTEST_LOG << "testGetMissionInfos008 begin" << std::endl;
2114 {
2115 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2116 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
2117 }
2118
2119 int32_t deviceType = 0;
2120 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, DEVICE_ID);
2121 {
2122 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2123 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[DEVICE_ID] = dmsDeviceInfo;
2124 }
2125 int32_t numMissions = NORMAL_NUM_MISSIONS;
2126 std::vector<AAFwk::MissionInfo> missionInfos;
2127 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(DEVICE_ID, numMissions, missionInfos);
2128 EXPECT_NE(ret, ERR_OK);
2129 DTEST_LOG << "testGetMissionInfos008 end" << std::endl;
2130 }
2131
2132 /**
2133 * @tc.name: testGetMissionInfos009
2134 * @tc.desc: get missions
2135 * @tc.type: FUNC
2136 */
2137 HWTEST_F(DMSMissionManagerTest, testGetMissionInfos009, TestSize.Level3)
2138 {
2139 DTEST_LOG << "testGetMissionInfos009 begin" << std::endl;
2140 {
2141 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2142 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
2143 }
2144
2145 int32_t deviceType = 0;
2146 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, DEVICE_ID);
2147 {
2148 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
2149 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[localDeviceId_] = dmsDeviceInfo;
2150 }
2151 int32_t numMissions = NORMAL_NUM_MISSIONS;
2152 std::vector<AAFwk::MissionInfo> missionInfos;
2153 std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(localDeviceId_);
2154 {
2155 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteMissionInfosLock_);
2156 DistributedSchedMissionManager::GetInstance().deviceMissionInfos_.erase(uuid);
2157 }
2158 std::vector<DstbMissionInfo> dstbMissionInfos;
2159 {
2160 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteMissionInfosLock_);
2161 DistributedSchedMissionManager::GetInstance().deviceMissionInfos_[uuid] = dstbMissionInfos;
2162 }
2163 auto ret = DistributedSchedMissionManager::GetInstance().GetMissionInfos(localDeviceId_, numMissions, missionInfos);
2164 EXPECT_EQ(ret, ERR_OK);
2165 DTEST_LOG << "testGetMissionInfos009 end" << std::endl;
2166 }
2167
2168 /**
2169 * @tc.name: testNotifyRemoteDied002
2170 * @tc.desc: test notify remote died
2171 * @tc.type: FUNC
2172 */
2173 HWTEST_F(DMSMissionManagerTest, testNotifyRemoteDied002, TestSize.Level3)
2174 {
2175 DTEST_LOG << "testNotifyRemoteDied002 begin" << std::endl;
2176 wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
2177 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ == nullptr) {
2178 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2179 std::make_shared<DistributedDataStorage>();
2180 }
2181 DistributedSchedMissionManager::GetInstance().NotifyRemoteDied(remote);
2182 DTEST_LOG << "testNotifyRemoteDied002 end" << std::endl;
2183 }
2184
2185 /**
2186 * @tc.name: testInitDataStorage003
2187 * @tc.desc: test init data storage
2188 * @tc.type: FUNC
2189 */
2190 HWTEST_F(DMSMissionManagerTest, testInitDataStorage003, TestSize.Level3)
2191 {
2192 DTEST_LOG << "testInitDataStorage003 begin" << std::endl;
2193 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ == nullptr) {
2194 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2195 std::make_shared<DistributedDataStorage>();
2196 }
2197 auto ret = DistributedSchedMissionManager::GetInstance().InitDataStorage();
2198 EXPECT_EQ(ret, ERR_NONE);
2199 ret = DistributedSchedMissionManager::GetInstance().StopDataStorage();
2200 DTEST_LOG << "testInitDataStorage003 end" << std::endl;
2201 }
2202
2203 /**
2204 * @tc.name: testStopDataStorage003
2205 * @tc.desc: test stop data storage
2206 * @tc.type: FUNC
2207 */
2208 HWTEST_F(DMSMissionManagerTest, testStopDataStorage003, TestSize.Level3)
2209 {
2210 DTEST_LOG << "testStopDataStorage003 begin" << std::endl;
2211 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2212 std::make_shared<DistributedDataStorage>();
2213 auto result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Init();
__anoneafaeaae0602() 2214 auto initDoneTask = []() {
2215 std::lock_guard<std::mutex> autoLock(caseDoneLock_);
2216 isCaseDone_ = true;
2217 caseDoneCondition_.notify_all();
2218 };
2219 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ != nullptr) {
2220 std::shared_ptr<AppExecFwk::EventHandler> dmsDataStorageHandler =
2221 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->dmsDataStorageHandler_;
2222 if (dmsDataStorageHandler != nullptr) {
2223 dmsDataStorageHandler->PostTask(initDoneTask);
2224 }
2225 }
2226 std::unique_lock<std::mutex> lock(caseDoneLock_);
2227 caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
__anoneafaeaae0702() 2228 [&] () { return isCaseDone_; });
2229 EXPECT_TRUE(result);
2230 isCaseDone_ = false;
2231 auto ret = DistributedSchedMissionManager::GetInstance().StopDataStorage();
2232 EXPECT_EQ(ret, ERR_NONE);
2233 DTEST_LOG << "testStopDataStorage003 end" << std::endl;
2234 }
2235
2236 /**
2237 * @tc.name: testStoreSnapshotInfo004
2238 * @tc.desc: test store snapshot info
2239 * @tc.type: FUNC
2240 */
2241 HWTEST_F(DMSMissionManagerTest, testStoreSnapshotInfo004, TestSize.Level3)
2242 {
2243 DTEST_LOG << "testStoreSnapshotInfo004 begin" << std::endl;
2244 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2245 std::make_shared<DistributedDataStorage>();
2246 auto ret = DistributedSchedMissionManager::GetInstance().StoreSnapshotInfo(DEVICE_ID, 0, 0, 0);
2247 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
2248 DTEST_LOG << "testStoreSnapshotInfo004 end" << std::endl;
2249 }
2250
2251 /**
2252 * @tc.name: testStoreSnapshotInfo003
2253 * @tc.desc: test store snapshot info
2254 * @tc.type: FUNC
2255 */
2256 HWTEST_F(DMSMissionManagerTest, testStoreSnapshotInfo003, TestSize.Level3)
2257 {
2258 DTEST_LOG << "testStoreSnapshotInfo003 begin" << std::endl;
2259 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2260 std::make_shared<DistributedDataStorage>();
2261 auto result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Init();
__anoneafaeaae0802() 2262 auto initDoneTask = []() {
2263 std::lock_guard<std::mutex> autoLock(caseDoneLock_);
2264 isCaseDone_ = true;
2265 caseDoneCondition_.notify_all();
2266 };
2267 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ != nullptr) {
2268 std::shared_ptr<AppExecFwk::EventHandler> dmsDataStorageHandler =
2269 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->dmsDataStorageHandler_;
2270 if (dmsDataStorageHandler != nullptr) {
2271 dmsDataStorageHandler->PostTask(initDoneTask);
2272 }
2273 }
2274 std::unique_lock<std::mutex> lock(caseDoneLock_);
2275 caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
__anoneafaeaae0902() 2276 [&] () { return isCaseDone_; });
2277 EXPECT_TRUE(result);
2278 isCaseDone_ = false;
2279 std::string uuid = "uuid for GetUuidByNetworkId";
2280 {
2281 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2282 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
2283 }
2284 uint8_t* byteStream = new uint8_t[BYTESTREAM_LENGTH];
2285 for (size_t i = 0; i < BYTESTREAM_LENGTH; ++i) {
2286 byteStream[i] = ONE_BYTE;
2287 }
2288 auto ret = DistributedSchedMissionManager::GetInstance().
2289 StoreSnapshotInfo(localDeviceId_, TASK_ID, byteStream, BYTESTREAM_LENGTH);
2290 EXPECT_EQ(ret, ERR_NONE);
2291 ret = DistributedSchedMissionManager::GetInstance().RemoveSnapshotInfo(localDeviceId_, TASK_ID);
2292 EXPECT_EQ(ret, ERR_NONE);
2293 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Stop();
2294 DTEST_LOG << "testStoreSnapshotInfo003 end" << std::endl;
2295 }
2296
2297 /**
2298 * @tc.name: testRemoveSnapshotInfo003
2299 * @tc.desc: test remove snapshot info
2300 * @tc.type: FUNC
2301 */
2302 HWTEST_F(DMSMissionManagerTest, testRemoveSnapshotInfo003, TestSize.Level3)
2303 {
2304 DTEST_LOG << "testRemoveSnapshotInfo003 begin" << std::endl;
2305 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2306 std::make_shared<DistributedDataStorage>();
2307 auto ret = DistributedSchedMissionManager::GetInstance().RemoveSnapshotInfo(DEVICE_ID, 0);
2308 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
2309 DTEST_LOG << "testRemoveSnapshotInfo003 end" << std::endl;
2310 }
2311
2312 /**
2313 * @tc.name: testGetRemoteMissionSnapshotInfo002
2314 * @tc.desc: test get remote mission snapshot info
2315 * @tc.type: FUNC
2316 */
2317 HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionSnapshotInfo002, TestSize.Level3)
2318 {
2319 DTEST_LOG << "testGetRemoteMissionSnapshotInfo002 begin" << std::endl;
2320 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
2321 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ = nullptr;
2322 std::string uuid = "uuid for GetUuidByNetworkId";
2323 {
2324 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2325 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
2326 }
2327 auto ret = DistributedSchedMissionManager::GetInstance().GetRemoteMissionSnapshotInfo(localDeviceId_,
2328 0, missionSnapshot);
2329 EXPECT_EQ(ret, ERR_NULL_OBJECT);
2330 DTEST_LOG << "testGetRemoteMissionSnapshotInfo002 end" << std::endl;
2331 }
2332
2333 /**
2334 * @tc.name: testGetRemoteMissionSnapshotInfo004
2335 * @tc.desc: test get remote mission snapshot info
2336 * @tc.type: FUNC
2337 */
2338 HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionSnapshotInfo004, TestSize.Level3)
2339 {
2340 DTEST_LOG << "testGetRemoteMissionSnapshotInfo004 begin" << std::endl;
2341 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
2342 std::string uuid = "uuid for GetUuidByNetworkId";
2343 {
2344 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2345 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
2346 }
2347 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2348 std::make_shared<DistributedDataStorage>();
2349 auto ret = DistributedSchedMissionManager::GetInstance().GetRemoteMissionSnapshotInfo(localDeviceId_,
2350 TASK_ID, missionSnapshot);
2351 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
2352 DTEST_LOG << "testGetRemoteMissionSnapshotInfo004 end" << std::endl;
2353 }
2354
2355 /**
2356 * @tc.name: testGetRemoteMissionSnapshotInfo005
2357 * @tc.desc: test get remote mission snapshot info
2358 * @tc.type: FUNC
2359 */
2360 HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionSnapshotInfo005, TestSize.Level3)
2361 {
2362 DTEST_LOG << "testGetRemoteMissionSnapshotInfo005 begin" << std::endl;
2363 unique_ptr<AAFwk::MissionSnapshot> missionSnapshot = nullptr;
2364 std::string uuid = "uuid for GetUuidByNetworkId";
2365 {
2366 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2367 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
2368 }
2369 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ =
2370 std::make_shared<DistributedDataStorage>();
2371 auto result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Init();
__anoneafaeaae0a02() 2372 auto initDoneTask = []() {
2373 std::lock_guard<std::mutex> autoLock(caseDoneLock_);
2374 isCaseDone_ = true;
2375 caseDoneCondition_.notify_all();
2376 };
2377 if (DistributedSchedMissionManager::GetInstance().distributedDataStorage_ != nullptr) {
2378 std::shared_ptr<AppExecFwk::EventHandler> dmsDataStorageHandler =
2379 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->dmsDataStorageHandler_;
2380 if (dmsDataStorageHandler != nullptr) {
2381 dmsDataStorageHandler->PostTask(initDoneTask);
2382 }
2383 }
2384 std::unique_lock<std::mutex> lock(caseDoneLock_);
2385 caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
__anoneafaeaae0b02() 2386 [&] () { return isCaseDone_; });
2387 EXPECT_TRUE(result);
2388 isCaseDone_ = false;
2389 uint8_t* byteStream = new uint8_t[BYTESTREAM_LENGTH];
2390 for (size_t i = 0; i < BYTESTREAM_LENGTH; ++i) {
2391 byteStream[i] = ONE_BYTE;
2392 }
2393 result = DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Insert(localDeviceId_,
2394 TASK_ID, byteStream, BYTESTREAM_LENGTH);
2395 EXPECT_TRUE(result);
2396 auto ret = DistributedSchedMissionManager::GetInstance().GetRemoteMissionSnapshotInfo(localDeviceId_,
2397 TASK_ID, missionSnapshot);
2398 EXPECT_EQ(ret, ERR_NULL_OBJECT);
2399 DistributedSchedMissionManager::GetInstance().distributedDataStorage_->Stop();
2400 DTEST_LOG << "testGetRemoteMissionSnapshotInfo005 end" << std::endl;
2401 }
2402
2403 /**
2404 * @tc.name: testDeviceOfflineNotify003
2405 * @tc.desc: test device offline notify
2406 * @tc.type: FUNC
2407 */
2408 HWTEST_F(DMSMissionManagerTest, testDeviceOfflineNotify003, TestSize.Level3)
2409 {
2410 DTEST_LOG << "testDeviceOfflineNotify003 begin" << std::endl;
2411 DistributedSchedMissionManager::GetInstance().Init();
2412 DistributedSchedMissionManager::GetInstance().DeviceOnlineNotify(DEVICE_ID);
2413 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2414 sptr<IDistributedSched> remoteDmsObj = iface_cast<IDistributedSched>(listener);
2415 {
2416 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2417 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
2418 }
2419 {
2420 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2421 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = remoteDmsObj;
2422 }
2423 DistributedSchedMissionManager::GetInstance().DeviceOfflineNotify(DEVICE_ID);
2424 DTEST_LOG << "testDeviceOfflineNotify003 end" << std::endl;
2425 }
2426
2427 /**
2428 * @tc.name: testStartSyncRemoteMissions015
2429 * @tc.desc: prepare and sync missions from remote
2430 * @tc.type: FUNC
2431 */
2432 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions015, TestSize.Level3)
2433 {
2434 DTEST_LOG << "testStartSyncRemoteMissions015 begin" << std::endl;
2435 u16string deviceId = Str8ToStr16(DEVICE_ID);
2436 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2437 {
2438 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2439 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2440 }
2441 {
2442 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2443 ListenerInfo listenerInfo;
2444 listenerInfo.Emplace(listener);
2445 listenerInfo.called = true;
2446 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2447 }
2448 sptr<IDistributedSched> proxy = GetDms();
2449 if (proxy == nullptr) {
2450 return;
2451 }
2452 {
2453 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2454 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
2455 }
2456 {
2457 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2458 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
2459 }
2460 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, localDeviceId_);
2461 EXPECT_EQ(ret, ERR_NONE);
2462 DTEST_LOG << "testStartSyncRemoteMissions015 end" << std::endl;
2463 }
2464
2465 /**
2466 * @tc.name: testStartSyncRemoteMissions016
2467 * @tc.desc: prepare and sync missions from remote
2468 * @tc.type: FUNC
2469 */
2470 HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions016, TestSize.Level3)
2471 {
2472 DTEST_LOG << "testStartSyncRemoteMissions016 begin" << std::endl;
2473 u16string deviceId = Str8ToStr16(DEVICE_ID);
2474 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2475 {
2476 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2477 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2478 }
2479 {
2480 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2481 ListenerInfo listenerInfo;
2482 listenerInfo.Emplace(listener);
2483 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2484 }
2485 sptr<IDistributedSched> proxy = GetDms();
2486 if (proxy == nullptr) {
2487 return;
2488 }
2489 {
2490 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2491 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
2492 }
2493 {
2494 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2495 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
2496 }
2497 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, localDeviceId_);
2498 EXPECT_NE(ret, ERR_NONE);
2499 DTEST_LOG << "testStartSyncRemoteMissions016 end" << std::endl;
2500 }
2501
2502 /**
2503 * @tc.name: testUnRegisterMissionListener006
2504 * @tc.desc: register mission listener
2505 * @tc.type: FUNC
2506 */
2507 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener006, TestSize.Level3)
2508 {
2509 DTEST_LOG << "testUnRegisterMissionListener006 begin" << std::endl;
2510 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2511 {
2512 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2513 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2514 }
2515 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(U16DEVICE_ID, listener);
2516 EXPECT_EQ(ret, ERR_NONE);
2517 DTEST_LOG << "testUnRegisterMissionListener006 end" << std::endl;
2518 }
2519
2520 /**
2521 * @tc.name: testUnRegisterMissionListener007
2522 * @tc.desc: register mission listener
2523 * @tc.type: FUNC
2524 */
2525 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener007, TestSize.Level3)
2526 {
2527 DTEST_LOG << "testUnRegisterMissionListener007 begin" << std::endl;
2528 u16string deviceId = Str8ToStr16(DEVICE_ID);
2529 {
2530 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2531 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2532 }
2533 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2534 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, listener);
2535 EXPECT_EQ(ret, ERR_NONE);
2536 DTEST_LOG << "testUnRegisterMissionListener007 end" << std::endl;
2537 }
2538
2539 /**
2540 * @tc.name: testUnRegisterMissionListener008
2541 * @tc.desc: register mission listener
2542 * @tc.type: FUNC
2543 */
2544 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener008, TestSize.Level3)
2545 {
2546 DTEST_LOG << "testUnRegisterMissionListener008 begin" << std::endl;
2547 u16string deviceId = Str8ToStr16(DEVICE_ID);
2548 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2549 {
2550 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2551 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2552 }
2553 {
2554 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2555 ListenerInfo listenerInfo;
2556 listenerInfo.Emplace(listener);
2557 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2558 }
2559 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, listener);
2560 EXPECT_EQ(ret, ERR_NONE);
2561 DTEST_LOG << "testUnRegisterMissionListener008 end" << std::endl;
2562 }
2563
2564 /**
2565 * @tc.name: testUnRegisterMissionListener009
2566 * @tc.desc: register mission listener
2567 * @tc.type: FUNC
2568 */
2569 HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener009, TestSize.Level3)
2570 {
2571 DTEST_LOG << "testUnRegisterMissionListener009 begin" << std::endl;
2572 u16string deviceId = Str8ToStr16(DEVICE_ID);
2573 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2574 sptr<IRemoteObject> nullListener = nullptr;
2575 {
2576 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2577 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2578 }
2579 {
2580 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2581 ListenerInfo listenerInfo;
2582 listenerInfo.Emplace(listener);
2583 listenerInfo.Emplace(nullListener);
2584 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2585 }
2586 auto ret = DistributedSchedMissionManager::GetInstance().UnRegisterMissionListener(deviceId, listener);
2587 EXPECT_EQ(ret, ERR_NONE);
2588 DTEST_LOG << "testUnRegisterMissionListener009 end" << std::endl;
2589 }
2590
2591 /**
2592 * @tc.name: testCleanMissionResources002
2593 * @tc.desc: prepare and sync missions from remote
2594 * @tc.type: FUNC
2595 */
2596 HWTEST_F(DMSMissionManagerTest, testCleanMissionResources002, TestSize.Level3)
2597 {
2598 DTEST_LOG << "testCleanMissionResources002 begin" << std::endl;
2599 u16string deviceId = Str8ToStr16(DEVICE_ID);
2600 sptr<IRemoteObject> nullListener = nullptr;
2601 {
2602 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2603 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2604 }
2605 {
2606 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2607 ListenerInfo listenerInfo;
2608 listenerInfo.Emplace(nullListener);
2609 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2610 }
2611 DistributedSchedMissionManager::GetInstance().CleanMissionResources(DEVICE_ID);
2612 DTEST_LOG << "testCleanMissionResources002 end" << std::endl;
2613 }
2614
2615 /**
2616 * @tc.name: testStopSyncRemoteMissions013
2617 * @tc.desc: stop sync missions from remote with deviceId
2618 * @tc.type: FUNC
2619 */
2620 HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions013, TestSize.Level3)
2621 {
2622 DTEST_LOG << "testStopSyncRemoteMissions013 begin" << std::endl;
2623 sptr<IDistributedSched> proxy = GetDms();
2624 if (proxy == nullptr) {
2625 return;
2626 }
2627 {
2628 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2629 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
2630 }
2631 {
2632 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
2633 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
2634 }
2635 auto ret = DistributedSchedMissionManager::GetInstance().StopSyncRemoteMissions(DEVICE_ID, false, false);
2636 EXPECT_NE(ret, ERR_NONE);
2637 DTEST_LOG << "testStopSyncRemoteMissions013 end" << std::endl;
2638 }
2639
2640 /**
2641 * @tc.name: testStartSyncMissionsFromRemote002
2642 * @tc.desc: prepare and sync missions from remote
2643 * @tc.type: FUNC
2644 */
2645 HWTEST_F(DMSMissionManagerTest, testStartSyncMissionsFromRemote002, TestSize.Level3)
2646 {
2647 DTEST_LOG << "testStartSyncMissionsFromRemote002 begin" << std::endl;
2648 std::vector<DstbMissionInfo> missionInfos;
2649 CallerInfo callerInfo;
2650 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
2651 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
2652 DistributedSchedMissionManager::GetInstance().missonChangeListener_ = new DistributedMissionChangeListener();
2653 DistributedSchedMissionManager::GetInstance().GenerateCallerInfo(callerInfo);
2654 DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = true;
2655 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncMissionsFromRemote(callerInfo, missionInfos);
2656 EXPECT_EQ(ret, ERR_NONE);
2657 DTEST_LOG << "testStartSyncMissionsFromRemote002 end" << std::endl;
2658 }
2659
2660 /**
2661 * @tc.name: testStartSyncMissionsFromRemote003
2662 * @tc.desc: prepare and sync missions from remote
2663 * @tc.type: FUNC
2664 */
2665 HWTEST_F(DMSMissionManagerTest, testStartSyncMissionsFromRemote003, TestSize.Level3)
2666 {
2667 DTEST_LOG << "testStartSyncMissionsFromRemote003 begin" << std::endl;
2668 std::vector<DstbMissionInfo> missionInfos;
2669 CallerInfo callerInfo;
2670 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
2671 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
2672 DistributedSchedMissionManager::GetInstance().missonChangeListener_ = nullptr;
2673 DistributedSchedMissionManager::GetInstance().GenerateCallerInfo(callerInfo);
2674 DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = false;
2675 auto ret = DistributedSchedMissionManager::GetInstance().StartSyncMissionsFromRemote(callerInfo, missionInfos);
2676 EXPECT_EQ(ret, ERR_NONE);
2677 DTEST_LOG << "testStartSyncMissionsFromRemote003 end" << std::endl;
2678 }
2679
2680 /**
2681 * @tc.name: testStopSyncMissionsFromRemote003
2682 * @tc.desc: stop sync missions from remote
2683 * @tc.type: FUNC
2684 */
2685 HWTEST_F(DMSMissionManagerTest, testStopSyncMissionsFromRemote003, TestSize.Level3)
2686 {
2687 DTEST_LOG << "testStopSyncMissionsFromRemote003 begin" << std::endl;
2688 std::vector<DstbMissionInfo> missionInfos;
2689 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
2690 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
2691 DistributedSchedMissionManager::GetInstance().missonChangeListener_ = nullptr;
2692 DistributedSchedMissionManager::GetInstance().StopSyncMissionsFromRemote(DEVICE_ID);
2693 DTEST_LOG << "testStopSyncMissionsFromRemote003 end" << std::endl;
2694 }
2695
2696 /**
2697 * @tc.name: testNeedSyncDevice003
2698 * @tc.desc: need sync device
2699 * @tc.type: FUNC
2700 */
2701 HWTEST_F(DMSMissionManagerTest, testNeedSyncDevice003, TestSize.Level3)
2702 {
2703 DTEST_LOG << "testNeedSyncDevice003 begin" << std::endl;
2704 {
2705 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteSyncDeviceLock_);
2706 DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.clear();
2707 }
2708 {
2709 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteSyncDeviceLock_);
2710 DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.emplace(DEVICE_ID);
2711 }
2712 bool ret = DistributedSchedMissionManager::GetInstance().NeedSyncDevice(DEVICE_ID);
2713 EXPECT_TRUE(ret);
2714 DTEST_LOG << "testNeedSyncDevice003 end" << std::endl;
2715 }
2716
2717 /**
2718 * @tc.name: testHasSyncListener002
2719 * @tc.desc: need sync device
2720 * @tc.type: FUNC
2721 */
2722 HWTEST_F(DMSMissionManagerTest, testHasSyncListener002, TestSize.Level3)
2723 {
2724 DTEST_LOG << "testHasSyncListener002 begin" << std::endl;
2725 u16string deviceId = Str8ToStr16(DEVICE_ID);
2726 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2727 {
2728 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2729 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2730 }
2731 {
2732 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2733 ListenerInfo listenerInfo;
2734 listenerInfo.Emplace(listener);
2735 listenerInfo.called = true;
2736 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2737 }
2738 bool ret = DistributedSchedMissionManager::GetInstance().HasSyncListener(DEVICE_ID);
2739 EXPECT_TRUE(ret);
2740 DTEST_LOG << "testHasSyncListener002 end" << std::endl;
2741 }
2742
2743 /**
2744 * @tc.name: testNotifySnapshotChanged002
2745 * @tc.desc: test notify snapshot changed
2746 * @tc.type: FUNC
2747 */
2748 HWTEST_F(DMSMissionManagerTest, testNotifySnapshotChanged002, TestSize.Level3)
2749 {
2750 DTEST_LOG << "testNotifySnapshotChanged002 begin" << std::endl;
2751 u16string deviceId = Str8ToStr16(DEVICE_ID);
2752 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2753 {
2754 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2755 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2756 }
2757 {
2758 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2759 ListenerInfo listenerInfo;
2760 listenerInfo.called = false;
2761 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2762 }
2763 DistributedSchedMissionManager::GetInstance().NotifySnapshotChanged(DEVICE_ID, 0);
2764 DTEST_LOG << "testNotifySnapshotChanged002 end" << std::endl;
2765 }
2766
2767 /**
2768 * @tc.name: testNotifySnapshotChanged003
2769 * @tc.desc: test notify snapshot changed
2770 * @tc.type: FUNC
2771 */
2772 HWTEST_F(DMSMissionManagerTest, testNotifySnapshotChanged003, TestSize.Level3)
2773 {
2774 DTEST_LOG << "testNotifySnapshotChanged003 begin" << std::endl;
2775 u16string deviceId = Str8ToStr16(DEVICE_ID);
2776 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2777 {
2778 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2779 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2780 }
2781 {
2782 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2783 ListenerInfo listenerInfo;
2784 listenerInfo.Emplace(listener);
2785 listenerInfo.called = true;
2786 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2787 }
2788 DistributedSchedMissionManager::GetInstance().NotifySnapshotChanged(DEVICE_ID, 0);
2789 DTEST_LOG << "testNotifySnapshotChanged003 end" << std::endl;
2790 }
2791
2792 /**
2793 * @tc.name: testOnRemoteDied003
2794 * @tc.desc: test on remote died
2795 * @tc.type: FUNC
2796 */
2797 HWTEST_F(DMSMissionManagerTest, testOnRemoteDied003, TestSize.Level3)
2798 {
2799 DTEST_LOG << "testOnRemoteDied003 begin" << std::endl;
2800 wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
2801 DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
2802 DistributedSchedMissionManager::GetInstance().OnRemoteDied(remote);
2803 DTEST_LOG << "testOnRemoteDied003 end" << std::endl;
2804 }
2805
2806 /**
2807 * @tc.name: testDequeueCachedSnapshotInfo003
2808 * @tc.desc: enqueue cached snapshot info
2809 * @tc.type: FUNC
2810 */
2811 HWTEST_F(DMSMissionManagerTest, testDequeueCachedSnapshotInfo003, TestSize.Level3)
2812 {
2813 DTEST_LOG << "testDequeueCachedSnapshotInfo003 begin" << std::endl;
2814 std::unique_ptr<Snapshot> snapshot = make_unique<Snapshot>();
2815 std::string key = DistributedSchedMissionManager::GetInstance().GenerateKeyInfo(DEVICE_ID, 1);
2816 {
2817 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2818 DistributedSchedMissionManager::GetInstance().cachedSnapshotInfos_.clear();
2819 }
2820 {
2821 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2822 DistributedSchedMissionManager::GetInstance().cachedSnapshotInfos_[key] = std::move(snapshot);
2823 }
2824 auto ret = DistributedSchedMissionManager::GetInstance().DequeueCachedSnapshotInfo(DEVICE_ID, 1);
2825 EXPECT_NE(ret, nullptr);
2826 DTEST_LOG << "testDequeueCachedSnapshotInfo003 end" << std::endl;
2827 }
2828
2829 /**
2830 * @tc.name: testDeleteCachedSnapshotInfo001
2831 * @tc.desc: delete cached snapshot info
2832 * @tc.type: FUNC
2833 */
2834 HWTEST_F(DMSMissionManagerTest, testDeleteCachedSnapshotInfo001, TestSize.Level3)
2835 {
2836 DTEST_LOG << "testDeleteCachedSnapshotInfo001 begin" << std::endl;
2837 std::string uuid = "uuid for GetUuidByNetworkId";
2838 {
2839 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2840 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
2841 }
2842 {
2843 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2844 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
2845 }
2846 std::unique_ptr<Snapshot> snapshot = make_unique<Snapshot>();
2847 std::string key = DistributedSchedMissionManager::GetInstance().GenerateKeyInfo(DEVICE_ID, 1);
2848 {
2849 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2850 DistributedSchedMissionManager::GetInstance().cachedSnapshotInfos_.clear();
2851 }
2852 {
2853 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2854 DistributedSchedMissionManager::GetInstance().cachedSnapshotInfos_[key] = std::move(snapshot);
2855 }
2856 DistributedSchedMissionManager::GetInstance().DeleteCachedSnapshotInfo(DEVICE_ID);
2857 DTEST_LOG << "testDeleteCachedSnapshotInfo001 end" << std::endl;
2858 }
2859
2860 /**
2861 * @tc.name: testDeleteCachedSnapshotInfo002
2862 * @tc.desc: delete cached snapshot info
2863 * @tc.type: FUNC
2864 */
2865 HWTEST_F(DMSMissionManagerTest, testDeleteCachedSnapshotInfo002, TestSize.Level3)
2866 {
2867 DTEST_LOG << "testDeleteCachedSnapshotInfo002 begin" << std::endl;
2868 std::string uuid = "uuid for GetUuidByNetworkId";
2869 {
2870 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2871 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
2872 }
2873 {
2874 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2875 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
2876 }
2877 std::unique_ptr<Snapshot> snapshot = make_unique<Snapshot>();
2878 {
2879 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2880 DistributedSchedMissionManager::GetInstance().cachedSnapshotInfos_.clear();
2881 }
2882 {
2883 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2884 DistributedSchedMissionManager::GetInstance().cachedSnapshotInfos_[uuid] = std::move(snapshot);
2885 }
2886 DistributedSchedMissionManager::GetInstance().DeleteCachedSnapshotInfo(DEVICE_ID);
2887 DTEST_LOG << "testDeleteCachedSnapshotInfo002 end" << std::endl;
2888 }
2889
2890 /**
2891 * @tc.name: testFetchCachedRemoteMissions010
2892 * @tc.desc: test FetchCachedRemoteMissions
2893 * @tc.type: FUNC
2894 */
2895 HWTEST_F(DMSMissionManagerTest, testFetchCachedRemoteMissions010, TestSize.Level3)
2896 {
2897 DTEST_LOG << "testFetchCachedRemoteMissions010 begin" << std::endl;
2898 std::string uuid = "uuid for GetUuidByNetworkId";
2899 {
2900 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2901 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
2902 }
2903 {
2904 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2905 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
2906 }
2907 {
2908 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteMissionInfosLock_);
2909 DistributedSchedMissionManager::GetInstance().deviceMissionInfos_.clear();
2910 }
2911 std::vector<DstbMissionInfo> dstbMissionInfos;
2912 {
2913 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteMissionInfosLock_);
2914 DistributedSchedMissionManager::GetInstance().deviceMissionInfos_[uuid] = dstbMissionInfos;
2915 }
2916 auto ret = DistributedSchedMissionManager::GetInstance().FetchCachedRemoteMissions(DEVICE_ID,
2917 0, dstbMissionInfos);
2918 EXPECT_EQ(ret, ERR_NONE);
2919 DTEST_LOG << "testFetchCachedRemoteMissions010 end" << std::endl;
2920 }
2921
2922 /**
2923 * @tc.name: testRebornMissionCache003
2924 * @tc.desc: reborn mission cache
2925 * @tc.type: FUNC
2926 */
2927 HWTEST_F(DMSMissionManagerTest, testRebornMissionCache003, TestSize.Level3)
2928 {
2929 DTEST_LOG << "testRebornMissionCache003 begin" << std::endl;
2930 std::string uuid = "uuid for GetUuidByNetworkId";
2931 {
2932 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2933 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
2934 }
2935 {
2936 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
2937 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
2938 }
2939 std::vector<DstbMissionInfo> missionInfos;
2940 DistributedSchedMissionManager::GetInstance().RebornMissionCache(DEVICE_ID, missionInfos);
2941 DTEST_LOG << "testRebornMissionCache003 end" << std::endl;
2942 }
2943
2944 /**
2945 * @tc.name: testNotifyMissionsChangedFromRemote003
2946 * @tc.desc: notify missions changed from remote
2947 * @tc.type: FUNC
2948 */
2949 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedFromRemote003, TestSize.Level3)
2950 {
2951 DTEST_LOG << "testNotifyMissionsChangedFromRemote003 begin" << std::endl;
2952 CallerInfo callerInfo;
2953 callerInfo.sourceDeviceId = DEVICE_ID;
2954 callerInfo.uid = 0;
2955 callerInfo.pid = 0;
2956 callerInfo.dmsVersion = 0;
2957 std::vector<DstbMissionInfo> missionInfos;
2958 u16string deviceId = Str8ToStr16(DEVICE_ID);
2959 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
2960 {
2961 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2962 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
2963 }
2964 {
2965 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
2966 ListenerInfo listenerInfo;
2967 listenerInfo.Emplace(listener);
2968 listenerInfo.called = true;
2969 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
2970 }
2971 DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
2972 auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedFromRemote(callerInfo, missionInfos);
2973 EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
2974 DTEST_LOG << "testNotifyMissionsChangedFromRemote003 end" << std::endl;
2975 }
2976
2977 /**
2978 * @tc.name: testNotifyMissionSnapshotCreated002
2979 * @tc.desc: notify mission snapshot created
2980 * @tc.type: FUNC
2981 */
2982 HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotCreated002, TestSize.Level3)
2983 {
2984 DTEST_LOG << "testNotifyMissionSnapshotCreated002 begin" << std::endl;
2985 auto missionChangeRunner = AppExecFwk::EventRunner::Create("DistributedMissionChange");
2986 DistributedSchedMissionManager::GetInstance().missionChangeHandler_ =
2987 std::make_shared<AppExecFwk::EventHandler>(missionChangeRunner);
2988 DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
2989 DTEST_LOG << "testNotifyMissionSnapshotCreated002 end" << std::endl;
2990 }
2991
2992 /**
2993 * @tc.name: testNotifyMissionSnapshotCreated003
2994 * @tc.desc: notify mission snapshot created
2995 * @tc.type: FUNC
2996 */
2997 HWTEST_F(DMSMissionManagerTest, testNotifyMissionSnapshotCreated003, TestSize.Level3)
2998 {
2999 DTEST_LOG << "testNotifyMissionSnapshotCreated003 begin" << std::endl;
3000 auto missionChangeRunner = AppExecFwk::EventRunner::Create("DistributedMissionChange");
3001 DistributedSchedMissionManager::GetInstance().missionChangeHandler_ =
3002 std::make_shared<AppExecFwk::EventHandler>(missionChangeRunner);
3003 DistributedSchedMissionManager::GetInstance().distributedDataStorage_ = nullptr;
3004 DistributedSchedMissionManager::GetInstance().NotifyMissionSnapshotCreated(1);
3005 DTEST_LOG << "testNotifyMissionSnapshotCreated003 end" << std::endl;
3006 }
3007
3008 /**
3009 * @tc.name: testNotifyMissionsChangedToRemote002
3010 * @tc.desc: notify missions changed to remote
3011 * @tc.type: FUNC
3012 */
3013 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemote002, TestSize.Level3)
3014 {
3015 DTEST_LOG << "testNotifyMissionsChangedToRemote002 begin" << std::endl;
3016 {
3017 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteSyncDeviceLock_);
3018 DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.clear();
3019 }
3020 std::vector<DstbMissionInfo> missionInfos;
3021 auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemote(missionInfos);
3022 EXPECT_EQ(ret, ERR_NONE);
3023 DTEST_LOG << "testNotifyMissionsChangedToRemote002 end" << std::endl;
3024 }
3025
3026 /**
3027 * @tc.name: testNotifyMissionsChangedToRemote003
3028 * @tc.desc: notify missions changed to remote
3029 * @tc.type: FUNC
3030 */
3031 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemote003, TestSize.Level3)
3032 {
3033 DTEST_LOG << "testNotifyMissionsChangedToRemote003 begin" << std::endl;
3034 {
3035 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteSyncDeviceLock_);
3036 DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.clear();
3037 }
3038 {
3039 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteSyncDeviceLock_);
3040 DistributedSchedMissionManager::GetInstance().remoteSyncDeviceSet_.emplace(localDeviceId_);
3041 }
3042 {
3043 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3044 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
3045 }
3046 int32_t deviceType = 0;
3047 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, localDeviceId_);
3048 {
3049 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3050 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[localDeviceId_] = dmsDeviceInfo;
3051 }
3052 std::string uuid = "uuid for GetUuidByNetworkId";
3053 {
3054 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
3055 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
3056 }
3057 {
3058 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
3059 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = localDeviceId_;
3060 }
3061 std::vector<DstbMissionInfo> missionInfos;
3062 auto ret = DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemote(missionInfos);
3063 EXPECT_EQ(ret, ERR_NONE);
3064 DTEST_LOG << "testNotifyMissionsChangedToRemote003 end" << std::endl;
3065 }
3066
3067 /**
3068 * @tc.name: testNotifyMissionsChangedToRemoteInner003
3069 * @tc.desc: notify missions changed to remote inner
3070 * @tc.type: FUNC
3071 */
3072 HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner003, TestSize.Level3)
3073 {
3074 DTEST_LOG << "testNotifyMissionsChangedToRemoteInner003 begin" << std::endl;
3075 sptr<IDistributedSched> proxy = GetDms();
3076 if (proxy == nullptr) {
3077 return;
3078 }
3079 {
3080 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3081 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
3082 }
3083 {
3084 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3085 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
3086 }
3087 CallerInfo callerInfo;
3088 std::vector<DstbMissionInfo> missionInfos;
3089 DistributedSchedMissionManager::GetInstance().NotifyMissionsChangedToRemoteInner(
3090 DEVICE_ID, missionInfos, callerInfo);
3091 DTEST_LOG << "testNotifyMissionsChangedToRemoteInner003 end" << std::endl;
3092 }
3093
3094 /**
3095 * @tc.name: testFetchDeviceHandler003
3096 * @tc.desc: fetch device handler
3097 * @tc.type: FUNC
3098 */
3099 HWTEST_F(DMSMissionManagerTest, testFetchDeviceHandler003, TestSize.Level3)
3100 {
3101 DTEST_LOG << "testFetchDeviceHandler003 begin" << std::endl;
3102 {
3103 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3104 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
3105 }
3106
3107 int32_t deviceType = 0;
3108 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, DEVICE_ID);
3109 {
3110 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3111 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[DEVICE_ID] = dmsDeviceInfo;
3112 }
3113 auto ret = DistributedSchedMissionManager::GetInstance().FetchDeviceHandler(DEVICE_ID);
3114 EXPECT_EQ(ret, nullptr);
3115 DTEST_LOG << "testFetchDeviceHandler003 end" << std::endl;
3116 }
3117
3118 /**
3119 * @tc.name: testFetchDeviceHandler004
3120 * @tc.desc: fetch device handler
3121 * @tc.type: FUNC
3122 */
3123 HWTEST_F(DMSMissionManagerTest, testFetchDeviceHandler004, TestSize.Level3)
3124 {
3125 DTEST_LOG << "testFetchDeviceHandler004 begin" << std::endl;
3126 {
3127 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3128 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
3129 }
3130 int32_t deviceType = 0;
3131 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, DEVICE_ID);
3132 {
3133 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3134 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[DEVICE_ID] = dmsDeviceInfo;
3135 }
3136
3137 std::string uuid = "uuid for GetUuidByNetworkId";
3138 {
3139 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
3140 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
3141 }
3142 {
3143 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
3144 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
3145 }
3146 auto ret = DistributedSchedMissionManager::GetInstance().FetchDeviceHandler(DEVICE_ID);
3147 EXPECT_NE(ret, nullptr);
3148 DTEST_LOG << "testFetchDeviceHandler004 end" << std::endl;
3149 }
3150
3151 /**
3152 * @tc.name: testFetchDeviceHandler005
3153 * @tc.desc: fetch device handler
3154 * @tc.type: FUNC
3155 */
3156 HWTEST_F(DMSMissionManagerTest, testFetchDeviceHandler005, TestSize.Level3)
3157 {
3158 DTEST_LOG << "testFetchDeviceHandler005 begin" << std::endl;
3159 {
3160 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3161 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_.clear();
3162 }
3163 int32_t deviceType = 0;
3164 std::shared_ptr<DmsDeviceInfo> dmsDeviceInfo = make_shared<DmsDeviceInfo>(DEVICE_NAME, deviceType, DEVICE_ID);
3165 {
3166 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().deviceLock_);
3167 DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[DEVICE_ID] = dmsDeviceInfo;
3168 }
3169
3170 std::string uuid = "uuid for GetUuidByNetworkId";
3171 {
3172 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
3173 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_.clear();
3174 }
3175 {
3176 lock_guard<mutex> autoLock(DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdLock_);
3177 DtbschedmgrDeviceInfoStorage::GetInstance().uuidNetworkIdMap_[uuid] = DEVICE_ID;
3178 }
3179 auto anonyUuid = DnetworkAdapter::AnonymizeDeviceId(uuid);
3180 auto runner = AppExecFwk::EventRunner::Create(anonyUuid + "_MissionN");
3181 auto handler = std::make_shared<AppExecFwk::EventHandler>(runner);
3182 DistributedSchedMissionManager::GetInstance().deviceHandle_.emplace(uuid, handler);
3183 auto ret = DistributedSchedMissionManager::GetInstance().FetchDeviceHandler(DEVICE_ID);
3184 EXPECT_NE(ret, nullptr);
3185 DTEST_LOG << "testFetchDeviceHandler005 end" << std::endl;
3186 }
3187
3188 /**
3189 * @tc.name: testOnRemoteDmsDied009
3190 * @tc.desc: on remote dms died
3191 * @tc.type: FUNC
3192 */
3193 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied009, TestSize.Level3)
3194 {
3195 DTEST_LOG << "testOnRemoteDmsDied009 begin" << std::endl;
3196 wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
3197 DistributedSchedMissionManager::GetInstance().missionHandler_ = nullptr;
3198 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
3199 DTEST_LOG << "testOnRemoteDmsDied009 end" << std::endl;
3200 }
3201
3202 /**
3203 * @tc.name: testOnRemoteDmsDied005
3204 * @tc.desc: on remote dms died
3205 * @tc.type: FUNC
3206 */
3207 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied005, TestSize.Level3)
3208 {
3209 DTEST_LOG << "testOnRemoteDmsDied005 begin" << std::endl;
3210 wptr<IRemoteObject> remote = new RemoteMissionListenerTest();
3211 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3212 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3213 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
3214 DTEST_LOG << "testOnRemoteDmsDied005 end" << std::endl;
3215 }
3216
3217 /**
3218 * @tc.name: testRetryStartSyncRemoteMissions003
3219 * @tc.desc: retry start sync remote missions
3220 * @tc.type: FUNC
3221 */
3222 HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions003, TestSize.Level3)
3223 {
3224 DTEST_LOG << "testRetryStartSyncRemoteMissions003 begin" << std::endl;
3225 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3226 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3227 DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
3228 DTEST_LOG << "testRetryStartSyncRemoteMissions003 end" << std::endl;
3229 }
3230
3231 /**
3232 * @tc.name: testRetryStartSyncRemoteMissions004
3233 * @tc.desc: retry start sync remote missions
3234 * @tc.type: FUNC
3235 */
3236 HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions004, TestSize.Level3)
3237 {
3238 DTEST_LOG << "testRetryStartSyncRemoteMissions004 begin" << std::endl;
3239 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3240 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3241 u16string deviceId = Str8ToStr16(DEVICE_ID);
3242 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
3243 {
3244 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3245 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
3246 }
3247 {
3248 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3249 ListenerInfo listenerInfo;
3250 listenerInfo.Emplace(listener);
3251 listenerInfo.called = true;
3252 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
3253 }
3254 DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
3255 DTEST_LOG << "testRetryStartSyncRemoteMissions004 end" << std::endl;
3256 }
3257
3258 /**
3259 * @tc.name: testRetryStartSyncRemoteMissions005
3260 * @tc.desc: retry start sync remote missions
3261 * @tc.type: FUNC
3262 */
3263 HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions005, TestSize.Level3)
3264 {
3265 DTEST_LOG << "testRetryStartSyncRemoteMissions005 begin" << std::endl;
3266 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3267 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3268 u16string deviceId = Str8ToStr16(DEVICE_ID);
3269 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
3270 {
3271 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3272 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
3273 }
3274 {
3275 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3276 ListenerInfo listenerInfo;
3277 listenerInfo.Emplace(listener);
3278 listenerInfo.called = true;
3279 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
3280 }
3281 sptr<IDistributedSched> proxy = GetDms();
3282 if (proxy == nullptr) {
3283 return;
3284 }
3285 {
3286 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3287 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
3288 }
3289 {
3290 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3291 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
3292 }
3293 DistributedSchedMissionManager::GetInstance().RetryStartSyncRemoteMissions(DEVICE_ID, localDeviceId_, 1);
3294 DTEST_LOG << "testRetryStartSyncRemoteMissions005 end" << std::endl;
3295 }
3296
3297 /**
3298 * @tc.name: testOnMissionListenerDied003
3299 * @tc.desc: on mission listener died
3300 * @tc.type: FUNC
3301 */
3302 HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied003, TestSize.Level3)
3303 {
3304 DTEST_LOG << "testOnMissionListenerDied003 begin" << std::endl;
3305 u16string deviceId = Str8ToStr16(DEVICE_ID);
3306 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
3307 {
3308 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3309 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
3310 }
3311 {
3312 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3313 ListenerInfo listenerInfo;
3314 listenerInfo.Emplace(listener);
3315 listenerInfo.called = true;
3316 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
3317 }
3318 DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(listener);
3319 DTEST_LOG << "testOnMissionListenerDied003 end" << std::endl;
3320 }
3321
3322 /**
3323 * @tc.name: testOnMissionListenerDied004
3324 * @tc.desc: on mission listener died
3325 * @tc.type: FUNC
3326 */
3327 HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied004, TestSize.Level3)
3328 {
3329 DTEST_LOG << "testOnMissionListenerDied004 begin" << std::endl;
3330 u16string deviceId = Str8ToStr16(DEVICE_ID);
3331 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
3332 {
3333 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3334 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
3335 }
3336 sptr<IRemoteObject> remote = sptr<IRemoteObject>();
3337 {
3338 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3339 ListenerInfo listenerInfo;
3340 listenerInfo.Emplace(listener);
3341 listenerInfo.called = true;
3342 listenerInfo.Emplace(remote);
3343 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
3344 }
3345 DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(listener);
3346 DTEST_LOG << "testOnMissionListenerDied004 end" << std::endl;
3347 }
3348
3349 /**
3350 * @tc.name: testOnMissionListenerDied005
3351 * @tc.desc: on mission listener died
3352 * @tc.type: FUNC
3353 */
3354 HWTEST_F(DMSMissionManagerTest, testOnMissionListenerDied005, TestSize.Level3)
3355 {
3356 DTEST_LOG << "testOnMissionListenerDied005 begin" << std::endl;
3357 u16string deviceId = Str8ToStr16(DEVICE_ID);
3358 sptr<IRemoteObject> listener = new RemoteMissionListenerTest();
3359 {
3360 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3361 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
3362 }
3363 {
3364 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3365 ListenerInfo listenerInfo;
3366 listenerInfo.Emplace(listener);
3367 listenerInfo.called = false;
3368 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
3369 }
3370 DistributedSchedMissionManager::GetInstance().OnMissionListenerDied(listener);
3371 DTEST_LOG << "testOnMissionListenerDied005 end" << std::endl;
3372 }
3373
3374 /**
3375 * @tc.name: testOnRemoteDmsDied006
3376 * @tc.desc: on remote dms died
3377 * @tc.type: FUNC
3378 */
3379 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied006, TestSize.Level3)
3380 {
3381 DTEST_LOG << "testOnRemoteDmsDied006 begin" << std::endl;
3382 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3383 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3384 sptr<IRemoteObject> remote = new RemoteMissionListenerTest();
3385 sptr<IDistributedSched> remoteDmsObj = iface_cast<IDistributedSched>(remote);
3386 {
3387 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3388 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
3389 }
3390 {
3391 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3392 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = remoteDmsObj;
3393 }
3394 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
3395 DTEST_LOG << "testOnRemoteDmsDied006 end" << std::endl;
3396 }
3397
3398 /**
3399 * @tc.name: testOnRemoteDmsDied007
3400 * @tc.desc: on remote dms died
3401 * @tc.type: FUNC
3402 */
3403 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied007, TestSize.Level3)
3404 {
3405 DTEST_LOG << "testOnRemoteDmsDied007 begin" << std::endl;
3406 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3407 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3408 sptr<IRemoteObject> remote = new RemoteMissionListenerTest();
3409 sptr<IDistributedSched> proxy = GetDms();
3410 if (proxy == nullptr) {
3411 return;
3412 }
3413 {
3414 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3415 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
3416 }
3417 {
3418 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3419 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = proxy;
3420 }
3421 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
3422 DTEST_LOG << "testOnRemoteDmsDied007 end" << std::endl;
3423 }
3424
3425 /**
3426 * @tc.name: testOnRemoteDmsDied008
3427 * @tc.desc: on remote dms died
3428 * @tc.type: FUNC
3429 */
3430 HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied008, TestSize.Level3)
3431 {
3432 DTEST_LOG << "testOnRemoteDmsDied008 begin" << std::endl;
3433 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3434 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3435 sptr<IRemoteObject> remote = new RemoteMissionListenerTest();
3436 sptr<IDistributedSched> remoteDmsObj = iface_cast<IDistributedSched>(remote);
3437 {
3438 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3439 DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear();
3440 }
3441 {
3442 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_);
3443 DistributedSchedMissionManager::GetInstance().remoteDmsMap_[DEVICE_ID] = remoteDmsObj;
3444 }
3445 u16string deviceId = Str8ToStr16(DEVICE_ID);
3446 {
3447 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3448 DistributedSchedMissionManager::GetInstance().listenDeviceMap_.clear();
3449 }
3450 {
3451 std::lock_guard<std::mutex> autoLock(DistributedSchedMissionManager::GetInstance().listenDeviceLock_);
3452 ListenerInfo listenerInfo;
3453 listenerInfo.Emplace(remote);
3454 listenerInfo.called = true;
3455 DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo;
3456 }
3457 DistributedSchedMissionManager::GetInstance().OnRemoteDmsDied(remote);
3458 DTEST_LOG << "testOnRemoteDmsDied008 end" << std::endl;
3459 }
3460
3461 /**
3462 * @tc.name: testNotifyDmsProxyProcessDied002
3463 * @tc.desc: notify dms proxy process died
3464 * @tc.type: FUNC
3465 */
3466 HWTEST_F(DMSMissionManagerTest, testNotifyDmsProxyProcessDied002, TestSize.Level3)
3467 {
3468 DTEST_LOG << "testNotifyDmsProxyProcessDied002 begin" << std::endl;
3469 DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = false;
3470 DistributedSchedMissionManager::GetInstance().NotifyDmsProxyProcessDied();
3471 DTEST_LOG << "testNotifyDmsProxyProcessDied002 end" << std::endl;
3472 }
3473
3474 /**
3475 * @tc.name: testRetryRegisterMissionChange002
3476 * @tc.desc: retry register mission change
3477 * @tc.type: FUNC
3478 */
3479 HWTEST_F(DMSMissionManagerTest, testRetryRegisterMissionChange002, TestSize.Level3)
3480 {
3481 DTEST_LOG << "testRetryRegisterMissionChange002 begin" << std::endl;
3482 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3483 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3484 DistributedSchedMissionManager::GetInstance().RetryRegisterMissionChange(1);
3485 DTEST_LOG << "testRetryRegisterMissionChange002 end" << std::endl;
3486 }
3487
3488 /**
3489 * @tc.name: testOnDnetDied002
3490 * @tc.desc: on dnet died
3491 * @tc.type: FUNC
3492 */
3493 HWTEST_F(DMSMissionManagerTest, testOnDnetDied002, TestSize.Level3)
3494 {
3495 DTEST_LOG << "testOnDnetDied002 begin" << std::endl;
3496 auto runner = AppExecFwk::EventRunner::Create("MissionManagerHandler");
3497 DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
3498 DistributedSchedMissionManager::GetInstance().isRegMissionChange_ = false;
3499 DistributedSchedMissionManager::GetInstance().OnDnetDied();
3500 DTEST_LOG << "testOnDnetDied002 end" << std::endl;
3501 }
3502 } // namespace DistributedSchedule
3503 } // namespace OHOS