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