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