1 /*
2 * Copyright (c) 2022-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
16 #define private public
17 #include "bundle/bundle_manager_internal.h"
18 #include "distributed_sched_service.h"
19 #undef private
20 #include "distributed_sched_stub_test.h"
21 #include "distributed_sched_test_util.h"
22 #define private public
23 #include "mission/distributed_sched_mission_manager.h"
24 #undef private
25 #include "mock_distributed_sched.h"
26 #include "mock_remote_stub.h"
27 #include "parcel_helper.h"
28 #include "test_log.h"
29 #include "token_setproc.h"
30
31 using namespace testing;
32 using namespace testing::ext;
33 using namespace OHOS::AAFwk;
34 using namespace OHOS::AppExecFwk;
35
36 namespace OHOS {
37 namespace DistributedSchedule {
38 namespace {
39 const std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.accessToken";
40 const std::u16string MOCK_INVALID_DESCRIPTOR = u"invalid descriptor";
41 const std::string EXTRO_INFO_JSON_KEY_ACCESS_TOKEN = "accessTokenID";
42 const std::string EXTRO_INFO_JSON_KEY_REQUEST_CODE = "requestCode";
43 const std::string DMS_VERSION_ID = "dmsVersion";
44 const std::string CMPT_PARAM_FREEINSTALL_BUNDLENAMES = "ohos.extra.param.key.allowedBundles";
45 constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
46 constexpr int32_t MAX_WAIT_TIME = 5000;
47 const char *PERMS[] = {
48 "ohos.permission.DISTRIBUTED_DATASYNC"
49 };
50 }
51
SetUpTestCase()52 void DistributedSchedStubTest::SetUpTestCase()
53 {
54 DTEST_LOG << "DistributedSchedStubTest::SetUpTestCase" << std::endl;
55 }
56
TearDownTestCase()57 void DistributedSchedStubTest::TearDownTestCase()
58 {
59 DTEST_LOG << "DistributedSchedStubTest::TearDownTestCase" << std::endl;
60 }
61
TearDown()62 void DistributedSchedStubTest::TearDown()
63 {
64 DTEST_LOG << "DistributedSchedStubTest::TearDown" << std::endl;
65 }
66
SetUp()67 void DistributedSchedStubTest::SetUp()
68 {
69 DTEST_LOG << "DistributedSchedStubTest::SetUp" << std::endl;
70 DistributedSchedUtil::MockProcessAndPermission(FOUNDATION_PROCESS_NAME, PERMS, 1);
71 }
72
WaitHandlerTaskDone(const std::shared_ptr<AppExecFwk::EventHandler> &handler)73 void DistributedSchedStubTest::WaitHandlerTaskDone(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
74 {
75 DTEST_LOG << "DistributedSchedStubTest::WaitHandlerTaskDone" << std::endl;
76 // Wait until all asyn tasks are completed before exiting the test suite
77 isTaskDone_ = false;
78 auto taskDoneNotifyTask = [this]() {
79 std::lock_guard<std::mutex> autoLock(taskDoneLock_);
80 isTaskDone_ = true;
81 taskDoneCondition_.notify_all();
82 };
83 if (handler != nullptr) {
84 handler->PostTask(taskDoneNotifyTask);
85 }
86 std::unique_lock<std::mutex> lock(taskDoneLock_);
87 taskDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
88 [&] () { return isTaskDone_;});
89 }
90
CallerInfoMarshalling(const CallerInfo& callerInfo, MessageParcel& data)91 void DistributedSchedStubTest::CallerInfoMarshalling(const CallerInfo& callerInfo, MessageParcel& data)
92 {
93 data.WriteInt32(callerInfo.uid);
94 data.WriteInt32(callerInfo.pid);
95 data.WriteInt32(callerInfo.callerType);
96 data.WriteString(callerInfo.sourceDeviceId);
97 data.WriteInt32(callerInfo.duid);
98 data.WriteString(callerInfo.callerAppId);
99 data.WriteInt32(callerInfo.dmsVersion);
100 }
101
FreeInstallInfoMarshalling(const CallerInfo& callerInfo, const DistributedSchedService::AccountInfo accountInfo, const int64_t taskId, MessageParcel& data)102 void DistributedSchedStubTest::FreeInstallInfoMarshalling(const CallerInfo& callerInfo,
103 const DistributedSchedService::AccountInfo accountInfo, const int64_t taskId, MessageParcel& data)
104 {
105 data.WriteInt32(callerInfo.uid);
106 data.WriteString(callerInfo.sourceDeviceId);
107 data.WriteInt32(accountInfo.accountType);
108 data.WriteStringVector(accountInfo.groupIdList);
109 data.WriteString(callerInfo.callerAppId);
110 data.WriteInt64(taskId);
111 }
112
113 /**
114 * @tc.name: OnRemoteRequest_001
115 * @tc.desc: check OnRemoteRequest
116 * @tc.type: FUNC
117 */
HWTEST_F(DistributedSchedStubTest, OnRemoteRequest_001, TestSize.Level3)118 HWTEST_F(DistributedSchedStubTest, OnRemoteRequest_001, TestSize.Level3)
119 {
120 DTEST_LOG << "DistributedSchedStubTest OnRemoteRequest_001 begin" << std::endl;
121 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY);
122 MessageParcel data;
123 MessageParcel reply;
124 MessageOption option;
125
126 data.WriteInterfaceToken(MOCK_INVALID_DESCRIPTOR);
127 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
128 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
129 DTEST_LOG << "DistributedSchedStubTest OnRemoteRequest_001 end" << std::endl;
130 }
131
132 /**
133 * @tc.name: StartRemoteAbilityInner_001
134 * @tc.desc: check StartRemoteAbilityInner
135 * @tc.type: FUNC
136 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_001, TestSize.Level3)137 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_001, TestSize.Level3)
138 {
139 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_001 begin" << std::endl;
140 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY);
141 MessageParcel data;
142 MessageParcel reply;
143 MessageOption option;
144
145 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
146 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
147 EXPECT_EQ(result, ERR_NULL_OBJECT);
148 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_001 end" << std::endl;
149 }
150
151 /**
152 * @tc.name: StartRemoteAbilityInner_002
153 * @tc.desc: check StartRemoteAbilityInner
154 * @tc.type: FUNC
155 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_002, TestSize.Level3)156 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_002, TestSize.Level3)
157 {
158 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_002 begin" << std::endl;
159 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY);
160 MessageParcel data;
161 MessageParcel reply;
162 MessageOption option;
163
164 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
165 Want want;
166 data.WriteParcelable(&want);
167 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
168 EXPECT_NE(result, ERR_NONE);
169
170 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
171 data.WriteParcelable(&want);
172 int32_t callingUid = 0;
173 data.WriteInt32(callingUid);
174 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
175 EXPECT_NE(result, ERR_NONE);
176
177 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
178 data.WriteParcelable(&want);
179 data.WriteInt32(callingUid);
180 int32_t requestCode = 0;
181 data.WriteInt32(requestCode);
182 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
183 EXPECT_NE(result, ERR_NONE);
184
185 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
186 data.WriteParcelable(&want);
187 data.WriteInt32(callingUid);
188 data.WriteInt32(requestCode);
189 uint32_t accessToken = 0;
190 data.WriteUint32(accessToken);
191 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
192 EXPECT_EQ(result, ERR_NONE);
193 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_002 end" << std::endl;
194 }
195
196 /**
197 * @tc.name: StartRemoteAbilityInner_003
198 * @tc.desc: check StartRemoteAbilityInner
199 * @tc.type: FUNC
200 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_003, TestSize.Level3)201 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_003, TestSize.Level3)
202 {
203 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_003 begin" << std::endl;
204 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY);
205 MessageParcel data;
206 MessageParcel reply;
207 MessageOption option;
208
209 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
210 Want want;
211 data.WriteParcelable(&want);
212 int32_t callingUid = 0;
213 data.WriteInt32(callingUid);
214 int32_t requestCode = 0;
215 data.WriteInt32(requestCode);
216 uint32_t accessToken = GetSelfTokenID();
217 data.WriteUint32(accessToken);
218 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
219 EXPECT_EQ(result, ERR_NONE);
220 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_003 end" << std::endl;
221 }
222
223 /**
224 * @tc.name: StartRemoteAbilityInner_004
225 * @tc.desc: check StartRemoteAbilityInner
226 * @tc.type: FUNC
227 * @tc.require: I70WDT
228 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_004, TestSize.Level3)229 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_004, TestSize.Level3)
230 {
231 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_004 begin" << std::endl;
232 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY);
233 MessageParcel data;
234 MessageParcel reply;
235 MessageOption option;
236
237 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
238 DistributedSchedUtil::MockPermission();
239 int32_t ret = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
240
241 Want want;
242 std::string eventName;
243 int32_t result = 0;
244 int32_t uid = -1;
245 DistributedSchedService::GetInstance().ReportEvent(want, eventName, result, uid);
246 EXPECT_EQ(ret, DMS_PERMISSION_DENIED);
247 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_004 end" << std::endl;
248 }
249
250 /**
251 * @tc.name: StartAbilityFromRemoteInner_001
252 * @tc.desc: check StartAbilityFromRemoteInner
253 * @tc.type: FUNC
254 */
HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_001, TestSize.Level3)255 HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_001, TestSize.Level3)
256 {
257 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_001 begin" << std::endl;
258 MessageParcel data;
259 MessageParcel reply;
260
261 int32_t result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
262 EXPECT_EQ(result, ERR_NULL_OBJECT);
263
264 Want want;
265 data.WriteParcelable(&want);
266 result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
267 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
268
269 data.WriteParcelable(&want);
270 AbilityInfo abilityInfo;
271 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
272 abilityInfo.ConvertToCompatiableAbilityInfo(compatibleAbilityInfo);
273 data.WriteParcelable(&compatibleAbilityInfo);
274 result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
275 EXPECT_NE(result, ERR_NONE);
276
277 data.WriteParcelable(&want);
278 data.WriteParcelable(&compatibleAbilityInfo);
279 int32_t requestCode = 0;
280 data.WriteInt32(requestCode);
281 result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
282 EXPECT_NE(result, ERR_NONE);
283
284 data.WriteParcelable(&want);
285 data.WriteParcelable(&compatibleAbilityInfo);
286 data.WriteInt32(requestCode);
287 CallerInfo callerInfo;
288 callerInfo.uid = 0;
289 data.WriteInt32(callerInfo.uid);
290 result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
291 EXPECT_NE(result, ERR_NONE);
292
293 data.WriteParcelable(&want);
294 data.WriteParcelable(&compatibleAbilityInfo);
295 data.WriteInt32(requestCode);
296 data.WriteInt32(callerInfo.uid);
297 callerInfo.sourceDeviceId = "";
298 data.WriteString(callerInfo.sourceDeviceId);
299 result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
300 EXPECT_EQ(result, ERR_NONE);
301 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_001 end" << std::endl;
302 }
303
304 /**
305 * @tc.name: StartAbilityFromRemoteInner_002
306 * @tc.desc: check StartAbilityFromRemoteInner
307 * @tc.type: FUNC
308 */
HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_002, TestSize.Level3)309 HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_002, TestSize.Level3)
310 {
311 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_002 begin" << std::endl;
312 MessageParcel data;
313 MessageParcel reply;
314 Want want;
315 AbilityInfo abilityInfo;
316 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
317 int32_t requestCode = 0;
318 CallerInfo callerInfo;
319 callerInfo.uid = 0;
320 callerInfo.sourceDeviceId = "";
321
322 data.WriteParcelable(&want);
323 data.WriteParcelable(&compatibleAbilityInfo);
324 data.WriteInt32(requestCode);
325 data.WriteInt32(callerInfo.uid);
326 data.WriteString(callerInfo.sourceDeviceId);
327 DistributedSchedService::AccountInfo accountInfo;
328 accountInfo.accountType = 0;
329 data.WriteInt32(accountInfo.accountType);
330 int32_t result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
331 EXPECT_EQ(result, ERR_NONE);
332
333 data.WriteParcelable(&want);
334 data.WriteParcelable(&compatibleAbilityInfo);
335 data.WriteInt32(requestCode);
336 data.WriteInt32(callerInfo.uid);
337 data.WriteString(callerInfo.sourceDeviceId);
338 data.WriteInt32(accountInfo.accountType);
339 callerInfo.callerAppId = "";
340 data.WriteString(callerInfo.callerAppId);
341 result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
342 EXPECT_EQ(result, ERR_NONE);
343 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_002 end" << std::endl;
344 }
345
346 /**
347 * @tc.name: StartAbilityFromRemoteInner_003
348 * @tc.desc: check StartAbilityFromRemoteInner
349 * @tc.type: FUNC
350 */
HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_003, TestSize.Level3)351 HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_003, TestSize.Level3)
352 {
353 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_003 begin" << std::endl;
354 MessageParcel data;
355 MessageParcel reply;
356
357 Want want;
358 data.WriteParcelable(&want);
359 AbilityInfo abilityInfo;
360 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
361 data.WriteParcelable(&compatibleAbilityInfo);
362 int32_t requestCode = 0;
363 data.WriteInt32(requestCode);
364 CallerInfo callerInfo;
365 callerInfo.uid = 0;
366 data.WriteInt32(callerInfo.uid);
367 callerInfo.sourceDeviceId = "";
368 data.WriteString(callerInfo.sourceDeviceId);
369 DistributedSchedService::AccountInfo accountInfo;
370 accountInfo.accountType = 0;
371 data.WriteInt32(accountInfo.accountType);
372 data.WriteStringVector(accountInfo.groupIdList);
373 callerInfo.callerAppId = "";
374 data.WriteString(callerInfo.callerAppId);
375 nlohmann::json extraInfoJson;
376 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
377 std::string extraInfo = extraInfoJson.dump();
378 data.WriteString(extraInfo);
379 int32_t result = DistributedSchedService::GetInstance().StartAbilityFromRemoteInner(data, reply);
380 EXPECT_EQ(result, ERR_NONE);
381 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_003 end" << std::endl;
382 }
383
384 /**
385 * @tc.name: SendResultFromRemoteInner_001
386 * @tc.desc: check SendResultFromRemoteInner
387 * @tc.type: FUNC
388 */
HWTEST_F(DistributedSchedStubTest, SendResultFromRemoteInner_001, TestSize.Level3)389 HWTEST_F(DistributedSchedStubTest, SendResultFromRemoteInner_001, TestSize.Level3)
390 {
391 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_001 begin" << std::endl;
392 MessageParcel data;
393 MessageParcel reply;
394
395 int32_t result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
396 EXPECT_EQ(result, ERR_NULL_OBJECT);
397
398 Want want;
399 data.WriteParcelable(&want);
400 result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
401 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
402
403 data.WriteParcelable(&want);
404 int32_t requestCode = 0;
405 data.WriteInt32(requestCode);
406 result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
407 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
408
409 data.WriteParcelable(&want);
410 data.WriteInt32(requestCode);
411 CallerInfo callerInfo;
412 callerInfo.uid = 0;
413 data.WriteInt32(callerInfo.uid);
414 result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
415 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
416
417 data.WriteParcelable(&want);
418 data.WriteInt32(requestCode);
419 data.WriteInt32(callerInfo.uid);
420 callerInfo.sourceDeviceId = "";
421 data.WriteString(callerInfo.sourceDeviceId);
422 result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
423 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
424 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_001 end" << std::endl;
425 }
426
427 /**
428 * @tc.name: SendResultFromRemoteInner_002
429 * @tc.desc: check SendResultFromRemoteInner
430 * @tc.type: FUNC
431 */
HWTEST_F(DistributedSchedStubTest, SendResultFromRemoteInner_002, TestSize.Level3)432 HWTEST_F(DistributedSchedStubTest, SendResultFromRemoteInner_002, TestSize.Level3)
433 {
434 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_002 begin" << std::endl;
435 MessageParcel data;
436 MessageParcel reply;
437 Want want;
438 int32_t requestCode = 0;
439 CallerInfo callerInfo;
440 callerInfo.uid = 0;
441 callerInfo.sourceDeviceId = "";
442 callerInfo.callerAppId = "";
443
444 data.WriteParcelable(&want);
445 data.WriteInt32(requestCode);
446 data.WriteInt32(callerInfo.uid);
447 data.WriteString(callerInfo.sourceDeviceId);
448 DistributedSchedService::AccountInfo accountInfo;
449 accountInfo.accountType = 0;
450 data.WriteInt32(accountInfo.accountType);
451 int32_t result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
452 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
453
454 data.WriteParcelable(&want);
455 data.WriteInt32(requestCode);
456 data.WriteInt32(callerInfo.uid);
457 data.WriteString(callerInfo.sourceDeviceId);
458 data.WriteInt32(accountInfo.accountType);
459 data.WriteString(callerInfo.callerAppId);
460 int32_t resultCode = 0;
461 data.WriteInt32(resultCode);
462 result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
463 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
464
465 data.WriteParcelable(&want);
466 data.WriteInt32(requestCode);
467 data.WriteInt32(callerInfo.uid);
468 data.WriteString(callerInfo.sourceDeviceId);
469 data.WriteInt32(accountInfo.accountType);
470 data.WriteString(callerInfo.callerAppId);
471 data.WriteInt32(resultCode);
472 nlohmann::json extraInfoJson;
473 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
474 std::string extraInfo = extraInfoJson.dump();
475 data.WriteString(extraInfo);
476 result = DistributedSchedService::GetInstance().SendResultFromRemoteInner(data, reply);
477 EXPECT_EQ(result, ERR_NONE);
478 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_002 end" << std::endl;
479 }
480
481 /**
482 * @tc.name: ContinueMissionInner_001
483 * @tc.desc: check ContinueMissionInner
484 * @tc.type: FUNC
485 */
HWTEST_F(DistributedSchedStubTest, ContinueMissionInner_001, TestSize.Level3)486 HWTEST_F(DistributedSchedStubTest, ContinueMissionInner_001, TestSize.Level3)
487 {
488 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_001 begin" << std::endl;
489 MessageParcel data;
490 MessageParcel reply;
491
492 DistributedSchedUtil::MockPermission();
493 int32_t result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
494 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
495 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_001 end" << std::endl;
496 }
497
498 /**
499 * @tc.name: ContinueMissionInner_002
500 * @tc.desc: check ContinueMissionInner
501 * @tc.type: FUNC
502 */
HWTEST_F(DistributedSchedStubTest, ContinueMissionInner_002, TestSize.Level3)503 HWTEST_F(DistributedSchedStubTest, ContinueMissionInner_002, TestSize.Level3)
504 {
505 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_002 begin" << std::endl;
506 MessageParcel data;
507 MessageParcel reply;
508
509 int32_t result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
510 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
511
512 std::string srcDevId = "";
513 data.WriteString(srcDevId);
514 result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
515 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
516
517 data.WriteString(srcDevId);
518 std::string dstDevId = "";
519 data.WriteString(dstDevId);
520 result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
521 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
522
523 data.WriteString(srcDevId);
524 data.WriteString(dstDevId);
525 int32_t missionId = 0;
526 data.WriteInt32(missionId);
527 result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
528 EXPECT_EQ(result, ERR_NULL_OBJECT);
529
530 data.WriteString(srcDevId);
531 data.WriteString(dstDevId);
532 data.WriteInt32(missionId);
533 sptr<IRemoteObject> dsched(new DistributedSchedService());
534 data.WriteRemoteObject(dsched);
535 result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
536 EXPECT_EQ(result, ERR_NULL_OBJECT);
537
538 data.WriteString(srcDevId);
539 data.WriteString(dstDevId);
540 data.WriteInt32(missionId);
541 data.WriteRemoteObject(dsched);
542 WantParams wantParams = {};
543 data.WriteParcelable(&wantParams);
544 result = DistributedSchedService::GetInstance().ContinueMissionInner(data, reply);
545 EXPECT_EQ(result, ERR_NULL_OBJECT);
546 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_002 end" << std::endl;
547 }
548
549 /**
550 * @tc.name:ContinueMissionOfBundleNameInner_003
551 * @tc.desc: call ContinueMissionOfBundleNameInner
552 * @tc.type: FUNC
553 * @tc.require: I7F8KH
554 */
HWTEST_F(DistributedSchedStubTest, ContinueMissionOfBundleNameInner_003, TestSize.Level3)555 HWTEST_F(DistributedSchedStubTest, ContinueMissionOfBundleNameInner_003, TestSize.Level3)
556 {
557 DTEST_LOG << "DistributedSchedStubTest ContinueMissionOfBundleNameInner_003 start" << std::endl;
558
559 MessageParcel data;
560 MessageParcel reply;
561
562 /**
563 * @tc.steps: step1. test ContinueMission when callback is nullptr;
564 */
565 std::string srcDevId = "srcDevId";
566 std::string dstDevId = "dstDevId";
567 std::string bundleName = "bundleName";
568 data.WriteString(srcDevId);
569 data.WriteString(dstDevId);
570 data.WriteString(bundleName);
571 int32_t result = DistributedSchedService::GetInstance().ContinueMissionOfBundleNameInner(data, reply);
572 EXPECT_EQ(result, ERR_NULL_OBJECT);
573
574 DTEST_LOG << "DistributedSchedStubTest ContinueMissionOfBundleNameInner_003 end" << std::endl;
575 }
576
577 /**
578 * @tc.name: StartContinuationInner_001
579 * @tc.desc: check StartContinuationInner
580 * @tc.type: FUNC
581 */
HWTEST_F(DistributedSchedStubTest, StartContinuationInner_001, TestSize.Level3)582 HWTEST_F(DistributedSchedStubTest, StartContinuationInner_001, TestSize.Level3)
583 {
584 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_001 begin" << std::endl;
585 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_CONTINUATION);
586 MessageParcel data;
587 MessageParcel reply;
588 MessageOption option;
589
590 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
591 DistributedSchedUtil::MockPermission();
592 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
593 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
594 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_001 end" << std::endl;
595 }
596
597 /**
598 * @tc.name: StartContinuationInner_002
599 * @tc.desc: check StartContinuationInner
600 * @tc.type: FUNC
601 */
HWTEST_F(DistributedSchedStubTest, StartContinuationInner_002, TestSize.Level3)602 HWTEST_F(DistributedSchedStubTest, StartContinuationInner_002, TestSize.Level3)
603 {
604 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_002 begin" << std::endl;
605 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_CONTINUATION);
606 MessageParcel data;
607 MessageParcel reply;
608 MessageOption option;
609
610 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
611 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
612 EXPECT_EQ(result, ERR_NULL_OBJECT);
613
614 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
615 Want want;
616 data.WriteParcelable(&want);
617 int32_t missionId = 0;
618 data.WriteInt32(missionId);
619 int32_t callerUid = 0;
620 data.WriteInt32(callerUid);
621 int32_t status = 0;
622 data.WriteInt32(status);
623 uint32_t accessToken = GetSelfTokenID();
624 data.WriteUint32(accessToken);
625 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
626 EXPECT_EQ(result, ERR_NONE);
627 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_002 end" << std::endl;
628 }
629
630 /**
631 * @tc.name: StartContinuationInner_003
632 * @tc.desc: check StartContinuationInner
633 * @tc.type: FUNC
634 */
HWTEST_F(DistributedSchedStubTest, StartContinuationInner_003, TestSize.Level3)635 HWTEST_F(DistributedSchedStubTest, StartContinuationInner_003, TestSize.Level3)
636 {
637 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_003 begin" << std::endl;
638 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_CONTINUATION);
639 MessageParcel data;
640 MessageParcel reply;
641 MessageOption option;
642
643 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
644 Want want;
645 data.WriteParcelable(&want);
646 int32_t missionId = 0;
647 data.WriteInt32(missionId);
648 int32_t callerUid = 0;
649 data.WriteInt32(callerUid);
650 int32_t status = 0;
651 data.WriteInt32(status);
652 uint32_t accessToken = 0;
653 data.WriteUint32(accessToken);
654 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
655 EXPECT_EQ(result, ERR_NONE);
656 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_003 end" << std::endl;
657 }
658
659 /**
660 * @tc.name: NotifyCompleteContinuationInner_001
661 * @tc.desc: check NotifyCompleteContinuationInner
662 * @tc.type: FUNC
663 */
HWTEST_F(DistributedSchedStubTest, NotifyCompleteContinuationInner_001, TestSize.Level3)664 HWTEST_F(DistributedSchedStubTest, NotifyCompleteContinuationInner_001, TestSize.Level3)
665 {
666 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_001 begin" << std::endl;
667 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_COMPLETE_CONTINUATION);
668 MessageParcel data;
669 MessageParcel reply;
670 MessageOption option;
671
672 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
673 DistributedSchedUtil::MockPermission();
674 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
675 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
676 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_001 end" << std::endl;
677 }
678
679 /**
680 * @tc.name: NotifyCompleteContinuationInner_002
681 * @tc.desc: check NotifyCompleteContinuationInner
682 * @tc.type: FUNC
683 */
HWTEST_F(DistributedSchedStubTest, NotifyCompleteContinuationInner_002, TestSize.Level3)684 HWTEST_F(DistributedSchedStubTest, NotifyCompleteContinuationInner_002, TestSize.Level3)
685 {
686 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_002 begin" << std::endl;
687 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_COMPLETE_CONTINUATION);
688 MessageParcel data;
689 MessageParcel reply;
690 MessageOption option;
691
692 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
693 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
694 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
695
696 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
697 std::u16string devId = u"192.168.43.100";
698 data.WriteString16(devId);
699 int32_t sessionId = 0;
700 data.WriteInt32(sessionId);
701 bool isSuccess = false;
702 data.WriteBool(isSuccess);
703 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
704 EXPECT_EQ(result, ERR_NONE);
705 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_002 end" << std::endl;
706 }
707
708 /**
709 * @tc.name: NotifyContinuationResultFromRemoteInner_001
710 * @tc.desc: check NotifyContinuationResultFromRemoteInner
711 * @tc.type: FUNC
712 */
HWTEST_F(DistributedSchedStubTest, NotifyContinuationResultFromRemoteInner_001, TestSize.Level3)713 HWTEST_F(DistributedSchedStubTest, NotifyContinuationResultFromRemoteInner_001, TestSize.Level3)
714 {
715 DTEST_LOG << "DistributedSchedStubTest NotifyContinuationResultFromRemoteInner_001 begin" << std::endl;
716 MessageParcel data;
717 MessageParcel reply;
718
719 int32_t sessionId = 0;
720 data.WriteInt32(sessionId);
721 bool continuationResult = false;
722 data.WriteBool(continuationResult);
723 std::string info(DMS_VERSION_ID);
724 data.WriteString(info.c_str());
725 int32_t result = DistributedSchedService::GetInstance().NotifyContinuationResultFromRemoteInner(data, reply);
726 EXPECT_EQ(result, INVALID_REMOTE_PARAMETERS_ERR);
727 DTEST_LOG << "DistributedSchedStubTest NotifyContinuationResultFromRemoteInner_001 end" << std::endl;
728 }
729
730 /**
731 * @tc.name: ConnectRemoteAbilityInner_001
732 * @tc.desc: check ConnectRemoteAbilityInner
733 * @tc.type: FUNC
734 */
HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_001, TestSize.Level3)735 HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_001, TestSize.Level3)
736 {
737 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_001 begin" << std::endl;
738 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::CONNECT_REMOTE_ABILITY);
739 MessageParcel data;
740 MessageParcel reply;
741 MessageOption option;
742
743 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
744 DistributedSchedUtil::MockPermission();
745 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
746 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
747 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_001 end" << std::endl;
748 }
749
750 /**
751 * @tc.name: ConnectRemoteAbilityInner_002
752 * @tc.desc: check ConnectRemoteAbilityInner
753 * @tc.type: FUNC
754 */
HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_002, TestSize.Level3)755 HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_002, TestSize.Level3)
756 {
757 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_002 begin" << std::endl;
758 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::CONNECT_REMOTE_ABILITY);
759 MessageParcel data;
760 MessageParcel reply;
761 MessageOption option;
762
763 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
764 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
765 EXPECT_EQ(result, ERR_NULL_OBJECT);
766
767 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
768 Want want;
769 data.WriteParcelable(&want);
770 int32_t callerUid = 0;
771 data.WriteInt32(callerUid);
772 int32_t callerPid = 0;
773 data.WriteInt32(callerPid);
774 uint32_t accessToken = 0;
775 data.WriteUint32(accessToken);
776 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
777 EXPECT_EQ(result, ERR_NONE);
778 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_002 end" << std::endl;
779 }
780
781 /**
782 * @tc.name: ConnectRemoteAbilityInner_003
783 * @tc.desc: check ConnectRemoteAbilityInner
784 * @tc.type: FUNC
785 */
HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_003, TestSize.Level3)786 HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_003, TestSize.Level3)
787 {
788 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_003 begin" << std::endl;
789 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::CONNECT_REMOTE_ABILITY);
790 MessageParcel data;
791 MessageParcel reply;
792 MessageOption option;
793
794 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
795 Want want;
796 data.WriteParcelable(&want);
797 int32_t callerUid = 0;
798 data.WriteInt32(callerUid);
799 int32_t callerPid = 0;
800 data.WriteInt32(callerPid);
801 uint32_t accessToken = GetSelfTokenID();
802 data.WriteUint32(accessToken);
803 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
804 EXPECT_EQ(result, ERR_NONE);
805 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_003 end" << std::endl;
806 }
807
808 /**
809 * @tc.name: DisconnectRemoteAbilityInner_001
810 * @tc.desc: check DisconnectRemoteAbilityInner
811 * @tc.type: FUNC
812 */
HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_001, TestSize.Level3)813 HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_001, TestSize.Level3)
814 {
815 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_001 begin" << std::endl;
816 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::DISCONNECT_REMOTE_ABILITY);
817 MessageParcel data;
818 MessageParcel reply;
819 MessageOption option;
820
821 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
822 DistributedSchedUtil::MockPermission();
823 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
824 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
825 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_001 end" << std::endl;
826 }
827
828 /**
829 * @tc.name: DisconnectRemoteAbilityInner_002
830 * @tc.desc: check DisconnectRemoteAbilityInner
831 * @tc.type: FUNC
832 */
HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_002, TestSize.Level3)833 HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_002, TestSize.Level3)
834 {
835 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_002 begin" << std::endl;
836 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::DISCONNECT_REMOTE_ABILITY);
837 MessageParcel data;
838 MessageParcel reply;
839 MessageOption option;
840
841 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
842 sptr<IRemoteObject> connect = nullptr;
843 data.WriteRemoteObject(connect);
844 int32_t callerUid = 0;
845 data.WriteInt32(callerUid);
846 uint32_t accessToken = 0;
847 data.WriteUint32(accessToken);
848 int result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
849 EXPECT_EQ(result, ERR_NONE);
850 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_002 end" << std::endl;
851 }
852
853 /**
854 * @tc.name: DisconnectRemoteAbilityInner_003
855 * @tc.desc: check DisconnectRemoteAbilityInner
856 * @tc.type: FUNC
857 */
HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_003, TestSize.Level3)858 HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_003, TestSize.Level3)
859 {
860 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_003 begin" << std::endl;
861 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::DISCONNECT_REMOTE_ABILITY);
862 MessageParcel data;
863 MessageParcel reply;
864 MessageOption option;
865
866 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
867 sptr<IRemoteObject> connect = nullptr;
868 data.WriteRemoteObject(connect);
869 int32_t callerUid = 0;
870 data.WriteInt32(callerUid);
871 uint32_t accessToken = GetSelfTokenID();
872 data.WriteUint32(accessToken);
873 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
874 EXPECT_EQ(result, ERR_NONE);
875 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_003 end" << std::endl;
876 }
877
878 /**
879 * @tc.name: ConnectAbilityFromRemoteInner_001
880 * @tc.desc: check ConnectAbilityFromRemoteInner
881 * @tc.type: FUNC
882 */
HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteInner_001, TestSize.Level3)883 HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteInner_001, TestSize.Level3)
884 {
885 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_001 begin" << std::endl;
886 MessageParcel data;
887 MessageParcel reply;
888
889 int32_t result = DistributedSchedService::GetInstance().ConnectAbilityFromRemoteInner(data, reply);
890 EXPECT_EQ(result, ERR_NULL_OBJECT);
891
892 Want want;
893 data.WriteParcelable(&want);
894 result = DistributedSchedService::GetInstance().ConnectAbilityFromRemoteInner(data, reply);
895 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
896
897 data.WriteParcelable(&want);
898 AbilityInfo abilityInfo;
899 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
900 abilityInfo.ConvertToCompatiableAbilityInfo(compatibleAbilityInfo);
901 data.WriteParcelable(&compatibleAbilityInfo);
902 sptr<IRemoteObject> connect = nullptr;
903 data.WriteRemoteObject(connect);
904 CallerInfo callerInfo;
905 callerInfo.uid = 0;
906 data.WriteInt32(callerInfo.uid);
907 callerInfo.pid = 0;
908 data.WriteInt32(callerInfo.pid);
909 callerInfo.sourceDeviceId = "";
910 data.WriteString(callerInfo.sourceDeviceId);
911 DistributedSchedService::AccountInfo accountInfo;
912 accountInfo.accountType = 0;
913 data.WriteInt32(accountInfo.accountType);
914 callerInfo.callerAppId = "";
915 data.WriteString(callerInfo.callerAppId);
916 result = DistributedSchedService::GetInstance().ConnectAbilityFromRemoteInner(data, reply);
917 EXPECT_EQ(result, ERR_NONE);
918 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_001 end" << std::endl;
919 }
920
921 /**
922 * @tc.name: ConnectAbilityFromRemoteInner_002
923 * @tc.desc: check ConnectAbilityFromRemoteInner
924 * @tc.type: FUNC
925 */
HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteInner_002, TestSize.Level3)926 HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteInner_002, TestSize.Level3)
927 {
928 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_002 begin" << std::endl;
929 MessageParcel data;
930 MessageParcel reply;
931
932 Want want;
933 data.WriteParcelable(&want);
934 AbilityInfo abilityInfo;
935 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
936 abilityInfo.ConvertToCompatiableAbilityInfo(compatibleAbilityInfo);
937 data.WriteParcelable(&compatibleAbilityInfo);
938 sptr<IRemoteObject> connect = nullptr;
939 data.WriteRemoteObject(connect);
940 CallerInfo callerInfo;
941 callerInfo.uid = 0;
942 data.WriteInt32(callerInfo.uid);
943 callerInfo.pid = 0;
944 data.WriteInt32(callerInfo.pid);
945 callerInfo.sourceDeviceId = "";
946 data.WriteString(callerInfo.sourceDeviceId);
947 DistributedSchedService::AccountInfo accountInfo;
948 accountInfo.accountType = 0;
949 data.WriteInt32(accountInfo.accountType);
950 data.WriteStringVector(accountInfo.groupIdList);
951 callerInfo.callerAppId = "";
952 data.WriteString(callerInfo.callerAppId);
953 nlohmann::json extraInfoJson;
954 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
955 std::string extraInfo = extraInfoJson.dump();
956 data.WriteString(extraInfo);
957 int32_t result = DistributedSchedService::GetInstance().ConnectAbilityFromRemoteInner(data, reply);
958 EXPECT_EQ(result, ERR_NONE);
959 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_002 end" << std::endl;
960 }
961
962 /**
963 * @tc.name: DisconnectAbilityFromRemoteInner_001
964 * @tc.desc: check DisconnectAbilityFromRemoteInner
965 * @tc.type: FUNC
966 */
HWTEST_F(DistributedSchedStubTest, DisconnectAbilityFromRemoteInner_001, TestSize.Level3)967 HWTEST_F(DistributedSchedStubTest, DisconnectAbilityFromRemoteInner_001, TestSize.Level3)
968 {
969 DTEST_LOG << "DistributedSchedStubTest DisconnectAbilityFromRemoteInner_001 begin" << std::endl;
970 MessageParcel data;
971 MessageParcel reply;
972
973 int32_t uid = 0;
974 data.WriteInt32(uid);
975 std::string sourceDeviceId = "";
976 data.WriteString(sourceDeviceId);
977 int32_t result = DistributedSchedService::GetInstance().DisconnectAbilityFromRemoteInner(data, reply);
978 EXPECT_EQ(result, ERR_NONE);
979 DTEST_LOG << "DistributedSchedStubTest DisconnectAbilityFromRemoteInner_001 end" << std::endl;
980 }
981
982 /**
983 * @tc.name: NotifyProcessDiedFromRemoteInner_001
984 * @tc.desc: check NotifyProcessDiedFromRemoteInner
985 * @tc.type: FUNC
986 */
HWTEST_F(DistributedSchedStubTest, NotifyProcessDiedFromRemoteInner_001, TestSize.Level3)987 HWTEST_F(DistributedSchedStubTest, NotifyProcessDiedFromRemoteInner_001, TestSize.Level3)
988 {
989 DTEST_LOG << "DistributedSchedStubTest NotifyProcessDiedFromRemoteInner_001 begin" << std::endl;
990 MessageParcel data;
991 MessageParcel reply;
992
993 int32_t uid = 0;
994 data.WriteInt32(uid);
995 int32_t pid = 0;
996 data.WriteInt32(pid);
997 std::string sourceDeviceId = "";
998 data.WriteString(sourceDeviceId);
999 int32_t result = DistributedSchedService::GetInstance().NotifyProcessDiedFromRemoteInner(data, reply);
1000 EXPECT_EQ(result, ERR_NONE);
1001 DTEST_LOG << "DistributedSchedStubTest NotifyProcessDiedFromRemoteInner_001 end" << std::endl;
1002 }
1003
1004 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
1005 /**
1006 * @tc.name: GetMissionInfosInner_001
1007 * @tc.desc: check GetMissionInfosInner
1008 * @tc.type: FUNC
1009 */
HWTEST_F(DistributedSchedStubTest, GetMissionInfosInner_001, TestSize.Level3)1010 HWTEST_F(DistributedSchedStubTest, GetMissionInfosInner_001, TestSize.Level3)
1011 {
1012 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_001 begin" << std::endl;
1013 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::GET_MISSION_INFOS);
1014 MessageParcel data;
1015 MessageParcel reply;
1016 MessageOption option;
1017
1018 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1019 DistributedSchedUtil::MockPermission();
1020 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1021 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1022 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_001 end" << std::endl;
1023 }
1024
1025 /**
1026 * @tc.name: GetMissionInfosInner_002
1027 * @tc.desc: check GetMissionInfosInner
1028 * @tc.type: FUNC
1029 */
HWTEST_F(DistributedSchedStubTest, GetMissionInfosInner_002, TestSize.Level3)1030 HWTEST_F(DistributedSchedStubTest, GetMissionInfosInner_002, TestSize.Level3)
1031 {
1032 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_002 begin" << std::endl;
1033 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::GET_MISSION_INFOS);
1034 MessageParcel data;
1035 MessageParcel reply;
1036 MessageOption option;
1037
1038 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1039 std::u16string deviceId = u"192.168.43.100";
1040 data.WriteString16(deviceId);
1041 int32_t numMissions = 0;
1042 data.WriteInt32(numMissions);
1043 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1044 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1045 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_002 end" << std::endl;
1046 }
1047
1048 /**
1049 * @tc.name: GetRemoteMissionSnapshotInfoInner_001
1050 * @tc.desc: check GetRemoteMissionSnapshotInfoInner
1051 * @tc.type: FUNC
1052 */
HWTEST_F(DistributedSchedStubTest, GetRemoteMissionSnapshotInfoInner_001, TestSize.Level3)1053 HWTEST_F(DistributedSchedStubTest, GetRemoteMissionSnapshotInfoInner_001, TestSize.Level3)
1054 {
1055 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_001 begin" << std::endl;
1056 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::GET_REMOTE_MISSION_SNAPSHOT_INFO);
1057 MessageParcel data;
1058 MessageParcel reply;
1059 MessageOption option;
1060
1061 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1062 DistributedSchedUtil::MockPermission();
1063 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1064 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1065 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_001 end" << std::endl;
1066 }
1067
1068 /**
1069 * @tc.name: GetRemoteMissionSnapshotInfoInner_002
1070 * @tc.desc: check GetRemoteMissionSnapshotInfoInner
1071 * @tc.type: FUNC
1072 */
HWTEST_F(DistributedSchedStubTest, GetRemoteMissionSnapshotInfoInner_002, TestSize.Level3)1073 HWTEST_F(DistributedSchedStubTest, GetRemoteMissionSnapshotInfoInner_002, TestSize.Level3)
1074 {
1075 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_002 begin" << std::endl;
1076 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::GET_REMOTE_MISSION_SNAPSHOT_INFO);
1077 MessageParcel data;
1078 MessageParcel reply;
1079 MessageOption option;
1080
1081 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1082 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1083 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1084
1085 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1086 std::string networkId = "255.255.255.255";
1087 data.WriteString(networkId);
1088 int32_t missionId = -1;
1089 data.WriteInt32(missionId);
1090 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1091 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1092
1093 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1094 data.WriteString(networkId);
1095 missionId = 0;
1096 data.WriteInt32(missionId);
1097 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1098 EXPECT_EQ(result, ERR_NULL_OBJECT);
1099 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_002 end" << std::endl;
1100 }
1101
1102 /**
1103 * @tc.name: RegisterMissionListenerInner_001
1104 * @tc.desc: check RegisterMissionListenerInner
1105 * @tc.type: FUNC
1106 */
HWTEST_F(DistributedSchedStubTest, RegisterMissionListenerInner_001, TestSize.Level3)1107 HWTEST_F(DistributedSchedStubTest, RegisterMissionListenerInner_001, TestSize.Level3)
1108 {
1109 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_001 begin" << std::endl;
1110 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_MISSION_LISTENER);
1111 MessageParcel data;
1112 MessageParcel reply;
1113 MessageOption option;
1114
1115 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1116 DistributedSchedUtil::MockPermission();
1117 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1118 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1119 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_001 end" << std::endl;
1120 }
1121
1122 /**
1123 * @tc.name: RegisterMissionListenerInner_002
1124 * @tc.desc: check RegisterMissionListenerInner
1125 * @tc.type: FUNC
1126 */
HWTEST_F(DistributedSchedStubTest, RegisterMissionListenerInner_002, TestSize.Level3)1127 HWTEST_F(DistributedSchedStubTest, RegisterMissionListenerInner_002, TestSize.Level3)
1128 {
1129 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_002 begin" << std::endl;
1130 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_MISSION_LISTENER);
1131 MessageParcel data;
1132 MessageParcel reply;
1133 MessageOption option;
1134
1135 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1136 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1137 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1138
1139 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1140 std::u16string devId = u"192.168.43.100";
1141 data.WriteString16(devId);
1142 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1143 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1144
1145 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1146 data.WriteString16(devId);
1147 sptr<IRemoteObject> missionChangedListener(new DistributedSchedService());
1148 data.WriteRemoteObject(missionChangedListener);
1149 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1150 EXPECT_EQ(result, ERR_NONE);
1151 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_002 end" << std::endl;
1152 }
1153
1154 /**
1155 * @tc.name: RegisterMissionListenerInner_003
1156 * @tc.desc: check RegisterOnListenerInner
1157 * @tc.type: FUNC
1158 * @tc.require: I7F8KH
1159 */
HWTEST_F(DistributedSchedStubTest, RegisterOnListenerInner_002, TestSize.Level3)1160 HWTEST_F(DistributedSchedStubTest, RegisterOnListenerInner_002, TestSize.Level3)
1161 {
1162 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_003 begin" << std::endl;
1163
1164
1165 MessageParcel data;
1166 MessageParcel reply;
1167
1168 /**
1169 * @tc.steps: step1. test RegisterOnListenerInner when type is empty;
1170 */
1171 int32_t result = DistributedSchedService::GetInstance().RegisterOnListenerInner(data, reply);
1172 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1173
1174 /**
1175 * @tc.steps: step2. test RegisterOnListenerInner when type is not empty;
1176 */
1177 data.WriteString("type");
1178 result = DistributedSchedService::GetInstance().RegisterOnListenerInner(data, reply);
1179 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1180
1181 /**
1182 * @tc.steps: step3. test RegisterOnListenerInner when onListener is not empty;
1183 */
1184 data.WriteString("type");
1185 sptr<IRemoteObject> onListener(new DistributedSchedService());
1186 data.WriteRemoteObject(onListener);
1187 result = DistributedSchedService::GetInstance().RegisterOnListenerInner(data, reply);
1188 EXPECT_EQ(result, ERR_OK);
1189
1190 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_003 end" << std::endl;
1191 }
1192
1193 /**
1194 * @tc.name: UnRegisterMissionListenerInner_001
1195 * @tc.desc: check UnRegisterMissionListenerInner
1196 * @tc.type: FUNC
1197 */
HWTEST_F(DistributedSchedStubTest, UnRegisterMissionListenerInner_001, TestSize.Level3)1198 HWTEST_F(DistributedSchedStubTest, UnRegisterMissionListenerInner_001, TestSize.Level3)
1199 {
1200 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_001 begin" << std::endl;
1201 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::UNREGISTER_MISSION_LISTENER);
1202 MessageParcel data;
1203 MessageParcel reply;
1204 MessageOption option;
1205
1206 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1207 DistributedSchedUtil::MockPermission();
1208 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1209 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1210 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_001 end" << std::endl;
1211 }
1212
1213 /**
1214 * @tc.name: UnRegisterMissionListenerInner_002
1215 * @tc.desc: check UnRegisterMissionListenerInner
1216 * @tc.type: FUNC
1217 */
HWTEST_F(DistributedSchedStubTest, UnRegisterMissionListenerInner_002, TestSize.Level3)1218 HWTEST_F(DistributedSchedStubTest, UnRegisterMissionListenerInner_002, TestSize.Level3)
1219 {
1220 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_002 begin" << std::endl;
1221 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::UNREGISTER_MISSION_LISTENER);
1222 MessageParcel data;
1223 MessageParcel reply;
1224 MessageOption option;
1225
1226 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1227 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1228 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1229
1230 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1231 std::u16string devId = u"192.168.43.100";
1232 data.WriteString16(devId);
1233 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1234 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1235
1236 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1237 data.WriteString16(devId);
1238 sptr<IRemoteObject> missionChangedListener(new DistributedSchedService());
1239 data.WriteRemoteObject(missionChangedListener);
1240 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1241 EXPECT_EQ(result, ERR_NONE);
1242 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_002 end" << std::endl;
1243 }
1244
1245 /**
1246 * @tc.name: StartSyncMissionsFromRemoteInner_001
1247 * @tc.desc: check StartSyncMissionsFromRemoteInner
1248 * @tc.type: FUNC
1249 */
HWTEST_F(DistributedSchedStubTest, StartSyncMissionsFromRemoteInner_001, TestSize.Level3)1250 HWTEST_F(DistributedSchedStubTest, StartSyncMissionsFromRemoteInner_001, TestSize.Level3)
1251 {
1252 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_001 begin" << std::endl;
1253 MessageParcel data;
1254 MessageParcel reply;
1255
1256 int32_t result = DistributedSchedService::GetInstance().StartSyncMissionsFromRemoteInner(data, reply);
1257 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1258 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_001 end" << std::endl;
1259 }
1260
1261 /**
1262 * @tc.name: StartSyncMissionsFromRemoteInner_002
1263 * @tc.desc: check StartSyncMissionsFromRemoteInner
1264 * @tc.type: FUNC
1265 */
HWTEST_F(DistributedSchedStubTest, StartSyncMissionsFromRemoteInner_002, TestSize.Level3)1266 HWTEST_F(DistributedSchedStubTest, StartSyncMissionsFromRemoteInner_002, TestSize.Level3)
1267 {
1268 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_002 begin" << std::endl;
1269 DistributedSchedUtil::MockManageMissions();
1270 MessageParcel data;
1271 MessageParcel reply;
1272 CallerInfo callerInfo;
1273 CallerInfoMarshalling(callerInfo, data);
1274
1275 DistributedSchedMissionManager::GetInstance().Init();
1276 int32_t result = DistributedSchedService::GetInstance().StartSyncMissionsFromRemoteInner(data, reply);
1277 EXPECT_EQ(result, ERR_NONE);
1278 WaitHandlerTaskDone(DistributedSchedMissionManager::GetInstance().missionHandler_);
1279 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_002 end" << std::endl;
1280 }
1281
1282 /**
1283 * @tc.name: StopSyncRemoteMissionsInner_001
1284 * @tc.desc: check StopSyncRemoteMissionsInner
1285 * @tc.type: FUNC
1286 */
HWTEST_F(DistributedSchedStubTest, StopSyncRemoteMissionsInner_001, TestSize.Level3)1287 HWTEST_F(DistributedSchedStubTest, StopSyncRemoteMissionsInner_001, TestSize.Level3)
1288 {
1289 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_001 begin" << std::endl;
1290 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::STOP_SYNC_MISSIONS);
1291 MessageParcel data;
1292 MessageParcel reply;
1293 MessageOption option;
1294
1295 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1296 DistributedSchedUtil::MockPermission();
1297 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1298 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1299 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_001 end" << std::endl;
1300 }
1301
1302 /**
1303 * @tc.name: StopSyncRemoteMissionsInner_002
1304 * @tc.desc: check StopSyncRemoteMissionsInner
1305 * @tc.type: FUNC
1306 */
HWTEST_F(DistributedSchedStubTest, StopSyncRemoteMissionsInner_002, TestSize.Level3)1307 HWTEST_F(DistributedSchedStubTest, StopSyncRemoteMissionsInner_002, TestSize.Level3)
1308 {
1309 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_002 begin" << std::endl;
1310 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::STOP_SYNC_MISSIONS);
1311 MessageParcel data;
1312 MessageParcel reply;
1313 MessageOption option;
1314
1315 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1316 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1317 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1318
1319 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1320 std::u16string deviceId = u"192.168.43.100";
1321 data.WriteString16(deviceId);
1322 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1323 EXPECT_EQ(result, ERR_NONE);
1324 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_002 end" << std::endl;
1325 }
1326
1327 /**
1328 * @tc.name: StopSyncMissionsFromRemoteInner_001
1329 * @tc.desc: check StopSyncMissionsFromRemoteInner
1330 * @tc.type: FUNC
1331 */
HWTEST_F(DistributedSchedStubTest, StopSyncMissionsFromRemoteInner_001, TestSize.Level3)1332 HWTEST_F(DistributedSchedStubTest, StopSyncMissionsFromRemoteInner_001, TestSize.Level3)
1333 {
1334 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_001 begin" << std::endl;
1335 MessageParcel data;
1336 MessageParcel reply;
1337
1338 int32_t result = DistributedSchedService::GetInstance().StopSyncMissionsFromRemoteInner(data, reply);
1339 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1340 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_001 end" << std::endl;
1341 }
1342
1343 /**
1344 * @tc.name: StopSyncMissionsFromRemoteInner_002
1345 * @tc.desc: check StopSyncMissionsFromRemoteInner
1346 * @tc.type: FUNC
1347 */
HWTEST_F(DistributedSchedStubTest, StopSyncMissionsFromRemoteInner_002, TestSize.Level3)1348 HWTEST_F(DistributedSchedStubTest, StopSyncMissionsFromRemoteInner_002, TestSize.Level3)
1349 {
1350 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_002 begin" << std::endl;
1351 MessageParcel data;
1352 MessageParcel reply;
1353 CallerInfo callerInfo;
1354 CallerInfoMarshalling(callerInfo, data);
1355
1356 DistributedSchedMissionManager::GetInstance().Init();
1357 int32_t result = DistributedSchedService::GetInstance().StopSyncMissionsFromRemoteInner(data, reply);
1358 EXPECT_NE(result, ERR_FLATTEN_OBJECT);
1359 WaitHandlerTaskDone(DistributedSchedMissionManager::GetInstance().missionHandler_);
1360 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_002 end" << std::endl;
1361 }
1362
1363 /**
1364 * @tc.name: NotifyMissionsChangedFromRemoteInner_001
1365 * @tc.desc: check NotifyMissionsChangedFromRemoteInner
1366 * @tc.type: FUNC
1367 */
HWTEST_F(DistributedSchedStubTest, NotifyMissionsChangedFromRemoteInner_001, TestSize.Level3)1368 HWTEST_F(DistributedSchedStubTest, NotifyMissionsChangedFromRemoteInner_001, TestSize.Level3)
1369 {
1370 DTEST_LOG << "DistributedSchedStubTest NotifyMissionsChangedFromRemoteInner_001 begin" << std::endl;
1371 MessageParcel data;
1372 MessageParcel reply;
1373
1374 int32_t version = 0;
1375 data.WriteInt32(version);
1376 int32_t result = DistributedSchedService::GetInstance().NotifyMissionsChangedFromRemoteInner(data, reply);
1377 EXPECT_EQ(result, ERR_NONE);
1378 DTEST_LOG << "DistributedSchedStubTest NotifyMissionsChangedFromRemoteInner_001 end" << std::endl;
1379 }
1380
1381 /**
1382 * @tc.name: StartSyncRemoteMissionsInner_001
1383 * @tc.desc: check StartSyncRemoteMissionsInner
1384 * @tc.type: FUNC
1385 */
HWTEST_F(DistributedSchedStubTest, StartSyncRemoteMissionsInner_001, TestSize.Level3)1386 HWTEST_F(DistributedSchedStubTest, StartSyncRemoteMissionsInner_001, TestSize.Level3)
1387 {
1388 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_001 begin" << std::endl;
1389 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_SYNC_MISSIONS);
1390 MessageParcel data;
1391 MessageParcel reply;
1392 MessageOption option;
1393
1394 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1395 DistributedSchedUtil::MockPermission();
1396 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1397 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1398 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_001 end" << std::endl;
1399 }
1400
1401 /**
1402 * @tc.name: StartSyncRemoteMissionsInner_002
1403 * @tc.desc: check StartSyncRemoteMissionsInner
1404 * @tc.type: FUNC
1405 */
HWTEST_F(DistributedSchedStubTest, StartSyncRemoteMissionsInner_002, TestSize.Level3)1406 HWTEST_F(DistributedSchedStubTest, StartSyncRemoteMissionsInner_002, TestSize.Level3)
1407 {
1408 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_002 begin" << std::endl;
1409 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_SYNC_MISSIONS);
1410 MessageParcel data;
1411 MessageParcel reply;
1412 MessageOption option;
1413
1414 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1415 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1416 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1417
1418 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1419 std::u16string deviceId = u"192.168.43.100";
1420 data.WriteString16(deviceId);
1421 bool fixConflict = false;
1422 data.WriteBool(fixConflict);
1423 int64_t tag = 0;
1424 data.WriteInt64(tag);
1425 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1426 EXPECT_EQ(result, ERR_NONE);
1427 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_002 end" << std::endl;
1428 }
1429
1430 /**
1431 * @tc.name: SetMissionContinueStateInner_001
1432 * @tc.desc: check SetMissionContinueStateInner
1433 * @tc.type: FUNC
1434 */
HWTEST_F(DistributedSchedStubTest, SetMissionContinueStateInner_001, TestSize.Level3)1435 HWTEST_F(DistributedSchedStubTest, SetMissionContinueStateInner_001, TestSize.Level3)
1436 {
1437 DTEST_LOG << "DistributedSchedStubTest SetMissionContinueStateInner_001 begin" << std::endl;
1438 MessageParcel data;
1439 MessageParcel reply;
1440
1441 int32_t missionId = 0;
1442 int32_t state = 0;
1443 data.WriteInt32(missionId);
1444 data.WriteInt32(state);
1445 int32_t result = DistributedSchedService::GetInstance().SetMissionContinueStateInner(data, reply);
1446 EXPECT_EQ(result, ERR_NONE);
1447 DTEST_LOG << "DistributedSchedStubTest SetMissionContinueStateInner_001 end" << std::endl;
1448 }
1449 #endif
1450
1451 /**
1452 * @tc.name: CallerInfoUnmarshalling_001
1453 * @tc.desc: check CallerInfoUnmarshalling
1454 * @tc.type: FUNC
1455 */
HWTEST_F(DistributedSchedStubTest, CallerInfoUnmarshalling_001, TestSize.Level3)1456 HWTEST_F(DistributedSchedStubTest, CallerInfoUnmarshalling_001, TestSize.Level3)
1457 {
1458 DTEST_LOG << "DistributedSchedStubTest CallerInfoUnmarshalling_001 begin" << std::endl;
1459 MessageParcel data;
1460 int32_t uid = 0;
1461 data.WriteInt32(uid);
1462 int32_t pid = 0;
1463 data.WriteInt32(pid);
1464 int32_t callerType = 0;
1465 data.WriteInt32(callerType);
1466 std::string sourceDeviceId = "";
1467 data.WriteString(sourceDeviceId);
1468 int32_t duid = 0;
1469 data.WriteInt32(duid);
1470 std::string callerAppId = "test";
1471 data.WriteString(callerAppId);
1472 int32_t version = 0;
1473 data.WriteInt32(version);
1474 CallerInfo callerInfo;
1475 bool result = DistributedSchedService::GetInstance().CallerInfoUnmarshalling(callerInfo, data);
1476 EXPECT_TRUE(result);
1477 DTEST_LOG << "DistributedSchedStubTest CallerInfoUnmarshalling_001 end" << std::endl;
1478 }
1479
1480 /**
1481 * @tc.name: StartRemoteAbilityByCallInner_001
1482 * @tc.desc: check StartRemoteAbilityByCallInner
1483 * @tc.type: FUNC
1484 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_001, TestSize.Level3)1485 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_001, TestSize.Level3)
1486 {
1487 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_001 begin" << std::endl;
1488 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY_BY_CALL);
1489 MessageParcel data;
1490 MessageParcel reply;
1491 MessageOption option;
1492
1493 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1494 DistributedSchedUtil::MockPermission();
1495 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1496 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1497 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_001 end" << std::endl;
1498 }
1499
1500 /**
1501 * @tc.name: StartRemoteAbilityByCallInner_002
1502 * @tc.desc: check StartRemoteAbilityByCallInner
1503 * @tc.type: FUNC
1504 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_002, TestSize.Level3)1505 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_002, TestSize.Level3)
1506 {
1507 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_002 begin" << std::endl;
1508 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY_BY_CALL);
1509 MessageParcel data;
1510 MessageParcel reply;
1511 MessageOption option;
1512
1513 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1514 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1515 EXPECT_EQ(result, ERR_NULL_OBJECT);
1516
1517 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1518 Want want;
1519 data.WriteParcelable(&want);
1520 sptr<IRemoteObject> connect = nullptr;
1521 data.WriteRemoteObject(connect);
1522 int32_t callerUid = 0;
1523 data.WriteInt32(callerUid);
1524 int32_t callerPid = 0;
1525 data.WriteInt32(callerPid);
1526 uint32_t accessToken = 0;
1527 data.WriteUint32(accessToken);
1528 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1529 EXPECT_EQ(result, ERR_NONE);
1530 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_002 end" << std::endl;
1531 }
1532
1533 /**
1534 * @tc.name: StartRemoteAbilityByCallInner_003
1535 * @tc.desc: check StartRemoteAbilityByCallInner
1536 * @tc.type: FUNC
1537 */
HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_003, TestSize.Level3)1538 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_003, TestSize.Level3)
1539 {
1540 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_003 begin" << std::endl;
1541 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY_BY_CALL);
1542 MessageParcel data;
1543 MessageParcel reply;
1544 MessageOption option;
1545
1546 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1547 Want want;
1548 data.WriteParcelable(&want);
1549 sptr<IRemoteObject> connect = nullptr;
1550 data.WriteRemoteObject(connect);
1551 int32_t callerUid = 0;
1552 data.WriteInt32(callerUid);
1553 int32_t callerPid = 0;
1554 data.WriteInt32(callerPid);
1555 uint32_t accessToken = GetSelfTokenID();
1556 data.WriteUint32(accessToken);
1557 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1558 EXPECT_EQ(result, ERR_NONE);
1559 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_003 end" << std::endl;
1560 }
1561
1562 /**
1563 * @tc.name: ReleaseRemoteAbilityInner_001
1564 * @tc.desc: check ReleaseRemoteAbilityInner
1565 * @tc.type: FUNC
1566 */
HWTEST_F(DistributedSchedStubTest, ReleaseRemoteAbilityInner_001, TestSize.Level3)1567 HWTEST_F(DistributedSchedStubTest, ReleaseRemoteAbilityInner_001, TestSize.Level3)
1568 {
1569 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_001 begin" << std::endl;
1570 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::RELEASE_REMOTE_ABILITY);
1571 MessageParcel data;
1572 MessageParcel reply;
1573 MessageOption option;
1574
1575 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1576 DistributedSchedUtil::MockPermission();
1577 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1578 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1579 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_001 end" << std::endl;
1580 }
1581
1582 /**
1583 * @tc.name: ReleaseRemoteAbilityInner_002
1584 * @tc.desc: check ReleaseRemoteAbilityInner
1585 * @tc.type: FUNC
1586 */
HWTEST_F(DistributedSchedStubTest, ReleaseRemoteAbilityInner_002, TestSize.Level3)1587 HWTEST_F(DistributedSchedStubTest, ReleaseRemoteAbilityInner_002, TestSize.Level3)
1588 {
1589 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_002 begin" << std::endl;
1590 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::RELEASE_REMOTE_ABILITY);
1591 MessageParcel data;
1592 MessageParcel reply;
1593 MessageOption option;
1594
1595 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1596 sptr<IRemoteObject> connect = nullptr;
1597 data.WriteRemoteObject(connect);
1598 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1599 EXPECT_EQ(result, ERR_INVALID_VALUE);
1600
1601 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1602 data.WriteRemoteObject(connect);
1603 ElementName element;
1604 data.WriteParcelable(&element);
1605 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1606 EXPECT_EQ(result, ERR_NONE);
1607 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_002 end" << std::endl;
1608 }
1609
1610 /**
1611 * @tc.name: StartAbilityByCallFromRemoteInner_001
1612 * @tc.desc: check StartAbilityByCallFromRemoteInner
1613 * @tc.type: FUNC
1614 */
HWTEST_F(DistributedSchedStubTest, StartAbilityByCallFromRemoteInner_001, TestSize.Level3)1615 HWTEST_F(DistributedSchedStubTest, StartAbilityByCallFromRemoteInner_001, TestSize.Level3)
1616 {
1617 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_001 begin" << std::endl;
1618 MessageParcel data;
1619 MessageParcel reply;
1620
1621 sptr<IRemoteObject> connect = nullptr;
1622 data.WriteRemoteObject(connect);
1623 CallerInfo callerInfo;
1624 callerInfo.uid = 0;
1625 data.WriteInt32(callerInfo.uid);
1626 callerInfo.pid = 0;
1627 data.WriteInt32(callerInfo.pid);
1628 callerInfo.sourceDeviceId = "";
1629 data.WriteString(callerInfo.sourceDeviceId);
1630 DistributedSchedService::AccountInfo accountInfo;
1631 accountInfo.accountType = 0;
1632 data.WriteInt32(accountInfo.accountType);
1633 data.WriteStringVector(accountInfo.groupIdList);
1634 callerInfo.callerAppId = "";
1635 data.WriteString(callerInfo.callerAppId);
1636 int32_t result = DistributedSchedService::GetInstance().StartAbilityByCallFromRemoteInner(data, reply);
1637 EXPECT_EQ(result, ERR_NULL_OBJECT);
1638
1639 data.WriteRemoteObject(connect);
1640 data.WriteInt32(callerInfo.uid);
1641 data.WriteInt32(callerInfo.pid);
1642 data.WriteString(callerInfo.sourceDeviceId);
1643 data.WriteInt32(accountInfo.accountType);
1644 data.WriteStringVector(accountInfo.groupIdList);
1645 data.WriteString(callerInfo.callerAppId);
1646 nlohmann::json extraInfoJson;
1647 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
1648 std::string extraInfo = extraInfoJson.dump();
1649 data.WriteString(extraInfo);
1650 result = DistributedSchedService::GetInstance().StartAbilityByCallFromRemoteInner(data, reply);
1651 EXPECT_EQ(result, ERR_NULL_OBJECT);
1652 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_001 end" << std::endl;
1653 }
1654
1655 /**
1656 * @tc.name: StartAbilityByCallFromRemoteInner_002
1657 * @tc.desc: check StartAbilityByCallFromRemoteInner
1658 * @tc.type: FUNC
1659 */
HWTEST_F(DistributedSchedStubTest, StartAbilityByCallFromRemoteInner_002, TestSize.Level3)1660 HWTEST_F(DistributedSchedStubTest, StartAbilityByCallFromRemoteInner_002, TestSize.Level3)
1661 {
1662 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_002 begin" << std::endl;
1663 MessageParcel data;
1664 MessageParcel reply;
1665
1666 sptr<IRemoteObject> connect = nullptr;
1667 data.WriteRemoteObject(connect);
1668 CallerInfo callerInfo;
1669 callerInfo.uid = 0;
1670 data.WriteInt32(callerInfo.uid);
1671 callerInfo.pid = 0;
1672 data.WriteInt32(callerInfo.pid);
1673 callerInfo.sourceDeviceId = "";
1674 data.WriteString(callerInfo.sourceDeviceId);
1675 DistributedSchedService::AccountInfo accountInfo;
1676 accountInfo.accountType = 0;
1677 data.WriteInt32(accountInfo.accountType);
1678 data.WriteStringVector(accountInfo.groupIdList);
1679 callerInfo.callerAppId = "";
1680 data.WriteString(callerInfo.callerAppId);
1681 nlohmann::json extraInfoJson;
1682 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
1683 std::string extraInfo = extraInfoJson.dump();
1684 data.WriteString(extraInfo);
1685 Want want;
1686 data.WriteParcelable(&want);
1687 int32_t result = DistributedSchedService::GetInstance().StartAbilityByCallFromRemoteInner(data, reply);
1688 EXPECT_EQ(result, ERR_NONE);
1689 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_002 end" << std::endl;
1690 }
1691
1692 /**
1693 * @tc.name: ReleaseAbilityFromRemoteInner_001
1694 * @tc.desc: check ReleaseAbilityFromRemoteInner
1695 * @tc.type: FUNC
1696 */
HWTEST_F(DistributedSchedStubTest, ReleaseAbilityFromRemoteInner_001, TestSize.Level3)1697 HWTEST_F(DistributedSchedStubTest, ReleaseAbilityFromRemoteInner_001, TestSize.Level3)
1698 {
1699 DTEST_LOG << "DistributedSchedStubTest ReleaseAbilityFromRemoteInner_001 begin" << std::endl;
1700 MessageParcel data;
1701 MessageParcel reply;
1702
1703 sptr<IRemoteObject> connect = nullptr;
1704 data.WriteRemoteObject(connect);
1705 int32_t result = DistributedSchedService::GetInstance().ReleaseAbilityFromRemoteInner(data, reply);
1706 EXPECT_EQ(result, ERR_INVALID_VALUE);
1707
1708 data.WriteRemoteObject(connect);
1709 ElementName element;
1710 data.WriteParcelable(&element);
1711 CallerInfo callerInfo;
1712 callerInfo.sourceDeviceId = "";
1713 data.WriteString(callerInfo.sourceDeviceId);
1714 nlohmann::json extraInfoJson;
1715 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
1716 std::string extraInfo = extraInfoJson.dump();
1717 data.WriteString(extraInfo);
1718 result = DistributedSchedService::GetInstance().ReleaseAbilityFromRemoteInner(data, reply);
1719 EXPECT_EQ(result, ERR_NONE);
1720 DTEST_LOG << "DistributedSchedStubTest ReleaseAbilityFromRemoteInner_001 end" << std::endl;
1721 }
1722
1723 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
1724 /**
1725 * @tc.name: StartRemoteShareFormInner_001
1726 * @tc.desc: check StartRemoteShareFormInner
1727 * @tc.type: FUNC
1728 */
HWTEST_F(DistributedSchedStubTest, StartRemoteShareFormInner_001, TestSize.Level3)1729 HWTEST_F(DistributedSchedStubTest, StartRemoteShareFormInner_001, TestSize.Level3)
1730 {
1731 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_001 begin" << std::endl;
1732 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_SHARE_FORM);
1733 MessageParcel data;
1734 MessageParcel reply;
1735 MessageOption option;
1736
1737 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1738 DistributedSchedUtil::MockPermission();
1739 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1740 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1741 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_001 end" << std::endl;
1742 }
1743
1744 /**
1745 * @tc.name: StartRemoteShareFormInner_002
1746 * @tc.desc: check StartRemoteShareFormInner
1747 * @tc.type: FUNC
1748 */
HWTEST_F(DistributedSchedStubTest, StartRemoteShareFormInner_002, TestSize.Level3)1749 HWTEST_F(DistributedSchedStubTest, StartRemoteShareFormInner_002, TestSize.Level3)
1750 {
1751 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_002 begin" << std::endl;
1752 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_SHARE_FORM);
1753 MessageParcel data;
1754 MessageParcel reply;
1755 MessageOption option;
1756
1757 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1758 std::string deviceId = "";
1759 data.WriteString(deviceId);
1760 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1761 EXPECT_EQ(result, ERR_NONE);
1762
1763 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1764 data.WriteString(deviceId);
1765 FormShareInfo formShareInfo;
1766 data.WriteParcelable(&formShareInfo);
1767 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1768 EXPECT_EQ(result, ERR_NONE);
1769 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_002 end" << std::endl;
1770 }
1771
1772 /**
1773 * @tc.name: StartShareFormFromRemoteInner_001
1774 * @tc.desc: check StartShareFormFromRemoteInner
1775 * @tc.type: FUNC
1776 */
HWTEST_F(DistributedSchedStubTest, StartShareFormFromRemoteInner_001, TestSize.Level3)1777 HWTEST_F(DistributedSchedStubTest, StartShareFormFromRemoteInner_001, TestSize.Level3)
1778 {
1779 DTEST_LOG << "DistributedSchedStubTest StartShareFormFromRemoteInner_001 begin" << std::endl;
1780 MessageParcel data;
1781 MessageParcel reply;
1782
1783 std::string deviceId = "";
1784 data.WriteString(deviceId);
1785 int32_t result = DistributedSchedService::GetInstance().StartShareFormFromRemoteInner(data, reply);
1786 EXPECT_EQ(result, ERR_NONE);
1787
1788 data.WriteString(deviceId);
1789 FormShareInfo formShareInfo;
1790 data.WriteParcelable(&formShareInfo);
1791 result = DistributedSchedService::GetInstance().StartShareFormFromRemoteInner(data, reply);
1792 EXPECT_EQ(result, ERR_NONE);
1793 DTEST_LOG << "DistributedSchedStubTest StartShareFormFromRemoteInner_001 end" << std::endl;
1794 }
1795 #endif
1796
1797 /**
1798 * @tc.name: StartRemoteFreeInstallInner_001
1799 * @tc.desc: check StartRemoteFreeInstallInner
1800 * @tc.type: FUNC
1801 */
HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_001, TestSize.Level3)1802 HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_001, TestSize.Level3)
1803 {
1804 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_001 begin" << std::endl;
1805 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_FREE_INSTALL);
1806 MessageParcel data;
1807 MessageParcel reply;
1808 MessageOption option;
1809
1810 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1811 DistributedSchedUtil::MockPermission();
1812 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1813 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1814 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_001 end" << std::endl;
1815 }
1816
1817 /**
1818 * @tc.name: StartRemoteFreeInstallInner_002
1819 * @tc.desc: check StartRemoteFreeInstallInner
1820 * @tc.type: FUNC
1821 */
HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_002, TestSize.Level3)1822 HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_002, TestSize.Level3)
1823 {
1824 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_002 begin" << std::endl;
1825 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_FREE_INSTALL);
1826 MessageParcel data;
1827 MessageParcel reply;
1828 MessageOption option;
1829
1830 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1831 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1832 EXPECT_EQ(result, ERR_NULL_OBJECT);
1833
1834 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1835 Want want;
1836 data.WriteParcelable(&want);
1837 int32_t callerUid = 0;
1838 data.WriteInt32(callerUid);
1839 int32_t requestCode = 0;
1840 data.WriteInt32(requestCode);
1841 uint32_t accessToken = 0;
1842 data.WriteUint32(accessToken);
1843 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1844 EXPECT_EQ(result, ERR_NULL_OBJECT);
1845
1846 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1847 data.WriteParcelable(&want);
1848 data.WriteInt32(callerUid);
1849 data.WriteInt32(requestCode);
1850 data.WriteUint32(accessToken);
1851 sptr<IRemoteObject> callback(new DistributedSchedService());
1852 data.WriteRemoteObject(callback);
1853 result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1854 EXPECT_EQ(result, ERR_NONE);
1855 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_002 end" << std::endl;
1856 }
1857
1858 /**
1859 * @tc.name: StartRemoteFreeInstallInner_003
1860 * @tc.desc: check StartRemoteFreeInstallInner
1861 * @tc.type: FUNC
1862 */
HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_003, TestSize.Level3)1863 HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_003, TestSize.Level3)
1864 {
1865 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_003 begin" << std::endl;
1866 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_FREE_INSTALL);
1867 MessageParcel data;
1868 MessageParcel reply;
1869 MessageOption option;
1870
1871 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1872 Want want;
1873 data.WriteParcelable(&want);
1874 int32_t callerUid = 0;
1875 data.WriteInt32(callerUid);
1876 int32_t requestCode = 0;
1877 data.WriteInt32(requestCode);
1878 uint32_t accessToken = GetSelfTokenID();
1879 data.WriteUint32(accessToken);
1880 sptr<IRemoteObject> callback(new DistributedSchedService());
1881 data.WriteRemoteObject(callback);
1882 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
1883 EXPECT_EQ(result, ERR_NONE);
1884 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_003 end" << std::endl;
1885 }
1886
1887 /**
1888 * @tc.name: StartFreeInstallFromRemoteInner_001
1889 * @tc.desc: check StartFreeInstallFromRemoteInner
1890 * @tc.type: FUNC
1891 */
HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_001, TestSize.Level3)1892 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_001, TestSize.Level3)
1893 {
1894 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_001 begin" << std::endl;
1895 MessageParcel data;
1896 MessageParcel reply;
1897
1898 int32_t result = DistributedSchedService::GetInstance().StartFreeInstallFromRemoteInner(data, reply);
1899 EXPECT_EQ(result, ERR_NULL_OBJECT);
1900 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_001 end" << std::endl;
1901 }
1902
1903 /**
1904 * @tc.name: StartFreeInstallFromRemoteInner_002
1905 * @tc.desc: check StartFreeInstallFromRemoteInner
1906 * @tc.type: FUNC
1907 */
HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_002, TestSize.Level3)1908 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_002, TestSize.Level3)
1909 {
1910 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_002 begin" << std::endl;
1911 MessageParcel data;
1912 MessageParcel reply;
1913 Want want;
1914 data.WriteParcelable(&want);
1915
1916 int32_t result = DistributedSchedService::GetInstance().StartFreeInstallFromRemoteInner(data, reply);
1917 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1918 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_002 end" << std::endl;
1919 }
1920
1921 /**
1922 * @tc.name: StartFreeInstallFromRemoteInner_003
1923 * @tc.desc: check StartFreeInstallFromRemoteInner
1924 * @tc.type: FUNC
1925 */
HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_003, TestSize.Level3)1926 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_003, TestSize.Level3)
1927 {
1928 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_003 begin" << std::endl;
1929 MessageParcel data;
1930 MessageParcel reply;
1931 Want want;
1932 CallerInfo callerInfo;
1933 DistributedSchedService::AccountInfo accountInfo;
1934 int64_t taskId = 0;
1935 Want cmpWant;
1936 std::string extraInfo = "extraInfo";
1937 data.WriteParcelable(&want);
1938 FreeInstallInfoMarshalling(callerInfo, accountInfo, taskId, data);
1939 data.WriteParcelable(&cmpWant);
1940 data.WriteString(extraInfo);
1941
1942 int32_t result = DistributedSchedService::GetInstance().StartFreeInstallFromRemoteInner(data, reply);
1943 EXPECT_EQ(result, ERR_NONE);
1944 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_003 end" << std::endl;
1945 }
1946
1947 /**
1948 * @tc.name: StartFreeInstallFromRemoteInner_004
1949 * @tc.desc: check StartFreeInstallFromRemoteInner
1950 * @tc.type: FUNC
1951 */
HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_004, TestSize.Level3)1952 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_004, TestSize.Level3)
1953 {
1954 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_004 begin" << std::endl;
1955 MessageParcel data;
1956 MessageParcel reply;
1957 Want want;
1958 CallerInfo callerInfo;
1959 DistributedSchedService::AccountInfo accountInfo;
1960 int64_t taskId = 0;
1961 Want cmpWant;
1962 std::string extraInfo = "{\"accessTokenID\": 0}";
1963 data.WriteParcelable(&want);
1964 FreeInstallInfoMarshalling(callerInfo, accountInfo, taskId, data);
1965 data.WriteParcelable(&cmpWant);
1966 data.WriteString(extraInfo);
1967
1968 int32_t result = DistributedSchedService::GetInstance().StartFreeInstallFromRemoteInner(data, reply);
1969 EXPECT_EQ(result, ERR_NONE);
1970 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_004 end" << std::endl;
1971 }
1972
1973 /**
1974 * @tc.name: StartFreeInstallFromRemoteInner_005
1975 * @tc.desc: check StartFreeInstallFromRemoteInner
1976 * @tc.type: FUNC
1977 */
HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_005, TestSize.Level3)1978 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_005, TestSize.Level3)
1979 {
1980 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_005 begin" << std::endl;
1981 MessageParcel data;
1982 MessageParcel reply;
1983 Want want;
1984 CallerInfo callerInfo;
1985 DistributedSchedService::AccountInfo accountInfo;
1986 int64_t taskId = 0;
1987 Want cmpWant;
1988 std::string extraInfo = "{\"requestCode\": 0, \"accessTokenID\": 0}";
1989 data.WriteParcelable(&want);
1990 FreeInstallInfoMarshalling(callerInfo, accountInfo, taskId, data);
1991 data.WriteParcelable(&cmpWant);
1992 data.WriteString(extraInfo);
1993
1994 int32_t result = DistributedSchedService::GetInstance().StartFreeInstallFromRemoteInner(data, reply);
1995 EXPECT_EQ(result, ERR_NONE);
1996 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_005 end" << std::endl;
1997 }
1998
1999 /**
2000 * @tc.name: NotifyCompleteFreeInstallFromRemoteInner_001
2001 * @tc.desc: check NotifyCompleteFreeInstallFromRemoteInner
2002 * @tc.type: FUNC
2003 */
HWTEST_F(DistributedSchedStubTest, NotifyCompleteFreeInstallFromRemoteInner_001, TestSize.Level3)2004 HWTEST_F(DistributedSchedStubTest, NotifyCompleteFreeInstallFromRemoteInner_001, TestSize.Level3)
2005 {
2006 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteFreeInstallFromRemoteInner_001 begin" << std::endl;
2007 MessageParcel data;
2008 MessageParcel reply;
2009
2010 int32_t result = DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemoteInner(data, reply);
2011 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
2012
2013 int64_t taskId = 0;
2014 data.WriteInt64(taskId);
2015 int32_t resultCode = 0;
2016 data.WriteInt32(resultCode);
2017 result = DistributedSchedService::GetInstance().NotifyCompleteFreeInstallFromRemoteInner(data, reply);
2018 EXPECT_EQ(result, ERR_NONE);
2019 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteFreeInstallFromRemoteInner_001 end" << std::endl;
2020 }
2021
2022 /**
2023 * @tc.name: StopRemoteExtensionAbilityInner_001
2024 * @tc.desc: check StopRemoteExtensionAbilityInner
2025 * @tc.type: FUNC
2026 */
HWTEST_F(DistributedSchedStubTest, StopRemoteExtensionAbilityInner_001, TestSize.Level1)2027 HWTEST_F(DistributedSchedStubTest, StopRemoteExtensionAbilityInner_001, TestSize.Level1)
2028 {
2029 DTEST_LOG << "DistributedSchedStubTest StopRemoteExtensionAbilityInner_001 begin" << std::endl;
2030 const char* processName = "testCase";
2031 const char* permissionState[] = {
2032 "ohos.permission.ACCESS_SERVICE_DM"
2033 };
2034 Want want;
2035 want.SetElementName("test.test.test", "Ability");
2036 int32_t callerUid = 0;
2037 uint32_t accessToken = 0;
2038 int32_t serviceType = 0;
2039 MessageParcel reply;
2040
2041 MessageParcel dataFirst;
2042 DistributedSchedUtil::MockProcessAndPermission(processName, permissionState, 1);
2043 auto result = DistributedSchedService::GetInstance().StopRemoteExtensionAbilityInner(dataFirst, reply);
2044 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
2045
2046 DistributedSchedUtil::MockProcessAndPermission(FOUNDATION_PROCESS_NAME, permissionState, 1);
2047 MessageParcel dataSecond;
2048 result = DistributedSchedService::GetInstance().StopRemoteExtensionAbilityInner(dataSecond, reply);
2049 EXPECT_EQ(result, ERR_NULL_OBJECT);
2050
2051 DistributedSchedUtil::MockProcessAndPermission(FOUNDATION_PROCESS_NAME, permissionState, 1);
2052
2053 MessageParcel dataThird;
2054 dataThird.WriteParcelable(&want);
2055 dataThird.WriteInt32(callerUid);
2056 dataThird.WriteUint32(accessToken);
2057 dataThird.WriteInt32(serviceType);
2058 result = DistributedSchedService::GetInstance().StopRemoteExtensionAbilityInner(dataThird, reply);
2059 EXPECT_EQ(result, ERR_NONE);
2060 DTEST_LOG << "DistributedSchedStubTest StopRemoteExtensionAbilityInner_001 end" << std::endl;
2061 }
2062
2063 /**
2064 * @tc.name: StopExtensionAbilityFromRemoteInner_001
2065 * @tc.desc: check StopExtensionAbilityFromRemoteInner
2066 * @tc.type: FUNC
2067 */
HWTEST_F(DistributedSchedStubTest, StopExtensionAbilityFromRemoteInner_001, TestSize.Level1)2068 HWTEST_F(DistributedSchedStubTest, StopExtensionAbilityFromRemoteInner_001, TestSize.Level1)
2069 {
2070 DTEST_LOG << "DistributedSchedStubTest StopExtensionAbilityFromRemoteInner_001 begin" << std::endl;
2071 Want want;
2072 want.SetElementName("test.test.test", "Ability");
2073 int32_t callerUid = 0;
2074 int32_t serviceType = 0;
2075 std::string deviceId = "1234567890abcdefghijklmnopqrstuvwxyz";
2076 std::vector<std::string> list = {
2077 "test1",
2078 "test2"
2079 };
2080 std::string appId = "1234567890abcdefghijklmnopqrstuvwxyz";
2081 std::string extraInfo = "{ \"accessTokenID\": 1989 }";
2082 std::string extraInfoEmptr = "";
2083 MessageParcel reply;
2084
2085 MessageParcel dataFirst;
2086 auto result = DistributedSchedService::GetInstance().StopExtensionAbilityFromRemoteInner(dataFirst, reply);
2087 EXPECT_EQ(result, ERR_NULL_OBJECT);
2088
2089 MessageParcel dataSecond;
2090 dataSecond.WriteParcelable(&want);
2091 dataSecond.WriteInt32(serviceType);
2092 dataSecond.WriteInt32(callerUid);
2093 dataSecond.WriteString(deviceId);
2094 dataSecond.WriteStringVector(list);
2095 dataSecond.WriteString(appId);
2096 dataSecond.WriteString(extraInfo);
2097 result = DistributedSchedService::GetInstance().StopExtensionAbilityFromRemoteInner(dataSecond, reply);
2098 EXPECT_EQ(result, ERR_NONE);
2099
2100 MessageParcel dataThird;
2101 dataThird.WriteParcelable(&want);
2102 dataThird.WriteInt32(serviceType);
2103 dataThird.WriteInt32(callerUid);
2104 dataThird.WriteString(deviceId);
2105 dataThird.WriteStringVector(list);
2106 dataThird.WriteString(appId);
2107 dataThird.WriteString(extraInfoEmptr);
2108 result = DistributedSchedService::GetInstance().StopExtensionAbilityFromRemoteInner(dataThird, reply);
2109 EXPECT_EQ(result, ERR_NONE);
2110 DTEST_LOG << "DistributedSchedStubTest StopExtensionAbilityFromRemoteInner_001 end" << std::endl;
2111 }
2112
2113 /**
2114 * @tc.name: NotifyStateChangedFromRemoteInner_001
2115 * @tc.desc: check NotifyStateChangedFromRemoteInner
2116 * @tc.type: FUNC
2117 * @tc.require: I6VDBO
2118 */
HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_001, TestSize.Level1)2119 HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_001, TestSize.Level1)
2120 {
2121 DTEST_LOG << "DistributedSchedStubTest NotifyStateChangedFromRemoteInner_001 begin" << std::endl;
2122 MessageParcel data;
2123 MessageParcel reply;
2124 int32_t abilityState = 0;
2125 data.WriteInt32(abilityState);
2126 int32_t missionId = 0;
2127 data.WriteInt32(missionId);
2128 ElementName element;
2129 data.WriteParcelable(&element);
2130
2131 int32_t result = DistributedSchedService::GetInstance().NotifyStateChangedFromRemoteInner(data, reply);
2132 EXPECT_EQ(result, ERR_NONE);
2133 DTEST_LOG << "DistributedSchedStubTest NotifyStateChangedFromRemoteInner_001 end" << std::endl;
2134 }
2135
2136 /**
2137 * @tc.name: NotifyStateChangedFromRemoteInner_002
2138 * @tc.desc: check NotifyStateChangedFromRemoteInner
2139 * @tc.type: FUNC
2140 * @tc.require: I6VDBO
2141 */
HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_002, TestSize.Level1)2142 HWTEST_F(DistributedSchedStubTest, NotifyStateChangedFromRemoteInner_002, TestSize.Level1)
2143 {
2144 DTEST_LOG << "DistributedSchedStubTest NotifyStateChangedFromRemoteInner_002 begin" << std::endl;
2145
2146 nlohmann::json extraInfoJson;
2147 CallerInfo callerInfo;
2148 IDistributedSched::AccountInfo accountInfo;
2149 DistributedSchedService::GetInstance().SaveExtraInfo(extraInfoJson, callerInfo, accountInfo);
2150
2151 nlohmann::json extraInfoJson1;
2152 extraInfoJson[DMS_VERSION_ID] = "4";
2153 CallerInfo callerInfo1;
2154 DistributedSchedService::GetInstance().SaveExtraInfo(extraInfoJson1, callerInfo1, accountInfo);
2155
2156 nlohmann::json extraInfoJson2;
2157 extraInfoJson[DMS_VERSION_ID] = 4;
2158 CallerInfo callerInfo2;
2159 DistributedSchedService::GetInstance().SaveExtraInfo(extraInfoJson2, callerInfo2, accountInfo);
2160
2161 MessageParcel data;
2162 MessageParcel reply;
2163
2164 int32_t abilityState = 0;
2165 data.WriteInt32(abilityState);
2166 int32_t missionId = 0;
2167 data.WriteInt32(missionId);
2168 int32_t result = DistributedSchedService::GetInstance().NotifyStateChangedFromRemoteInner(data, reply);
2169 EXPECT_EQ(result, ERR_INVALID_VALUE);
2170 DTEST_LOG << "DistributedSchedStubTest NotifyStateChangedFromRemoteInner_002 end" << std::endl;
2171 }
2172
2173 /**
2174 * @tc.name: StopRemoteExtensionAbilityInner_002
2175 * @tc.desc: check StopRemoteExtensionAbilityInner
2176 * @tc.type: FUNC
2177 * @tc.require: I6YLV1
2178 */
HWTEST_F(DistributedSchedStubTest, StopRemoteExtensionAbilityInner_002, TestSize.Level1)2179 HWTEST_F(DistributedSchedStubTest, StopRemoteExtensionAbilityInner_002, TestSize.Level1)
2180 {
2181 DTEST_LOG << "DistributedSchedStubTest StopRemoteExtensionAbilityInner_002 begin" << std::endl;
2182
2183 nlohmann::json extraInfoJson;
2184 CallerInfo callerInfo;
2185 IDistributedSched::AccountInfo accountInfo;
2186 DistributedSchedService::GetInstance().SaveExtraInfo(extraInfoJson, callerInfo, accountInfo);
2187
2188 nlohmann::json extraInfoJson1;
2189 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
2190 CallerInfo callerInfo1;
2191 DistributedSchedService::GetInstance().SaveExtraInfo(extraInfoJson1, callerInfo1, accountInfo);
2192
2193 nlohmann::json extraInfoJson2;
2194 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = "4";
2195 CallerInfo callerInfo2;
2196 DistributedSchedService::GetInstance().SaveExtraInfo(extraInfoJson2, callerInfo2, accountInfo);
2197
2198 int32_t code = static_cast<uint32_t>(IDSchedInterfaceCode::STOP_REMOTE_EXTERNSION_ABILITY);
2199 MessageParcel data;
2200 MessageParcel reply;
2201 MessageOption option;
2202
2203 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
2204 Want want;
2205 data.WriteParcelable(&want);
2206 int32_t callingUid = 0;
2207 data.WriteInt32(callingUid);
2208 uint32_t accessToken = GetSelfTokenID();
2209 data.WriteUint32(accessToken);
2210 int32_t serviceType = 0;
2211 data.WriteInt32(serviceType);
2212 int32_t result = DistributedSchedService::GetInstance().OnRemoteRequest(code, data, reply, option);
2213 EXPECT_EQ(result, ERR_NONE);
2214 DTEST_LOG << "DistributedSchedStubTest StopRemoteExtensionAbilityInner_002 end" << std::endl;
2215 }
2216 }
2217 }