• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dsched_collab_manager_test.h"
17 
18 #include "dtbschedmgr_device_info_storage.h"
19 #include "distributed_sched_test_util.h"
20 #include "dtbcollabmgr_log.h"
21 #include "string_wrapper.h"
22 #include "test_log.h"
23 #include "mock_distributed_sched.h"
24 
25 using namespace testing;
26 using namespace testing::ext;
27 using namespace OHOS::DistributedHardware;
28 
29 namespace OHOS {
30 namespace DistributedSchedule {
31 
32 static bool g_mockDbs = false;
33 
34 namespace {
35     const std::string LOCAL_DEVICEID = "localdeviceid";
36     const std::string REMOTE_DEVICEID = "remotedeviceid";
37     const std::string CONTINUETYPE = "continueType";
38     const std::string BASEDIR = "/data/service/el1/public/database/DistributedSchedule";
39     constexpr int32_t MISSION_ID = 1;
40     constexpr size_t SIZE = 10;
41     const int32_t WAITTIME = 2000;
42     const std::string BUNDLE_NAME = "com.ohos.permissionmanager";
43 }
44 
GetDistributedBundleInfo(const std::string & networkId,const uint16_t & bundleNameId,DmsBundleInfo & distributeBundleInfo)45 bool DmsBmStorage::GetDistributedBundleInfo(const std::string &networkId,
46     const uint16_t &bundleNameId, DmsBundleInfo &distributeBundleInfo)
47 {
48     return g_mockDbs;
49 }
50 
SetUpTestCase()51 void DSchedCollabManagerTest::SetUpTestCase()
52 {
53     DTEST_LOG << "DSchedCollabManagerTest::SetUpTestCase" << std::endl;
54     mkdir(BASEDIR.c_str(), (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
55     DSchedCollabManager::GetInstance().Init();
56     dmsStoreMock = std::make_shared<MockDmsMgrDeviceInfoStore>();
57     MockDmsMgrDeviceInfoStore::dmsStore = dmsStoreMock;
58     multiUserMgrMock_ = std::make_shared<MultiUserManagerMock>();
59     MultiUserManagerMock::multiUserMgrMock = multiUserMgrMock_;
60 }
61 
TearDownTestCase()62 void DSchedCollabManagerTest::TearDownTestCase()
63 {
64     DTEST_LOG << "DSchedCollabManagerTest::TearDownTestCase" << std::endl;
65     (void)remove(BASEDIR.c_str());
66     MockDmsMgrDeviceInfoStore::dmsStore = nullptr;
67     dmsStoreMock = nullptr;
68     MultiUserManagerMock::multiUserMgrMock = nullptr;
69     multiUserMgrMock_ = nullptr;
70 }
71 
TearDown()72 void DSchedCollabManagerTest::TearDown()
73 {
74     DTEST_LOG << "DSchedCollabManagerTest::TearDown" << std::endl;
75     usleep(WAITTIME);
76     g_mockDbs = false;
77     DSchedCollabManager::GetInstance().collabs_.clear();
78 }
79 
SetUp()80 void DSchedCollabManagerTest::SetUp()
81 {
82     usleep(WAITTIME);
83     DSchedCollabManager::GetInstance().collabs_.clear();
84     DTEST_LOG << "DSchedCollabManagerTest::SetUp" << std::endl;
85 }
86 
OnRemoteDied()87 void DSchedCollabManagerTest::DeviceInitCallBack::OnRemoteDied()
88 {
89 }
90 
GetDSchedService() const91 sptr<IRemoteObject> DSchedCollabManagerTest::GetDSchedService() const
92 {
93     sptr<IRemoteObject> dsched(new MockDistributedSched());
94     return dsched;
95 }
96 
CreateObject()97 std::shared_ptr<DSchedCollab> DSchedCollabManagerTest::CreateObject()
98 {
99     const std::string collabToken = "";
100     DSchedCollabInfo info;
101     std::shared_ptr<DSchedCollab> dCollab = std::make_shared<DSchedCollab>(collabToken, info);
102     dCollab->Init();
103     return dCollab;
104 }
105 
106 /**
107  * @tc.name: Init_001
108  * @tc.desc: test Init func
109  * @tc.type: FUNC
110  */
111 HWTEST_F(DSchedCollabManagerTest, Init_001, TestSize.Level3)
112 {
113     DTEST_LOG << "DSchedCollabManagerTest Init_001 begin" << std::endl;
114     DSchedCollabManager::GetInstance().Init();
115     std::shared_ptr<OHOS::AppExecFwk::EventHandler> eventHandler =
116         DSchedCollabManager::GetInstance().eventHandler_;
117     EXPECT_NE(eventHandler, nullptr);
118     DTEST_LOG << "DSchedCollabManagerTest Init_001 end" << std::endl;
119 }
120 
121 /**
122  * @tc.name: CollabMission_001
123  * @tc.desc: test CollabMission func
124  * @tc.type: FUNC
125  */
126 HWTEST_F(DSchedCollabManagerTest, CollabMission_001, TestSize.Level3)
127 {
128     DTEST_LOG << "DSchedCollabManagerTest CollabMission_001 begin" << std::endl;
129     DSchedCollabInfo info;
130     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(false));
131     int32_t ret = DSchedCollabManager::GetInstance().CollabMission(info);
132     EXPECT_EQ(ret, DMS_NOT_FOREGROUND_USER);
133 
134     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
135     ret = DSchedCollabManager::GetInstance().CollabMission(info);
136     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
137     DTEST_LOG << "DSchedCollabManagerTest CollabMission_001 end" << std::endl;
138 }
139 
140 /**
141  * @tc.name: CollabMission_002
142  * @tc.desc: test CollabMission func
143  * @tc.type: FUNC
144  */
145 HWTEST_F(DSchedCollabManagerTest, CollabMission_002, TestSize.Level3)
146 {
147     DTEST_LOG << "DSchedCollabManagerTest CollabMission_002 begin" << std::endl;
148     DSchedCollabInfo info;
149     info.srcClientCB_ = sptr<DistributedSchedService>(new DistributedSchedService());
150     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
151     int32_t ret = DSchedCollabManager::GetInstance().CollabMission(info);
152     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
153 
154     info.srcInfo_.bundleName_ = "srcBundle";
155     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
156     ret = DSchedCollabManager::GetInstance().CollabMission(info);
157     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
158 
159     info.sinkInfo_.bundleName_ = "sinkBundle";
160     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
161     ret = DSchedCollabManager::GetInstance().CollabMission(info);
162     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
163 
164     info.srcInfo_.moduleName_ = "srcModule";
165     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
166     ret = DSchedCollabManager::GetInstance().CollabMission(info);
167     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
168 
169     info.sinkInfo_.moduleName_ = "sinkModule";
170     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
171     ret = DSchedCollabManager::GetInstance().CollabMission(info);
172     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
173 
174     info.srcInfo_.abilityName_ = "srcAbility";
175     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
176     ret = DSchedCollabManager::GetInstance().CollabMission(info);
177     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
178 
179     info.sinkInfo_.abilityName_ = "sinkAbility";
180     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
181     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(false));
182     ret = DSchedCollabManager::GetInstance().CollabMission(info);
183     EXPECT_EQ(ret, FIND_LOCAL_DEVICEID_ERR);
184     DTEST_LOG << "DSchedCollabManagerTest CollabMission_002 end" << std::endl;
185 }
186 
187 /**
188  * @tc.name: CollabMission_003
189  * @tc.desc: test CollabMission func
190  * @tc.type: FUNC
191  */
192 HWTEST_F(DSchedCollabManagerTest, CollabMission_003, TestSize.Level3)
193 {
194     DTEST_LOG << "DSchedCollabManagerTest CollabMission_003 begin" << std::endl;
195     DSchedCollabInfo info;
196     info.srcInfo_.bundleName_ = "srcBundle";
197     info.sinkInfo_.bundleName_ = "sinkBundle";
198     info.srcInfo_.moduleName_ = "srcModule";
199     info.sinkInfo_.moduleName_ = "sinkModule";
200     info.srcInfo_.abilityName_ = "srcAbility";
201     info.sinkInfo_.abilityName_ = "sinkAbility";
202     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
203     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
204     EXPECT_CALL(*dmsStoreMock, GetDeviceInfoById(_)).WillOnce(Return(nullptr));
205     int32_t ret = DSchedCollabManager::GetInstance().CollabMission(info);
206     EXPECT_EQ(ret, FIND_REMOTE_DEVICEID_ERR);
207 
208     std::shared_ptr<DmsDeviceInfo> ptr = std::make_shared<DmsDeviceInfo>("", 0, "");
209     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
210     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
211     EXPECT_CALL(*dmsStoreMock, GetDeviceInfoById(_)).WillOnce(Return(ptr));
212     ret = DSchedCollabManager::GetInstance().CollabMission(info);
213     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
214     DTEST_LOG << "DSchedCollabManagerTest CollabMission_003 end" << std::endl;
215 }
216 
217 /**
218  * @tc.name: CollabMission_004
219  * @tc.desc: test CollabMission func
220  * @tc.type: FUNC
221  */
222 HWTEST_F(DSchedCollabManagerTest, CollabMission_004, TestSize.Level3)
223 {
224     DTEST_LOG << "DSchedCollabManagerTest CollabMission_004 begin" << std::endl;
225     DSchedCollabInfo info;
226     info.srcInfo_.bundleName_ = "srcBundle";
227     info.sinkInfo_.bundleName_ = "sinkBundle";
228     info.srcInfo_.moduleName_ = "srcModule";
229     info.sinkInfo_.moduleName_ = "sinkModule";
230     info.srcInfo_.abilityName_ = "srcAbility";
231     info.sinkInfo_.abilityName_ = "sinkAbility";
232     info.srcOpt_.startParams_.SetParam(KEY_START_OPTION, AAFwk::String::Box(VALUE_START_OPTION_FOREGROUND));
233     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
234     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
235     EXPECT_CALL(*dmsStoreMock, GetDeviceInfoById(_)).WillOnce(Return(nullptr));
236     int32_t ret = DSchedCollabManager::GetInstance().CollabMission(info);
237     EXPECT_EQ(ret, FIND_REMOTE_DEVICEID_ERR);
238 
239     std::shared_ptr<DmsDeviceInfo> ptr = std::make_shared<DmsDeviceInfo>("", 0, "");
240     EXPECT_CALL(*multiUserMgrMock_, IsCallerForeground(_)).WillOnce(Return(true));
241     EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
242     EXPECT_CALL(*dmsStoreMock, GetDeviceInfoById(_)).WillOnce(Return(ptr));
243     ret = DSchedCollabManager::GetInstance().CollabMission(info);
244     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
245     DTEST_LOG << "DSchedCollabManagerTest CollabMission_004 end" << std::endl;
246 }
247 
248 /**
249  * @tc.name: SetTimeOut_001
250  * @tc.desc: test SetTimeOut func
251  * @tc.type: FUNC
252  */
253 HWTEST_F(DSchedCollabManagerTest, SetTimeOut_001, TestSize.Level3)
254 {
255     DTEST_LOG << "DSchedCollabManagerTest SetTimeOut_001 begin" << std::endl;
256     const std::string collabToken = "testToken";
257     int32_t timeout = 0;
258     DSchedCollabManager::GetInstance().collabs_.clear();
259     DSchedCollabManager::GetInstance().SetTimeOut(collabToken, timeout);
260     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
261     DTEST_LOG << "DSchedCollabManagerTest SetTimeOut_001 end" << std::endl;
262 }
263 
264 /**
265  * @tc.name: SetTimeOut_002
266  * @tc.desc: test SetTimeOut func
267  * @tc.type: FUNC
268  */
269 HWTEST_F(DSchedCollabManagerTest, SetTimeOut_002, TestSize.Level3)
270 {
271     DTEST_LOG << "DSchedCollabManagerTest SetTimeOut_002 begin" << std::endl;
272     const std::string collabToken = "testToken";
273     int32_t timeout = 10;
274     DSchedCollabManager::GetInstance().collabs_.clear();
275     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair(collabToken, nullptr));
276     DSchedCollabManager::GetInstance().SetTimeOut(collabToken, timeout);
277     EXPECT_NE(DSchedCollabManager::GetInstance().collabs_.empty(), true);
278     DSchedCollabManager::GetInstance().collabs_.clear();
279     DTEST_LOG << "DSchedCollabManagerTest SetTimeOut_002 end" << std::endl;
280 }
281 
282 /**
283  * @tc.name: SetTimeOut_003
284  * @tc.desc: test SetTimeOut func
285  * @tc.type: FUNC
286  */
287 HWTEST_F(DSchedCollabManagerTest, SetTimeOut_003, TestSize.Level3)
288 {
289     DTEST_LOG << "DSchedCollabManagerTest SetTimeOut_003 begin" << std::endl;
290     const std::string collabToken = "testToken";
291     int32_t timeout = 10;
292     DSchedCollabInfo info;
293     info.srcInfo_.pid_ = 100;
294     info.srcCollabSessionId_ = 1;
295     auto collab = std::make_shared<DSchedCollab>("test1", info);
296     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair(collabToken, collab));
297     DSchedCollabManager::GetInstance().SetTimeOut(collabToken, timeout);
298     EXPECT_NE(DSchedCollabManager::GetInstance().collabs_.empty(), true);
299     DTEST_LOG << "DSchedCollabManagerTest SetTimeOut_003 end" << std::endl;
300 }
301 
302 /**
303  * @tc.name: RemoveTimeout_001
304  * @tc.desc: test RemoveTimeout func
305  * @tc.type: FUNC
306  */
307 HWTEST_F(DSchedCollabManagerTest, RemoveTimeout_001, TestSize.Level3)
308 {
309     DTEST_LOG << "DSchedCollabManagerTest RemoveTimeout_001 begin" << std::endl;
310     const std::string collabToken = "testToken";
311     DSchedCollabManager::GetInstance().collabs_.clear();
312     DSchedCollabManager::GetInstance().RemoveTimeout(collabToken);
313     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
314     DTEST_LOG << "DSchedCollabManagerTest RemoveTimeout_001 end" << std::endl;
315 }
316 
317 /**
318  * @tc.name: NotifyStartAbilityResult_001
319  * @tc.desc: test NotifyStartAbilityResult func
320  * @tc.type: FUNC
321  */
322 HWTEST_F(DSchedCollabManagerTest, NotifyStartAbilityResult_001, TestSize.Level3)
323 {
324     DTEST_LOG << "DSchedCollabManagerTest NotifyStartAbilityResult_001 begin" << std::endl;
325     const std::string collabToken = "";
326     const int32_t result = 0;
327     const int32_t sinkPid = 0;
328     const int32_t sinkUid = 0;
329     const int32_t sinkAccessTokenId = 0;
330     int32_t ret1 = DSchedCollabManager::GetInstance().NotifyStartAbilityResult(collabToken, result,
331         sinkPid, sinkUid, sinkAccessTokenId);
332     EXPECT_EQ(ret1, INVALID_PARAMETERS_ERR);
333     DTEST_LOG << "DSchedCollabManagerTest NotifyStartAbilityResult_001 end" << std::endl;
334 }
335 
336 /**
337  * @tc.name: NotifySinkPrepareResult_001
338  * @tc.desc: test NotifySinkPrepareResult func
339  * @tc.type: FUNC
340  */
341 HWTEST_F(DSchedCollabManagerTest, NotifySinkPrepareResult_001, TestSize.Level3)
342 {
343     DTEST_LOG << "DSchedCollabManagerTest NotifySinkPrepareResult_001 begin" << std::endl;
344     const int32_t result = 0;
345     DSchedCollabInfo dSchedCollabInfo;
346     int32_t ret = DSchedCollabManager::GetInstance().NotifySinkPrepareResult(dSchedCollabInfo, result);
347     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
348     DTEST_LOG << "DSchedCollabManagerTest NotifySinkPrepareResult_001 end" << std::endl;
349 }
350 
351 /**
352  * @tc.name: NotifySinkRejectReason_001
353  * @tc.desc: test NotifySinkRejectReason func
354  * @tc.type: FUNC
355  */
356 HWTEST_F(DSchedCollabManagerTest, NotifySinkRejectReason_001, TestSize.Level3)
357 {
358     DTEST_LOG << "DSchedCollabManagerTest NotifySinkRejectReason_001 begin" << std::endl;
359     const std::string collabToken = "";
360     const std::string reason = "";
361     int32_t ret = DSchedCollabManager::GetInstance().NotifySinkRejectReason(collabToken, reason);
362     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
363     DTEST_LOG << "DSchedCollabManagerTest NotifySinkRejectReason_001 end" << std::endl;
364 }
365 
366 /**
367  * @tc.name: NotifyAbilityDied_002
368  * @tc.desc: test NotifyAbilityDied func
369  * @tc.type: FUNC
370  */
371 HWTEST_F(DSchedCollabManagerTest, NotifyAbilityDied_002, TestSize.Level3)
372 {
373     DTEST_LOG << "DSchedCollabManagerTest NotifyAbilityDied_002 begin" << std::endl;
374     const std::string bundleName = "";
375     const int32_t pid = 0;
376     int32_t ret = DSchedCollabManager::GetInstance().NotifyAbilityDied(bundleName, pid);
377     EXPECT_EQ(ret, ERR_OK);
378     DTEST_LOG << "DSchedCollabManagerTest NotifyAbilityDied_002 end" << std::endl;
379 }
380 
381 /**
382  * @tc.name: ReleaseAbilityLink_001
383  * @tc.desc: test ReleaseAbilityLink func
384  * @tc.type: FUNC
385  */
386 HWTEST_F(DSchedCollabManagerTest, ReleaseAbilityLink_001, TestSize.Level3)
387 {
388     DTEST_LOG << "DSchedCollabManagerTest ReleaseAbilityLink_001 begin" << std::endl;
389     const std::string bundleName = "";
390     const int32_t pid = 0;
391     DSchedCollabManager::GetInstance().collabs_.clear();
392     int32_t ret = DSchedCollabManager::GetInstance().ReleaseAbilityLink(bundleName, pid);
393     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
394     DTEST_LOG << "DSchedCollabManagerTest ReleaseAbilityLink_001 end" << std::endl;
395 }
396 
397 /**
398  * @tc.name: CancleReleaseAbilityLink_001
399  * @tc.desc: test CancleReleaseAbilityLink func
400  * @tc.type: FUNC
401  */
402 HWTEST_F(DSchedCollabManagerTest, CancleReleaseAbilityLink_001, TestSize.Level3)
403 {
404     DTEST_LOG << "DSchedCollabManagerTest CancleReleaseAbilityLink_001 begin" << std::endl;
405     const std::string bundleName = "";
406     const int32_t pid = 0;
407     int32_t ret = DSchedCollabManager::GetInstance().CancleReleaseAbilityLink(bundleName, pid);
408     EXPECT_EQ(ret, ERR_OK);
409     DTEST_LOG << "DSchedCollabManagerTest CancleReleaseAbilityLink_001 end" << std::endl;
410 }
411 
412 /**
413  * @tc.name: CleanUpSession_001
414  * @tc.desc: test CleanUpSession func
415  * @tc.type: FUNC
416  */
417 HWTEST_F(DSchedCollabManagerTest, CleanUpSession_001, TestSize.Level3)
418 {
419     DTEST_LOG << "DSchedCollabManagerTest CleanUpSession_001 begin" << std::endl;
420     const std::string collabToken = "";
421     int32_t ret = DSchedCollabManager::GetInstance().CleanUpSession(collabToken);
422     EXPECT_EQ(ret, ERR_OK);
423     DTEST_LOG << "DSchedCollabManagerTest CleanUpSession_001 end" << std::endl;
424 }
425 
426 /**
427  * @tc.name: GetDSchedCollabByTokenId_001
428  * @tc.desc: test GetDSchedCollabByTokenId func
429  * @tc.type: FUNC
430  */
431 HWTEST_F(DSchedCollabManagerTest, GetDSchedCollabByTokenId_001, TestSize.Level3)
432 {
433     DTEST_LOG << "DSchedCollabManagerTest GetDSchedCollabByTokenId_001 begin" << std::endl;
434     const std::string collabToken = "";
435     auto collab = DSchedCollabManager::GetInstance().GetDSchedCollabByTokenId(collabToken);
436     EXPECT_EQ(collab, nullptr);
437     DTEST_LOG << "DSchedCollabManagerTest GetDSchedCollabByTokenId_001 end" << std::endl;
438 }
439 
440 /**
441  * @tc.name: OnDataRecv_001
442  * @tc.desc: test OnDataRecv func
443  * @tc.type: FUNC
444  */
445 HWTEST_F(DSchedCollabManagerTest, OnDataRecv_001, TestSize.Level3)
446 {
447     DTEST_LOG << "DSchedCollabManagerTest OnDataRecv_001 begin" << std::endl;
448     const int32_t softbusSessionId = 0;
449     std::shared_ptr<DSchedDataBuffer> dataBuffer;
450     DSchedCollabManager::GetInstance().OnDataRecv(softbusSessionId, dataBuffer);
451     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
452     DTEST_LOG << "DSchedCollabManagerTest OnDataRecv_001 end" << std::endl;
453 }
454 
455 /**
456  * @tc.name: OnDataRecv_002
457  * @tc.desc: test OnDataRecv func
458  * @tc.type: FUNC
459  */
460 HWTEST_F(DSchedCollabManagerTest, OnDataRecv_002, TestSize.Level3)
461 {
462     DTEST_LOG << "DSchedCollabManagerTest OnDataRecv_002 begin" << std::endl;
463     int32_t softbusSessionId = 0;
464     size_t sizeL = 20;
465     std::shared_ptr<DSchedDataBuffer> dataBuffer = std::make_shared<DSchedDataBuffer>(sizeL);
466     DSchedCollabManager::GetInstance().OnDataRecv(softbusSessionId, dataBuffer);
467     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
468     DTEST_LOG << "DSchedCollabManagerTest OnDataRecv_002 end" << std::endl;
469 }
470 
471 /**
472  * @tc.name: OnShutdown_001
473  * @tc.desc: test OnShutdown func
474  * @tc.type: FUNC
475  */
476 HWTEST_F(DSchedCollabManagerTest, OnShutdown_001, TestSize.Level3)
477 {
478     DTEST_LOG << "DSchedCollabManagerTest OnShutdown_001 begin" << std::endl;
479     int32_t softbusSessionId = 0;
480     DSchedCollabManager::GetInstance().OnShutdown(softbusSessionId, true);
481     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
482     DSchedCollabManager::GetInstance().OnShutdown(softbusSessionId, false);
483     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
484     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test1", nullptr));
485     const std::string collabToken = "";
486     DSchedCollabInfo info;
487     auto newCollab = std::make_shared<DSchedCollab>(collabToken, info);
488     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test2", newCollab));
489     int32_t sessionId = 1;
490     auto dCollab = std::make_shared<DSchedCollab>(collabToken, info);
491     newCollab->softbusSessionId_ = softbusSessionId;
492     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test3", dCollab));
493     DSchedCollabManager::GetInstance().OnShutdown(softbusSessionId, false);
494     EXPECT_NE(DSchedCollabManager::GetInstance().collabs_.empty(), true);
495     DSchedCollabManager::GetInstance().collabs_.erase("test1");
496     DSchedCollabManager::GetInstance().collabs_.erase("test2");
497     DSchedCollabManager::GetInstance().collabs_.erase("test3");
498     EXPECT_EQ(DSchedCollabManager::GetInstance().collabs_.empty(), true);
499     DSchedCollabManager::GetInstance().collabs_.clear();
500     DTEST_LOG << "DSchedCollabManagerTest OnShutdown_001 end" << std::endl;
501 }
502 
503 /**
504  * @tc.name: CheckCollabRelation_001
505  * @tc.desc: test CheckCollabRelation func
506  * @tc.type: FUNC
507  */
508 HWTEST_F(DSchedCollabManagerTest, CheckCollabRelation_001, TestSize.Level3)
509 {
510     DTEST_LOG << "DSchedCollabManagerTest CheckCollabRelation_001 begin" << std::endl;
511     DSchedCollabManager::GetInstance().collabs_.clear();
512     CollabInfo sourceInfo{.deviceId = "srcUdid", .pid = 100, .tokenId = 100, .userId = 100};
513     CollabInfo sinkInfo{.deviceId = "sinkUdid", .pid = 200, .tokenId = 200, .userId = 101};
514     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
515 
516     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test1", nullptr));
517     const std::string collabToken = "";
518     DSchedCollabInfo info;
519     info.srcUdid_ = sourceInfo.deviceId;
520     info.sinkUdid_ = sinkInfo.deviceId;
521     info.sinkUserId_ = sinkInfo.userId;
522     info.srcInfo_.pid_ = sourceInfo.pid;
523     info.srcInfo_.accessToken_ = sourceInfo.tokenId;
524     info.sinkInfo_.pid_ = sinkInfo.pid;
525     info.sinkInfo_.accessToken_ = sinkInfo.tokenId;
526     info.srcAccountInfo_.userId = sourceInfo.userId;
527     auto newCollab = std::make_shared<DSchedCollab>(collabToken, info);
528     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test2", newCollab));
529     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), ERR_OK);
530 
531     sinkInfo.userId = info.sinkUserId_ + 1;
532     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
533     sinkInfo.userId = info.sinkUserId_;
534     sourceInfo.userId = info.srcAccountInfo_.userId + 1;
535     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
536     sourceInfo.userId = info.srcAccountInfo_.userId;
537     sinkInfo.tokenId = info.sinkInfo_.accessToken_ + 1;
538     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
539     sinkInfo.tokenId = info.sinkInfo_.accessToken_;
540     sourceInfo.tokenId = info.srcInfo_.accessToken_ + 1;
541     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
542     sourceInfo.tokenId = info.srcInfo_.accessToken_;
543     sinkInfo.pid = info.sinkInfo_.pid_ + 1;
544     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
545     sinkInfo.pid = info.sinkInfo_.pid_;
546     sourceInfo.pid = info.srcInfo_.pid_ + 1;
547     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
548     sourceInfo.pid = info.srcInfo_.pid_;
549     int len = sprintf_s(sinkInfo.deviceId, sizeof(sinkInfo.deviceId), "%s", "test");
550     ASSERT_GT(len, 0);
551     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
552     len = sprintf_s(sinkInfo.deviceId, sizeof(sinkInfo.deviceId), "%s", info.srcUdid_.c_str());
553     ASSERT_GT(len, 0);
554     len = sprintf_s(sourceInfo.deviceId, sizeof(sourceInfo.deviceId), "%s", "test");
555     ASSERT_GT(len, 0);
556     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckCollabRelation(&sourceInfo, &sinkInfo), INVALID_PARAMETERS_ERR);
557     DSchedCollabManager::GetInstance().collabs_.clear();
558     DTEST_LOG << "DSchedCollabManagerTest CheckCollabRelation_001 end" << std::endl;
559 }
560 
561 /**
562  * @tc.name: CheckSrcCollabRelation_001
563  * @tc.desc: test CheckSrcCollabRelation func
564  * @tc.type: FUNC
565  */
566 HWTEST_F(DSchedCollabManagerTest, CheckSrcCollabRelation_001, TestSize.Level3)
567 {
568     DTEST_LOG << "DSchedCollabManagerTest CheckSrcCollabRelation_001 begin" << std::endl;
569     CollabInfo *nullSourceInfo;
570     DSchedCollabInfo *collabInfo;
571     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckSrcCollabRelation(nullSourceInfo, collabInfo),
572         INVALID_PARAMETERS_ERR);
573 
574     CollabInfo sourceInfo{.deviceId = "srcUdid", .pid = 100, .tokenId = 100, .userId = 100};
575     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckSrcCollabRelation(&sourceInfo, collabInfo),
576         INVALID_PARAMETERS_ERR);
577     DTEST_LOG << "DSchedCollabManagerTest CheckSrcCollabRelation_001 end" << std::endl;
578 }
579 
580 /**
581  * @tc.name: CheckSinkCollabRelation_001
582  * @tc.desc: test CheckSinkCollabRelation func
583  * @tc.type: FUNC
584  */
585 HWTEST_F(DSchedCollabManagerTest, CheckSinkCollabRelation_001, TestSize.Level3)
586 {
587     DTEST_LOG << "DSchedCollabManagerTest CheckSinkCollabRelation_001 begin" << std::endl;
588     CollabInfo *nullSinkInfo;
589     DSchedCollabInfo *collabInfo;
590     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckSinkCollabRelation(nullSinkInfo, collabInfo),
591         INVALID_PARAMETERS_ERR);
592 
593     CollabInfo sinkInfo{.deviceId = "sinkUdid", .pid = 200, .tokenId = 200, .userId = 101};
594     EXPECT_EQ(DSchedCollabManager::GetInstance().CheckSinkCollabRelation(&sinkInfo, collabInfo),
595         INVALID_PARAMETERS_ERR);
596     DTEST_LOG << "DSchedCollabManagerTest CheckSinkCollabRelation_001 end" << std::endl;
597 }
598 
599 /**
600  * @tc.name: IsSessionExists_001
601  * @tc.desc: test IsSessionExists func
602  * @tc.type: FUNC
603  */
604 HWTEST_F(DSchedCollabManagerTest, IsSessionExists_001, TestSize.Level3)
605 {
606     DTEST_LOG << "DSchedCollabManagerTest IsSessionExists_001 begin" << std::endl;
607     DSchedCollabManager::GetInstance().collabs_.clear();
608     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", nullptr));
609     DSchedCollabInfo info;
610     info.srcInfo_.pid_ = 100;
611     info.srcCollabSessionId_ = 1;
612 
613     DSchedCollabInfo info2;
614     info2.srcInfo_.pid_ = 100;
615     info2.srcCollabSessionId_ = 2;
616     auto collab2 = std::make_shared<DSchedCollab>("test2", info2);
617     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test2", collab2));
618 
619     DSchedCollabInfo info3;
620     info3.srcInfo_.pid_ = 101;
621     info3.srcCollabSessionId_ = 2;
622     auto collab3 = std::make_shared<DSchedCollab>("test3", info3);
623     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test3", collab3));
624 
625     DSchedCollabInfo info4;
626     info4.srcInfo_.pid_ = 101;
627     info4.srcCollabSessionId_ = 1;
628     auto collab4 = std::make_shared<DSchedCollab>("test4", info4);
629     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test4", collab4));
630     EXPECT_FALSE(DSchedCollabManager::GetInstance().IsSessionExists(info));
631 
632     auto collab = std::make_shared<DSchedCollab>("test1", info);
633     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test1", collab));
634     EXPECT_TRUE(DSchedCollabManager::GetInstance().IsSessionExists(info));
635     DTEST_LOG << "DSchedCollabManagerTest IsSessionExists_001 end" << std::endl;
636 }
637 
638 
639 /**
640  * @tc.name: NotifyDataRecv_001
641  * @tc.desc: test NotifyDataRecv func
642  * @tc.type: FUNC
643  */
644 HWTEST_F(DSchedCollabManagerTest, NotifyDataRecv_001, TestSize.Level3)
645 {
646     DTEST_LOG << "DSchedCollabManagerTest NotifyDataRecv_001 begin" << std::endl;
647     int32_t softbusSessionId = 1;
648     int32_t command = NOTIFY_RESULT_CMD;
649     std::string collabToken = "token";
650     std::string jsonStr = "test";
651     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
652     EXPECT_TRUE(DSchedCollabManager::GetInstance().collabs_.empty());
653 
654     DSchedCollabInfo info;
655     auto dCollab = std::make_shared<DSchedCollab>(collabToken, info);
656     dCollab->softbusSessionId_ = 0;
657     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", nullptr));
658     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
659     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
660 
661     DSchedCollabManager::GetInstance().collabs_.erase("test");
662     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", dCollab));
663     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
664     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
665 
666     DSchedCollabManager::GetInstance().collabs_.erase("test");
667     dCollab->softbusSessionId_ = softbusSessionId;
668     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", dCollab));
669     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
670     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
671 
672     collabToken = "diffToken";
673     DSchedCollabManager::GetInstance().collabs_.erase("test");
674     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", dCollab));
675     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
676     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
677     DTEST_LOG << "DSchedCollabManagerTest NotifyDataRecv_001 end" << std::endl;
678 }
679 
680 /**
681  * @tc.name: NotifyDataRecv_002
682  * @tc.desc: test NotifyDataRecv func
683  * @tc.type: FUNC
684  */
685 HWTEST_F(DSchedCollabManagerTest, NotifyDataRecv_002, TestSize.Level3)
686 {
687     DTEST_LOG << "DSchedCollabManagerTest NotifyDataRecv_002 begin" << std::endl;
688     int32_t softbusSessionId = 1;
689     int32_t command = SINK_START_CMD;
690     std::string collabToken = "token";
691     std::string jsonStr;
692     auto startCmd = std::make_shared<SinkStartCmd>();
693     startCmd->Marshal(jsonStr);
694     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
695     EXPECT_TRUE(DSchedCollabManager::GetInstance().collabs_.empty());
696 
697     DSchedCollabInfo info;
698     auto dCollab = std::make_shared<DSchedCollab>(collabToken, info);
699     dCollab->softbusSessionId_ = 0;
700     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", nullptr));
701     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
702     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
703 
704     DSchedCollabManager::GetInstance().collabs_.erase("test");
705     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", dCollab));
706     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
707     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
708 
709     DSchedCollabManager::GetInstance().collabs_.erase("test");
710     dCollab->softbusSessionId_ = softbusSessionId;
711     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", dCollab));
712     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
713     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
714 
715     collabToken = "diffToken";
716     DSchedCollabManager::GetInstance().collabs_.erase("test");
717     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", dCollab));
718     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
719     DSchedCollabManager::GetInstance().NotifyDataRecv(softbusSessionId, command, jsonStr, nullptr, collabToken);
720     EXPECT_FALSE(DSchedCollabManager::GetInstance().collabs_.empty());
721     DTEST_LOG << "DSchedCollabManagerTest NotifyDataRecv_002 end" << std::endl;
722 }
723 
724 /**
725  * @tc.name: HandleReleaseAbilityLink_001
726  * @tc.desc: test HandleReleaseAbilityLink func
727  * @tc.type: FUNC
728  */
729 HWTEST_F(DSchedCollabManagerTest, HandleReleaseAbilityLink_001, TestSize.Level3)
730 {
731     DTEST_LOG << "DSchedCollabManagerTest HandleReleaseAbilityLink_001 begin" << std::endl;
732     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", nullptr));
733 
734     DSchedCollabInfo info;
735     info.srcInfo_.bundleName_ = "bundleName";
736     info.srcInfo_.pid_ = 1;
737     info.sinkInfo_.pid_ = 2;
738 
739     std::string collabToken = "token";
740     auto dCollab = std::make_shared<DSchedCollab>(collabToken, info);
741 
742     std::string bundleName = "test";
743     int32_t pid = 0;
744     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test1", dCollab));
745     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().HandleReleaseAbilityLink(bundleName, pid, ""));
746 
747     bundleName = info.srcInfo_.bundleName_;
748     pid = info.srcInfo_.pid_;
749     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().HandleReleaseAbilityLink(bundleName, pid, ""));
750 
751     pid = info.sinkInfo_.pid_;
752     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().HandleReleaseAbilityLink(bundleName, pid, ""));
753     DTEST_LOG << "DSchedCollabManagerTest HandleReleaseAbilityLink_001 end" << std::endl;
754 }
755 
756 /**
757  * @tc.name: NotifyWifiOpen_001
758  * @tc.desc: test NotifyWifiOpen func
759  * @tc.type: FUNC
760  */
761 HWTEST_F(DSchedCollabManagerTest, NotifyWifiOpen_001, TestSize.Level3)
762 {
763     DTEST_LOG << "DSchedCollabManagerTest NotifyWifiOpen_001 begin" << std::endl;
764     DSchedCollabManager::GetInstance().collabs_.insert(std::make_pair("test", nullptr));
765 
766     DSchedCollabInfo info;
767     std::string collabToken = "token";
768     auto dCollab = std::make_shared<DSchedCollab>(collabToken, info);
769     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().NotifyWifiOpen());
770     DTEST_LOG << "DSchedCollabManagerTest NotifyWifiOpen_001 end" << std::endl;
771 }
772 
773 /**
774  * @tc.name: ConvertCollaborateResult_001
775  * @tc.desc: test ConvertCollaborateResult func
776  * @tc.type: FUNC
777  */
778 HWTEST_F(DSchedCollabManagerTest, ConvertCollaborateResult_001, TestSize.Level3)
779 {
780     DTEST_LOG << "DSchedCollabManagerTest ConvertCollaborateResult_001 begin" << std::endl;
781     int32_t result = REJECT;
782     int32_t ret = DSchedCollabManager::GetInstance().ConvertCollaborateResult(result);
783     EXPECT_EQ(ret, DistributedCollab::PEER_APP_REJECTED);
784 
785     result = ON_COLLABORATE_ERR;
786     ret = DSchedCollabManager::GetInstance().ConvertCollaborateResult(result);
787     EXPECT_EQ(ret, DistributedCollab::PEER_ABILITY_NO_ONCOLLABORATE);
788 
789     result = ACCEPT;
790     ret = DSchedCollabManager::GetInstance().ConvertCollaborateResult(result);
791     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
792     DTEST_LOG << "DSchedCollabManagerTest ConvertCollaborateResult_001 end" << std::endl;
793 }
794 
795 /**
796  * @tc.name: HandleCollabPrepareResult_001
797  * @tc.desc: test HandleCollabPrepareResult func
798  * @tc.type: FUNC
799  */
800 HWTEST_F(DSchedCollabManagerTest, HandleCollabPrepareResult_001, TestSize.Level3)
801 {
802     DTEST_LOG << "DSchedCollabManagerTest HandleCollabPrepareResult_001 begin" << std::endl;
803     std::string collabToken = "collabToken";
804     DSchedCollabInfo info;
805     std::shared_ptr<DSchedCollab> ptr = std::make_shared<DSchedCollab>(collabToken, info);
806     DSchedCollabManager::GetInstance().collabs_["collabToken"] = ptr;
807 
808     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().HandleCollabPrepareResult(
809         info, 0));
810 
811     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().NotifySinkRejectReason(
812         "collabToken", "reason"));
813 
814     EXPECT_NO_FATAL_FAILURE(DSchedCollabManager::GetInstance().HandleReleaseAbilityLink(
815         "collabToken", 0, "token"));
816     DTEST_LOG << "DSchedCollabManagerTest HandleCollabPrepareResult_001 end" << std::endl;
817 }
818 
819 /**
820  * @tc.name: HandleCloseSessions_001
821  * @tc.desc: test HandleCloseSessions func
822  * @tc.type: FUNC
823  */
824 HWTEST_F(DSchedCollabManagerTest, HandleCloseSessions_001, TestSize.Level3)
825 {
826     DTEST_LOG << "DSchedCollabManagerTest HandleCloseSessions_001 begin" << std::endl;
827     std::string collabToken = "collabToken";
828     DSchedCollabInfo info;
829     DSchedCollabInfo collabInfo;
830     std::shared_ptr<DSchedCollab> ptr = std::make_shared<DSchedCollab>(collabToken, info);
831     ptr->collabInfo_ = collabInfo;
832     DSchedCollabManager::GetInstance().collabs_.clear();
833     DSchedCollabManager::GetInstance().collabs_["token"] = nullptr;
834     DSchedCollabManager::GetInstance().collabs_["collabToken"] = ptr;
835 
836     std::string bundleName = "bundleName";
837     int32_t pid = 0;
838     int32_t ret = DSchedCollabManager::GetInstance().HandleCloseSessions(bundleName, pid);
839     EXPECT_EQ(ret, ERR_OK);
840     DTEST_LOG << "DSchedCollabManagerTest HandleCloseSessions_001 end" << std::endl;
841 }
842 
843 /**
844  * @tc.name: HandleCloseSessions_002
845  * @tc.desc: test HandleCloseSessions func
846  * @tc.type: FUNC
847  */
848 HWTEST_F(DSchedCollabManagerTest, HandleCloseSessions_002, TestSize.Level3)
849 {
850     DTEST_LOG << "DSchedCollabManagerTest HandleCloseSessions_002 begin" << std::endl;
851     std::string collabToken = "collabToken";
852     DSchedCollabInfo info;
853     DSchedCollabInfo collabInfo;
854     collabInfo.srcInfo_.bundleName_ = "bundleName";
855     collabInfo.srcInfo_.pid_ = 0;
856     std::shared_ptr<DSchedCollab> ptr = std::make_shared<DSchedCollab>(collabToken, info);
857     ptr->collabInfo_ = collabInfo;
858     DSchedCollabManager::GetInstance().collabs_.clear();
859     DSchedCollabManager::GetInstance().collabs_["collabToken"] = ptr;
860 
861     std::string bundleName = "bundleName";
862     int32_t pid = 0;
863     int32_t ret = DSchedCollabManager::GetInstance().HandleCloseSessions(bundleName, pid);
864     EXPECT_NE(ret, ERR_OK);
865 
866     collabInfo.srcInfo_.pid_ = 1;
867     collabInfo.sinkInfo_.bundleName_ = "bundleName";
868     collabInfo.sinkInfo_.pid_ = 0;
869     std::shared_ptr<DSchedCollab> ptr1 = std::make_shared<DSchedCollab>(collabToken, info);
870     ptr1->collabInfo_ = collabInfo;
871     DSchedCollabManager::GetInstance().collabs_.clear();
872     DSchedCollabManager::GetInstance().collabs_["collabToken"] = ptr1;
873     ret = DSchedCollabManager::GetInstance().HandleCloseSessions(bundleName, pid);
874     EXPECT_NE(ret, ERR_OK);
875     DTEST_LOG << "DSchedCollabManagerTest HandleCloseSessions_002 end" << std::endl;
876 }
877 }
878 }
879