1 /*
2 * Copyright (c) 2022 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 "distributed_sched_service.h"
18 #undef private
19 #include "distributed_sched_stub_test.h"
20 #include "distributed_sched_util.h"
21 #define private public
22 #include "mission/distributed_sched_mission_manager.h"
23 #undef private
24 #include "mock_distributed_sched.h"
25 #include "mock_remote_stub.h"
26 #include "parcel_helper.h"
27 #include "test_log.h"
28 #include "token_setproc.h"
29
30 using namespace testing;
31 using namespace testing::ext;
32 using namespace OHOS::AAFwk;
33 using namespace OHOS::AppExecFwk;
34
35 namespace OHOS {
36 namespace DistributedSchedule {
37 namespace {
38 const std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.accessToken";
39 const std::u16string MOCK_INVALID_DESCRIPTOR = u"invalid descriptor";
40 const std::string EXTRO_INFO_JSON_KEY_ACCESS_TOKEN = "accessTokenID";
41 const std::string EXTRO_INFO_JSON_KEY_REQUEST_CODE = "requestCode";
42 const std::string CMPT_PARAM_FREEINSTALL_BUNDLENAMES = "ohos.extra.param.key.allowedBundles";
43 constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
44 constexpr int32_t MAX_WAIT_TIME = 5000;
45 const char *PERMS[] = {
46 "ohos.permission.DISTRIBUTED_DATASYNC"
47 };
48 }
49
SetUpTestCase()50 void DistributedSchedStubTest::SetUpTestCase()
51 {
52 DTEST_LOG << "DistributedSchedStubTest::SetUpTestCase" << std::endl;
53 }
54
TearDownTestCase()55 void DistributedSchedStubTest::TearDownTestCase()
56 {
57 DTEST_LOG << "DistributedSchedStubTest::TearDownTestCase" << std::endl;
58 }
59
TearDown()60 void DistributedSchedStubTest::TearDown()
61 {
62 DTEST_LOG << "DistributedSchedStubTest::TearDown" << std::endl;
63 distributedSchedStub_ = nullptr;
64 }
65
SetUp()66 void DistributedSchedStubTest::SetUp()
67 {
68 DTEST_LOG << "DistributedSchedStubTest::SetUp" << std::endl;
69 distributedSchedStub_ = new DistributedSchedService();
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 = DistributedSchedStub::START_REMOTE_ABILITY;
122 MessageParcel data;
123 MessageParcel reply;
124 MessageOption option;
125
126 data.WriteInterfaceToken(MOCK_INVALID_DESCRIPTOR);
127 int32_t result = distributedSchedStub_->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 = DistributedSchedStub::START_REMOTE_ABILITY;
141 MessageParcel data;
142 MessageParcel reply;
143 MessageOption option;
144
145 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
146 int32_t result = distributedSchedStub_->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 = DistributedSchedStub::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 = distributedSchedStub_->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 = distributedSchedStub_->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 = distributedSchedStub_->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 = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
192 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
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 = DistributedSchedStub::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 = distributedSchedStub_->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 */
228 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_004, TestSize.Level3)
229 {
230 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_004 begin" << std::endl;
231 int32_t code = DistributedSchedStub::START_REMOTE_ABILITY;
232 MessageParcel data;
233 MessageParcel reply;
234 MessageOption option;
235
236 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
237 DistributedSchedUtil::MockPermission();
238 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
239 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
240 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_004 end" << std::endl;
241 }
242
243 /**
244 * @tc.name: StartAbilityFromRemoteInner_001
245 * @tc.desc: check StartAbilityFromRemoteInner
246 * @tc.type: FUNC
247 */
248 HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_001, TestSize.Level3)
249 {
250 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_001 begin" << std::endl;
251 MessageParcel data;
252 MessageParcel reply;
253
254 int32_t result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
255 EXPECT_EQ(result, ERR_NULL_OBJECT);
256
257 Want want;
258 data.WriteParcelable(&want);
259 result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
260 EXPECT_EQ(result, ERR_NULL_OBJECT);
261
262 data.WriteParcelable(&want);
263 AbilityInfo abilityInfo;
264 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
265 abilityInfo.ConvertToCompatiableAbilityInfo(compatibleAbilityInfo);
266 data.WriteParcelable(&compatibleAbilityInfo);
267 result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
268 EXPECT_NE(result, ERR_NONE);
269
270 data.WriteParcelable(&want);
271 data.WriteParcelable(&compatibleAbilityInfo);
272 int32_t requestCode = 0;
273 data.WriteInt32(requestCode);
274 result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
275 EXPECT_NE(result, ERR_NONE);
276
277 data.WriteParcelable(&want);
278 data.WriteParcelable(&compatibleAbilityInfo);
279 data.WriteInt32(requestCode);
280 CallerInfo callerInfo;
281 callerInfo.uid = 0;
282 data.WriteInt32(callerInfo.uid);
283 result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
284 EXPECT_NE(result, ERR_NONE);
285
286 data.WriteParcelable(&want);
287 data.WriteParcelable(&compatibleAbilityInfo);
288 data.WriteInt32(requestCode);
289 data.WriteInt32(callerInfo.uid);
290 callerInfo.sourceDeviceId = "";
291 data.WriteString(callerInfo.sourceDeviceId);
292 result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
293 EXPECT_EQ(result, ERR_NONE);
294 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_001 end" << std::endl;
295 }
296
297 /**
298 * @tc.name: StartAbilityFromRemoteInner_002
299 * @tc.desc: check StartAbilityFromRemoteInner
300 * @tc.type: FUNC
301 */
302 HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_002, TestSize.Level3)
303 {
304 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_002 begin" << std::endl;
305 MessageParcel data;
306 MessageParcel reply;
307 Want want;
308 AbilityInfo abilityInfo;
309 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
310 int32_t requestCode = 0;
311 CallerInfo callerInfo;
312 callerInfo.uid = 0;
313 callerInfo.sourceDeviceId = "";
314
315 data.WriteParcelable(&want);
316 data.WriteParcelable(&compatibleAbilityInfo);
317 data.WriteInt32(requestCode);
318 data.WriteInt32(callerInfo.uid);
319 data.WriteString(callerInfo.sourceDeviceId);
320 DistributedSchedService::AccountInfo accountInfo;
321 accountInfo.accountType = 0;
322 data.WriteInt32(accountInfo.accountType);
323 int32_t result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
324 EXPECT_EQ(result, ERR_NONE);
325
326 data.WriteParcelable(&want);
327 data.WriteParcelable(&compatibleAbilityInfo);
328 data.WriteInt32(requestCode);
329 data.WriteInt32(callerInfo.uid);
330 data.WriteString(callerInfo.sourceDeviceId);
331 data.WriteInt32(accountInfo.accountType);
332 callerInfo.callerAppId = "";
333 data.WriteString(callerInfo.callerAppId);
334 result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
335 EXPECT_EQ(result, ERR_NONE);
336 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_002 end" << std::endl;
337 }
338
339 /**
340 * @tc.name: StartAbilityFromRemoteInner_003
341 * @tc.desc: check StartAbilityFromRemoteInner
342 * @tc.type: FUNC
343 */
344 HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteInner_003, TestSize.Level3)
345 {
346 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_003 begin" << std::endl;
347 MessageParcel data;
348 MessageParcel reply;
349
350 Want want;
351 data.WriteParcelable(&want);
352 AbilityInfo abilityInfo;
353 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
354 data.WriteParcelable(&compatibleAbilityInfo);
355 int32_t requestCode = 0;
356 data.WriteInt32(requestCode);
357 CallerInfo callerInfo;
358 callerInfo.uid = 0;
359 data.WriteInt32(callerInfo.uid);
360 callerInfo.sourceDeviceId = "";
361 data.WriteString(callerInfo.sourceDeviceId);
362 DistributedSchedService::AccountInfo accountInfo;
363 accountInfo.accountType = 0;
364 data.WriteInt32(accountInfo.accountType);
365 data.WriteStringVector(accountInfo.groupIdList);
366 callerInfo.callerAppId = "";
367 data.WriteString(callerInfo.callerAppId);
368 nlohmann::json extraInfoJson;
369 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
370 std::string extraInfo = extraInfoJson.dump();
371 data.WriteString(extraInfo);
372 int32_t result = distributedSchedStub_->StartAbilityFromRemoteInner(data, reply);
373 EXPECT_EQ(result, ERR_NONE);
374 DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteInner_003 end" << std::endl;
375 }
376
377 /**
378 * @tc.name: SendResultFromRemoteInner_001
379 * @tc.desc: check SendResultFromRemoteInner
380 * @tc.type: FUNC
381 */
382 HWTEST_F(DistributedSchedStubTest, SendResultFromRemoteInner_001, TestSize.Level3)
383 {
384 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_001 begin" << std::endl;
385 MessageParcel data;
386 MessageParcel reply;
387
388 int32_t result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
389 EXPECT_EQ(result, ERR_NULL_OBJECT);
390
391 Want want;
392 data.WriteParcelable(&want);
393 result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
394 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
395
396 data.WriteParcelable(&want);
397 int32_t requestCode = 0;
398 data.WriteInt32(requestCode);
399 result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
400 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
401
402 data.WriteParcelable(&want);
403 data.WriteInt32(requestCode);
404 CallerInfo callerInfo;
405 callerInfo.uid = 0;
406 data.WriteInt32(callerInfo.uid);
407 result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
408 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
409
410 data.WriteParcelable(&want);
411 data.WriteInt32(requestCode);
412 data.WriteInt32(callerInfo.uid);
413 callerInfo.sourceDeviceId = "";
414 data.WriteString(callerInfo.sourceDeviceId);
415 result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
416 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
417 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_001 end" << std::endl;
418 }
419
420 /**
421 * @tc.name: SendResultFromRemoteInner_002
422 * @tc.desc: check SendResultFromRemoteInner
423 * @tc.type: FUNC
424 */
425 HWTEST_F(DistributedSchedStubTest, SendResultFromRemoteInner_002, TestSize.Level3)
426 {
427 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_002 begin" << std::endl;
428 MessageParcel data;
429 MessageParcel reply;
430 Want want;
431 int32_t requestCode = 0;
432 CallerInfo callerInfo;
433 callerInfo.uid = 0;
434 callerInfo.sourceDeviceId = "";
435 callerInfo.callerAppId = "";
436
437 data.WriteParcelable(&want);
438 data.WriteInt32(requestCode);
439 data.WriteInt32(callerInfo.uid);
440 data.WriteString(callerInfo.sourceDeviceId);
441 DistributedSchedService::AccountInfo accountInfo;
442 accountInfo.accountType = 0;
443 data.WriteInt32(accountInfo.accountType);
444 int32_t result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
445 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
446
447 data.WriteParcelable(&want);
448 data.WriteInt32(requestCode);
449 data.WriteInt32(callerInfo.uid);
450 data.WriteString(callerInfo.sourceDeviceId);
451 data.WriteInt32(accountInfo.accountType);
452 data.WriteString(callerInfo.callerAppId);
453 int32_t resultCode = 0;
454 data.WriteInt32(resultCode);
455 result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
456 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
457
458 data.WriteParcelable(&want);
459 data.WriteInt32(requestCode);
460 data.WriteInt32(callerInfo.uid);
461 data.WriteString(callerInfo.sourceDeviceId);
462 data.WriteInt32(accountInfo.accountType);
463 data.WriteString(callerInfo.callerAppId);
464 data.WriteInt32(resultCode);
465 nlohmann::json extraInfoJson;
466 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
467 std::string extraInfo = extraInfoJson.dump();
468 data.WriteString(extraInfo);
469 result = distributedSchedStub_->SendResultFromRemoteInner(data, reply);
470 EXPECT_EQ(result, ERR_NONE);
471 DTEST_LOG << "DistributedSchedStubTest SendResultFromRemoteInner_002 end" << std::endl;
472 }
473
474 /**
475 * @tc.name: ContinueMissionInner_001
476 * @tc.desc: check ContinueMissionInner
477 * @tc.type: FUNC
478 */
479 HWTEST_F(DistributedSchedStubTest, ContinueMissionInner_001, TestSize.Level3)
480 {
481 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_001 begin" << std::endl;
482 MessageParcel data;
483 MessageParcel reply;
484
485 DistributedSchedUtil::MockPermission();
486 int32_t result = distributedSchedStub_->ContinueMissionInner(data, reply);
487 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
488 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_001 end" << std::endl;
489 }
490
491 /**
492 * @tc.name: ContinueMissionInner_002
493 * @tc.desc: check ContinueMissionInner
494 * @tc.type: FUNC
495 */
496 HWTEST_F(DistributedSchedStubTest, ContinueMissionInner_002, TestSize.Level3)
497 {
498 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_002 begin" << std::endl;
499 MessageParcel data;
500 MessageParcel reply;
501
502 int32_t result = distributedSchedStub_->ContinueMissionInner(data, reply);
503 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
504
505 std::string srcDevId = "";
506 data.WriteString(srcDevId);
507 result = distributedSchedStub_->ContinueMissionInner(data, reply);
508 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
509
510 data.WriteString(srcDevId);
511 std::string dstDevId = "";
512 data.WriteString(dstDevId);
513 result = distributedSchedStub_->ContinueMissionInner(data, reply);
514 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
515
516 data.WriteString(srcDevId);
517 data.WriteString(dstDevId);
518 int32_t missionId = 0;
519 data.WriteInt32(missionId);
520 result = distributedSchedStub_->ContinueMissionInner(data, reply);
521 EXPECT_EQ(result, ERR_NULL_OBJECT);
522
523 data.WriteString(srcDevId);
524 data.WriteString(dstDevId);
525 data.WriteInt32(missionId);
526 sptr<IRemoteObject> dsched = new DistributedSchedService();
527 data.WriteRemoteObject(dsched);
528 result = distributedSchedStub_->ContinueMissionInner(data, reply);
529 EXPECT_EQ(result, ERR_NULL_OBJECT);
530
531 data.WriteString(srcDevId);
532 data.WriteString(dstDevId);
533 data.WriteInt32(missionId);
534 data.WriteRemoteObject(dsched);
535 WantParams wantParams = {};
536 data.WriteParcelable(&wantParams);
537 result = distributedSchedStub_->ContinueMissionInner(data, reply);
538 EXPECT_EQ(result, ERR_NONE);
539 DTEST_LOG << "DistributedSchedStubTest ContinueMissionInner_002 end" << std::endl;
540 }
541
542 /**
543 * @tc.name: StartContinuationInner_001
544 * @tc.desc: check StartContinuationInner
545 * @tc.type: FUNC
546 */
547 HWTEST_F(DistributedSchedStubTest, StartContinuationInner_001, TestSize.Level3)
548 {
549 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_001 begin" << std::endl;
550 int32_t code = DistributedSchedStub::START_CONTINUATION;
551 MessageParcel data;
552 MessageParcel reply;
553 MessageOption option;
554
555 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
556 DistributedSchedUtil::MockPermission();
557 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
558 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
559 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_001 end" << std::endl;
560 }
561
562 /**
563 * @tc.name: StartContinuationInner_002
564 * @tc.desc: check StartContinuationInner
565 * @tc.type: FUNC
566 */
567 HWTEST_F(DistributedSchedStubTest, StartContinuationInner_002, TestSize.Level3)
568 {
569 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_002 begin" << std::endl;
570 int32_t code = DistributedSchedStub::START_CONTINUATION;
571 MessageParcel data;
572 MessageParcel reply;
573 MessageOption option;
574
575 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
576 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
577 EXPECT_EQ(result, ERR_NULL_OBJECT);
578
579 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
580 Want want;
581 data.WriteParcelable(&want);
582 int32_t missionId = 0;
583 data.WriteInt32(missionId);
584 int32_t callerUid = 0;
585 data.WriteInt32(callerUid);
586 int32_t status = 0;
587 data.WriteInt32(status);
588 uint32_t accessToken = GetSelfTokenID();
589 data.WriteUint32(accessToken);
590 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
591 EXPECT_EQ(result, ERR_NONE);
592 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_002 end" << std::endl;
593 }
594
595 /**
596 * @tc.name: StartContinuationInner_003
597 * @tc.desc: check StartContinuationInner
598 * @tc.type: FUNC
599 */
600 HWTEST_F(DistributedSchedStubTest, StartContinuationInner_003, TestSize.Level3)
601 {
602 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_003 begin" << std::endl;
603 int32_t code = DistributedSchedStub::START_CONTINUATION;
604 MessageParcel data;
605 MessageParcel reply;
606 MessageOption option;
607
608 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
609 Want want;
610 data.WriteParcelable(&want);
611 int32_t missionId = 0;
612 data.WriteInt32(missionId);
613 int32_t callerUid = 0;
614 data.WriteInt32(callerUid);
615 int32_t status = 0;
616 data.WriteInt32(status);
617 uint32_t accessToken = 0;
618 data.WriteUint32(accessToken);
619 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
620 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
621 DTEST_LOG << "DistributedSchedStubTest StartContinuationInner_003 end" << std::endl;
622 }
623
624 /**
625 * @tc.name: NotifyCompleteContinuationInner_001
626 * @tc.desc: check NotifyCompleteContinuationInner
627 * @tc.type: FUNC
628 */
629 HWTEST_F(DistributedSchedStubTest, NotifyCompleteContinuationInner_001, TestSize.Level3)
630 {
631 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_001 begin" << std::endl;
632 int32_t code = DistributedSchedStub::NOTIFY_COMPLETE_CONTINUATION;
633 MessageParcel data;
634 MessageParcel reply;
635 MessageOption option;
636
637 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
638 DistributedSchedUtil::MockPermission();
639 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
640 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
641 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_001 end" << std::endl;
642 }
643
644 /**
645 * @tc.name: NotifyCompleteContinuationInner_002
646 * @tc.desc: check NotifyCompleteContinuationInner
647 * @tc.type: FUNC
648 */
649 HWTEST_F(DistributedSchedStubTest, NotifyCompleteContinuationInner_002, TestSize.Level3)
650 {
651 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_002 begin" << std::endl;
652 int32_t code = DistributedSchedStub::NOTIFY_COMPLETE_CONTINUATION;
653 MessageParcel data;
654 MessageParcel reply;
655 MessageOption option;
656
657 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
658 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
659 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
660
661 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
662 std::u16string devId = u"192.168.43.100";
663 data.WriteString16(devId);
664 int32_t sessionId = 0;
665 data.WriteInt32(sessionId);
666 bool isSuccess = false;
667 data.WriteBool(isSuccess);
668 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
669 EXPECT_EQ(result, ERR_NONE);
670 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteContinuationInner_002 end" << std::endl;
671 }
672
673 /**
674 * @tc.name: NotifyContinuationResultFromRemoteInner_001
675 * @tc.desc: check NotifyContinuationResultFromRemoteInner
676 * @tc.type: FUNC
677 */
678 HWTEST_F(DistributedSchedStubTest, NotifyContinuationResultFromRemoteInner_001, TestSize.Level3)
679 {
680 DTEST_LOG << "DistributedSchedStubTest NotifyContinuationResultFromRemoteInner_001 begin" << std::endl;
681 MessageParcel data;
682 MessageParcel reply;
683
684 int32_t sessionId = 0;
685 data.WriteInt32(sessionId);
686 bool continuationResult = false;
687 data.WriteBool(continuationResult);
688 int32_t result = distributedSchedStub_->NotifyContinuationResultFromRemoteInner(data, reply);
689 EXPECT_EQ(result, INVALID_REMOTE_PARAMETERS_ERR);
690 DTEST_LOG << "DistributedSchedStubTest NotifyContinuationResultFromRemoteInner_001 end" << std::endl;
691 }
692
693 /**
694 * @tc.name: ConnectRemoteAbilityInner_001
695 * @tc.desc: check ConnectRemoteAbilityInner
696 * @tc.type: FUNC
697 */
698 HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_001, TestSize.Level3)
699 {
700 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_001 begin" << std::endl;
701 int32_t code = DistributedSchedStub::CONNECT_REMOTE_ABILITY;
702 MessageParcel data;
703 MessageParcel reply;
704 MessageOption option;
705
706 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
707 DistributedSchedUtil::MockPermission();
708 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
709 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
710 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_001 end" << std::endl;
711 }
712
713 /**
714 * @tc.name: ConnectRemoteAbilityInner_002
715 * @tc.desc: check ConnectRemoteAbilityInner
716 * @tc.type: FUNC
717 */
718 HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_002, TestSize.Level3)
719 {
720 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_002 begin" << std::endl;
721 int32_t code = DistributedSchedStub::CONNECT_REMOTE_ABILITY;
722 MessageParcel data;
723 MessageParcel reply;
724 MessageOption option;
725
726 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
727 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
728 EXPECT_EQ(result, ERR_NULL_OBJECT);
729
730 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
731 Want want;
732 data.WriteParcelable(&want);
733 int32_t callerUid = 0;
734 data.WriteInt32(callerUid);
735 int32_t callerPid = 0;
736 data.WriteInt32(callerPid);
737 uint32_t accessToken = 0;
738 data.WriteUint32(accessToken);
739 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
740 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
741 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_002 end" << std::endl;
742 }
743
744 /**
745 * @tc.name: ConnectRemoteAbilityInner_003
746 * @tc.desc: check ConnectRemoteAbilityInner
747 * @tc.type: FUNC
748 */
749 HWTEST_F(DistributedSchedStubTest, ConnectRemoteAbilityInner_003, TestSize.Level3)
750 {
751 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_003 begin" << std::endl;
752 int32_t code = DistributedSchedStub::CONNECT_REMOTE_ABILITY;
753 MessageParcel data;
754 MessageParcel reply;
755 MessageOption option;
756
757 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
758 Want want;
759 data.WriteParcelable(&want);
760 int32_t callerUid = 0;
761 data.WriteInt32(callerUid);
762 int32_t callerPid = 0;
763 data.WriteInt32(callerPid);
764 uint32_t accessToken = GetSelfTokenID();
765 data.WriteUint32(accessToken);
766 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
767 EXPECT_EQ(result, ERR_NONE);
768 DTEST_LOG << "DistributedSchedStubTest ConnectRemoteAbilityInner_003 end" << std::endl;
769 }
770
771 /**
772 * @tc.name: DisconnectRemoteAbilityInner_001
773 * @tc.desc: check DisconnectRemoteAbilityInner
774 * @tc.type: FUNC
775 */
776 HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_001, TestSize.Level3)
777 {
778 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_001 begin" << std::endl;
779 int32_t code = DistributedSchedStub::DISCONNECT_REMOTE_ABILITY;
780 MessageParcel data;
781 MessageParcel reply;
782 MessageOption option;
783
784 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
785 DistributedSchedUtil::MockPermission();
786 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
787 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
788 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_001 end" << std::endl;
789 }
790
791 /**
792 * @tc.name: DisconnectRemoteAbilityInner_002
793 * @tc.desc: check DisconnectRemoteAbilityInner
794 * @tc.type: FUNC
795 */
796 HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_002, TestSize.Level3)
797 {
798 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_002 begin" << std::endl;
799 int32_t code = DistributedSchedStub::DISCONNECT_REMOTE_ABILITY;
800 MessageParcel data;
801 MessageParcel reply;
802 MessageOption option;
803
804 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
805 sptr<IRemoteObject> connect;
806 data.WriteRemoteObject(connect);
807 int32_t callerUid = 0;
808 data.WriteInt32(callerUid);
809 uint32_t accessToken = 0;
810 data.WriteUint32(accessToken);
811 int result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
812 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
813 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_002 end" << std::endl;
814 }
815
816 /**
817 * @tc.name: DisconnectRemoteAbilityInner_003
818 * @tc.desc: check DisconnectRemoteAbilityInner
819 * @tc.type: FUNC
820 */
821 HWTEST_F(DistributedSchedStubTest, DisconnectRemoteAbilityInner_003, TestSize.Level3)
822 {
823 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_003 begin" << std::endl;
824 int32_t code = DistributedSchedStub::DISCONNECT_REMOTE_ABILITY;
825 MessageParcel data;
826 MessageParcel reply;
827 MessageOption option;
828
829 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
830 sptr<IRemoteObject> connect;
831 data.WriteRemoteObject(connect);
832 int32_t callerUid = 0;
833 data.WriteInt32(callerUid);
834 uint32_t accessToken = GetSelfTokenID();
835 data.WriteUint32(accessToken);
836 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
837 EXPECT_EQ(result, ERR_NONE);
838 DTEST_LOG << "DistributedSchedStubTest DisconnectRemoteAbilityInner_003 end" << std::endl;
839 }
840
841 /**
842 * @tc.name: ConnectAbilityFromRemoteInner_001
843 * @tc.desc: check ConnectAbilityFromRemoteInner
844 * @tc.type: FUNC
845 */
846 HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteInner_001, TestSize.Level3)
847 {
848 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_001 begin" << std::endl;
849 MessageParcel data;
850 MessageParcel reply;
851
852 int32_t result = distributedSchedStub_->ConnectAbilityFromRemoteInner(data, reply);
853 EXPECT_EQ(result, ERR_NULL_OBJECT);
854
855 Want want;
856 data.WriteParcelable(&want);
857 result = distributedSchedStub_->ConnectAbilityFromRemoteInner(data, reply);
858 EXPECT_EQ(result, ERR_NULL_OBJECT);
859
860 data.WriteParcelable(&want);
861 AbilityInfo abilityInfo;
862 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
863 abilityInfo.ConvertToCompatiableAbilityInfo(compatibleAbilityInfo);
864 data.WriteParcelable(&compatibleAbilityInfo);
865 sptr<IRemoteObject> connect;
866 data.WriteRemoteObject(connect);
867 CallerInfo callerInfo;
868 callerInfo.uid = 0;
869 data.WriteInt32(callerInfo.uid);
870 callerInfo.pid = 0;
871 data.WriteInt32(callerInfo.pid);
872 callerInfo.sourceDeviceId = "";
873 data.WriteString(callerInfo.sourceDeviceId);
874 DistributedSchedService::AccountInfo accountInfo;
875 accountInfo.accountType = 0;
876 data.WriteInt32(accountInfo.accountType);
877 callerInfo.callerAppId = "";
878 data.WriteString(callerInfo.callerAppId);
879 result = distributedSchedStub_->ConnectAbilityFromRemoteInner(data, reply);
880 EXPECT_EQ(result, ERR_NONE);
881 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_001 end" << std::endl;
882 }
883
884 /**
885 * @tc.name: ConnectAbilityFromRemoteInner_002
886 * @tc.desc: check ConnectAbilityFromRemoteInner
887 * @tc.type: FUNC
888 */
889 HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteInner_002, TestSize.Level3)
890 {
891 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_002 begin" << std::endl;
892 MessageParcel data;
893 MessageParcel reply;
894
895 Want want;
896 data.WriteParcelable(&want);
897 AbilityInfo abilityInfo;
898 AppExecFwk::CompatibleAbilityInfo compatibleAbilityInfo;
899 abilityInfo.ConvertToCompatiableAbilityInfo(compatibleAbilityInfo);
900 data.WriteParcelable(&compatibleAbilityInfo);
901 sptr<IRemoteObject> connect;
902 data.WriteRemoteObject(connect);
903 CallerInfo callerInfo;
904 callerInfo.uid = 0;
905 data.WriteInt32(callerInfo.uid);
906 callerInfo.pid = 0;
907 data.WriteInt32(callerInfo.pid);
908 callerInfo.sourceDeviceId = "";
909 data.WriteString(callerInfo.sourceDeviceId);
910 DistributedSchedService::AccountInfo accountInfo;
911 accountInfo.accountType = 0;
912 data.WriteInt32(accountInfo.accountType);
913 data.WriteStringVector(accountInfo.groupIdList);
914 callerInfo.callerAppId = "";
915 data.WriteString(callerInfo.callerAppId);
916 nlohmann::json extraInfoJson;
917 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
918 std::string extraInfo = extraInfoJson.dump();
919 data.WriteString(extraInfo);
920 int32_t result = distributedSchedStub_->ConnectAbilityFromRemoteInner(data, reply);
921 EXPECT_EQ(result, ERR_NONE);
922 DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteInner_002 end" << std::endl;
923 }
924
925 /**
926 * @tc.name: DisconnectAbilityFromRemoteInner_001
927 * @tc.desc: check DisconnectAbilityFromRemoteInner
928 * @tc.type: FUNC
929 */
930 HWTEST_F(DistributedSchedStubTest, DisconnectAbilityFromRemoteInner_001, TestSize.Level3)
931 {
932 DTEST_LOG << "DistributedSchedStubTest DisconnectAbilityFromRemoteInner_001 begin" << std::endl;
933 MessageParcel data;
934 MessageParcel reply;
935
936 int32_t uid = 0;
937 data.WriteInt32(uid);
938 std::string sourceDeviceId = "";
939 data.WriteString(sourceDeviceId);
940 int32_t result = distributedSchedStub_->DisconnectAbilityFromRemoteInner(data, reply);
941 EXPECT_EQ(result, ERR_NONE);
942 DTEST_LOG << "DistributedSchedStubTest DisconnectAbilityFromRemoteInner_001 end" << std::endl;
943 }
944
945 /**
946 * @tc.name: NotifyProcessDiedFromRemoteInner_001
947 * @tc.desc: check NotifyProcessDiedFromRemoteInner
948 * @tc.type: FUNC
949 */
950 HWTEST_F(DistributedSchedStubTest, NotifyProcessDiedFromRemoteInner_001, TestSize.Level3)
951 {
952 DTEST_LOG << "DistributedSchedStubTest NotifyProcessDiedFromRemoteInner_001 begin" << std::endl;
953 MessageParcel data;
954 MessageParcel reply;
955
956 int32_t uid = 0;
957 data.WriteInt32(uid);
958 int32_t pid = 0;
959 data.WriteInt32(pid);
960 std::string sourceDeviceId = "";
961 data.WriteString(sourceDeviceId);
962 int32_t result = distributedSchedStub_->NotifyProcessDiedFromRemoteInner(data, reply);
963 EXPECT_EQ(result, ERR_NONE);
964 DTEST_LOG << "DistributedSchedStubTest NotifyProcessDiedFromRemoteInner_001 end" << std::endl;
965 }
966
967 #ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
968 /**
969 * @tc.name: GetMissionInfosInner_001
970 * @tc.desc: check GetMissionInfosInner
971 * @tc.type: FUNC
972 */
973 HWTEST_F(DistributedSchedStubTest, GetMissionInfosInner_001, TestSize.Level3)
974 {
975 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_001 begin" << std::endl;
976 int32_t code = DistributedSchedStub::GET_MISSION_INFOS;
977 MessageParcel data;
978 MessageParcel reply;
979 MessageOption option;
980
981 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
982 DistributedSchedUtil::MockPermission();
983 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
984 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
985 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_001 end" << std::endl;
986 }
987
988 /**
989 * @tc.name: GetMissionInfosInner_002
990 * @tc.desc: check GetMissionInfosInner
991 * @tc.type: FUNC
992 */
993 HWTEST_F(DistributedSchedStubTest, GetMissionInfosInner_002, TestSize.Level3)
994 {
995 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_002 begin" << std::endl;
996 int32_t code = DistributedSchedStub::GET_MISSION_INFOS;
997 MessageParcel data;
998 MessageParcel reply;
999 MessageOption option;
1000
1001 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1002 std::u16string deviceId = u"192.168.43.100";
1003 data.WriteString16(deviceId);
1004 int32_t numMissions = 0;
1005 data.WriteInt32(numMissions);
1006 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1007 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1008 DTEST_LOG << "DistributedSchedStubTest GetMissionInfosInner_002 end" << std::endl;
1009 }
1010
1011 /**
1012 * @tc.name: GetRemoteMissionSnapshotInfoInner_001
1013 * @tc.desc: check GetRemoteMissionSnapshotInfoInner
1014 * @tc.type: FUNC
1015 */
1016 HWTEST_F(DistributedSchedStubTest, GetRemoteMissionSnapshotInfoInner_001, TestSize.Level3)
1017 {
1018 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_001 begin" << std::endl;
1019 int32_t code = DistributedSchedStub::GET_REMOTE_MISSION_SNAPSHOT_INFO;
1020 MessageParcel data;
1021 MessageParcel reply;
1022 MessageOption option;
1023
1024 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1025 DistributedSchedUtil::MockPermission();
1026 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1027 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1028 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_001 end" << std::endl;
1029 }
1030
1031 /**
1032 * @tc.name: GetRemoteMissionSnapshotInfoInner_002
1033 * @tc.desc: check GetRemoteMissionSnapshotInfoInner
1034 * @tc.type: FUNC
1035 */
1036 HWTEST_F(DistributedSchedStubTest, GetRemoteMissionSnapshotInfoInner_002, TestSize.Level3)
1037 {
1038 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_002 begin" << std::endl;
1039 int32_t code = DistributedSchedStub::GET_REMOTE_MISSION_SNAPSHOT_INFO;
1040 MessageParcel data;
1041 MessageParcel reply;
1042 MessageOption option;
1043
1044 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1045 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1046 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1047
1048 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1049 std::string networkId = "255.255.255.255";
1050 data.WriteString(networkId);
1051 int32_t missionId = -1;
1052 data.WriteInt32(missionId);
1053 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1054 EXPECT_EQ(result, INVALID_PARAMETERS_ERR);
1055
1056 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1057 data.WriteString(networkId);
1058 missionId = 0;
1059 data.WriteInt32(missionId);
1060 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1061 EXPECT_EQ(result, ERR_NULL_OBJECT);
1062 DTEST_LOG << "DistributedSchedStubTest GetRemoteMissionSnapshotInfoInner_002 end" << std::endl;
1063 }
1064
1065 /**
1066 * @tc.name: RegisterMissionListenerInner_001
1067 * @tc.desc: check RegisterMissionListenerInner
1068 * @tc.type: FUNC
1069 */
1070 HWTEST_F(DistributedSchedStubTest, RegisterMissionListenerInner_001, TestSize.Level3)
1071 {
1072 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_001 begin" << std::endl;
1073 int32_t code = DistributedSchedStub::REGISTER_MISSION_LISTENER;
1074 MessageParcel data;
1075 MessageParcel reply;
1076 MessageOption option;
1077
1078 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1079 DistributedSchedUtil::MockPermission();
1080 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1081 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1082 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_001 end" << std::endl;
1083 }
1084
1085 /**
1086 * @tc.name: RegisterMissionListenerInner_002
1087 * @tc.desc: check RegisterMissionListenerInner
1088 * @tc.type: FUNC
1089 */
1090 HWTEST_F(DistributedSchedStubTest, RegisterMissionListenerInner_002, TestSize.Level3)
1091 {
1092 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_002 begin" << std::endl;
1093 int32_t code = DistributedSchedStub::REGISTER_MISSION_LISTENER;
1094 MessageParcel data;
1095 MessageParcel reply;
1096 MessageOption option;
1097
1098 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1099 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1100 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1101
1102 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1103 std::u16string devId = u"192.168.43.100";
1104 data.WriteString16(devId);
1105 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1106 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1107
1108 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1109 data.WriteString16(devId);
1110 sptr<IRemoteObject> missionChangedListener = new DistributedSchedService();
1111 data.WriteRemoteObject(missionChangedListener);
1112 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1113 EXPECT_EQ(result, ERR_NONE);
1114 DTEST_LOG << "DistributedSchedStubTest RegisterMissionListenerInner_002 end" << std::endl;
1115 }
1116
1117 /**
1118 * @tc.name: UnRegisterMissionListenerInner_001
1119 * @tc.desc: check UnRegisterMissionListenerInner
1120 * @tc.type: FUNC
1121 */
1122 HWTEST_F(DistributedSchedStubTest, UnRegisterMissionListenerInner_001, TestSize.Level3)
1123 {
1124 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_001 begin" << std::endl;
1125 int32_t code = DistributedSchedStub::UNREGISTER_MISSION_LISTENER;
1126 MessageParcel data;
1127 MessageParcel reply;
1128 MessageOption option;
1129
1130 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1131 DistributedSchedUtil::MockPermission();
1132 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1133 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1134 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_001 end" << std::endl;
1135 }
1136
1137 /**
1138 * @tc.name: UnRegisterMissionListenerInner_002
1139 * @tc.desc: check UnRegisterMissionListenerInner
1140 * @tc.type: FUNC
1141 */
1142 HWTEST_F(DistributedSchedStubTest, UnRegisterMissionListenerInner_002, TestSize.Level3)
1143 {
1144 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_002 begin" << std::endl;
1145 int32_t code = DistributedSchedStub::UNREGISTER_MISSION_LISTENER;
1146 MessageParcel data;
1147 MessageParcel reply;
1148 MessageOption option;
1149
1150 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1151 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1152 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1153
1154 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1155 std::u16string devId = u"192.168.43.100";
1156 data.WriteString16(devId);
1157 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1158 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1159
1160 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1161 data.WriteString16(devId);
1162 sptr<IRemoteObject> missionChangedListener = new DistributedSchedService();
1163 data.WriteRemoteObject(missionChangedListener);
1164 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1165 EXPECT_EQ(result, ERR_NONE);
1166 DTEST_LOG << "DistributedSchedStubTest UnRegisterMissionListenerInner_002 end" << std::endl;
1167 }
1168
1169 /**
1170 * @tc.name: StartSyncMissionsFromRemoteInner_001
1171 * @tc.desc: check StartSyncMissionsFromRemoteInner
1172 * @tc.type: FUNC
1173 */
1174 HWTEST_F(DistributedSchedStubTest, StartSyncMissionsFromRemoteInner_001, TestSize.Level3)
1175 {
1176 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_001 begin" << std::endl;
1177 MessageParcel data;
1178 MessageParcel reply;
1179
1180 int32_t result = distributedSchedStub_->StartSyncMissionsFromRemoteInner(data, reply);
1181 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1182 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_001 end" << std::endl;
1183 }
1184
1185 /**
1186 * @tc.name: StartSyncMissionsFromRemoteInner_002
1187 * @tc.desc: check StartSyncMissionsFromRemoteInner
1188 * @tc.type: FUNC
1189 */
1190 HWTEST_F(DistributedSchedStubTest, StartSyncMissionsFromRemoteInner_002, TestSize.Level3)
1191 {
1192 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_002 begin" << std::endl;
1193 MessageParcel data;
1194 MessageParcel reply;
1195 CallerInfo callerInfo;
1196 CallerInfoMarshalling(callerInfo, data);
1197
1198 DistributedSchedMissionManager::GetInstance().Init();
1199 int32_t result = distributedSchedStub_->StartSyncMissionsFromRemoteInner(data, reply);
1200 EXPECT_EQ(result, ERR_NONE);
1201 WaitHandlerTaskDone(DistributedSchedMissionManager::GetInstance().missionHandler_);
1202 DTEST_LOG << "DistributedSchedStubTest StartSyncMissionsFromRemoteInner_002 end" << std::endl;
1203 }
1204
1205 /**
1206 * @tc.name: StopSyncRemoteMissionsInner_001
1207 * @tc.desc: check StopSyncRemoteMissionsInner
1208 * @tc.type: FUNC
1209 */
1210 HWTEST_F(DistributedSchedStubTest, StopSyncRemoteMissionsInner_001, TestSize.Level3)
1211 {
1212 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_001 begin" << std::endl;
1213 int32_t code = DistributedSchedStub::STOP_SYNC_MISSIONS;
1214 MessageParcel data;
1215 MessageParcel reply;
1216 MessageOption option;
1217
1218 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1219 DistributedSchedUtil::MockPermission();
1220 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1221 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1222 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_001 end" << std::endl;
1223 }
1224
1225 /**
1226 * @tc.name: StopSyncRemoteMissionsInner_002
1227 * @tc.desc: check StopSyncRemoteMissionsInner
1228 * @tc.type: FUNC
1229 */
1230 HWTEST_F(DistributedSchedStubTest, StopSyncRemoteMissionsInner_002, TestSize.Level3)
1231 {
1232 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_002 begin" << std::endl;
1233 int32_t code = DistributedSchedStub::STOP_SYNC_MISSIONS;
1234 MessageParcel data;
1235 MessageParcel reply;
1236 MessageOption option;
1237
1238 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1239 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1240 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1241
1242 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1243 std::u16string deviceId = u"192.168.43.100";
1244 data.WriteString16(deviceId);
1245 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1246 EXPECT_EQ(result, ERR_NONE);
1247 DTEST_LOG << "DistributedSchedStubTest StopSyncRemoteMissionsInner_002 end" << std::endl;
1248 }
1249
1250 /**
1251 * @tc.name: StopSyncMissionsFromRemoteInner_001
1252 * @tc.desc: check StopSyncMissionsFromRemoteInner
1253 * @tc.type: FUNC
1254 */
1255 HWTEST_F(DistributedSchedStubTest, StopSyncMissionsFromRemoteInner_001, TestSize.Level3)
1256 {
1257 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_001 begin" << std::endl;
1258 MessageParcel data;
1259 MessageParcel reply;
1260
1261 int32_t result = distributedSchedStub_->StopSyncMissionsFromRemoteInner(data, reply);
1262 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1263 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_001 end" << std::endl;
1264 }
1265
1266 /**
1267 * @tc.name: StopSyncMissionsFromRemoteInner_002
1268 * @tc.desc: check StopSyncMissionsFromRemoteInner
1269 * @tc.type: FUNC
1270 */
1271 HWTEST_F(DistributedSchedStubTest, StopSyncMissionsFromRemoteInner_002, TestSize.Level3)
1272 {
1273 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_002 begin" << std::endl;
1274 MessageParcel data;
1275 MessageParcel reply;
1276 CallerInfo callerInfo;
1277 CallerInfoMarshalling(callerInfo, data);
1278
1279 DistributedSchedMissionManager::GetInstance().Init();
1280 int32_t result = distributedSchedStub_->StopSyncMissionsFromRemoteInner(data, reply);
1281 EXPECT_NE(result, ERR_FLATTEN_OBJECT);
1282 WaitHandlerTaskDone(DistributedSchedMissionManager::GetInstance().missionHandler_);
1283 DTEST_LOG << "DistributedSchedStubTest StopSyncMissionsFromRemoteInner_002 end" << std::endl;
1284 }
1285
1286 /**
1287 * @tc.name: NotifyMissionsChangedFromRemoteInner_001
1288 * @tc.desc: check NotifyMissionsChangedFromRemoteInner
1289 * @tc.type: FUNC
1290 */
1291 HWTEST_F(DistributedSchedStubTest, NotifyMissionsChangedFromRemoteInner_001, TestSize.Level3)
1292 {
1293 DTEST_LOG << "DistributedSchedStubTest NotifyMissionsChangedFromRemoteInner_001 begin" << std::endl;
1294 MessageParcel data;
1295 MessageParcel reply;
1296
1297 int32_t version = 0;
1298 data.WriteInt32(version);
1299 int32_t result = distributedSchedStub_->NotifyMissionsChangedFromRemoteInner(data, reply);
1300 EXPECT_EQ(result, ERR_NONE);
1301 DTEST_LOG << "DistributedSchedStubTest NotifyMissionsChangedFromRemoteInner_001 end" << std::endl;
1302 }
1303
1304 /**
1305 * @tc.name: StartSyncRemoteMissionsInner_001
1306 * @tc.desc: check StartSyncRemoteMissionsInner
1307 * @tc.type: FUNC
1308 */
1309 HWTEST_F(DistributedSchedStubTest, StartSyncRemoteMissionsInner_001, TestSize.Level3)
1310 {
1311 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_001 begin" << std::endl;
1312 int32_t code = DistributedSchedStub::START_SYNC_MISSIONS;
1313 MessageParcel data;
1314 MessageParcel reply;
1315 MessageOption option;
1316
1317 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1318 DistributedSchedUtil::MockPermission();
1319 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1320 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1321 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_001 end" << std::endl;
1322 }
1323
1324 /**
1325 * @tc.name: StartSyncRemoteMissionsInner_002
1326 * @tc.desc: check StartSyncRemoteMissionsInner
1327 * @tc.type: FUNC
1328 */
1329 HWTEST_F(DistributedSchedStubTest, StartSyncRemoteMissionsInner_002, TestSize.Level3)
1330 {
1331 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_002 begin" << std::endl;
1332 int32_t code = DistributedSchedStub::START_SYNC_MISSIONS;
1333 MessageParcel data;
1334 MessageParcel reply;
1335 MessageOption option;
1336
1337 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1338 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1339 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1340
1341 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1342 std::u16string deviceId = u"192.168.43.100";
1343 data.WriteString16(deviceId);
1344 bool fixConflict = false;
1345 data.WriteBool(fixConflict);
1346 int64_t tag = 0;
1347 data.WriteInt64(tag);
1348 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1349 EXPECT_EQ(result, ERR_NONE);
1350 DTEST_LOG << "DistributedSchedStubTest StartSyncRemoteMissionsInner_002 end" << std::endl;
1351 }
1352 #endif
1353
1354 /**
1355 * @tc.name: CallerInfoUnmarshalling_001
1356 * @tc.desc: check CallerInfoUnmarshalling
1357 * @tc.type: FUNC
1358 */
1359 HWTEST_F(DistributedSchedStubTest, CallerInfoUnmarshalling_001, TestSize.Level3)
1360 {
1361 DTEST_LOG << "DistributedSchedStubTest CallerInfoUnmarshalling_001 begin" << std::endl;
1362 MessageParcel data;
1363 int32_t uid = 0;
1364 data.WriteInt32(uid);
1365 int32_t pid = 0;
1366 data.WriteInt32(pid);
1367 int32_t callerType = 0;
1368 data.WriteInt32(callerType);
1369 std::string sourceDeviceId = "";
1370 data.WriteString(sourceDeviceId);
1371 int32_t duid = 0;
1372 data.WriteInt32(duid);
1373 std::string callerAppId = "test";
1374 data.WriteString(callerAppId);
1375 int32_t version = 0;
1376 data.WriteInt32(version);
1377 CallerInfo callerInfo;
1378 bool result = distributedSchedStub_->CallerInfoUnmarshalling(callerInfo, data);
1379 EXPECT_TRUE(result);
1380 DTEST_LOG << "DistributedSchedStubTest CallerInfoUnmarshalling_001 end" << std::endl;
1381 }
1382
1383 /**
1384 * @tc.name: StartRemoteAbilityByCallInner_001
1385 * @tc.desc: check StartRemoteAbilityByCallInner
1386 * @tc.type: FUNC
1387 */
1388 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_001, TestSize.Level3)
1389 {
1390 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_001 begin" << std::endl;
1391 int32_t code = DistributedSchedStub::START_REMOTE_ABILITY_BY_CALL;
1392 MessageParcel data;
1393 MessageParcel reply;
1394 MessageOption option;
1395
1396 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1397 DistributedSchedUtil::MockPermission();
1398 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1399 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1400 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_001 end" << std::endl;
1401 }
1402
1403 /**
1404 * @tc.name: StartRemoteAbilityByCallInner_002
1405 * @tc.desc: check StartRemoteAbilityByCallInner
1406 * @tc.type: FUNC
1407 */
1408 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_002, TestSize.Level3)
1409 {
1410 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_002 begin" << std::endl;
1411 int32_t code = DistributedSchedStub::START_REMOTE_ABILITY_BY_CALL;
1412 MessageParcel data;
1413 MessageParcel reply;
1414 MessageOption option;
1415
1416 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1417 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1418 EXPECT_EQ(result, ERR_NULL_OBJECT);
1419
1420 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1421 Want want;
1422 data.WriteParcelable(&want);
1423 sptr<IRemoteObject> connect;
1424 data.WriteRemoteObject(connect);
1425 int32_t callerUid = 0;
1426 data.WriteInt32(callerUid);
1427 int32_t callerPid = 0;
1428 data.WriteInt32(callerPid);
1429 uint32_t accessToken = 0;
1430 data.WriteUint32(accessToken);
1431 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1432 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1433 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_002 end" << std::endl;
1434 }
1435
1436 /**
1437 * @tc.name: StartRemoteAbilityByCallInner_003
1438 * @tc.desc: check StartRemoteAbilityByCallInner
1439 * @tc.type: FUNC
1440 */
1441 HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityByCallInner_003, TestSize.Level3)
1442 {
1443 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_003 begin" << std::endl;
1444 int32_t code = DistributedSchedStub::START_REMOTE_ABILITY_BY_CALL;
1445 MessageParcel data;
1446 MessageParcel reply;
1447 MessageOption option;
1448
1449 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1450 Want want;
1451 data.WriteParcelable(&want);
1452 sptr<IRemoteObject> connect;
1453 data.WriteRemoteObject(connect);
1454 int32_t callerUid = 0;
1455 data.WriteInt32(callerUid);
1456 int32_t callerPid = 0;
1457 data.WriteInt32(callerPid);
1458 uint32_t accessToken = GetSelfTokenID();
1459 data.WriteUint32(accessToken);
1460 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1461 EXPECT_EQ(result, ERR_NONE);
1462 DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityByCallInner_003 end" << std::endl;
1463 }
1464
1465 /**
1466 * @tc.name: ReleaseRemoteAbilityInner_001
1467 * @tc.desc: check ReleaseRemoteAbilityInner
1468 * @tc.type: FUNC
1469 */
1470 HWTEST_F(DistributedSchedStubTest, ReleaseRemoteAbilityInner_001, TestSize.Level3)
1471 {
1472 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_001 begin" << std::endl;
1473 int32_t code = DistributedSchedStub::RELEASE_REMOTE_ABILITY;
1474 MessageParcel data;
1475 MessageParcel reply;
1476 MessageOption option;
1477
1478 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1479 DistributedSchedUtil::MockPermission();
1480 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1481 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1482 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_001 end" << std::endl;
1483 }
1484
1485 /**
1486 * @tc.name: ReleaseRemoteAbilityInner_002
1487 * @tc.desc: check ReleaseRemoteAbilityInner
1488 * @tc.type: FUNC
1489 */
1490 HWTEST_F(DistributedSchedStubTest, ReleaseRemoteAbilityInner_002, TestSize.Level3)
1491 {
1492 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_002 begin" << std::endl;
1493 int32_t code = DistributedSchedStub::RELEASE_REMOTE_ABILITY;
1494 MessageParcel data;
1495 MessageParcel reply;
1496 MessageOption option;
1497
1498 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1499 sptr<IRemoteObject> connect;
1500 data.WriteRemoteObject(connect);
1501 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1502 EXPECT_EQ(result, ERR_INVALID_VALUE);
1503
1504 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1505 data.WriteRemoteObject(connect);
1506 ElementName element;
1507 data.WriteParcelable(&element);
1508 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1509 EXPECT_EQ(result, ERR_NONE);
1510 DTEST_LOG << "DistributedSchedStubTest ReleaseRemoteAbilityInner_002 end" << std::endl;
1511 }
1512
1513 /**
1514 * @tc.name: StartAbilityByCallFromRemoteInner_001
1515 * @tc.desc: check StartAbilityByCallFromRemoteInner
1516 * @tc.type: FUNC
1517 */
1518 HWTEST_F(DistributedSchedStubTest, StartAbilityByCallFromRemoteInner_001, TestSize.Level3)
1519 {
1520 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_001 begin" << std::endl;
1521 MessageParcel data;
1522 MessageParcel reply;
1523
1524 sptr<IRemoteObject> connect;
1525 data.WriteRemoteObject(connect);
1526 CallerInfo callerInfo;
1527 callerInfo.uid = 0;
1528 data.WriteInt32(callerInfo.uid);
1529 callerInfo.pid = 0;
1530 data.WriteInt32(callerInfo.pid);
1531 callerInfo.sourceDeviceId = "";
1532 data.WriteString(callerInfo.sourceDeviceId);
1533 DistributedSchedService::AccountInfo accountInfo;
1534 accountInfo.accountType = 0;
1535 data.WriteInt32(accountInfo.accountType);
1536 data.WriteStringVector(accountInfo.groupIdList);
1537 callerInfo.callerAppId = "";
1538 data.WriteString(callerInfo.callerAppId);
1539 int32_t result = distributedSchedStub_->StartAbilityByCallFromRemoteInner(data, reply);
1540 EXPECT_EQ(result, ERR_NULL_OBJECT);
1541
1542 data.WriteRemoteObject(connect);
1543 data.WriteInt32(callerInfo.uid);
1544 data.WriteInt32(callerInfo.pid);
1545 data.WriteString(callerInfo.sourceDeviceId);
1546 data.WriteInt32(accountInfo.accountType);
1547 data.WriteStringVector(accountInfo.groupIdList);
1548 data.WriteString(callerInfo.callerAppId);
1549 nlohmann::json extraInfoJson;
1550 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
1551 std::string extraInfo = extraInfoJson.dump();
1552 data.WriteString(extraInfo);
1553 result = distributedSchedStub_->StartAbilityByCallFromRemoteInner(data, reply);
1554 EXPECT_EQ(result, ERR_NULL_OBJECT);
1555 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_001 end" << std::endl;
1556 }
1557
1558 /**
1559 * @tc.name: StartAbilityByCallFromRemoteInner_002
1560 * @tc.desc: check StartAbilityByCallFromRemoteInner
1561 * @tc.type: FUNC
1562 */
1563 HWTEST_F(DistributedSchedStubTest, StartAbilityByCallFromRemoteInner_002, TestSize.Level3)
1564 {
1565 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_002 begin" << std::endl;
1566 MessageParcel data;
1567 MessageParcel reply;
1568
1569 sptr<IRemoteObject> connect;
1570 data.WriteRemoteObject(connect);
1571 CallerInfo callerInfo;
1572 callerInfo.uid = 0;
1573 data.WriteInt32(callerInfo.uid);
1574 callerInfo.pid = 0;
1575 data.WriteInt32(callerInfo.pid);
1576 callerInfo.sourceDeviceId = "";
1577 data.WriteString(callerInfo.sourceDeviceId);
1578 DistributedSchedService::AccountInfo accountInfo;
1579 accountInfo.accountType = 0;
1580 data.WriteInt32(accountInfo.accountType);
1581 data.WriteStringVector(accountInfo.groupIdList);
1582 callerInfo.callerAppId = "";
1583 data.WriteString(callerInfo.callerAppId);
1584 nlohmann::json extraInfoJson;
1585 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
1586 std::string extraInfo = extraInfoJson.dump();
1587 data.WriteString(extraInfo);
1588 Want want;
1589 data.WriteParcelable(&want);
1590 int32_t result = distributedSchedStub_->StartAbilityByCallFromRemoteInner(data, reply);
1591 EXPECT_EQ(result, ERR_NONE);
1592 DTEST_LOG << "DistributedSchedStubTest StartAbilityByCallFromRemoteInner_002 end" << std::endl;
1593 }
1594
1595 /**
1596 * @tc.name: ReleaseAbilityFromRemoteInner_001
1597 * @tc.desc: check ReleaseAbilityFromRemoteInner
1598 * @tc.type: FUNC
1599 */
1600 HWTEST_F(DistributedSchedStubTest, ReleaseAbilityFromRemoteInner_001, TestSize.Level3)
1601 {
1602 DTEST_LOG << "DistributedSchedStubTest ReleaseAbilityFromRemoteInner_001 begin" << std::endl;
1603 MessageParcel data;
1604 MessageParcel reply;
1605
1606 sptr<IRemoteObject> connect;
1607 data.WriteRemoteObject(connect);
1608 int32_t result = distributedSchedStub_->ReleaseAbilityFromRemoteInner(data, reply);
1609 EXPECT_EQ(result, ERR_INVALID_VALUE);
1610
1611 data.WriteRemoteObject(connect);
1612 ElementName element;
1613 data.WriteParcelable(&element);
1614 CallerInfo callerInfo;
1615 callerInfo.sourceDeviceId = "";
1616 data.WriteString(callerInfo.sourceDeviceId);
1617 nlohmann::json extraInfoJson;
1618 extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN] = 0;
1619 std::string extraInfo = extraInfoJson.dump();
1620 data.WriteString(extraInfo);
1621 result = distributedSchedStub_->ReleaseAbilityFromRemoteInner(data, reply);
1622 EXPECT_EQ(result, ERR_NONE);
1623 DTEST_LOG << "DistributedSchedStubTest ReleaseAbilityFromRemoteInner_001 end" << std::endl;
1624 }
1625
1626 #ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
1627 /**
1628 * @tc.name: StartRemoteShareFormInner_001
1629 * @tc.desc: check StartRemoteShareFormInner
1630 * @tc.type: FUNC
1631 */
1632 HWTEST_F(DistributedSchedStubTest, StartRemoteShareFormInner_001, TestSize.Level3)
1633 {
1634 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_001 begin" << std::endl;
1635 int32_t code = DistributedSchedStub::START_REMOTE_SHARE_FORM;
1636 MessageParcel data;
1637 MessageParcel reply;
1638 MessageOption option;
1639
1640 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1641 DistributedSchedUtil::MockPermission();
1642 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1643 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1644 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_001 end" << std::endl;
1645 }
1646
1647 /**
1648 * @tc.name: StartRemoteShareFormInner_002
1649 * @tc.desc: check StartRemoteShareFormInner
1650 * @tc.type: FUNC
1651 */
1652 HWTEST_F(DistributedSchedStubTest, StartRemoteShareFormInner_002, TestSize.Level3)
1653 {
1654 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_002 begin" << std::endl;
1655 int32_t code = DistributedSchedStub::START_REMOTE_SHARE_FORM;
1656 MessageParcel data;
1657 MessageParcel reply;
1658 MessageOption option;
1659
1660 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1661 std::string deviceId = "";
1662 data.WriteString(deviceId);
1663 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1664 EXPECT_EQ(result, ERR_NONE);
1665
1666 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1667 data.WriteString(deviceId);
1668 FormShareInfo formShareInfo;
1669 data.WriteParcelable(&formShareInfo);
1670 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1671 EXPECT_EQ(result, ERR_NONE);
1672 DTEST_LOG << "DistributedSchedStubTest StartRemoteShareFormInner_002 end" << std::endl;
1673 }
1674
1675 /**
1676 * @tc.name: StartShareFormFromRemoteInner_001
1677 * @tc.desc: check StartShareFormFromRemoteInner
1678 * @tc.type: FUNC
1679 */
1680 HWTEST_F(DistributedSchedStubTest, StartShareFormFromRemoteInner_001, TestSize.Level3)
1681 {
1682 DTEST_LOG << "DistributedSchedStubTest StartShareFormFromRemoteInner_001 begin" << std::endl;
1683 MessageParcel data;
1684 MessageParcel reply;
1685
1686 std::string deviceId = "";
1687 data.WriteString(deviceId);
1688 int32_t result = distributedSchedStub_->StartShareFormFromRemoteInner(data, reply);
1689 EXPECT_EQ(result, ERR_NONE);
1690
1691 data.WriteString(deviceId);
1692 FormShareInfo formShareInfo;
1693 data.WriteParcelable(&formShareInfo);
1694 result = distributedSchedStub_->StartShareFormFromRemoteInner(data, reply);
1695 EXPECT_EQ(result, ERR_NONE);
1696 DTEST_LOG << "DistributedSchedStubTest StartShareFormFromRemoteInner_001 end" << std::endl;
1697 }
1698 #endif
1699
1700 /**
1701 * @tc.name: StartRemoteFreeInstallInner_001
1702 * @tc.desc: check StartRemoteFreeInstallInner
1703 * @tc.type: FUNC
1704 */
1705 HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_001, TestSize.Level3)
1706 {
1707 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_001 begin" << std::endl;
1708 int32_t code = DistributedSchedStub::START_REMOTE_FREE_INSTALL;
1709 MessageParcel data;
1710 MessageParcel reply;
1711 MessageOption option;
1712
1713 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1714 DistributedSchedUtil::MockPermission();
1715 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1716 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1717 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_001 end" << std::endl;
1718 }
1719
1720 /**
1721 * @tc.name: StartRemoteFreeInstallInner_002
1722 * @tc.desc: check StartRemoteFreeInstallInner
1723 * @tc.type: FUNC
1724 */
1725 HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_002, TestSize.Level3)
1726 {
1727 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_002 begin" << std::endl;
1728 int32_t code = DistributedSchedStub::START_REMOTE_FREE_INSTALL;
1729 MessageParcel data;
1730 MessageParcel reply;
1731 MessageOption option;
1732
1733 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1734 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1735 EXPECT_EQ(result, ERR_NULL_OBJECT);
1736
1737 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1738 Want want;
1739 data.WriteParcelable(&want);
1740 int32_t callerUid = 0;
1741 data.WriteInt32(callerUid);
1742 int32_t requestCode = 0;
1743 data.WriteInt32(requestCode);
1744 uint32_t accessToken = 0;
1745 data.WriteUint32(accessToken);
1746 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1747 EXPECT_EQ(result, ERR_NULL_OBJECT);
1748
1749 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1750 data.WriteParcelable(&want);
1751 data.WriteInt32(callerUid);
1752 data.WriteInt32(requestCode);
1753 data.WriteUint32(accessToken);
1754 sptr<IRemoteObject> callback = new DistributedSchedService();
1755 data.WriteRemoteObject(callback);
1756 result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1757 EXPECT_EQ(result, DMS_PERMISSION_DENIED);
1758 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_002 end" << std::endl;
1759 }
1760
1761 /**
1762 * @tc.name: StartRemoteFreeInstallInner_003
1763 * @tc.desc: check StartRemoteFreeInstallInner
1764 * @tc.type: FUNC
1765 */
1766 HWTEST_F(DistributedSchedStubTest, StartRemoteFreeInstallInner_003, TestSize.Level3)
1767 {
1768 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_003 begin" << std::endl;
1769 int32_t code = DistributedSchedStub::START_REMOTE_FREE_INSTALL;
1770 MessageParcel data;
1771 MessageParcel reply;
1772 MessageOption option;
1773
1774 data.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN);
1775 Want want;
1776 data.WriteParcelable(&want);
1777 int32_t callerUid = 0;
1778 data.WriteInt32(callerUid);
1779 int32_t requestCode = 0;
1780 data.WriteInt32(requestCode);
1781 uint32_t accessToken = GetSelfTokenID();
1782 data.WriteUint32(accessToken);
1783 sptr<IRemoteObject> callback = new DistributedSchedService();
1784 data.WriteRemoteObject(callback);
1785 int32_t result = distributedSchedStub_->OnRemoteRequest(code, data, reply, option);
1786 EXPECT_EQ(result, ERR_NONE);
1787 DTEST_LOG << "DistributedSchedStubTest StartRemoteFreeInstallInner_003 end" << std::endl;
1788 }
1789
1790 /**
1791 * @tc.name: StartFreeInstallFromRemoteInner_001
1792 * @tc.desc: check StartFreeInstallFromRemoteInner
1793 * @tc.type: FUNC
1794 */
1795 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_001, TestSize.Level3)
1796 {
1797 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_001 begin" << std::endl;
1798 MessageParcel data;
1799 MessageParcel reply;
1800
1801 int32_t result = distributedSchedStub_->StartFreeInstallFromRemoteInner(data, reply);
1802 EXPECT_EQ(result, ERR_NULL_OBJECT);
1803 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_001 end" << std::endl;
1804 }
1805
1806 /**
1807 * @tc.name: StartFreeInstallFromRemoteInner_002
1808 * @tc.desc: check StartFreeInstallFromRemoteInner
1809 * @tc.type: FUNC
1810 */
1811 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_002, TestSize.Level3)
1812 {
1813 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_002 begin" << std::endl;
1814 MessageParcel data;
1815 MessageParcel reply;
1816 Want want;
1817 data.WriteParcelable(&want);
1818
1819 int32_t result = distributedSchedStub_->StartFreeInstallFromRemoteInner(data, reply);
1820 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1821 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_002 end" << std::endl;
1822 }
1823
1824 /**
1825 * @tc.name: StartFreeInstallFromRemoteInner_003
1826 * @tc.desc: check StartFreeInstallFromRemoteInner
1827 * @tc.type: FUNC
1828 */
1829 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_003, TestSize.Level3)
1830 {
1831 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_003 begin" << std::endl;
1832 MessageParcel data;
1833 MessageParcel reply;
1834 Want want;
1835 CallerInfo callerInfo;
1836 DistributedSchedService::AccountInfo accountInfo;
1837 int64_t taskId = 0;
1838 Want cmpWant;
1839 std::string extraInfo = "extraInfo";
1840 data.WriteParcelable(&want);
1841 FreeInstallInfoMarshalling(callerInfo, accountInfo, taskId, data);
1842 data.WriteParcelable(&cmpWant);
1843 data.WriteString(extraInfo);
1844
1845 int32_t result = distributedSchedStub_->StartFreeInstallFromRemoteInner(data, reply);
1846 EXPECT_EQ(result, ERR_NONE);
1847 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_003 end" << std::endl;
1848 }
1849
1850 /**
1851 * @tc.name: StartFreeInstallFromRemoteInner_004
1852 * @tc.desc: check StartFreeInstallFromRemoteInner
1853 * @tc.type: FUNC
1854 */
1855 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_004, TestSize.Level3)
1856 {
1857 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_004 begin" << std::endl;
1858 MessageParcel data;
1859 MessageParcel reply;
1860 Want want;
1861 CallerInfo callerInfo;
1862 DistributedSchedService::AccountInfo accountInfo;
1863 int64_t taskId = 0;
1864 Want cmpWant;
1865 std::string extraInfo = "{\"accessTokenID\": 0}";
1866 data.WriteParcelable(&want);
1867 FreeInstallInfoMarshalling(callerInfo, accountInfo, taskId, data);
1868 data.WriteParcelable(&cmpWant);
1869 data.WriteString(extraInfo);
1870
1871 int32_t result = distributedSchedStub_->StartFreeInstallFromRemoteInner(data, reply);
1872 EXPECT_EQ(result, ERR_NONE);
1873 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_004 end" << std::endl;
1874 }
1875
1876 /**
1877 * @tc.name: StartFreeInstallFromRemoteInner_005
1878 * @tc.desc: check StartFreeInstallFromRemoteInner
1879 * @tc.type: FUNC
1880 */
1881 HWTEST_F(DistributedSchedStubTest, StartFreeInstallFromRemoteInner_005, TestSize.Level3)
1882 {
1883 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_005 begin" << std::endl;
1884 MessageParcel data;
1885 MessageParcel reply;
1886 Want want;
1887 CallerInfo callerInfo;
1888 DistributedSchedService::AccountInfo accountInfo;
1889 int64_t taskId = 0;
1890 Want cmpWant;
1891 std::string extraInfo = "{\"requestCode\": 0, \"accessTokenID\": 0}";
1892 data.WriteParcelable(&want);
1893 FreeInstallInfoMarshalling(callerInfo, accountInfo, taskId, data);
1894 data.WriteParcelable(&cmpWant);
1895 data.WriteString(extraInfo);
1896
1897 int32_t result = distributedSchedStub_->StartFreeInstallFromRemoteInner(data, reply);
1898 EXPECT_EQ(result, ERR_NONE);
1899 DTEST_LOG << "DistributedSchedStubTest StartFreeInstallFromRemoteInner_005 end" << std::endl;
1900 }
1901
1902 /**
1903 * @tc.name: NotifyCompleteFreeInstallFromRemoteInner_001
1904 * @tc.desc: check NotifyCompleteFreeInstallFromRemoteInner
1905 * @tc.type: FUNC
1906 */
1907 HWTEST_F(DistributedSchedStubTest, NotifyCompleteFreeInstallFromRemoteInner_001, TestSize.Level3)
1908 {
1909 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteFreeInstallFromRemoteInner_001 begin" << std::endl;
1910 MessageParcel data;
1911 MessageParcel reply;
1912
1913 int32_t result = distributedSchedStub_->NotifyCompleteFreeInstallFromRemoteInner(data, reply);
1914 EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
1915
1916 int64_t taskId = 0;
1917 data.WriteInt64(taskId);
1918 int32_t resultCode = 0;
1919 data.WriteInt32(resultCode);
1920 result = distributedSchedStub_->NotifyCompleteFreeInstallFromRemoteInner(data, reply);
1921 EXPECT_EQ(result, ERR_NONE);
1922 DTEST_LOG << "DistributedSchedStubTest NotifyCompleteFreeInstallFromRemoteInner_001 end" << std::endl;
1923 }
1924 }
1925 }