1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <thread>
16 
17 #define private public
18 #define protected public
19 #include "gtest/gtest.h"
20 
21 #include "ability_connection_wrapper_stub.h"
22 #include "bundle/bundle_manager_internal.h"
23 #include "device_manager.h"
24 #include "distributed_sched_permission.h"
25 #include "distributed_sched_proxy.h"
26 #include "distributed_sched_service.h"
27 #include "distributed_sched_test_util.h"
28 #include "distributed_sched_utils.h"
29 #include "dtbschedmgr_device_info_storage.h"
30 #include "dtbschedmgr_log.h"
31 #include "form_mgr_errors.h"
32 #include "if_system_ability_manager.h"
33 #include "ipc_skeleton.h"
34 #include "iservice_registry.h"
35 #include "mock_form_mgr_service.h"
36 #include "mock_distributed_sched.h"
37 #include "system_ability_definition.h"
38 #include "test_log.h"
39 #include "thread_pool.h"
40 #undef private
41 #undef protected
42 
43 using namespace std;
44 using namespace testing;
45 using namespace testing::ext;
46 using namespace OHOS;
47 
48 namespace OHOS {
49 namespace DistributedSchedule {
50 using namespace AAFwk;
51 using namespace AppExecFwk;
52 using namespace DistributedHardware;
53 namespace {
54     const string LOCAL_DEVICEID = "192.168.43.100";
55     const string REMOTE_DEVICEID = "255.255.255.255";
56     const std::string DMS_MISSION_ID = "dmsMissionId";
57     const std::string DMS_CONNECT_TOKEN = "connectToken";
58     constexpr int32_t MISSION_ID = 1;
59     const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
60     const int DEFAULT_REQUEST_CODE = -1;
61     const string ABILITY_NAME = "com.ohos.permissionmanager.MainAbility";
62     const string BUNDLE_NAME = "com.ohos.permissionmanager";
63     const string DMS_IS_CALLER_BACKGROUND = "dmsIsCallerBackGround";
64     constexpr int32_t FOREGROUND = 2;
65     constexpr int32_t MAX_TOKEN_NUM = 100000000;
66     constexpr int32_t SLEEP_TIME = 1000;
67 }
68 
69 class DistributedSchedServiceSecondTest : public testing::Test {
70 public:
71     static void SetUpTestCase();
72     static void TearDownTestCase();
73     void SetUp();
74     void TearDown();
75     sptr<IDistributedSched> GetDms();
76     int32_t InstallBundle(const std::string &bundlePath) const;
77     sptr<IDistributedSched> proxy_;
78 
79 protected:
80     enum class LoopTime : int32_t {
81         LOOP_TIME = 10,
82         LOOP_PRESSURE_TIME = 100,
83     };
84     sptr<IRemoteObject> GetDSchedService() const;
85     void GetAbilityInfo(const std::string& package, const std::string& name,
86         const std::string& bundleName, const std::string& deviceId,
87         OHOS::AppExecFwk::AbilityInfo& abilityInfo);
88 
89     class DeviceInitCallBack : public DmInitCallback {
90         void OnRemoteDied() override;
91     };
92 };
93 
SetUpTestCase()94 void DistributedSchedServiceSecondTest::SetUpTestCase()
95 {
96     if (!DistributedSchedUtil::LoadDistributedSchedService()) {
97         DTEST_LOG << "DistributedSchedServiceSecondTest::SetUpTestCase LoadDistributedSchedService failed" << std::endl;
98     }
99     const std::string pkgName = "DBinderBus_" + std::to_string(getprocpid());
100     std::shared_ptr<DmInitCallback> initCallback_ = std::make_shared<DeviceInitCallBack>();
101     DeviceManager::GetInstance().InitDeviceManager(pkgName, initCallback_);
102     std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME));
103 }
104 
TearDownTestCase()105 void DistributedSchedServiceSecondTest::TearDownTestCase()
106 {}
107 
SetUp()108 void DistributedSchedServiceSecondTest::SetUp()
109 {
110     DistributedSchedUtil::MockPermission();
111 }
112 
TearDown()113 void DistributedSchedServiceSecondTest::TearDown()
114 {}
115 
OnRemoteDied()116 void DistributedSchedServiceSecondTest::DeviceInitCallBack::OnRemoteDied()
117 {}
118 
GetDms()119 sptr<IDistributedSched> DistributedSchedServiceSecondTest::GetDms()
120 {
121     if (proxy_ != nullptr) {
122         return proxy_;
123     }
124     auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
125     EXPECT_TRUE(sm != nullptr);
126     if (sm == nullptr) {
127         DTEST_LOG << "DistributedSchedServiceSecondTest sm is nullptr" << std::endl;
128         return nullptr;
129     }
130     DTEST_LOG << "DistributedSchedServiceSecondTest sm is not nullptr" << std::endl;
131     auto distributedObject = sm->GetSystemAbility(DISTRIBUTED_SCHED_SA_ID);
132     proxy_ = iface_cast<IDistributedSched>(distributedObject);
133     if (proxy_ == nullptr) {
134         DTEST_LOG << "DistributedSchedServiceSecondTest DistributedSched is nullptr" << std::endl;
135     } else {
136         DTEST_LOG << "DistributedSchedServiceSecondTest DistributedSched is not nullptr" << std::endl;
137     }
138     return proxy_;
139 }
140 
GetDSchedService() const141 sptr<IRemoteObject> DistributedSchedServiceSecondTest::GetDSchedService() const
142 {
143     sptr<IRemoteObject> dsched(new MockDistributedSched());
144     return dsched;
145 }
146 
GetAbilityInfo(const std::string& package, const std::string& name, const std::string& bundleName, const std::string& deviceId, OHOS::AppExecFwk::AbilityInfo& abilityInfo)147 void DistributedSchedServiceSecondTest::GetAbilityInfo(const std::string& package, const std::string& name,
148     const std::string& bundleName, const std::string& deviceId, OHOS::AppExecFwk::AbilityInfo& abilityInfo)
149 {
150     abilityInfo.bundleName = bundleName;
151     abilityInfo.deviceId = deviceId;
152 }
153 
154 /**
155  * @tc.name: StartRemoteShareForm_001
156  * @tc.desc: call StartRemoteShareForm with dms
157  * @tc.type: StartRemoteShareForm
158  * @tc.require: issueI5M62D
159  */
HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteShareForm_001, TestSize.Level1)160 HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteShareForm_001, TestSize.Level1)
161 {
162     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteShareForm_001 start" << std::endl;
163     sptr<IDistributedSched> proxy = GetDms();
164     const std::string remoteDeviceId = "";
165     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
166     auto result = proxy->StartRemoteShareForm(remoteDeviceId, formShareInfo);
167     DTEST_LOG << "result:" << result << std::endl;
168     EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), result);
169     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteShareForm_001 end" << std::endl;
170 }
171 
172 /**
173  * @tc.name: StartRemoteShareForm_002
174  * @tc.desc: call StartAbilityFromRemote with dms
175  * @tc.type: StartRemoteShareForm
176  * @tc.require: issueI5M62D
177  */
HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteShareForm_002, TestSize.Level1)178 HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteShareForm_002, TestSize.Level1)
179 {
180     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteShareForm_002 start" << std::endl;
181     sptr<IDistributedSched> proxy = GetDms();
182     const std::string remoteDeviceId = "123456";
183     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
184     auto result = proxy->StartRemoteShareForm(remoteDeviceId, formShareInfo);
185     DTEST_LOG << "result:" << result << std::endl;
186     EXPECT_EQ(static_cast<int>(DMS_PERMISSION_DENIED), result);
187     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteShareForm_002 end" << std::endl;
188 }
189 
190 /**
191  * @tc.name: StartRemoteShareForm_003
192  * @tc.desc: call StartRemoteShareForm with dms
193  * @tc.type: StartRemoteShareForm
194  * @tc.require: issueI5M62D
195  */
HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteShareForm_003, TestSize.Level1)196 HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteShareForm_003, TestSize.Level1)
197 {
198     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteShareForm_003 start" << std::endl;
199     sptr<IDistributedSched> proxy = GetDms();
200     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
201     auto result = proxy->StartRemoteShareForm(REMOTE_DEVICEID, formShareInfo);
202     DTEST_LOG << "result:" << result << std::endl;
203     EXPECT_NE(ERR_OK, result);
204     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteShareForm_003 end" << std::endl;
205 }
206 
207 /**
208  * @tc.name: StartShareFormFromRemote_001
209  * @tc.desc: call StartAbilityFromRemote with dms
210  * @tc.type: StartShareFormFromRemote
211  * @tc.require: issueI5M62D
212  */
HWTEST_F(DistributedSchedServiceSecondTest, StartShareFormFromRemote_001, TestSize.Level1)213 HWTEST_F(DistributedSchedServiceSecondTest, StartShareFormFromRemote_001, TestSize.Level1)
214 {
215     DTEST_LOG << "DistributedSchedServiceSecondTest StartShareFormFromRemote_001 start" << std::endl;
216     std::string remoteDeviceId = "";
217     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(remoteDeviceId);
218     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
219     DistributedSchedService::GetInstance().formMgrProxy_ = new MockFormMgrService();
220     auto result = DistributedSchedService::GetInstance().StartShareFormFromRemote(remoteDeviceId, formShareInfo);
221     DTEST_LOG << "result:" << result << std::endl;
222     EXPECT_EQ(static_cast<int>(ERR_OK), result);
223 
224     DTEST_LOG << "DistributedSchedServiceSecondTest StartShareFormFromRemote_001 end" << std::endl;
225 }
226 
227 /**
228  * @tc.name: StartShareFormFromRemote_002
229  * @tc.desc: call StartAbilityFromRemote with dms
230  * @tc.type: StartShareFormFromRemote
231  * @tc.require: issueI5M62D
232  */
HWTEST_F(DistributedSchedServiceSecondTest, StartShareFormFromRemote_002, TestSize.Level1)233 HWTEST_F(DistributedSchedServiceSecondTest, StartShareFormFromRemote_002, TestSize.Level1)
234 {
235     DTEST_LOG << "DistributedSchedServiceSecondTest StartShareFormFromRemote_002 start" << std::endl;
236     std::string remoteDeviceId = "123456";
237     const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
238     /**
239      * @tc.steps: step1. call GetContinuaitonDevice
240      */
241     DTEST_LOG << "DistributedSchedServiceSecondTest GetContinuaitonDevice_001 start" << std::endl;
242     if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) {
243         DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
244     }
245     int32_t missionId = MISSION_ID;
246     (void)DistributedSchedService::GetInstance().GetContinuaitonDevice(missionId);
247     DTEST_LOG << "DistributedSchedServiceSecondTest GetContinuaitonDevice_001 end" << std::endl;
248 
249     auto result = DistributedSchedService::GetInstance().StartShareFormFromRemote(remoteDeviceId, formShareInfo);
250     DTEST_LOG << "result:" << result << std::endl;
251     EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result);
252     DTEST_LOG << "DistributedSchedServiceSecondTest StartShareFormFromRemote_002 end" << std::endl;
253 }
254 
255 /**
256  * @tc.name: ProcessCalleeDied_001
257  * @tc.desc: call ProcessCalleeDied
258  * @tc.type: FUNC
259  * @tc.require: I6YLV1
260  */
HWTEST_F(DistributedSchedServiceSecondTest, ProcessCalleeDied_001, TestSize.Level1)261 HWTEST_F(DistributedSchedServiceSecondTest, ProcessCalleeDied_001, TestSize.Level1)
262 {
263     DTEST_LOG << "DistributedSchedServiceSecondTest ProcessCalleeDied_001 start" << std::endl;
264     std::string localDeviceId;
265     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
266     sptr<IRemoteObject> connect(new MockDistributedSched());
267     DistributedSchedService::GetInstance().ProcessCalleeDied(connect);
268     DistributedSchedService::GetInstance().calleeMap_.clear();
269     EXPECT_TRUE(DistributedSchedService::GetInstance().calleeMap_.empty());
270     DTEST_LOG << "DistributedSchedServiceSecondTest ProcessCalleeDied_001 end" << std::endl;
271 }
272 
273 /**
274  * @tc.name: StartRemoteFreeInstall_001
275  * @tc.desc: call StartRemoteFreeInstall
276  * @tc.type: FUNC
277  * @tc.require: I76THI
278  */
HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteFreeInstall_001, TestSize.Level3)279 HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteFreeInstall_001, TestSize.Level3)
280 {
281     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteFreeInstall_001 start" << std::endl;
282     AAFwk::Want want;
283     AppExecFwk::ElementName element("devicdId", "com.ohos.distributedmusicplayer",
284         "com.ohos.distributedmusicplayer.MainAbility");
285     want.SetElement(element);
286     auto callback = GetDSchedService();
287     int32_t result = DistributedSchedService::GetInstance().StartRemoteFreeInstall(want, 0, 0, 0, callback);
288     EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
289     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteFreeInstall_001 end" << std::endl;
290 }
291 
292 /**
293  * @tc.name: NotifyCompleteFreeInstall_001
294  * @tc.desc: call NotifyCompleteFreeInstall
295  * @tc.type: FUNC
296  * @tc.require: I76THI
297  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyCompleteFreeInstall_001, TestSize.Level3)298 HWTEST_F(DistributedSchedServiceSecondTest, NotifyCompleteFreeInstall_001, TestSize.Level3)
299 {
300     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyCompleteFreeInstall_001 start" << std::endl;
301 
302     sptr<IDistributedSched> proxy = GetDms();
303     ASSERT_NE(nullptr, proxy);
304 
305     AAFwk::Want want;
306     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
307         "com.ohos.distributedmusicplayer.MainAbility");
308     want.SetElement(element);
309     AppExecFwk::AbilityInfo abilityInfo;
310     GetAbilityInfo("com.ohos.distributedmusicplayer", "com.ohos.distributedmusicplayer.MainAbility",
311         "com.ohos.distributedmusicplayer", "192.168.43.100", abilityInfo);
312     CallerInfo callerInfo;
313     callerInfo.uid = 0;
314     callerInfo.sourceDeviceId = "255.255.255.255";
315     IDistributedSched::AccountInfo accountInfo;
316 
317     int result1 = proxy->StartAbilityFromRemote(want, abilityInfo, 0, callerInfo, accountInfo);
318     DTEST_LOG << "result1 is" << result1 << std::endl;
319 
320     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
321         "com.ohos.distributedmusicplayer.MainAbilityService");
322     want.SetElement(element2);
323     GetAbilityInfo("com.ohos.distributedmusicplayer", "com.ohos.distributedmusicplayer.MainAbilityService",
324         "com.ohos.distributedmusicplayer", "192.168.43.100", abilityInfo);
325     int result2 = proxy->StartAbilityFromRemote(want, abilityInfo, 0, callerInfo, accountInfo);
326     DTEST_LOG << "result2:" << result2 << std::endl;
327 
328     /**
329     * @tc.steps: step1. call NotifyCompleteFreeInstall when resultCode is not ERR_OK.
330     */
331     IDistributedSched::FreeInstallInfo info;
332     int32_t result = DistributedSchedService::GetInstance().NotifyCompleteFreeInstall(info, 1, -1);
333     EXPECT_NE(result, ERR_OK);
334     /**
335     * @tc.steps: step2. call ProcessCallResult.
336     */
337     sptr<IRemoteObject> connect(new MockDistributedSched());
338     DistributedSchedService::GetInstance().ProcessCallResult(connect, connect);
339     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyCompleteFreeInstall_001 end" << std::endl;
340 }
341 
342 /**
343  * @tc.name: NotifyStateChangedFromRemote_001
344  * @tc.desc: call NotifyStateChangedFromRemote with illegal params
345  * @tc.type: FUNC
346  * @tc.require: I6SJQ6
347  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_001, TestSize.Level1)348 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_001, TestSize.Level1)
349 {
350     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_001 start" << std::endl;
351     sptr<IDistributedSched> proxy = GetDms();
352     ASSERT_NE(nullptr, proxy);
353     AppExecFwk::ElementName element("", BUNDLE_NAME, ABILITY_NAME);
354     int result1 = proxy->NotifyStateChangedFromRemote(0, 0, element);
355     DTEST_LOG << "result1:" << result1 << std::endl;
356 
357     EXPECT_NE(result1, ERR_OK);
358     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_001 end" << std::endl;
359 }
360 
361 /**
362  * @tc.name: NotifyStateChangedFromRemote_002
363  * @tc.desc: test NotifyStateChangedFromRemote
364  * @tc.type: FUNC
365  * @tc.require: I6SJQ6
366  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_002, TestSize.Level3)367 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_002, TestSize.Level3)
368 {
369     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_002 start" << std::endl;
370     std::string localDeviceId;
371     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
372     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
373 
374     int ret = DistributedSchedService::GetInstance().NotifyStateChangedFromRemote(0, 0, element);
375     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
376     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_002 end" << std::endl;
377 }
378 
379 /**
380  * @tc.name: NotifyStateChangedFromRemote_003
381  * @tc.desc: test NotifyStateChangedFromRemote
382  * @tc.type: FUNC
383  * @tc.require: I6SJQ6
384  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_003, TestSize.Level3)385 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_003, TestSize.Level3)
386 {
387     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_003 start" << std::endl;
388     std::string localDeviceId;
389     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
390     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
391 
392     sptr<IRemoteObject> connect = nullptr;
393     DistributedSchedService::GetInstance().callMap_[connect] = {1, localDeviceId};
394     int ret = DistributedSchedService::GetInstance().NotifyStateChangedFromRemote(0, 0, element);
395     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
396     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_003 end" << std::endl;
397 }
398 
399 /**
400  * @tc.name: NotifyStateChangedFromRemote_004
401  * @tc.desc: test NotifyStateChangedFromRemote
402  * @tc.type: FUNC
403  * @tc.require: I6VDBO
404  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_004, TestSize.Level3)405 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_004, TestSize.Level3)
406 {
407     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_004 start" << std::endl;
408     sptr<AppStateObserver> appStateObserver = sptr<AppStateObserver>(new (std::nothrow) AppStateObserver());
409     int32_t abilityState = FOREGROUND;
410     std::string localDeviceId;
411     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
412     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
413     int32_t ret = DistributedSchedService::GetInstance().NotifyStateChangedFromRemote(abilityState, 0, element);
414     DTEST_LOG << "ret:" << ret << std::endl;
415     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
416     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_004 end" << std::endl;
417 }
418 
419 /**
420  * @tc.name: NotifyStateChangedFromRemote_005
421  * @tc.desc: test NotifyStateChangedFromRemote
422  * @tc.type: FUNC
423  * @tc.require: I6VDBO
424  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_005, TestSize.Level3)425 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_005, TestSize.Level3)
426 {
427     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_005 start" << std::endl;
428     sptr<AppStateObserver> appStateObserver = sptr<AppStateObserver>(new (std::nothrow) AppStateObserver());
429     int32_t abilityState = FOREGROUND;
430     std::string localDeviceId;
431     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
432     sptr<IRemoteObject> connect = nullptr;
433     DistributedSchedService::GetInstance().callMap_[connect] = {2, localDeviceId};
434     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
435     int32_t ret = DistributedSchedService::GetInstance().NotifyStateChangedFromRemote(abilityState, 0, element);
436     DTEST_LOG << "ret:" << ret << std::endl;
437     DistributedSchedService::GetInstance().callMap_.clear();
438     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
439     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_005 end" << std::endl;
440 }
441 
442 /**
443  * @tc.name: NotifyStateChangedFromRemote_006
444  * @tc.desc: test NotifyStateChangedFromRemote
445  * @tc.type: FUNC
446  * @tc.require: I6VDBO
447  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_006, TestSize.Level3)448 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_006, TestSize.Level3)
449 {
450     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_006 start" << std::endl;
451     sptr<AppStateObserver> appStateObserver = sptr<AppStateObserver>(new (std::nothrow) AppStateObserver());
452     int32_t abilityState = FOREGROUND;
453     std::string localDeviceId;
454     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
455     sptr<IRemoteObject> connect(new MockDistributedSched());
456     DistributedSchedService::GetInstance().callMap_[connect] = {3, localDeviceId};
457     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
458     int32_t ret = DistributedSchedService::GetInstance().NotifyStateChangedFromRemote(abilityState, 3, element);
459     DTEST_LOG << "ret:" << ret << std::endl;
460     DistributedSchedService::GetInstance().callMap_.clear();
461     EXPECT_EQ(ret, ERR_OK);
462     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_006 end" << std::endl;
463 }
464 
465 /**
466  * @tc.name: NotifyStateChanged_001
467  * @tc.desc: test NotifyStateChanged
468  * @tc.type: FUNC
469  * @tc.require: I6SJQ6
470  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChanged_001, TestSize.Level3)471 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChanged_001, TestSize.Level3)
472 {
473     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChanged_001 start" << std::endl;
474 
475     sptr<IDistributedSched> proxy = GetDms();
476 
477     AAFwk::Want want;
478     AppExecFwk::ElementName element("1.1.1.1", "com.ohos.distributedmusicplayer",
479         "com.ohos.distributedmusicplayer.MainAbility");
480     want.SetElement(element);
481     CallerInfo callerInfo;
482     callerInfo.uid = 0;
483     callerInfo.sourceDeviceId = "255.255.255.255";
484     IDistributedSched::AccountInfo accountInfo;
485     accountInfo.accountType = 1;
486     accountInfo.groupIdList.push_back("123456");
487     int missionId = 0;
488     want.SetParam(DMS_SRC_NETWORK_ID, callerInfo.sourceDeviceId);
489     want.SetParam(DMS_MISSION_ID, missionId);
490 
491     int result1 = DistributedSchedService::GetInstance().SendResultFromRemote(want, 0, callerInfo, accountInfo, 0);
492     DTEST_LOG << "result1:" << result1 << std::endl;
493 
494     AppExecFwk::ElementName element2("1.1.1.1", "com.ohos.distributedmusicplayer",
495         "com.ohos.distributedmusicplayer.MainAbilityService");
496     want.SetElement(element2);
497     int result2 = DistributedSchedService::GetInstance().SendResultFromRemote(want, 0, callerInfo, accountInfo, 0);
498     DTEST_LOG << "result2:" << result2 << std::endl;
499 
500     int32_t abilityState = FOREGROUND;
501     std::string localDeviceId;
502     AppExecFwk::ElementName element3(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
503     int32_t ret = DistributedSchedService::GetInstance().NotifyStateChanged(abilityState, element3, nullptr);
504     DTEST_LOG << "ret:" << ret << std::endl;
505     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
506     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChanged_001 end" << std::endl;
507 }
508 
509 /**
510  * @tc.name: NotifyStateChanged_002
511  * @tc.desc: test NotifyStateChanged
512  * @tc.type: FUNC
513  * @tc.require: I6VDBO
514  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChanged_002, TestSize.Level3)515 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChanged_002, TestSize.Level3)
516 {
517     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChanged_002 start" << std::endl;
518     sptr<AppStateObserver> appStateObserver = sptr<AppStateObserver>(new (std::nothrow) AppStateObserver());
519     int32_t abilityState = FOREGROUND;
520     std::string localDeviceId;
521     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
522     sptr<IRemoteObject> connect(new MockDistributedSched());
523     DistributedSchedService::GetInstance().observerMap_[connect] = {appStateObserver, localDeviceId, 0, BUNDLE_NAME,
524         ABILITY_NAME};
525     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
526     int32_t ret = DistributedSchedService::GetInstance().NotifyStateChanged(abilityState, element, nullptr);
527     DTEST_LOG << "ret:" << ret << std::endl;
528     DistributedSchedService::GetInstance().observerMap_.clear();
529     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
530     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChanged_002 end" << std::endl;
531 }
532 
533 /**
534  * @tc.name: NotifyStateChanged_003
535  * @tc.desc: test NotifyStateChanged
536  * @tc.type: FUNC
537  * @tc.require: I6VDBO
538  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChanged_003, TestSize.Level3)539 HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChanged_003, TestSize.Level3)
540 {
541     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChanged_003 start" << std::endl;
542     sptr<AppStateObserver> appStateObserver = sptr<AppStateObserver>(new (std::nothrow) AppStateObserver());
543     int32_t abilityState = FOREGROUND;
544     std::string localDeviceId;
545     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
546     sptr<IRemoteObject> connect(new MockDistributedSched());
547     DistributedSchedService::GetInstance().observerMap_[connect] = {appStateObserver, REMOTE_DEVICEID, 0, BUNDLE_NAME,
548         ABILITY_NAME};
549     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
550     int32_t ret = DistributedSchedService::GetInstance().NotifyStateChanged(abilityState, element, nullptr);
551     DTEST_LOG << "ret:" << ret << std::endl;
552     DistributedSchedService::GetInstance().observerMap_.clear();
553     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
554     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChanged_003 end" << std::endl;
555 }
556 
557 /**
558  * @tc.name: StopRemoteExtensionAbility_001
559  * @tc.desc: StopRemoteExtensionAbility with uninitialized params, return INVALID_PARAMETERS_ERR.
560  * @tc.type: FUNC
561  */
HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_001, TestSize.Level3)562 HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_001, TestSize.Level3)
563 {
564     DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_001 start" << std::endl;
565     AAFwk::Want want;
566     int32_t callerUid = 0;
567     uint32_t accessToken = 0;
568     int32_t extensionType = 3;
569     std::string deviceId;
570     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(deviceId);
571     AppExecFwk::ElementName element(deviceId, "com.ohos.distributedmusicplayer",
572         "com.ohos.distributedmusicplayer.MainAbility");
573     want.SetElement(element);
574     EXPECT_EQ(DistributedSchedService::GetInstance().StopRemoteExtensionAbility(want, callerUid, accessToken,
575         extensionType), INVALID_PARAMETERS_ERR);
576     DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_001 end" << std::endl;
577 }
578 
579 /**
580  * @tc.name: StopRemoteExtensionAbility_002
581  * @tc.desc: StopRemoteExtensionAbility with empty want's deviceId, return INVALID_PARAMETERS_ERR.
582  * @tc.type: FUNC
583  */
HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_002, TestSize.Level3)584 HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_002, TestSize.Level3)
585 {
586     DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_002 start" << std::endl;
587     AAFwk::Want want;
588     int32_t callerUid = 0;
589     uint32_t accessToken = 0;
590     int32_t extensionType = 3;
591     AppExecFwk::ElementName element("abcdefg123456", "com.ohos.distributedmusicplayer",
592         "com.ohos.distributedmusicplayer.MainAbility");
593     want.SetElement(element);
594     EXPECT_EQ(DistributedSchedService::GetInstance().StopRemoteExtensionAbility(want, callerUid, accessToken,
595         extensionType), INVALID_PARAMETERS_ERR);
596     DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_002 end" << std::endl;
597 }
598 
599 /**
600  * @tc.name: StopRemoteExtensionAbility_003
601  * @tc.desc: call StopRemoteExtensionAbility
602  * @tc.type: FUNC
603  * @tc.require: I6YLV1
604  */
HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_003, TestSize.Level3)605 HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_003, TestSize.Level3)
606 {
607     DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_003 start" << std::endl;
608     sptr<IDistributedSched> proxy = GetDms();
609     ASSERT_NE(nullptr, proxy);
610     AAFwk::Want want;
611     std::string localDeviceId;
612     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
613     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME,
614         ABILITY_NAME);
615     want.SetElement(element);
616     int32_t extensionType = 3;
617     int result = proxy->StopRemoteExtensionAbility(want, 0, 0, extensionType);
618     EXPECT_EQ(result, DMS_PERMISSION_DENIED);
619     DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_003 end" << std::endl;
620 }
621 
622 /**
623  * @tc.name: StopExtensionAbilityFromRemote_001
624  * @tc.desc: StopExtensionAbilityFromRemote with uninitialized params, return INVALID_REMOTE_PARAMETERS_ERR.
625  * @tc.type: FUNC
626  */
HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_001, TestSize.Level3)627 HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_001, TestSize.Level3)
628 {
629     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_001 start" << std::endl;
630     sptr<IDistributedSched> proxy = GetDms();
631     ASSERT_NE(nullptr, proxy);
632     AAFwk::Want remoteWant;
633     std::string deviceId;
634     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(deviceId);
635     AppExecFwk::ElementName element(deviceId, "com.ohos.distributedmusicplayer",
636         "com.ohos.distributedmusicplayer.MainAbility");
637     remoteWant.SetElement(element);
638     CallerInfo callerInfo;
639     callerInfo.uid = 0;
640     callerInfo.sourceDeviceId = "255.255.255.255";
641     IDistributedSched::AccountInfo accountInfo;
642     int32_t extensionType = 3;
643     EXPECT_EQ(DistributedSchedService::GetInstance().StopExtensionAbilityFromRemote(remoteWant, callerInfo,
644         accountInfo, extensionType), INVALID_REMOTE_PARAMETERS_ERR);
645     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_001 end" << std::endl;
646 }
647 
648 /**
649  * @tc.name: StopExtensionAbilityFromRemote_002
650  * @tc.desc: StopExtensionAbilityFromRemote with empty want's deviceId, return DMS_PERMISSION_DENIED.
651  * @tc.type: FUNC
652  */
HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_002, TestSize.Level3)653 HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_002, TestSize.Level3)
654 {
655     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_002 start" << std::endl;
656 
657     sptr<IDistributedSched> proxy = GetDms();
658     ASSERT_NE(nullptr, proxy);
659     /**
660      * @tc.steps: step1. set want and abilityInfo
661      */
662     AAFwk::Want want;
663     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
664         "com.ohos.distributedmusicplayer.MainAbility");
665     want.SetElement(element);
666     CallerInfo callerInfo;
667     callerInfo.uid = 0;
668     callerInfo.sourceDeviceId = "255.255.255.255";
669     IDistributedSched::AccountInfo accountInfo;
670     int missionId = 0;
671     want.SetParam(DMS_SRC_NETWORK_ID, callerInfo.sourceDeviceId);
672     want.SetParam(DMS_MISSION_ID, missionId);
673     /**
674      * @tc.steps: step2. SendResultFromRemote for pressure test
675      * @tc.expected: step2. SendResultFromRemote for result
676      */
677     for (int index = 0; index < static_cast<int32_t>(LoopTime::LOOP_TIME); index++) {
678         int result = proxy->SendResultFromRemote(want, 0, callerInfo, accountInfo, 0);
679         DTEST_LOG << "pressure" + to_string(index) + " result is " << result << std::endl;
680     }
681 
682     AAFwk::Want remoteWant;
683     AppExecFwk::ElementName element1("abcdefg123456", "com.ohos.distributedmusicplayer",
684         "com.ohos.distributedmusicplayer.MainAbility");
685     remoteWant.SetElement(element1);
686     CallerInfo callerInfo1;
687     callerInfo1.uid = 0;
688     callerInfo1.sourceDeviceId = "255.255.255.255";
689     IDistributedSched::AccountInfo accountInfo1;
690     int32_t extensionType = 3;
691     EXPECT_EQ(DistributedSchedService::GetInstance().StopExtensionAbilityFromRemote(remoteWant, callerInfo1,
692         accountInfo1, extensionType), INVALID_REMOTE_PARAMETERS_ERR);
693     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_002 end" << std::endl;
694 }
695 
696 /**
697  * @tc.name: StopExtensionAbilityFromRemote_003
698  * @tc.desc: StopExtensionAbilityFromRemote with empty want's deviceId, return INVALID_REMOTE_PARAMETERS_ERR.
699  * @tc.type: FUNC
700  */
HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_003, TestSize.Level3)701 HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_003, TestSize.Level3)
702 {
703     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_003 start" << std::endl;
704     sptr<IDistributedSched> proxy = GetDms();
705     ASSERT_NE(nullptr, proxy);
706     AAFwk::Want remoteWant;
707     AppExecFwk::ElementName element("abcdefg123456", "com.ohos.distributedmusicplayer",
708         "com.ohos.distributedmusicplayer.MainAbility");
709     remoteWant.SetElement(element);
710     CallerInfo callerInfo;
711     callerInfo.uid = 0;
712     callerInfo.sourceDeviceId = "255.255.255.255";
713     IDistributedSched::AccountInfo accountInfo;
714     int32_t extensionType = 3;
715     EXPECT_EQ(proxy->StopExtensionAbilityFromRemote(remoteWant, callerInfo,
716         accountInfo, extensionType), IPC_STUB_UNKNOW_TRANS_ERR);
717     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_003 end" << std::endl;
718 }
719 
720 /**
721  * @tc.name: StopExtensionAbilityFromRemote_004
722  * @tc.desc: call StopExtensionAbilityFromRemote
723  * @tc.type: FUNC
724  * @tc.require: I6YLV1
725  */
HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_004, TestSize.Level3)726 HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_004, TestSize.Level3)
727 {
728     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_004 start" << std::endl;
729     AAFwk::Want want;
730     std::string localDeviceId;
731     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
732     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME,
733         ABILITY_NAME);
734     want.SetElement(element);
735     want.SetParam(DMS_IS_CALLER_BACKGROUND, false);
736     AppExecFwk::AbilityInfo abilityInfo;
737     abilityInfo.permissions.clear();
738     sptr<IRemoteObject> connect(new MockDistributedSched());
739     CallerInfo callerInfo;
740     callerInfo.uid = 0;
741     callerInfo.sourceDeviceId = LOCAL_DEVICEID;
742     bool result = BundleManagerInternal::GetCallerAppIdFromBms(BUNDLE_NAME, callerInfo.callerAppId);
743     EXPECT_TRUE(result);
744     IDistributedSched::AccountInfo accountInfo;
745     accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
746     int32_t extensionType = 3;
747     int ret = DistributedSchedService::GetInstance().StopExtensionAbilityFromRemote(want, callerInfo,
748         accountInfo, extensionType);
749     EXPECT_EQ(ret, INVALID_REMOTE_PARAMETERS_ERR);
750     DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_004 end" << std::endl;
751 }
752 
753 /**
754  * @tc.name: CheckDistributedConnectLocked001
755  * @tc.desc: call CheckDistributedConnectLocked
756  * @tc.type: FUNC
757  * @tc.require: I6P0I9
758  */
HWTEST_F(DistributedSchedServiceSecondTest, CheckDistributedConnectLocked001, TestSize.Level3)759 HWTEST_F(DistributedSchedServiceSecondTest, CheckDistributedConnectLocked001, TestSize.Level3)
760 {
761     DTEST_LOG << "DistributedSchedServiceSecondTest CheckDistributedConnectLocked001 start" << std::endl;
762     int32_t uid = IPCSkeleton::GetCallingUid();
763     CallerInfo callerInfo;
764     callerInfo.uid = uid;
765     int32_t ret = DistributedSchedService::GetInstance().CheckDistributedConnectLocked(callerInfo);
766     EXPECT_EQ(ret, ERR_OK);
767     DTEST_LOG << "DistributedSchedServiceSecondTest CheckDistributedConnectLocked001 end" << std::endl;
768 }
769 
770 /**
771  * @tc.name: CheckDistributedConnectLocked002
772  * @tc.desc: call CheckDistributedConnectLocked
773  * @tc.type: FUNC
774  * @tc.require: I6P0I9
775  */
HWTEST_F(DistributedSchedServiceSecondTest, CheckDistributedConnectLocked002, TestSize.Level3)776 HWTEST_F(DistributedSchedServiceSecondTest, CheckDistributedConnectLocked002, TestSize.Level3)
777 {
778     DTEST_LOG << "DistributedSchedServiceSecondTest CheckDistributedConnectLocked002 start" << std::endl;
779     int32_t uid = -1;
780     CallerInfo callerInfo;
781     callerInfo.uid = uid;
782     int32_t ret = DistributedSchedService::GetInstance().CheckDistributedConnectLocked(callerInfo);
783     EXPECT_EQ(ret, BIND_ABILITY_UID_INVALID_ERR);
784     DTEST_LOG << "DistributedSchedServiceSecondTest CheckDistributedConnectLocked002 end" << std::endl;
785 }
786 
787 /**
788  * @tc.name: TryConnectRemoteAbility001
789  * @tc.desc: call TryConnectRemoteAbility
790  * @tc.type: FUNC
791  * @tc.require: I6P0I9
792  */
HWTEST_F(DistributedSchedServiceSecondTest, TryConnectRemoteAbility001, TestSize.Level3)793 HWTEST_F(DistributedSchedServiceSecondTest, TryConnectRemoteAbility001, TestSize.Level3)
794 {
795     DTEST_LOG << "DistributedSchedServiceSecondTest TryConnectRemoteAbility001 start" << std::endl;
796     std::string remoteDeviceId = "remoteDeviceId";
797     OHOS::AAFwk::Want want;
798     want.SetElementName(remoteDeviceId, "ohos.demo.bundleName", "abilityName");
799     sptr<IRemoteObject> connect = nullptr;
800     CallerInfo callerInfo;
801     int32_t ret = DistributedSchedService::GetInstance().TryConnectRemoteAbility(want, connect, callerInfo);
802     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
803     DTEST_LOG << "DistributedSchedServiceSecondTest TryConnectRemoteAbility001 end" << std::endl;
804 }
805 
806 /**
807  * @tc.name: TryConnectRemoteAbility002
808  * @tc.desc: call TryConnectRemoteAbility
809  * @tc.type: FUNC
810  * @tc.require: I6P0I9
811  */
HWTEST_F(DistributedSchedServiceSecondTest, TryConnectRemoteAbility002, TestSize.Level3)812 HWTEST_F(DistributedSchedServiceSecondTest, TryConnectRemoteAbility002, TestSize.Level3)
813 {
814     DTEST_LOG << "DistributedSchedServiceSecondTest TryConnectRemoteAbility002 start" << std::endl;
815     std::string remoteDeviceId = "remoteDeviceId";
816     OHOS::AAFwk::Want want;
817     want.SetElementName(remoteDeviceId, "ohos.demo.bundleName", "abilityName");
818     sptr<IRemoteObject> connect = nullptr;
819     CallerInfo callerInfo;
820     int32_t ret = DistributedSchedService::GetInstance().TryConnectRemoteAbility(want, connect, callerInfo);
821     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
822     DTEST_LOG << "DistributedSchedServiceSecondTest TryConnectRemoteAbility002 end" << std::endl;
823 }
824 
825 /**
826  * @tc.name: SetCallerInfo_001
827  * @tc.desc: call SetCallerInfo
828  * @tc.type: FUNC
829  * @tc.require: I76THI
830  */
HWTEST_F(DistributedSchedServiceSecondTest, SetCallerInfo_001, TestSize.Level3)831 HWTEST_F(DistributedSchedServiceSecondTest, SetCallerInfo_001, TestSize.Level3)
832 {
833     DTEST_LOG << "DistributedSchedServiceSecondTest SetCallerInfo_001 start" << std::endl;
834 
835     sptr<IDistributedSched> proxy = GetDms();
836     ASSERT_NE(nullptr, proxy);
837     /**
838      * @tc.steps: step1. set want and abilityInfo
839      */
840     AAFwk::Want want;
841     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
842         "com.ohos.distributedmusicplayer.MainAbility");
843     want.SetElement(element);
844     AppExecFwk::AbilityInfo abilityInfo;
845     GetAbilityInfo("com.ohos.distributedmusicplayer", "com.ohos.distributedmusicplayer.MainAbility",
846         "com.ohos.distributedmusicplayer", "192.168.43.100", abilityInfo);
847     CallerInfo callerInfo;
848     callerInfo.uid = 0;
849     callerInfo.sourceDeviceId = "255.255.255.255";
850     IDistributedSched::AccountInfo accountInfo;
851     /**
852      * @tc.steps: step2. StartAbilityFromRemote for pressure test
853      * @tc.expected: step2. StartAbilityFromRemote for result
854      */
855     for (int index = 0; index < static_cast<int32_t>(LoopTime::LOOP_TIME); index++) {
856         int result = proxy->StartAbilityFromRemote(want, abilityInfo, 0, callerInfo, accountInfo);
857         DTEST_LOG << "pressure" + to_string(index) + " result is " << result << std::endl;
858     }
859 
860     /**
861     * @tc.steps: step1. call SetCallerInfo with invalid parameters.
862     */
863     CallerInfo callerInfo1;
864     int32_t result = DistributedSchedService::GetInstance().SetCallerInfo(0, LOCAL_DEVICEID, 0, callerInfo1);
865     EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
866     /**
867     * @tc.steps: step2. call OnRemoteDied.
868     */
869     const wptr<IRemoteObject> remote;
870     CallerDeathRecipient callerDeathRecipient;
871     callerDeathRecipient.OnRemoteDied(remote);
872     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteAbilityByCall_001 end" << std::endl;
873 }
874 
875 /**
876  * @tc.name: ContinueRemoteMission_001
877  * @tc.desc: call ContinueRemoteMission
878  * @tc.type: FUNC
879  */
HWTEST_F(DistributedSchedServiceSecondTest, ContinueRemoteMission_001, TestSize.Level1)880 HWTEST_F(DistributedSchedServiceSecondTest, ContinueRemoteMission_001, TestSize.Level1)
881 {
882     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_001 start" << std::endl;
883     if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) {
884         DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared<DSchedContinuation>();
885     }
886     int32_t missionId = MISSION_ID;
887     int32_t timeout = 5;
888     DistributedSchedService::GetInstance().SetContinuationTimeout(missionId, timeout);
889     WantParams wantParams;
890     EXPECT_EQ(ERR_OK, LoadContinueConfig());
891     auto callback = GetDSchedService();
892     int32_t result = DistributedSchedService::GetInstance().ContinueRemoteMission(
893         "", "string", "bundleName", callback, wantParams);
894     EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result);
895     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_001 end" << std::endl;
896 }
897 
898 /**
899  * @tc.name: ContinueRemoteMission_002
900  * @tc.desc: call ContinueRemoteMission
901  * @tc.type: FUNC
902  */
HWTEST_F(DistributedSchedServiceSecondTest, ContinueRemoteMission_002, TestSize.Level1)903 HWTEST_F(DistributedSchedServiceSecondTest, ContinueRemoteMission_002, TestSize.Level1)
904 {
905     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_002 start" << std::endl;
906     WantParams wantParams;
907     EXPECT_EQ(ERR_OK, LoadContinueConfig());
908     auto callback = GetDSchedService();
909     std::string localDeviceId;
910     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
911     int32_t result = DistributedSchedService::GetInstance().ContinueRemoteMission(
912         "string", localDeviceId, "bundleName", callback, wantParams);
913     EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result);
914     DTEST_LOG << "DSchedContinuationTest ContinueRemoteMission_002 end" << std::endl;
915 }
916 
917 /**
918  * @tc.name: StartLocalAbility_001
919  * @tc.desc: call StartLocalAbility with dms
920  * @tc.type: FUNC
921  */
HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_001, TestSize.Level1)922 HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_001, TestSize.Level1)
923 {
924     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_001 start" << std::endl;
925     sptr<IDistributedSched> proxy = GetDms();
926 
927     AAFwk::Want want;
928     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
929         "com.ohos.distributedmusicplayer.MainAbility");
930     want.SetElement(element);
931     CallerInfo callerInfo;
932     callerInfo.uid = 0;
933     callerInfo.sourceDeviceId = "255.255.255.255";
934     IDistributedSched::AccountInfo accountInfo;
935     int missionId = 0;
936     want.SetParam(DMS_SRC_NETWORK_ID, callerInfo.sourceDeviceId);
937     want.SetParam(DMS_MISSION_ID, missionId);
938     DistributedSchedProxy::FreeInstallInfo info = {.want = want, .requestCode = 0, .callerInfo = callerInfo,
939         .accountInfo = accountInfo};
940     int result1 = DistributedSchedService::GetInstance().StartLocalAbility(info, 0, 0);
941     DTEST_LOG << "result1:" << result1 << std::endl;
942 
943     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
944         "com.ohos.distributedmusicplayer.MainAbilityService");
945     want.SetElement(element2);
946     DistributedSchedProxy::FreeInstallInfo info2 = {.want = want, .requestCode = 0, .callerInfo = callerInfo,
947         .accountInfo = accountInfo};
948     int result2 = DistributedSchedService::GetInstance().StartLocalAbility(info2, 0, 0);
949     DTEST_LOG << "result2:" << result2 << std::endl;
950     EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), result1);
951     EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), result2);
952     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_001 end" << std::endl;
953 }
954 
955 /**
956  * @tc.name: StartLocalAbility_002
957  * @tc.desc: call StartLocalAbility with dms
958  * @tc.type: FUNC
959  */
HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_002, TestSize.Level1)960 HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_002, TestSize.Level1)
961 {
962     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_002 start" << std::endl;
963     sptr<IDistributedSched> proxy = GetDms();
964 
965     AAFwk::Want want;
966     AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer",
967         "com.ohos.distributedmusicplayer.MainAbility");
968     want.SetElement(element);
969     CallerInfo callerInfo;
970     callerInfo.uid = 0;
971     callerInfo.sourceDeviceId = "255.255.255.255";
972     IDistributedSched::AccountInfo accountInfo;
973     DistributedSchedProxy::FreeInstallInfo info = {.want = want, .requestCode = DEFAULT_REQUEST_CODE,
974         .callerInfo = callerInfo, .accountInfo = accountInfo};
975     int result1 = DistributedSchedService::GetInstance().StartLocalAbility(info, 0, 0);
976     DTEST_LOG << "result1:" << result1 << std::endl;
977 
978     AppExecFwk::ElementName element2("", "com.ohos.distributedmusicplayer",
979         "com.ohos.distributedmusicplayer.MainAbilityService");
980     want.SetElement(element2);
981     DistributedSchedProxy::FreeInstallInfo info2 = {.want = want, .requestCode = DEFAULT_REQUEST_CODE,
982         .callerInfo = callerInfo, .accountInfo = accountInfo};
983     int result2 = DistributedSchedService::GetInstance().StartLocalAbility(info2, 0, 0);
984     DTEST_LOG << "result2:" << result2 << std::endl;
985     EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), result1);
986     EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), result2);
987     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_002 end" << std::endl;
988 }
989 
990 /**
991  * @tc.name: StartLocalAbility_003
992  * @tc.desc: call StartLocalAbility with dms
993  * @tc.type: FUNC
994  */
HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_003, TestSize.Level1)995 HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_003, TestSize.Level1)
996 {
997     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_003 start" << std::endl;
998     sptr<IDistributedSched> proxy = GetDms();
999 
1000     AAFwk::Want want;
1001     AppExecFwk::ElementName element("1.1.1.1", "com.ohos.distributedmusicplayer",
1002         "com.ohos.distributedmusicplayer.MainAbility");
1003     want.SetElement(element);
1004     CallerInfo callerInfo;
1005     callerInfo.uid = 0;
1006     callerInfo.sourceDeviceId = "255.255.255.255";
1007     IDistributedSched::AccountInfo accountInfo;
1008     accountInfo.accountType = 1;
1009     accountInfo.groupIdList.push_back("123456");
1010     int missionId = 0;
1011     want.SetParam(DMS_SRC_NETWORK_ID, callerInfo.sourceDeviceId);
1012     want.SetParam(DMS_MISSION_ID, missionId);
1013     DistributedSchedProxy::FreeInstallInfo info = {.want = want, .requestCode = 0, .callerInfo = callerInfo,
1014         .accountInfo = accountInfo};
1015     int result1 = DistributedSchedService::GetInstance().StartLocalAbility(info, 0, 0);
1016     DTEST_LOG << "result1:" << result1 << std::endl;
1017 
1018     AppExecFwk::ElementName element2("1.1.1.1", "com.ohos.distributedmusicplayer",
1019         "com.ohos.distributedmusicplayer.MainAbilityService");
1020     want.SetElement(element2);
1021     DistributedSchedProxy::FreeInstallInfo info2 = {.want = want, .requestCode = 0, .callerInfo = callerInfo,
1022         .accountInfo = accountInfo};
1023     int result2 = DistributedSchedService::GetInstance().StartLocalAbility(info2, 0, 0);
1024     DTEST_LOG << "result2:" << result2 << std::endl;
1025     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_003 end" << std::endl;
1026 }
1027 
1028 /**
1029  * @tc.name: StartLocalAbility_004
1030  * @tc.desc: call StartLocalAbility with dms
1031  * @tc.type: FUNC
1032  */
HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_004, TestSize.Level1)1033 HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_004, TestSize.Level1)
1034 {
1035     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_004 start" << std::endl;
1036     sptr<IDistributedSched> proxy = GetDms();
1037 
1038     AAFwk::Want want;
1039     AppExecFwk::ElementName element("1.1.1.1", "com.ohos.distributedmusicplayer",
1040         "com.ohos.distributedmusicplayer.MainAbility");
1041     want.SetElement(element);
1042     CallerInfo callerInfo;
1043     callerInfo.uid = 0;
1044     callerInfo.sourceDeviceId = "255.255.255.255";
1045     IDistributedSched::AccountInfo accountInfo;
1046     accountInfo.accountType = 1;
1047     accountInfo.groupIdList.push_back("123456");
1048     DistributedSchedProxy::FreeInstallInfo info = {.want = want, .requestCode = DEFAULT_REQUEST_CODE,
1049         .callerInfo = callerInfo, .accountInfo = accountInfo};
1050     int result1 = DistributedSchedService::GetInstance().StartLocalAbility(info, 0, 0);
1051     DTEST_LOG << "result1:" << result1 << std::endl;
1052 
1053     AppExecFwk::ElementName element2("1.1.1.1", "com.ohos.distributedmusicplayer",
1054         "com.ohos.distributedmusicplayer.MainAbilityService");
1055     want.SetElement(element2);
1056     DistributedSchedProxy::FreeInstallInfo info2 = {.want = want, .requestCode = DEFAULT_REQUEST_CODE,
1057         .callerInfo = callerInfo, .accountInfo = accountInfo};
1058     int result2 = DistributedSchedService::GetInstance().StartLocalAbility(info2, 0, 0);
1059     DTEST_LOG << "result2:" << result2 << std::endl;
1060     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_004 end" << std::endl;
1061 }
1062 
1063 /**
1064  * @tc.name: StartLocalAbility_005
1065  * @tc.desc: test StartLocalAbility
1066  * @tc.type: FUNC
1067  * @tc.require: issueI5T6GJ
1068  */
HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_005, TestSize.Level3)1069 HWTEST_F(DistributedSchedServiceSecondTest, StartLocalAbility_005, TestSize.Level3)
1070 {
1071     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_005 start" << std::endl;
1072     AAFwk::Want want;
1073     std::string localDeviceId;
1074     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1075     AppExecFwk::ElementName element(localDeviceId, "com.ohos.mms", "bmsThirdBundle");
1076     want.SetElement(element);
1077     want.SetParam(DMS_IS_CALLER_BACKGROUND, false);
1078     AppExecFwk::AbilityInfo abilityInfo;
1079     abilityInfo.permissions.clear();
1080     CallerInfo callerInfo;
1081     callerInfo.uid = 0;
1082     callerInfo.sourceDeviceId = LOCAL_DEVICEID;
1083     bool result = BundleManagerInternal::GetCallerAppIdFromBms("com.third.hiworld.example", callerInfo.callerAppId);
1084     EXPECT_TRUE(result);
1085     IDistributedSched::AccountInfo accountInfo;
1086     accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
1087     DistributedSchedProxy::FreeInstallInfo info = {.want = want, .requestCode = 0,
1088         .callerInfo = callerInfo, .accountInfo = accountInfo};
1089     int ret = DistributedSchedService::GetInstance().StartLocalAbility(info, 0, 0);
1090     EXPECT_NE(ret, ERR_OK);
1091     DTEST_LOG << "DistributedSchedServiceSecondTest StartLocalAbility_005 end" << std::endl;
1092 }
1093 
1094 /**
1095  * @tc.name: HandleLocalCallerDied_001
1096  * @tc.desc: call HandleLocalCallerDied
1097  * @tc.type: FUNC
1098  * @tc.require: I6YLV1
1099  */
HWTEST_F(DistributedSchedServiceSecondTest, HandleLocalCallerDied_001, TestSize.Level1)1100 HWTEST_F(DistributedSchedServiceSecondTest, HandleLocalCallerDied_001, TestSize.Level1)
1101 {
1102     DTEST_LOG << "DistributedSchedServiceSecondTest HandleLocalCallerDied_001 start" << std::endl;
1103     std::string localDeviceId;
1104     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1105     sptr<IRemoteObject> connect(new MockDistributedSched());
1106     std::list<ConnectAbilitySession> sessionsList;
1107     DistributedSchedService::GetInstance().callerMap_[connect] = sessionsList;
1108     DistributedSchedService::GetInstance().callMap_[connect] = {4, localDeviceId};
1109     DistributedSchedService::GetInstance().HandleLocalCallerDied(connect);
1110     DistributedSchedService::GetInstance().callerMap_.clear();
1111     EXPECT_TRUE(DistributedSchedService::GetInstance().callerMap_.empty());
1112     DistributedSchedService::GetInstance().callMap_.clear();
1113     EXPECT_TRUE(DistributedSchedService::GetInstance().callMap_.empty());
1114     DTEST_LOG << "DistributedSchedServiceSecondTest HandleLocalCallerDied_001 end" << std::endl;
1115 }
1116 
1117 /**
1118  * @tc.name: RemoveCallerComponent_001
1119  * @tc.desc: call RemoveCallerComponent
1120  * @tc.type: FUNC
1121  * @tc.require: I6YLV1
1122  */
HWTEST_F(DistributedSchedServiceSecondTest, RemoveCallerComponent_001, TestSize.Level1)1123 HWTEST_F(DistributedSchedServiceSecondTest, RemoveCallerComponent_001, TestSize.Level1)
1124 {
1125     DTEST_LOG << "DistributedSchedServiceSecondTest RemoveCallerComponent_001 start" << std::endl;
1126     std::string localDeviceId;
1127     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1128     sptr<IRemoteObject> connect(new MockDistributedSched());
1129     std::list<ConnectAbilitySession> sessionsList;
1130     DistributedSchedService::GetInstance().callerMap_[connect] = sessionsList;
1131     DistributedSchedService::GetInstance().callMap_[connect] = {5, localDeviceId};
1132     DistributedSchedService::GetInstance().RemoveCallerComponent(connect);
1133     DistributedSchedService::GetInstance().RemoveCallerComponent(nullptr);
1134     DistributedSchedService::GetInstance().callerMap_.clear();
1135     EXPECT_TRUE(DistributedSchedService::GetInstance().callerMap_.empty());
1136     DistributedSchedService::GetInstance().callMap_.clear();
1137     EXPECT_TRUE(DistributedSchedService::GetInstance().callMap_.empty());
1138     DTEST_LOG << "DistributedSchedServiceSecondTest RemoveCallerComponent_001 end" << std::endl;
1139 }
1140 
1141 /**
1142  * @tc.name: ProcessCalleeOffline_001
1143  * @tc.desc: call ProcessCalleeOffline
1144  * @tc.type: FUNC
1145  * @tc.require: I6YLV1
1146  */
HWTEST_F(DistributedSchedServiceSecondTest, ProcessCalleeOffline_001, TestSize.Level1)1147 HWTEST_F(DistributedSchedServiceSecondTest, ProcessCalleeOffline_001, TestSize.Level1)
1148 {
1149     DTEST_LOG << "DistributedSchedServiceSecondTest ProcessCalleeOffline_001 start" << std::endl;
1150     std::string localDeviceId;
1151     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1152     sptr<IRemoteObject> connect(new MockDistributedSched());
1153     std::list<ConnectAbilitySession> sessionsList;
1154     DistributedSchedService::GetInstance().callerMap_[connect] = sessionsList;
1155     DistributedSchedService::GetInstance().callMap_[connect] = {6, localDeviceId};
1156     DistributedSchedService::GetInstance().ProcessCalleeOffline(REMOTE_DEVICEID);
1157 
1158     sptr<IRemoteObject> mockConnect = nullptr;
1159     DistributedSchedService::GetInstance().callerMap_[mockConnect] = sessionsList;
1160     DistributedSchedService::GetInstance().ProcessCalleeOffline(localDeviceId);
1161     DistributedSchedService::GetInstance().callerMap_.clear();
1162     EXPECT_TRUE(DistributedSchedService::GetInstance().callerMap_.empty());
1163     DistributedSchedService::GetInstance().callMap_.clear();
1164     EXPECT_TRUE(DistributedSchedService::GetInstance().callMap_.empty());
1165     DTEST_LOG << "DistributedSchedServiceSecondTest ProcessCalleeOffline_001 end" << std::endl;
1166 }
1167 
1168 /**
1169  * @tc.name: GetConnectComponentList_001
1170  * @tc.desc: call GetConnectComponentList
1171  * @tc.type: FUNC
1172  * @tc.require: I76THI
1173  */
HWTEST_F(DistributedSchedServiceSecondTest, GetConnectComponentList_001, TestSize.Level1)1174 HWTEST_F(DistributedSchedServiceSecondTest, GetConnectComponentList_001, TestSize.Level1)
1175 {
1176     DTEST_LOG << "DistributedSchedServiceSecondTest GetConnectComponentList_001 start" << std::endl;
1177     /**
1178     * @tc.steps: step1. call GetConnectComponentList when iter.second is empty.
1179     */
1180     sptr<IRemoteObject> connect(new MockDistributedSched());
1181     std::list<ConnectAbilitySession> sessionsList;
1182     std::vector<std::string> distributedComponents;
1183     {
1184         std::lock_guard<std::mutex> autoLock(DistributedSchedService::GetInstance().distributedLock_);
1185         DistributedSchedService::GetInstance().distributedConnectAbilityMap_.clear();
1186         DistributedSchedService::GetInstance().distributedConnectAbilityMap_[connect] = sessionsList;
1187     }
1188     DistributedSchedService::GetInstance().GetConnectComponentList(distributedComponents);
1189     EXPECT_TRUE(distributedComponents.empty());
1190     /**
1191     * @tc.steps: step2. call GetConnectComponentList when iter.second is not empty.
1192     */
1193     CallerInfo callerInfo;
1194     ConnectAbilitySession connectAbilitySession("sourceDeviceId", "destinationDeviceId", callerInfo);
1195     sessionsList.emplace_back(connectAbilitySession);
1196     {
1197         std::lock_guard<std::mutex> autoLock(DistributedSchedService::GetInstance().distributedLock_);
1198         DistributedSchedService::GetInstance().distributedConnectAbilityMap_[connect] = sessionsList;
1199     }
1200     DistributedSchedService::GetInstance().GetConnectComponentList(distributedComponents);
1201     EXPECT_FALSE(distributedComponents.empty());
1202     /**
1203     * @tc.steps: step3. call GetConnectComponentList when connectAbilityMap_ is not empty.
1204     */
1205     distributedComponents.clear();
1206     ConnectInfo connectInfo;
1207     {
1208         std::lock_guard<std::mutex> autoLock(DistributedSchedService::GetInstance().connectLock_);
1209         DistributedSchedService::GetInstance().connectAbilityMap_[connect] = connectInfo;
1210     }
1211     DistributedSchedService::GetInstance().GetConnectComponentList(distributedComponents);
1212     EXPECT_FALSE(distributedComponents.empty());
1213     DTEST_LOG << "DistributedSchedServiceSecondTest GetConnectComponentList_001 end" << std::endl;
1214 }
1215 
1216 /**
1217  * @tc.name: GetCallComponentList_001
1218  * @tc.desc: call GetCallComponentList
1219  * @tc.type: FUNC
1220  * @tc.require: I76THI
1221  */
HWTEST_F(DistributedSchedServiceSecondTest, GetCallComponentList_001, TestSize.Level1)1222 HWTEST_F(DistributedSchedServiceSecondTest, GetCallComponentList_001, TestSize.Level1)
1223 {
1224     DTEST_LOG << "DistributedSchedServiceSecondTest GetCallComponentList_001 start" << std::endl;
1225     /**
1226     * @tc.steps: step1. call GetCallComponentList when iter.second is empty.
1227     */
1228     sptr<IRemoteObject> connect(new MockDistributedSched());
1229     std::list<ConnectAbilitySession> sessionsList;
1230     std::vector<std::string> distributedComponents;
1231     {
1232         std::lock_guard<std::mutex> autoLock(DistributedSchedService::GetInstance().callerLock_);
1233         DistributedSchedService::GetInstance().callerMap_.clear();
1234         DistributedSchedService::GetInstance().callerMap_[connect] = sessionsList;
1235     }
1236     DistributedSchedService::GetInstance().GetCallComponentList(distributedComponents);
1237     EXPECT_TRUE(distributedComponents.empty());
1238     /**
1239     * @tc.steps: step2. call GetCallComponentList when iter.second is not empty.
1240     */
1241     CallerInfo callerInfo;
1242     ConnectAbilitySession connectAbilitySession("sourceDeviceId", "destinationDeviceId", callerInfo);
1243     sessionsList.emplace_back(connectAbilitySession);
1244     {
1245         std::lock_guard<std::mutex> autoLock(DistributedSchedService::GetInstance().callerLock_);
1246         DistributedSchedService::GetInstance().callerMap_[connect] = sessionsList;
1247     }
1248     DistributedSchedService::GetInstance().GetCallComponentList(distributedComponents);
1249     EXPECT_FALSE(distributedComponents.empty());
1250     /**
1251     * @tc.steps: step3. call GetCallComponentList when calleeMap_ is not empty.
1252     */
1253     distributedComponents.clear();
1254     ConnectInfo connectInfo;
1255     {
1256         std::lock_guard<std::mutex> autoLock(DistributedSchedService::GetInstance().calleeLock_);
1257         DistributedSchedService::GetInstance().calleeMap_[connect] = connectInfo;
1258     }
1259     DistributedSchedService::GetInstance().GetCallComponentList(distributedComponents);
1260     EXPECT_FALSE(distributedComponents.empty());
1261     DTEST_LOG << "DistributedSchedServiceSecondTest GetCallComponentList_001 end" << std::endl;
1262 }
1263 
1264 /**
1265  * @tc.name: RegisterAppStateObserver_001
1266  * @tc.desc: test RegisterAppStateObserver
1267  * @tc.type: FUNC
1268  * @tc.require: I6VDBO
1269  */
HWTEST_F(DistributedSchedServiceSecondTest, RegisterAppStateObserver_001, TestSize.Level3)1270 HWTEST_F(DistributedSchedServiceSecondTest, RegisterAppStateObserver_001, TestSize.Level3)
1271 {
1272     DTEST_LOG << "DistributedSchedServiceSecondTest RegisterAppStateObserver_001 start" << std::endl;
1273     AAFwk::Want want;
1274     std::string localDeviceId;
1275     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1276     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
1277     want.SetElement(element);
1278     want.SetParam(DMS_MISSION_ID, 0);
1279     want.SetParam(DMS_CONNECT_TOKEN, 0);
1280     sptr<IRemoteObject> connect(new MockDistributedSched());
1281     CallerInfo callerInfo;
1282     callerInfo.uid = 0;
1283     callerInfo.sourceDeviceId = localDeviceId;
1284     bool ret = DistributedSchedService::GetInstance().RegisterAppStateObserver(want, callerInfo, nullptr, connect);
1285     DistributedSchedService::GetInstance().UnregisterAppStateObserver(connect);
1286     EXPECT_TRUE(ret);
1287     DTEST_LOG << "DistributedSchedServiceSecondTest RegisterAppStateObserver_001 end" << std::endl;
1288 }
1289 
1290 /**
1291  * @tc.name: UnregisterAppStateObserver_001
1292  * @tc.desc: test UnregisterAppStateObserver
1293  * @tc.type: FUNC
1294  * @tc.require: I6VDBO
1295  */
HWTEST_F(DistributedSchedServiceSecondTest, UnregisterAppStateObserver_001, TestSize.Level3)1296 HWTEST_F(DistributedSchedServiceSecondTest, UnregisterAppStateObserver_001, TestSize.Level3)
1297 {
1298     DTEST_LOG << "DistributedSchedServiceSecondTest UnregisterAppStateObserver_001 start" << std::endl;
1299     sptr<IRemoteObject> connect = nullptr;
1300     DistributedSchedService::GetInstance().UnregisterAppStateObserver(connect);
1301     EXPECT_EQ(connect, nullptr);
1302     DTEST_LOG << "DistributedSchedServiceSecondTest UnregisterAppStateObserver_001 end" << std::endl;
1303 }
1304 
1305 /**
1306  * @tc.name: UnregisterAppStateObserver_002
1307  * @tc.desc: test UnregisterAppStateObserver
1308  * @tc.type: FUNC
1309  * @tc.require: I6VDBO
1310  */
HWTEST_F(DistributedSchedServiceSecondTest, UnregisterAppStateObserver_002, TestSize.Level3)1311 HWTEST_F(DistributedSchedServiceSecondTest, UnregisterAppStateObserver_002, TestSize.Level3)
1312 {
1313     DTEST_LOG << "DistributedSchedServiceSecondTest UnregisterAppStateObserver_002 start" << std::endl;
1314     AAFwk::Want want;
1315     std::string localDeviceId;
1316     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1317     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME, ABILITY_NAME);
1318     want.SetElement(element);
1319     want.SetParam(DMS_MISSION_ID, 0);
1320     want.SetParam(DMS_CONNECT_TOKEN, 0);
1321     sptr<IRemoteObject> connect(new MockDistributedSched());
1322     CallerInfo callerInfo;
1323     callerInfo.uid = 0;
1324     callerInfo.sourceDeviceId = localDeviceId;
1325     bool ret = DistributedSchedService::GetInstance().RegisterAppStateObserver(want, callerInfo, nullptr, connect);
1326     EXPECT_TRUE(ret);
1327     sptr<IRemoteObject> connect1(new MockDistributedSched());
1328     DistributedSchedService::GetInstance().UnregisterAppStateObserver(connect1);
1329     EXPECT_NE(connect, connect1);
1330     DistributedSchedService::GetInstance().SaveCallerComponent(want, nullptr, callerInfo);
1331     DTEST_LOG << "DistributedSchedServiceSecondTest UnregisterAppStateObserver_002 end" << std::endl;
1332 }
1333 
1334 /**
1335  * @tc.name: GetAppManager_001
1336  * @tc.desc: test GetAppManager
1337  * @tc.type: FUNC
1338  * @tc.require: I6VDBO
1339  */
HWTEST_F(DistributedSchedServiceSecondTest, GetAppManager_001, TestSize.Level3)1340 HWTEST_F(DistributedSchedServiceSecondTest, GetAppManager_001, TestSize.Level3)
1341 {
1342     DTEST_LOG << "DistributedSchedServiceSecondTest GetAppManager_001 start" << std::endl;
1343     auto ret = DistributedSchedService::GetInstance().GetAppManager();
1344     EXPECT_NE(ret, nullptr);
1345     DTEST_LOG << "DistributedSchedServiceSecondTest GetAppManager_001 end" << std::endl;
1346 }
1347 
1348 /**
1349  * @tc.name: SaveConnectToken_001
1350  * @tc.desc: call SaveConnectToken
1351  * @tc.type: FUNC
1352  * @tc.require: I76THI
1353  */
HWTEST_F(DistributedSchedServiceSecondTest, SaveConnectToken_001, TestSize.Level3)1354 HWTEST_F(DistributedSchedServiceSecondTest, SaveConnectToken_001, TestSize.Level3)
1355 {
1356     DTEST_LOG << "DistributedSchedServiceSecondTest SaveConnectToken_001 start" << std::endl;
1357     AAFwk::Want want;
1358     std::string localDeviceId;
1359     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1360     AppExecFwk::ElementName element(localDeviceId, BUNDLE_NAME,
1361         ABILITY_NAME);
1362     sptr<IRemoteObject> connect(new MockDistributedSched());
1363     /**
1364     * @tc.steps: step1. call SaveConnectToken
1365     * @tc.expected: step1. SaveConnectToken return token_
1366     */
1367     int32_t token = 0;
1368     {
1369         std::lock_guard<std::mutex> tokenLock(DistributedSchedService::GetInstance().tokenMutex_);
1370         token = DistributedSchedService::GetInstance().token_.load();
1371     }
1372     int32_t result = DistributedSchedService::GetInstance().SaveConnectToken(want, connect);
1373     EXPECT_EQ(result, token + 1);
1374     /**
1375     * @tc.steps: step2. call SaveConnectToken when tToken > MAX_TOKEN_NUM
1376     * @tc.expected: step2. SaveConnectToken return 1
1377     */
1378     {
1379         std::lock_guard<std::mutex> tokenLock(DistributedSchedService::GetInstance().tokenMutex_);
1380         DistributedSchedService::GetInstance().token_.store(MAX_TOKEN_NUM);
1381     }
1382     result = DistributedSchedService::GetInstance().SaveConnectToken(want, connect);
1383     EXPECT_EQ(result, 1);
1384     DTEST_LOG << "DistributedSchedServiceSecondTest SaveConnectToken_001 end" << std::endl;
1385 }
1386 
1387 /**
1388  * @tc.name: ContinueMissionBundleName_001
1389  * @tc.desc: call ContinueMissionBundleName
1390  * @tc.type: FUNC
1391  */
HWTEST_F(DistributedSchedServiceSecondTest, ContinueMissionBundleName_001, TestSize.Level1)1392 HWTEST_F(DistributedSchedServiceSecondTest, ContinueMissionBundleName_001, TestSize.Level1)
1393 {
1394     DTEST_LOG << "DSchedContinuationTest ContinueMissionBundleName_001 start" << std::endl;
1395     WantParams wantParams;
1396     auto callback = GetDSchedService();
1397     std::string localDeviceId;
1398     DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId);
1399     int32_t result = DistributedSchedService::GetInstance().ContinueMission(
1400         "string", localDeviceId, "bundleName", callback, wantParams);
1401     EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result);
1402     DistributedSchedService::GetInstance().ContinueMission(
1403         localDeviceId, "string", "bundleName", callback, wantParams);
1404     DTEST_LOG << "DSchedContinuationTest ContinueMissionBundleName_001 end" << std::endl;
1405 }
1406 
1407 /**
1408  * @tc.name: ContinueMissionBundleName_002
1409  * @tc.desc: call ContinueMissionBundleName
1410  * @tc.type: FUNC
1411  */
HWTEST_F(DistributedSchedServiceSecondTest, ContinueMissionBundleName_002, TestSize.Level1)1412 HWTEST_F(DistributedSchedServiceSecondTest, ContinueMissionBundleName_002, TestSize.Level1)
1413 {
1414     DTEST_LOG << "DSchedContinuationTest ContinueMissionBundleName_002 start" << std::endl;
1415     WantParams wantParams;
1416     auto callback = GetDSchedService();
1417     int32_t result = DistributedSchedService::GetInstance().ContinueMission(
1418         "string", "string", "bundleName", callback, wantParams);
1419     EXPECT_EQ(static_cast<int>(OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET), result);
1420     DTEST_LOG << "DSchedContinuationTest ContinueMissionBundleName_002 end" << std::endl;
1421 }
1422 
1423 /**
1424  * @tc.name: GetCallerInfo_001
1425  * @tc.desc: GetCallerInfo
1426  * @tc.type: FUNC
1427  */
HWTEST_F(DistributedSchedServiceSecondTest, GetCallerInfo_001, TestSize.Level3)1428 HWTEST_F(DistributedSchedServiceSecondTest, GetCallerInfo_001, TestSize.Level3)
1429 {
1430     DTEST_LOG << "DistributedSchedServiceSecondTest GetCallerInfo_001 start" << std::endl;
1431     int32_t callerUid = 0;
1432     uint32_t accessToken = 0;
1433     CallerInfo callerInfo;
1434     int32_t result = DistributedSchedService::GetInstance().GetCallerInfo(
1435         LOCAL_DEVICEID, callerUid, accessToken, callerInfo);
1436     EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1437     DTEST_LOG << "DistributedSchedServiceSecondTest GetCallerInfo_001 end" << std::endl;
1438 }
1439 
1440 /**
1441  * @tc.name: ProcessContinueLocalMission_001
1442  * @tc.desc: ProcessContinueLocalMission
1443  * @tc.type: FUNC
1444  */
HWTEST_F(DistributedSchedServiceSecondTest, ProcessContinueLocalMission_001, TestSize.Level3)1445 HWTEST_F(DistributedSchedServiceSecondTest, ProcessContinueLocalMission_001, TestSize.Level3)
1446 {
1447     DTEST_LOG << "DistributedSchedServiceSecondTest ProcessContinueLocalMission_001 start" << std::endl;
1448     WantParams wantParams;
1449     int32_t result = DistributedSchedService::GetInstance().ProcessContinueLocalMission(
1450         LOCAL_DEVICEID, REMOTE_DEVICEID, BUNDLE_NAME, nullptr, wantParams);
1451 
1452     bool ret = DistributedSchedService::GetInstance().GetIsFreeInstall(0);
1453     EXPECT_EQ(ret, false);
1454     DTEST_LOG << "DistributedSchedServiceSecondTest ProcessContinueLocalMission_001 end" << std::endl;
1455 }
1456 
1457 /**
1458  * @tc.name: StartAbility_001
1459  * @tc.desc: StartAbility
1460  * @tc.type: FUNC
1461  */
HWTEST_F(DistributedSchedServiceSecondTest, StartAbility_001, TestSize.Level3)1462 HWTEST_F(DistributedSchedServiceSecondTest, StartAbility_001, TestSize.Level3)
1463 {
1464     DTEST_LOG << "DistributedSchedServiceSecondTest StartAbility_001 start" << std::endl;
1465     Want want;
1466     int32_t requestCode = 0;
1467     int32_t ret = DistributedSchedService::GetInstance().StartAbility(want, requestCode);
1468     EXPECT_NE(ret, ERR_OK);
1469     DTEST_LOG << "DistributedSchedServiceSecondTest StartAbility_001 end" << std::endl;
1470 }
1471 
1472 /**
1473  * @tc.name: CheckTargetPermission4DiffBundle_001
1474  * @tc.desc: CheckTargetPermission4DiffBundle
1475  * @tc.type: FUNC
1476  */
HWTEST_F(DistributedSchedServiceSecondTest, CheckTargetPermission4DiffBundle_001, TestSize.Level3)1477 HWTEST_F(DistributedSchedServiceSecondTest, CheckTargetPermission4DiffBundle_001, TestSize.Level3)
1478 {
1479     DTEST_LOG << "DistributedSchedServiceSecondTest CheckTargetPermission4DiffBundle_001 start" << std::endl;
1480     OHOS::AAFwk::Want want;
1481     CallerInfo callerInfo;
1482     AccountInfo accountInfo;
1483     int32_t flag = 0;
1484     int32_t ret = DistributedSchedService::GetInstance().CheckTargetPermission4DiffBundle(want,
1485         callerInfo, accountInfo, flag, true);
1486     EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
1487     DTEST_LOG << "DistributedSchedServiceSecondTest CheckTargetPermission4DiffBundle_001 end" << std::endl;
1488 }
1489 
1490 #ifdef DMSFWK_INTERACTIVE_ADAPTER
1491 /**
1492  * @tc.name: StartRemoteAbilityAdapter_001
1493  * @tc.desc: StartRemoteAbilityAdapter
1494  * @tc.type: FUNC
1495  */
HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteAbilityAdapter_001, TestSize.Level3)1496 HWTEST_F(DistributedSchedServiceSecondTest, StartRemoteAbilityAdapter_001, TestSize.Level3)
1497 {
1498     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteAbilityAdapter_001 start" << std::endl;
1499     OHOS::AAFwk::Want want;
1500     int32_t callerUid = 0;
1501     int32_t requestCode = 0;
1502     uint32_t accessToken = 0;
1503     int32_t ret = DistributedSchedService::GetInstance().StartRemoteAbilityAdapter(want,
1504         callerUid, requestCode, accessToken);
1505     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1506     DTEST_LOG << "DistributedSchedServiceSecondTest StartRemoteAbilityAdapter_001 end" << std::endl;
1507 }
1508 
1509 /**
1510  * @tc.name: ConnectRemoteAbilityAdapter_001
1511  * @tc.desc: ConnectRemoteAbilityAdapter
1512  * @tc.type: FUNC
1513  */
HWTEST_F(DistributedSchedServiceSecondTest, ConnectRemoteAbilityAdapter_001, TestSize.Level3)1514 HWTEST_F(DistributedSchedServiceSecondTest, ConnectRemoteAbilityAdapter_001, TestSize.Level3)
1515 {
1516     DTEST_LOG << "DistributedSchedServiceSecondTest ConnectRemoteAbilityAdapter_001 start" << std::endl;
1517     OHOS::AAFwk::Want want;
1518     sptr<IRemoteObject> connect;
1519     int32_t callerUid = 0;
1520     int32_t callerPid = 0;
1521     uint32_t accessToken = 0;
1522     int32_t ret = DistributedSchedService::GetInstance().ConnectRemoteAbilityAdapter(want, connect,
1523         callerUid, callerPid, accessToken);
1524     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1525     DTEST_LOG << "DistributedSchedServiceSecondTest ConnectRemoteAbilityAdapter_001 end" << std::endl;
1526 }
1527 
1528 /**
1529  * @tc.name: StartAbilityFromRemoteAdapter_001
1530  * @tc.desc: StartAbilityFromRemoteAdapter
1531  * @tc.type: FUNC
1532  */
HWTEST_F(DistributedSchedServiceSecondTest, StartAbilityFromRemoteAdapter_001, TestSize.Level3)1533 HWTEST_F(DistributedSchedServiceSecondTest, StartAbilityFromRemoteAdapter_001, TestSize.Level3)
1534 {
1535     DTEST_LOG << "DistributedSchedServiceSecondTest StartAbilityFromRemoteAdapter_001 start" << std::endl;
1536     MessageParcel data;
1537     MessageParcel reply;
1538     int32_t ret = DistributedSchedService::GetInstance().StartAbilityFromRemoteAdapter(data, reply);
1539     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1540     DTEST_LOG << "DistributedSchedServiceSecondTest StartAbilityFromRemoteAdapter_001 end" << std::endl;
1541 }
1542 
1543 /**
1544  * @tc.name: StopAbilityFromRemoteAdapter_001
1545  * @tc.desc: StopAbilityFromRemoteAdapter
1546  * @tc.type: FUNC
1547  */
HWTEST_F(DistributedSchedServiceSecondTest, StopAbilityFromRemoteAdapter_001, TestSize.Level3)1548 HWTEST_F(DistributedSchedServiceSecondTest, StopAbilityFromRemoteAdapter_001, TestSize.Level3)
1549 {
1550     DTEST_LOG << "DistributedSchedServiceSecondTest StopAbilityFromRemoteAdapter_001 start" << std::endl;
1551     MessageParcel data;
1552     MessageParcel reply;
1553     int32_t ret = DistributedSchedService::GetInstance().StopAbilityFromRemoteAdapter(data, reply);
1554     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1555     DTEST_LOG << "DistributedSchedServiceSecondTest StopAbilityFromRemoteAdapter_001 end" << std::endl;
1556 }
1557 
1558 /**
1559  * @tc.name: ConnectAbilityFromRemoteAdapter_001
1560  * @tc.desc: ConnectAbilityFromRemoteAdapter
1561  * @tc.type: FUNC
1562  */
HWTEST_F(DistributedSchedServiceSecondTest, ConnectAbilityFromRemoteAdapter_001, TestSize.Level3)1563 HWTEST_F(DistributedSchedServiceSecondTest, ConnectAbilityFromRemoteAdapter_001, TestSize.Level3)
1564 {
1565     DTEST_LOG << "DistributedSchedServiceSecondTest ConnectAbilityFromRemoteAdapter_001 start" << std::endl;
1566     MessageParcel data;
1567     MessageParcel reply;
1568     int32_t ret = DistributedSchedService::GetInstance().ConnectAbilityFromRemoteAdapter(data, reply);
1569     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1570     DTEST_LOG << "DistributedSchedServiceSecondTest ConnectAbilityFromRemoteAdapter_001 end" << std::endl;
1571 }
1572 
1573 /**
1574  * @tc.name: DisconnectAbilityFromRemoteAdapter_001
1575  * @tc.desc: DisconnectAbilityFromRemoteAdapter
1576  * @tc.type: FUNC
1577  */
HWTEST_F(DistributedSchedServiceSecondTest, DisconnectAbilityFromRemoteAdapter_001, TestSize.Level3)1578 HWTEST_F(DistributedSchedServiceSecondTest, DisconnectAbilityFromRemoteAdapter_001, TestSize.Level3)
1579 {
1580     DTEST_LOG << "DistributedSchedServiceSecondTest DisconnectAbilityFromRemoteAdapter_001 start" << std::endl;
1581     MessageParcel data;
1582     MessageParcel reply;
1583     int32_t ret = DistributedSchedService::GetInstance().DisconnectAbilityFromRemoteAdapter(data, reply);
1584     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1585     DTEST_LOG << "DistributedSchedServiceSecondTest DisconnectAbilityFromRemoteAdapter_001 end" << std::endl;
1586 }
1587 
1588 /**
1589  * @tc.name: NotifyAbilityLifecycleChangedFromRemoteAdapter_001
1590  * @tc.desc: NotifyAbilityLifecycleChangedFromRemoteAdapter
1591  * @tc.type: FUNC
1592  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyAbilityLifecycleChangedFromRemoteAdapter_001, TestSize.Level3)1593 HWTEST_F(DistributedSchedServiceSecondTest, NotifyAbilityLifecycleChangedFromRemoteAdapter_001, TestSize.Level3)
1594 {
1595     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyAbilityLifecycleChangedFromRemoteAdapter_001 start" <<
1596         std::endl;
1597     MessageParcel data;
1598     MessageParcel reply;
1599     int32_t ret = DistributedSchedService::GetInstance().NotifyAbilityLifecycleChangedFromRemoteAdapter(data, reply);
1600     EXPECT_EQ(ret, NOT_FIND_SERVICE_REGISTRY);
1601     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyAbilityLifecycleChangedFromRemoteAdapter_001 end" <<
1602         std::endl;
1603 }
1604 #endif // DMSFWK_INTERACTIVE_ADAPTER
1605 
1606 /**
1607  * @tc.name: NotifyDSchedEventResultFromRemote_001
1608  * @tc.desc: NotifyDSchedEventResultFromRemote
1609  * @tc.type: FUNC
1610  */
HWTEST_F(DistributedSchedServiceSecondTest, NotifyDSchedEventResultFromRemote_001, TestSize.Level3)1611 HWTEST_F(DistributedSchedServiceSecondTest, NotifyDSchedEventResultFromRemote_001, TestSize.Level3)
1612 {
1613     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyDSchedEventResultFromRemote_001 start" << std::endl;
1614     std::string type;
1615     int32_t dSchedEventResult = 0;
1616     int32_t ret = DistributedSchedService::GetInstance().NotifyDSchedEventResultFromRemote(type, dSchedEventResult);
1617     EXPECT_EQ(ret, ERR_OK);
1618     DTEST_LOG << "DistributedSchedServiceSecondTest NotifyDSchedEventResultFromRemote_001 end" << std::endl;
1619 }
1620 }
1621 }
1622