1 /*
2 * Copyright (c) 2021-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 #include <gtest/gtest.h>
17
18 #define private public
19 #define protected public
20 #include "bundle_manager_helper.h"
21 #include "common_event_subscriber_manager.h"
22 #include "static_subscriber_manager.h"
23 #include "ability_manager_helper.h"
24 #undef private
25 #undef protected
26
27 #include "common_event_listener.h"
28 #include "common_event_stub.h"
29 #include "common_event_subscriber.h"
30 #include "inner_common_event_manager.h"
31 #include "mock_bundle_manager.h"
32 #include "bundle_manager_helper.h"
33 #include "common_event_manager_service.h"
34
35 using namespace testing::ext;
36 using namespace OHOS::EventFwk;
37 using namespace OHOS::AppExecFwk;
38
39 namespace {
40 const std::string EVENT = "com.ces.test.event";
41 const std::string ENTITY = "com.ces.test.entity";
42 const std::string SCHEME = "com.ces.test.scheme";
43 const std::string PERMISSION = "com.ces.test.permission";
44 const std::string DEVICEDID = "deviceId";
45 constexpr int32_t ERR_COMMON = -1;
46 } // namespace
47
48 static OHOS::sptr<OHOS::IRemoteObject> bundleObject = nullptr;
49 class CommonEventSubscribeUnitTest : public testing::Test {
50 public:
CommonEventSubscribeUnitTest()51 CommonEventSubscribeUnitTest()
52 {}
~CommonEventSubscribeUnitTest()53 ~CommonEventSubscribeUnitTest()
54 {}
55 static void SetUpTestCase(void);
56 static void TearDownTestCase(void);
57 void SetUp();
58 void TearDown();
59 };
60
61 class SubscriberTest : public CommonEventSubscriber {
62 public:
SubscriberTest(const CommonEventSubscribeInfo & sp)63 SubscriberTest(const CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp)
64 {}
65
~SubscriberTest()66 ~SubscriberTest()
67 {}
68
OnReceiveEvent(const CommonEventData & data)69 virtual void OnReceiveEvent(const CommonEventData &data)
70 {}
71 };
72
73 class CommonEventStubTest : public CommonEventStub {
74 public:
CommonEventStubTest()75 CommonEventStubTest()
76 {}
77
PublishCommonEvent(const CommonEventData & event,const CommonEventPublishInfo & publishinfo,const OHOS::sptr<OHOS::IRemoteObject> & commonEventListener,const int32_t & userId)78 virtual int32_t PublishCommonEvent(const CommonEventData &event, const CommonEventPublishInfo &publishinfo,
79 const OHOS::sptr<OHOS::IRemoteObject> &commonEventListener, const int32_t &userId)
80 {
81 return ERR_COMMON;
82 }
83
SubscribeCommonEvent(const CommonEventSubscribeInfo & subscribeInfo,const OHOS::sptr<OHOS::IRemoteObject> & commonEventListener)84 virtual int32_t SubscribeCommonEvent(
85 const CommonEventSubscribeInfo &subscribeInfo, const OHOS::sptr<OHOS::IRemoteObject> &commonEventListener)
86 {
87 return ERR_COMMON;
88 }
89
UnsubscribeCommonEvent(const OHOS::sptr<OHOS::IRemoteObject> & commonEventListener)90 virtual int32_t UnsubscribeCommonEvent(const OHOS::sptr<OHOS::IRemoteObject> &commonEventListener)
91 {
92 return ERR_COMMON;
93 }
94
DumpState(const uint8_t & dumpType,const std::string & event,const int32_t & userId,std::vector<std::string> & state)95 virtual bool DumpState(const uint8_t &dumpType, const std::string &event, const int32_t &userId,
96 std::vector<std::string> &state)
97 {
98 return false;
99 }
100
~CommonEventStubTest()101 virtual ~CommonEventStubTest()
102 {}
103
FinishReceiver(const OHOS::sptr<OHOS::IRemoteObject> & proxy,const int & code,const std::string & receiverData,const bool & abortEvent)104 virtual bool FinishReceiver(const OHOS::sptr<OHOS::IRemoteObject> &proxy, const int &code,
105 const std::string &receiverData, const bool &abortEvent)
106 {
107 return false;
108 }
109 };
110
111 class EventReceiveStubTest : public EventReceiveStub {
112 public:
EventReceiveStubTest()113 EventReceiveStubTest()
114 {}
115
~EventReceiveStubTest()116 ~EventReceiveStubTest()
117 {}
118
NotifyEvent(const CommonEventData & commonEventData,const bool & ordered,const bool & sticky)119 virtual void NotifyEvent(const CommonEventData &commonEventData, const bool &ordered, const bool &sticky)
120 {}
121 };
122
SetUpTestCase(void)123 void CommonEventSubscribeUnitTest::SetUpTestCase(void)
124 {
125 bundleObject = new MockBundleMgrService();
126 OHOS::DelayedSingleton<BundleManagerHelper>::GetInstance()->sptrBundleMgr_ =
127 OHOS::iface_cast<OHOS::AppExecFwk::IBundleMgr>(bundleObject);
128 }
129
TearDownTestCase(void)130 void CommonEventSubscribeUnitTest::TearDownTestCase(void)
131 {}
132
SetUp(void)133 void CommonEventSubscribeUnitTest::SetUp(void)
134 {}
135
TearDown(void)136 void CommonEventSubscribeUnitTest::TearDown(void)
137 {}
138
139 /*
140 * @tc.number: CommonEventSubscribeUnitTest_0300
141 * @tc.name: test subscribe event
142 * @tc.desc: InnerCommonEventManager subscribe common event success
143 */
144 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0300, Function | MediumTest | Level1)
145 {
146 // make subscriber info
147 MatchingSkills matchingSkills;
148 matchingSkills.AddEvent(EVENT);
149 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
150
151 // make subscriber
152 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
153
154 // make common event listener
155 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
156 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
157
158 // SubscribeCommonEvent
159 struct tm curTime {0};
160 OHOS::Security::AccessToken::AccessTokenID tokenID = 0;
161 InnerCommonEventManager innerCommonEventManager;
162 EXPECT_TRUE(innerCommonEventManager.SubscribeCommonEvent(
163 subscribeInfo, commonEventListenerPtr, curTime, 0, 0, tokenID, ""));
164 }
165
166 /*
167 * @tc.number: CommonEventSubscribeUnitTest_0400
168 * @tc.name: test subscribe event
169 * @tc.desc: InnerCommonEventManager subscribe common event fail because subscribeInfo has not event
170 */
171 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0400, Function | MediumTest | Level1)
172 {
173 // make subscriber info
174 MatchingSkills matchingSkills;
175 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
176
177 // make subscriber
178 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
179
180 // make common event listener
181 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
182 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
183
184 // SubscribeCommonEvent
185 struct tm curTime {0};
186 OHOS::Security::AccessToken::AccessTokenID tokenID = 0;
187 InnerCommonEventManager innerCommonEventManager;
188 EXPECT_FALSE(innerCommonEventManager.SubscribeCommonEvent(
189 subscribeInfo, commonEventListenerPtr, curTime, 0, 0, tokenID, ""));
190 }
191
192 /*
193 * @tc.number: CommonEventSubscribeUnitTest_0500
194 * @tc.name: test subscribe event
195 * @tc.desc: 1. subscribe common event
196 * 2. fail subscribe common event, inner common event manager
197 * common event listener is null
198 */
199 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0500, Function | MediumTest | Level1)
200 {
201 // make subscriber info
202 MatchingSkills matchingSkills;
203 matchingSkills.AddEvent(EVENT);
204 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
205
206 // SubscribeCommonEvent
207 OHOS::sptr<OHOS::IRemoteObject> sp(nullptr);
208 struct tm curTime {0};
209 OHOS::Security::AccessToken::AccessTokenID tokenID = 0;
210 InnerCommonEventManager innerCommonEventManager;
211 EXPECT_FALSE(innerCommonEventManager.SubscribeCommonEvent(subscribeInfo, sp, curTime, 0, 0, tokenID, ""));
212 }
213
214 /*
215 * @tc.number: CommonEventSubscribeUnitTest_0600
216 * @tc.name: test subscribe event
217 * @tc.desc: subscribe common event success
218 */
219 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0600, Function | MediumTest | Level1)
220 {
221 // make subscriber info
222 MatchingSkills matchingSkills;
223 matchingSkills.AddEvent(EVENT);
224 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
225 std::shared_ptr<CommonEventSubscribeInfo> subscribeInfoPtr =
226 std::make_shared<CommonEventSubscribeInfo>(subscribeInfo);
227
228 // make subscriber
229 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
230
231 // make common event listener
232 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
233 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
234
235 // InsertSubscriber
236 struct tm curTime {0};
237 EventRecordInfo eventRecordInfo;
238 eventRecordInfo.pid = 0;
239 eventRecordInfo.uid = 0;
240 eventRecordInfo.bundleName = "bundleName";
241 CommonEventSubscriberManager commonEventSubscriberManager;
242 auto result = commonEventSubscriberManager.InsertSubscriber(
243 subscribeInfoPtr, commonEventListener, curTime, eventRecordInfo);
244 EXPECT_NE(nullptr, result);
245 }
246
247 /*
248 * @tc.number: CommonEventSubscribeUnitTest_0700
249 * @tc.name: test subscribe event
250 * @tc.desc: 1. subscribe common event
251 * 2. fail subscribe common event , common event subscriber manager
252 * event subscriber info is null
253 */
254 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0700, Function | MediumTest | Level1)
255 {
256 // make subscriber info
257 MatchingSkills matchingSkills;
258 matchingSkills.AddEvent(EVENT);
259 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
260
261 // make subscriber
262 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
263
264 // make common event listener
265 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
266 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
267
268 // InsertSubscriber
269 struct tm curTime {0};
270 EventRecordInfo eventRecordInfo;
271 eventRecordInfo.pid = 0;
272 eventRecordInfo.uid = 0;
273 eventRecordInfo.bundleName = "bundleName";
274 CommonEventSubscriberManager commonEventSubscriberManager;
275 auto result =
276 commonEventSubscriberManager.InsertSubscriber(nullptr, commonEventListenerPtr, curTime, eventRecordInfo);
277 EXPECT_EQ(nullptr, result);
278 }
279
280 /*
281 * @tc.number: CommonEventSubscribeUnitTest_0800
282 * @tc.name: test subscribe event
283 * @tc.desc: 1. subscribe common event
284 * 2. fail subscribe common event , common event subscriber manager
285 * event common event listener is null
286 */
287 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0800, Function | MediumTest | Level1)
288 {
289 // make subscriber info
290 MatchingSkills matchingSkills;
291 matchingSkills.AddEvent(EVENT);
292 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
293 std::shared_ptr<CommonEventSubscribeInfo> subscribeInfoPtr =
294 std::make_shared<CommonEventSubscribeInfo>(subscribeInfo);
295
296 // make subscriber
297 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
298
299 // InsertSubscriber
300 struct tm curTime {0};
301 EventRecordInfo eventRecordInfo;
302 eventRecordInfo.pid = 0;
303 eventRecordInfo.uid = 0;
304 eventRecordInfo.bundleName = "bundleName";
305 CommonEventSubscriberManager commonEventSubscriberManager;
306 auto result = commonEventSubscriberManager.InsertSubscriber(subscribeInfoPtr, nullptr, curTime, eventRecordInfo);
307 EXPECT_EQ(nullptr, result);
308 }
309
310 /*
311 * @tc.number: CommonEventSubscribeUnitTest_0900
312 * @tc.name: test subscribe event
313 * @tc.desc: 1. subscribe common event
314 * 2. fail subscribe common event , common event subscriber manager
315 * event size is null
316 */
317 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_0900, Function | MediumTest | Level1)
318 {
319 // make subscriber info
320 MatchingSkills matchingSkills;
321 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
322 std::shared_ptr<CommonEventSubscribeInfo> subscribeInfoPtr =
323 std::make_shared<CommonEventSubscribeInfo>(subscribeInfo);
324
325 // make subscriber
326 CommonEventStubTest CommonEventStubTest;
327 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
328
329 // make common event listener
330 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
331 std::shared_ptr<InnerCommonEventManager> innerCommonEventManager = std::make_shared<InnerCommonEventManager>();
332 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
333
334 // InsertSubscriber
335 struct tm curTime {0};
336 EventRecordInfo eventRecordInfo;
337 eventRecordInfo.pid = 0;
338 eventRecordInfo.uid = 0;
339 eventRecordInfo.bundleName = "bundleName";
340 CommonEventSubscriberManager commonEventSubscriberManager;
341 auto result = commonEventSubscriberManager.InsertSubscriber(
342 subscribeInfoPtr, commonEventListenerPtr, curTime, eventRecordInfo);
343 EXPECT_EQ(nullptr, result);
344 }
345
346 /*
347 * @tc.number: CommonEventSubscribeUnitTest_1000
348 * @tc.name: ttest subscribe event
349 * @tc.desc: insert subscriber record locked success
350 */
351 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_1000, Function | MediumTest | Level1)
352 {
353 // make subscriber info
354 MatchingSkills matchingSkills;
355 matchingSkills.AddEvent(EVENT);
356 matchingSkills.AddEvent(ENTITY);
357 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
358
359 // make subscriber
360 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
361
362 // make common event listener
363 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
364 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
365
366 // make events
367 std::vector<std::string> events = subscribeInfo.GetMatchingSkills().GetEvents();
368
369 // make record
370 struct tm recordTime {0};
371 auto record = std::make_shared<EventSubscriberRecord>();
372 record->eventSubscribeInfo = std::make_shared<CommonEventSubscribeInfo>(subscribeInfo);
373 record->commonEventListener = commonEventListenerPtr;
374 record->recordTime = recordTime;
375 record->eventRecordInfo.pid = 0;
376 record->eventRecordInfo.uid = 0;
377 record->eventRecordInfo.bundleName = "bundleName";
378
379 // InsertSubscriberRecordLocked
380 CommonEventSubscriberManager commonEventSubscriberManager;
381 EXPECT_TRUE(commonEventSubscriberManager.InsertSubscriberRecordLocked(events, record));
382 }
383
384 /*
385 * @tc.number: CommonEventSubscribeUnitTest_1100
386 * @tc.name: test subscribe event
387 * @tc.desc: insert subscriber record locked fail because events size is 0
388 */
389 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_1100, Function | MediumTest | Level1)
390 {
391 // make subscriber info
392 MatchingSkills matchingSkills;
393 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
394
395 // make subscriber
396 std::shared_ptr<SubscriberTest> subscriber = std::make_shared<SubscriberTest>(subscribeInfo);
397
398 // make common event listener
399 OHOS::sptr<CommonEventListener> commonEventListener = new CommonEventListener(subscriber);
400 OHOS::sptr<OHOS::IRemoteObject> commonEventListenerPtr(commonEventListener);
401
402 // make events
403 std::vector<std::string> events = subscribeInfo.GetMatchingSkills().GetEvents();
404
405 // make record
406 struct tm recordTime {0};
407 auto record = std::make_shared<EventSubscriberRecord>();
408 record->eventSubscribeInfo = std::make_shared<CommonEventSubscribeInfo>(subscribeInfo);
409 record->commonEventListener = commonEventListenerPtr;
410 record->recordTime = recordTime;
411 record->eventRecordInfo.pid = 0;
412 record->eventRecordInfo.uid = 0;
413 record->eventRecordInfo.bundleName = "bundleName";
414
415 // InsertSubscriberRecordLocked
416 CommonEventSubscriberManager commonEventSubscriberManager;
417 EXPECT_FALSE(commonEventSubscriberManager.InsertSubscriberRecordLocked(events, record));
418 }
419
420 /*
421 * @tc.number: CommonEventSubscribeUnitTest_1200
422 * @tc.name: test subscribe event
423 * @tc.desc: insert subscriber record locked fail because record is nullptr
424 */
425 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventSubscribeUnitTest_1200, Function | MediumTest | Level1)
426 {
427 // make subscriber info
428 MatchingSkills matchingSkills;
429 CommonEventSubscribeInfo subscribeInfo(matchingSkills);
430
431 // make events
432 std::vector<std::string> events = subscribeInfo.GetMatchingSkills().GetEvents();
433 CommonEventSubscriberManager commonEventSubscriberManager;
434
435 // InsertSubscriberRecordLocked
436 EXPECT_FALSE(commonEventSubscriberManager.InsertSubscriberRecordLocked(events, nullptr));
437 }
438
439 /**
440 * @tc.name: AbilityManagerHelper_0001
441 * @tc.desc: GetAbilityMgrProxy
442 * @tc.type: FUNC
443 * @tc.require: I5R11Y
444 */
445 HWTEST_F(CommonEventSubscribeUnitTest, AbilityManagerHelper_0001, Function | MediumTest | Level1)
446 {
447 AbilityManagerHelper abilityManagerHelper;
448 bool result = abilityManagerHelper.GetAbilityMgrProxy();
449 abilityManagerHelper.Clear();
450 EXPECT_EQ(result, true);
451 }
452
453 /**
454 * @tc.name: AbilityManagerHelper_0002
455 * @tc.desc: ConnectAbility
456 * @tc.type: FUNC
457 * @tc.require: I5R11Y
458 */
459 HWTEST_F(CommonEventSubscribeUnitTest, AbilityManagerHelper_0002, Function | MediumTest | Level1)
460 {
461 // make a want
462 Want want;
463 want.SetAction(EVENT);
464
465 // make common event data
466 CommonEventData event;
467 OHOS::sptr<OHOS::IRemoteObject> callerToken(nullptr);
468 int32_t userId = 1;
469 AbilityManagerHelper abilityManagerHelper;
470 int result = abilityManagerHelper.ConnectAbility(want, event, callerToken, userId);
471 EXPECT_EQ(result, 2097177);
472 }
473
474 /**
475 * @tc.name: BundleManagerHelper_0001
476 * @tc.desc: QueryExtensionInfos
477 * @tc.type: FUNC
478 * @tc.require: I5R11Y
479 */
480 HWTEST_F(CommonEventSubscribeUnitTest, BundleManagerHelper_0001, Function | MediumTest | Level1)
481 {
482 std::vector<OHOS::AppExecFwk::ExtensionAbilityInfo> extensionInfos;
483 int32_t userId = 3;
484 BundleManagerHelper bundleManagerHelper;
485 bool result = bundleManagerHelper.QueryExtensionInfos(extensionInfos, userId);
486 EXPECT_EQ(result, false);
487 }
488
489 /**
490 * @tc.name: BundleManagerHelper_0002
491 * @tc.desc: GetResConfigFile
492 * @tc.type: FUNC
493 * @tc.require: I5R11Y
494 */
495 HWTEST_F(CommonEventSubscribeUnitTest, BundleManagerHelper_0002, Function | MediumTest | Level1)
496 {
497 OHOS::AppExecFwk::ExtensionAbilityInfo extension;
498 std::vector<std::string> profileInfos;
499 BundleManagerHelper bundleManagerHelper;
500 bool result = bundleManagerHelper.GetResConfigFile(extension, profileInfos);
501 EXPECT_EQ(result, false);
502 }
503
504 /**
505 * @tc.name: CommonEventManagerService_0001
506 * @tc.desc: PublishCommonEvent
507 * @tc.type: FUNC
508 * @tc.require: I5R11Y
509 */
510 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventManagerService_0001, Function | MediumTest | Level1)
511 {
512 // make a want
513 Want want;
514 want.SetAction(EVENT);
515 // make common event data
516 CommonEventData event;
517 // make publish info
518 CommonEventPublishInfo publishinfo;
519 OHOS::sptr<OHOS::IRemoteObject> commonEventListener(nullptr);
520 uid_t uid = 1;
521 int32_t userId = 1;
522 int32_t tokenId = 0;
523 CommonEventManagerService commonEventManagerService;
524 bool result = commonEventManagerService.PublishCommonEvent(event, publishinfo, commonEventListener, uid,
525 tokenId, userId);
526 EXPECT_EQ(result, false);
527 }
528
529 /**
530 * @tc.name: CommonEventManagerService_0002
531 * @tc.desc: DumpState
532 * @tc.type: FUNC
533 * @tc.require: I5R11Y
534 */
535 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventManagerService_0002, Function | MediumTest | Level1)
536 {
537 uint8_t dumpType = 1;
538 std::string event = "Event";
539 int32_t userId =2;
540 std::vector<std::string> state;
541 CommonEventManagerService commonEventManagerService;
542 bool result = commonEventManagerService.DumpState(dumpType, event, userId, state);
543 EXPECT_EQ(result, false);
544 }
545
546 /**
547 * @tc.name: CommonEventManagerService_0003
548 * @tc.desc: FinishReceiver
549 * @tc.type: FUNC
550 * @tc.require: I5R11Y
551 */
552 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventManagerService_0003, Function | MediumTest | Level1)
553 {
554 OHOS::sptr<OHOS::IRemoteObject> proxy(nullptr);
555 int32_t code = 0;
556 std::string receiverData = "receiverData";
557 CommonEventManagerService commonEventManagerService;
558 bool result = commonEventManagerService.FinishReceiver(proxy, code, receiverData, false);
559 EXPECT_EQ(result, false);
560 }
561
562 /**
563 * @tc.name: CommonEventManagerService_0004
564 * @tc.desc: Dump
565 * @tc.type: FUNC
566 * @tc.require: I5R11Y
567 */
568 HWTEST_F(CommonEventSubscribeUnitTest, CommonEventManagerService_0004, Function | MediumTest | Level1)
569 {
570 int fd = 1;
571 std::vector<std::u16string> args;
572 CommonEventManagerService commonEventManagerService;
573 int result = commonEventManagerService.Dump(fd, args);
574 EXPECT_EQ(result, int(OHOS::ERR_OK));
575 }