• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "first_use_dialog_test.h"
16 
17 #include <cstdio>
18 #include "accesstoken_kit.h"
19 #include "location_button.h"
20 #include "save_button.h"
21 #include "sec_comp_log.h"
22 #include "sec_comp_err.h"
23 #include "sec_event_handler.h"
24 
25 using namespace testing::ext;
26 using namespace OHOS;
27 using namespace OHOS::Security::SecurityComponent;
28 using namespace OHOS::Security::AccessToken;
29 
30 namespace {
31 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
32     LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "FirstUseDialogTest"};
33 static const std::string SEC_COMP_SRV_CFG_PATH = "/data/service/el1/public/security_component_service";
34 static const std::string SEC_COMP_SRV_CFG_FILE = SEC_COMP_SRV_CFG_PATH + "/" + "first_use_record.json";
35 static const std::string SEC_COMP_SRV_CFG_BACK_FILE = SEC_COMP_SRV_CFG_PATH + "/" + "first_use_record.json.bak";
36 constexpr uint64_t LOCATION_BUTTON_FIRST_USE = 1 << 0;
37 constexpr uint64_t SAVE_BUTTON_FIRST_USE = 1 << 1;
38 }
39 
SetUpTestCase()40 void FirstUseDialogTest::SetUpTestCase()
41 {
42 }
43 
TearDownTestCase()44 void FirstUseDialogTest::TearDownTestCase()
45 {
46     struct stat fstatJson = {};
47     if (stat(SEC_COMP_SRV_CFG_FILE.c_str(), &fstatJson) != 0) {
48         return;
49     }
50     // if json file is created by root, delete it
51     if (fstatJson.st_uid == 0) {
52         std::string cmdline = "rm -f " + SEC_COMP_SRV_CFG_FILE;
53         system(cmdline.c_str());
54     }
55     struct stat fstatDir = {};
56     if (stat(SEC_COMP_SRV_CFG_PATH.c_str(), &fstatDir) != 0) {
57         return;
58     }
59     if (fstatDir.st_uid == 0) {
60         std::string cmdline = "chown security_component:security_component " + SEC_COMP_SRV_CFG_PATH;
61         system(cmdline.c_str());
62     }
63 }
64 
SetUp()65 void FirstUseDialogTest::SetUp()
66 {
67     SC_LOG_INFO(LABEL, "setup");
68     struct stat fstat = {};
69     if (stat(SEC_COMP_SRV_CFG_FILE.c_str(), &fstat) != 0) {
70         return;
71     }
72     std::string cmdline = "mv " + SEC_COMP_SRV_CFG_FILE + " " + SEC_COMP_SRV_CFG_BACK_FILE;
73     system(cmdline.c_str());
74 }
75 
TearDown()76 void FirstUseDialogTest::TearDown()
77 {
78     struct stat fstat = {};
79     if (stat(SEC_COMP_SRV_CFG_BACK_FILE.c_str(), &fstat) != 0) {
80         return;
81     }
82     std::string cmdline = "mv " + SEC_COMP_SRV_CFG_BACK_FILE + " " + SEC_COMP_SRV_CFG_FILE;
83     system(cmdline.c_str());
84 }
85 
86 /**
87  * @tc.name: LoadFirstUseRecord001
88  * @tc.desc: Test cfg file not exist
89  * @tc.type: FUNC
90  * @tc.require:
91  */
92 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord001, TestSize.Level1)
93 {
94     FirstUseDialog diag;
95     diag.LoadFirstUseRecord();
96     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
97 }
98 
99 /**
100  * @tc.name: LoadFirstUseRecord002
101  * @tc.desc: Test cfg file too large
102  * @tc.type: FUNC
103  * @tc.require:
104  */
105 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord002, TestSize.Level1)
106 {
107     std::string cmdline = "dd if=/dev/random of=" + SEC_COMP_SRV_CFG_FILE + " bs=101k count=1";
108     system(cmdline.c_str());
109     FirstUseDialog diag;
110     diag.LoadFirstUseRecord();
111     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
112 }
113 
114 /**
115  * @tc.name: LoadFirstUseRecord003
116  * @tc.desc: Test cfg file is not json
117  * @tc.type: FUNC
118  * @tc.require:
119  */
120 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord003, TestSize.Level1)
121 {
122     std::string cmdline = "echo {x=\\\' > " + SEC_COMP_SRV_CFG_FILE;
123     system(cmdline.c_str());
124     FirstUseDialog diag;
125     diag.LoadFirstUseRecord();
126     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
127 }
128 
129 /**
130  * @tc.name: LoadFirstUseRecord004
131  * @tc.desc: Test cfg file has no tag named FIRST_USE_RECORD_TAG
132  * @tc.type: FUNC
133  * @tc.require:
134  */
135 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord004, TestSize.Level1)
136 {
137     std::string cmdline = "echo {\\\"x\\\":1} > " + SEC_COMP_SRV_CFG_FILE;
138     system(cmdline.c_str());
139     FirstUseDialog diag;
140     diag.LoadFirstUseRecord();
141     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
142 }
143 
144 /**
145  * @tc.name: LoadFirstUseRecord005
146  * @tc.desc: Test cfg file has no tag named TOKEN_ID_TAG
147  * @tc.type: FUNC
148  * @tc.require:
149  */
150 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord005, TestSize.Level1)
151 {
152     std::string cmdline = "echo {\\\"FirstUseRecord\\\":[{\\\"CompType\\\":1}]} > "
153          + SEC_COMP_SRV_CFG_FILE;
154     system(cmdline.c_str());
155     FirstUseDialog diag;
156     diag.LoadFirstUseRecord();
157     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
158 }
159 
160 /**
161  * @tc.name: LoadFirstUseRecord006
162  * @tc.desc: Test cfg file TOKEN_ID_TAG is not number
163  * @tc.type: FUNC
164  * @tc.require:
165  */
166 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord006, TestSize.Level1)
167 {
168     std::string cmdline = "echo {\\\"FirstUseRecord\\\":[{\\\"CompType\\\":1,\\\"TokenId\\\":\\\"kk\\\"}]} > "
169          + SEC_COMP_SRV_CFG_FILE;
170     system(cmdline.c_str());
171     FirstUseDialog diag;
172     diag.LoadFirstUseRecord();
173     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
174 }
175 
176 /**
177  * @tc.name: LoadFirstUseRecord007
178  * @tc.desc: Test cfg file TOKEN_ID_TAG value is 0
179  * @tc.type: FUNC
180  * @tc.require:
181  */
182 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord007, TestSize.Level1)
183 {
184     std::string cmdline = "echo {\\\"FirstUseRecord\\\":[{\\\"CompType\\\":1,\\\"TokenId\\\":0}]} > "
185          + SEC_COMP_SRV_CFG_FILE;
186     system(cmdline.c_str());
187     FirstUseDialog diag;
188     diag.LoadFirstUseRecord();
189     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
190 }
191 
192 /**
193  * @tc.name: LoadFirstUseRecord008
194  * @tc.desc: Test cfg file COMP_TYPE_TAG is not exist
195  * @tc.type: FUNC
196  * @tc.require:
197  */
198 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord008, TestSize.Level1)
199 {
200     std::string cmdline = "echo {\\\"FirstUseRecord\\\":[{\\\"TokenId\\\":1}]} > "
201          + SEC_COMP_SRV_CFG_FILE;
202     system(cmdline.c_str());
203     FirstUseDialog diag;
204     diag.LoadFirstUseRecord();
205     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
206 }
207 
208 /**
209  * @tc.name: LoadFirstUseRecord009
210  * @tc.desc: Test cfg file COMP_TYPE_TAG is number
211  * @tc.type: FUNC
212  * @tc.require:
213  */
214 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord009, TestSize.Level1)
215 {
216     std::string cmdline = "echo {\\\"FirstUseRecord\\\":[{\\\"CompType\\\":\\\"k\\\",\\\"TokenId\\\":1}]} > "
217          + SEC_COMP_SRV_CFG_FILE;
218     system(cmdline.c_str());
219     FirstUseDialog diag;
220     diag.LoadFirstUseRecord();
221     ASSERT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
222 }
223 
224 /**
225  * @tc.name: LoadFirstUseRecord010
226  * @tc.desc: Test cfg file is success
227  * @tc.type: FUNC
228  * @tc.require:
229  */
230 HWTEST_F(FirstUseDialogTest, LoadFirstUseRecord010, TestSize.Level1)
231 {
232     std::string cmdline = "echo {\\\"FirstUseRecord\\\":[{\\\"CompType\\\":1,\\\"TokenId\\\":1}]} > "
233          + SEC_COMP_SRV_CFG_FILE;
234     system(cmdline.c_str());
235     FirstUseDialog diag;
236     diag.LoadFirstUseRecord();
237     ASSERT_EQ(1, static_cast<int32_t>(diag.firstUseMap_.size()));
238     ASSERT_EQ(1, static_cast<int32_t>(diag.firstUseMap_[1]));
239 }
240 
241 /**
242  * @tc.name: SaveFirstUseRecord001
243  * @tc.desc: Test cfg dir is not exist
244  * @tc.type: FUNC
245  * @tc.require:
246  */
247 HWTEST_F(FirstUseDialogTest, SaveFirstUseRecord001, TestSize.Level1)
248 {
249     std::string cmdline = "rm " + SEC_COMP_SRV_CFG_PATH + " -rf";
250     system(cmdline.c_str());
251     FirstUseDialog diag;
252     diag.firstUseMap_[1] = 1;
253     diag.SaveFirstUseRecord();
254     diag.firstUseMap_.clear();
255     diag.LoadFirstUseRecord();
256     EXPECT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
257     std::string cmdline1 = "mkdir " + SEC_COMP_SRV_CFG_PATH + " 0750 security_component security_component";
258     system(cmdline1.c_str());
259 }
260 
261 /**
262  * @tc.name: SaveFirstUseRecord002
263  * @tc.desc: Test cfg dir is not dir
264  * @tc.type: FUNC
265  * @tc.require:
266  */
267 HWTEST_F(FirstUseDialogTest, SaveFirstUseRecord002, TestSize.Level1)
268 {
269     std::string cmdline = "rm " + SEC_COMP_SRV_CFG_PATH + " -rf && touch " + SEC_COMP_SRV_CFG_PATH;
270     system(cmdline.c_str());
271     FirstUseDialog diag;
272     diag.firstUseMap_[1] = 1;
273     diag.SaveFirstUseRecord();
274     diag.firstUseMap_.clear();
275     diag.LoadFirstUseRecord();
276     EXPECT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
277     std::string cmdline1 = "rm " + SEC_COMP_SRV_CFG_PATH +  " && mkdir " +
278         SEC_COMP_SRV_CFG_PATH + " 0750 security_component security_component";
279     system(cmdline1.c_str());
280 }
281 
282 /**
283  * @tc.name: SaveFirstUseRecord003
284  * @tc.desc: Test cfg file is not exist, tokenid is invalid.
285  * @tc.type: FUNC
286  * @tc.require:
287  */
288 HWTEST_F(FirstUseDialogTest, SaveFirstUseRecord003, TestSize.Level1)
289 {
290     FirstUseDialog diag;
291     OHOS::Security::AccessToken::AccessTokenKit::getHapTokenInfoRes = -1;
292     diag.firstUseMap_[1] = 1;
293     diag.SaveFirstUseRecord();
294     diag.firstUseMap_.clear();
295     diag.LoadFirstUseRecord();
296     EXPECT_EQ(0, static_cast<int32_t>(diag.firstUseMap_.size()));
297     OHOS::Security::AccessToken::AccessTokenKit::getHapTokenInfoRes = 0;
298 }
299 
300 /**
301  * @tc.name: SaveFirstUseRecord004
302  * @tc.desc: Test cfg file is exist, save ok
303  * @tc.type: FUNC
304  * @tc.require:
305  */
306 HWTEST_F(FirstUseDialogTest, SaveFirstUseRecord004, TestSize.Level1)
307 {
308     FirstUseDialog diag;
309     diag.firstUseMap_[1] = 1;
310     diag.SaveFirstUseRecord();
311     diag.firstUseMap_.clear();
312     diag.LoadFirstUseRecord();
313     EXPECT_EQ(1, static_cast<int32_t>(diag.firstUseMap_.size()));
314     EXPECT_EQ(1, static_cast<int32_t>(diag.firstUseMap_[1]));
315 }
316 
317 class TestRemoteObject : public IRemoteObject {
318 public:
TestRemoteObject(std::u16string descriptor)319     explicit TestRemoteObject(std::u16string descriptor) : IRemoteObject(descriptor)
320     {
321     };
322 
323     ~TestRemoteObject() = default;
324 
IsProxyObject() const325     bool IsProxyObject() const override
326     {
327         return false;
328     };
329 
GetObjectRefCount()330     int32_t GetObjectRefCount() override
331     {
332         return 0;
333     };
334 
Dump(int fd,const std::vector<std::u16string> & args)335     int Dump(int fd, const std::vector<std::u16string>& args) override
336     {
337         return 0;
338     };
339 
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)340     int SendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override
341     {
342         return -1;
343     };
344 
AddDeathRecipient(const sptr<DeathRecipient> & recipient)345     bool AddDeathRecipient(const sptr<DeathRecipient>& recipient) override
346     {
347         return false;
348     };
349 
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)350     bool RemoveDeathRecipient(const sptr<DeathRecipient>& recipient) override
351     {
352         return false;
353     };
354 };
355 
356 /*
357  * @tc.name: SetFirstUseMap001
358  * @tc.desc: Test SetFirstUseMap
359  * @tc.type: FUNC
360  * @tc.require:
361  */
362 HWTEST_F(FirstUseDialogTest, SetFirstUseMap001, TestSize.Level1)
363 {
364     FirstUseDialog diag;
365     std::shared_ptr<SecCompEntity> entity = std::make_shared<SecCompEntity>(nullptr, 0, 0, 0, 0);
366 
367     std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
368     ASSERT_NE(nullptr, runner);
369     std::shared_ptr<SecEventHandler> handler = std::make_shared<SecEventHandler>(runner);
370     diag.secHandler_ = handler;
371 
372     // no entity
373     EXPECT_EQ(diag.SetFirstUseMap(nullptr), false);
374 
375     // type invalid
376     EXPECT_EQ(diag.SetFirstUseMap(entity), false);
377 
378     // first use location button
379     entity->componentInfo_ = std::make_shared<LocationButton>();
380     entity->componentInfo_->type_ = LOCATION_COMPONENT;
381     entity->tokenId_ = 0;
382     EXPECT_EQ(diag.SetFirstUseMap(entity), true);
383     EXPECT_EQ(LOCATION_BUTTON_FIRST_USE, static_cast<uint64_t>(diag.firstUseMap_[0]));
384 
385     // first use save button
386     entity->componentInfo_->type_ = SAVE_COMPONENT;
387     EXPECT_EQ(diag.SetFirstUseMap(entity), true);
388     EXPECT_EQ(LOCATION_BUTTON_FIRST_USE | SAVE_BUTTON_FIRST_USE, static_cast<uint64_t>(diag.firstUseMap_[0]));
389 
390     // second use save button
391     EXPECT_EQ(diag.SetFirstUseMap(entity), true);
392     EXPECT_EQ(LOCATION_BUTTON_FIRST_USE | SAVE_BUTTON_FIRST_USE, static_cast<uint64_t>(diag.firstUseMap_[0]));
393 
394     // wait for event handler done
395     sleep(3);
396 }
397 
398 /*
399  * @tc.name: NotifyFirstUseDialog001
400  * @tc.desc: Test NotifyFirstUseDialog
401  * @tc.type: FUNC
402  * @tc.require:
403  */
404 HWTEST_F(FirstUseDialogTest, NotifyFirstUseDialog001, TestSize.Level1)
405 {
406     FirstUseDialog diag;
407     diag.secHandler_ = nullptr;
408 
409     // no entity
410     EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID),
411         SC_SERVICE_ERROR_VALUE_INVALID);
412 
413     std::shared_ptr<SecCompEntity> entity = std::make_shared<SecCompEntity>(nullptr, 0, 0, 0, 0);
414     // no handler
415     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID),
416         SC_SERVICE_ERROR_VALUE_INVALID);
417 
418     // no calltoken
419     std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
420     ASSERT_NE(nullptr, runner);
421     std::shared_ptr<SecEventHandler> handler = std::make_shared<SecEventHandler>(runner);
422     diag.secHandler_ = handler;
423     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID),
424         SC_SERVICE_ERROR_VALUE_INVALID);
425 
426     // no dialogCallback
427     sptr<TestRemoteObject> testRemoteObject = new TestRemoteObject(std::u16string());
428     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr, 0, CrossAxisState::STATE_INVALID),
429         SC_SERVICE_ERROR_VALUE_INVALID);
430 
431     // type invalid
432     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID),
433         SC_OK);
434 
435     // first use location button
436     entity->componentInfo_ = std::make_shared<LocationButton>();
437     entity->componentInfo_->type_ = LOCATION_COMPONENT;
438     entity->tokenId_ = 0;
439     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID),
440         SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE);
441     EXPECT_EQ(0, static_cast<uint64_t>(diag.firstUseMap_[0]));
442 
443     // first use save button
444     entity->componentInfo_->type_ = SAVE_COMPONENT;
445     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID),
446         SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE);
447     EXPECT_EQ(0, static_cast<uint64_t>(diag.firstUseMap_[0]));
448 
449     // second use save button
450     EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID),
451         SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE);
452     EXPECT_EQ(0, static_cast<uint64_t>(diag.firstUseMap_[0]));
453 
454     diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID);
455 
456     // wait for event handler done
457     sleep(3);
458 }
459 
460 /*
461  * @tc.name: GrantDialogWaitEntity001
462  * @tc.desc: Test GrantDialogWaitEntity
463  * @tc.type: FUNC
464  * @tc.require:
465  */
466 HWTEST_F(FirstUseDialogTest, GrantDialogWaitEntity001, TestSize.Level1)
467 {
468     FirstUseDialog diag;
469     EXPECT_EQ(diag.GrantDialogWaitEntity(0), SC_SERVICE_ERROR_COMPONENT_NOT_EXIST);
470 
471     diag.dialogWaitMap_[0] = nullptr;
472     EXPECT_EQ(diag.GrantDialogWaitEntity(0), SC_SERVICE_ERROR_COMPONENT_NOT_EXIST);
473 
474     std::shared_ptr<SecCompEntity> entity = std::make_shared<SecCompEntity>(nullptr, 1, 0, 0, 0);
475     diag.dialogWaitMap_[0] = entity;
476     EXPECT_EQ(diag.GrantDialogWaitEntity(0), SC_SERVICE_ERROR_PERMISSION_OPER_FAIL);
477 
478     std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
479     ASSERT_NE(runner, nullptr);
480 
481     std::shared_ptr<SecEventHandler> handler = std::make_shared<SecEventHandler>(runner);
482     SecCompPermManager::GetInstance().InitEventHandler(handler);
483     entity->componentInfo_ = std::make_shared<SaveButton>();
484     entity->componentInfo_->type_ = SAVE_COMPONENT;
485     diag.dialogWaitMap_[1] = entity;
486     EXPECT_EQ(diag.GrantDialogWaitEntity(1), SC_OK);
487 }
488 
489 /*
490  * @tc.name: RemoveDialogWaitEntitys001
491  * @tc.desc: Test RemoveDialogWaitEntitys
492  * @tc.type: FUNC
493  * @tc.require:
494  */
495 HWTEST_F(FirstUseDialogTest, RemoveDialogWaitEntitys001, TestSize.Level1)
496 {
497     FirstUseDialog diag;
498     std::shared_ptr<SecCompEntity> entity = std::make_shared<SecCompEntity>(nullptr, 0, 0, 0, 0);
499     std::shared_ptr<SecCompEntity> entity1 = std::make_shared<SecCompEntity>(nullptr, 0, 0, 1, 0);
500     diag.dialogWaitMap_[0] = entity;
501     diag.dialogWaitMap_[1] = entity1;
502     diag.RemoveDialogWaitEntitys(1);
503     EXPECT_EQ(diag.dialogWaitMap_.count(1), 0);
504 }
505 
506 /*
507  * @tc.name: SecCompDialogSrvCallback001
508  * @tc.desc: Test SecCompDialogSrvCallback
509  * @tc.type: FUNC
510  * @tc.require:
511  */
512 HWTEST_F(FirstUseDialogTest, SecCompDialogSrvCallback001, TestSize.Level1)
513 {
514     SecCompDialogSrvCallback *call = new (std::nothrow)SecCompDialogSrvCallback(0, nullptr, nullptr);
515     sptr<SecCompDialogSrvCallback> srvCallback = call;
516 
517     MessageParcel data;
518     MessageParcel reply;
519     MessageOption option;
520     EXPECT_EQ(srvCallback->OnRemoteRequest(ISecCompDialogCallback::ON_DIALOG_CLOSED, data, reply, option),
521         SC_SERVICE_ERROR_IPC_REQUEST_FAIL);
522 
523     data.WriteInterfaceToken(ISecCompDialogCallback::GetDescriptor());
524     EXPECT_EQ(srvCallback->OnRemoteRequest(ISecCompDialogCallback::ON_DIALOG_CLOSED, data, reply, option),
525         SC_SERVICE_ERROR_IPC_REQUEST_FAIL);
526 
527     MessageParcel data1;
528     data1.WriteInterfaceToken(ISecCompDialogCallback::GetDescriptor());
529     data1.WriteInt32(0);
530     EXPECT_EQ(srvCallback->OnRemoteRequest(ISecCompDialogCallback::ON_DIALOG_CLOSED, data1, reply, option),
531         0);
532 
533     MessageParcel data2;
534     data2.WriteInterfaceToken(ISecCompDialogCallback::GetDescriptor());
535     EXPECT_NE(srvCallback->OnRemoteRequest(-1, data2, reply, option), 0);
536 }
537