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 <atomic>
17 #include <gtest/gtest.h>
18
19 #include "event_handler.h"
20 #include "event_queue.h"
21 #include "event_runner.h"
22 #include "inner_event.h"
23
24 using namespace testing::ext;
25 using namespace OHOS;
26 using namespace OHOS::AppExecFwk;
27
28 namespace {
29 std::mutex g_mtx;
30 const uint32_t EVENT_ID = 0;
31 const uint32_t EVENT_ID_ONE = 100;
32 const uint32_t EVENT_ID_TWO = 101;
33 const uint32_t EVENT_ID_THREE = 102;
34 const uint32_t EVENT_ID_FOUR = 103;
35 const uint32_t EVENT_ID_FIVE = 104;
36 const int64_t EVENT_PARAM_ONE = 1000;
37 const int64_t EVENT_PARAM_TWO = 10000;
38 const int64_t EVENT_PARAM_THREE = 100000;
39 const int64_t EVENT_PARAM_FOUR = 10000000;
40 const int64_t EVENT_PARAM_FIVE = 100000000;
41 const int64_t FLAG_ONE = 1;
42 const int64_t FLAG_TWO = 2;
43 const int64_t FLAG_THREE = 3;
44 const int64_t FLAG_FOUR = 4;
45 const int64_t FLAG_FIVE = 5;
46 const int64_t DELAY_TIME = 10;
47 const int64_t DELAYWAITTIME = 100000;
48 bool g_isDump = true;
49 std::atomic<bool> eventRan(false);
50 const std::string THREAD_NAME_TEST1 = "threadNameTest1";
51 const std::string THREAD_NAME_TEST2 = " ";
52 const std::string THREAD_NAME_TEST3 = "@#¥#3243adsafdf_中文";
53 const std::string THREAD_NAME_TEST4 = std::to_string(0);
54 const std::string THREAD_NAME_TEST5 = std::to_string(0) + "@#¥#3243adsafdf_中文";
55 } // namespace
56
57 class EmsEventHandlerTest : public testing::Test {
58 public:
59 static void SetUpTestCase(void);
60 static void TearDownTestCase(void);
61 void SetUp();
62 void TearDown();
63 };
64
65 class CommonUtils {
66 public:
67 CommonUtils() = delete;
68 ~CommonUtils() = delete;
69 DISALLOW_COPY_AND_MOVE(CommonUtils);
70
71 /**
72 * Function: Get the processed result of event.
73 * @return Returns true if event has been processed.
74 */
EventRunGet()75 static inline bool EventRunGet()
76 {
77 GTEST_LOG_(INFO) << "CommonUtils: EventRunGet begain";
78 return g_eventRun_.load();
79 }
80
81 /**
82 * Function: Set the processed result of event.
83 * @param run Set false or true for processed result.
84 */
EventRunSet(bool run)85 static inline void EventRunSet(bool run)
86 {
87 GTEST_LOG_(INFO) << "CommonUtils: EventRunSet begain";
88 g_eventRun_.store(run);
89 }
90
91 /**
92 * Function: Get the called result of task.
93 * @return Returns true if task has been called.
94 */
TaskCalledGet()95 static inline bool TaskCalledGet()
96 {
97 return g_taskCalled_.load();
98 }
99
100 /**
101 * Function: Set the called result of task.
102 * @param run Set false or true for called result.
103 */
TaskCalledSet(bool called)104 static inline void TaskCalledSet(bool called)
105 {
106 g_taskCalled_.store(called);
107 }
108
109 /**
110 * Function: Get the processed times of event.
111 * @return Returns processed times.
112 */
EventRunCount()113 static inline uint32_t EventRunCount()
114 {
115 return g_eventRunTimes_;
116 }
117
118 /**
119 * Function: Increment of event processed times.
120 */
EventRunCountIncrement()121 static inline void EventRunCountIncrement()
122 {
123 g_eventRunTimes_++;
124 }
125
126 /**
127 * Function: Reset the count of event processed to 0.
128 */
EventRunCountReset()129 static inline void EventRunCountReset()
130 {
131 g_eventRunTimes_ = 0;
132 }
133
134 private:
135 static std::atomic<bool> g_eventRun_;
136 static std::atomic<bool> g_taskCalled_;
137 static std::atomic<uint32_t> g_eventRunTimes_;
138 };
139
140 std::atomic<bool> CommonUtils::g_eventRun_ = {false};
141 std::atomic<bool> CommonUtils::g_taskCalled_ = {false};
142 std::atomic<uint32_t> CommonUtils::g_eventRunTimes_ = {0};
143
SetUpTestCase(void)144 void EmsEventHandlerTest::SetUpTestCase(void)
145 {}
146
TearDownTestCase(void)147 void EmsEventHandlerTest::TearDownTestCase(void)
148 {}
149
SetUp(void)150 void EmsEventHandlerTest::SetUp(void)
151 {
152 /**
153 * @tc.setup: reset the eventRan value.
154 */
155 eventRan.store(false);
156 /**
157 * @tc.setup: Set the value of flags to the default.
158 */
159 CommonUtils::EventRunSet(false);
160 CommonUtils::TaskCalledSet(false);
161 }
162
TearDown(void)163 void EmsEventHandlerTest::TearDown(void)
164 {}
165
166 class MyEventHandler : public EventHandler {
167 public:
MyEventHandler(const std::shared_ptr<EventRunner> & runner)168 explicit MyEventHandler(const std::shared_ptr<EventRunner> &runner) : EventHandler(runner)
169 {}
~MyEventHandler()170 ~MyEventHandler()
171 {}
172
ProcessEvent(const InnerEvent::Pointer &)173 void ProcessEvent(const InnerEvent::Pointer &) override
174 {
175 GTEST_LOG_(INFO) << "MyEventHandler: ProcessEvent begain";
176 CommonUtils::EventRunSet(true);
177 }
178
179 MyEventHandler(const MyEventHandler &) = delete;
180 MyEventHandler &operator=(const MyEventHandler &) = delete;
181 MyEventHandler(MyEventHandler &&) = delete;
182 MyEventHandler &operator=(MyEventHandler &&) = delete;
183 };
184
185 class DumpTest : public Dumper {
186 public:
187 /**
188 * Processes the content of a specified string.
189 * @param message the content of a specified string.
190 */
Dump(const std::string & message)191 void Dump(const std::string &message)
192 {
193 g_isDump = true;
194 GTEST_LOG_(INFO) << message;
195 }
196
197 /**
198 * Obtains the tag information.
199 * which is a prefix added to each string before the string content is processed.
200 * @return the tag information.
201 */
GetTag()202 std::string GetTag()
203 {
204 return "DumpTest";
205 }
206 };
207
208 class TestEventHandler : public EventHandler {
209 public:
TestEventHandler(const std::shared_ptr<EventRunner> & runner)210 explicit TestEventHandler(const std::shared_ptr<EventRunner> &runner) : EventHandler(runner)
211 {}
~TestEventHandler()212 ~TestEventHandler() override
213 {}
214
ProcessEvent(const InnerEvent::Pointer & event)215 void ProcessEvent(const InnerEvent::Pointer &event) override
216 {
217 g_mtx.unlock();
218 switch (event->GetParam()) {
219 case FLAG_ONE: {
220 EXPECT_EQ(event->GetParam(), FLAG_ONE);
221 break;
222 }
223 case FLAG_TWO: {
224 EXPECT_EQ(event->GetParam(), FLAG_TWO);
225 break;
226 }
227 case FLAG_THREE: {
228 EXPECT_EQ(event->GetParam(), FLAG_THREE);
229 break;
230 }
231 case FLAG_FOUR: {
232 EXPECT_EQ(event->GetParam(), FLAG_FOUR);
233 break;
234 }
235 case FLAG_FIVE: {
236 EXPECT_EQ(event->GetParam(), FLAG_FIVE);
237 break;
238 }
239 default:
240 break;
241 }
242 }
243 };
244
ProcessEventTest(int flagParam)245 static void ProcessEventTest(int flagParam)
246 {
247 auto runner = EventRunner::Create(true);
248 auto handler = std::make_shared<TestEventHandler>(runner);
249 uint32_t innerEventId = 0;
250 auto event = InnerEvent::Get(innerEventId, flagParam);
251 g_mtx.lock();
252 handler->SendEvent(event);
253 int count = 0;
254 while (!g_mtx.try_lock()) {
255 if (count == 0) {
256 GTEST_LOG_(INFO) << "Wait ProcessEvent callback function process";
257 count = 1;
258 } else {
259 usleep(DELAYWAITTIME);
260 }
261 }
262
263 g_mtx.unlock();
264 }
265
266 /*
267 * @tc.name: GetEventName001
268 * @tc.desc: check when send event has no task return event id
269 * @tc.type: FUNC
270 */
271 HWTEST_F(EmsEventHandlerTest, GetEventName001, TestSize.Level1)
272 {
273 auto runner = EventRunner::Create(true);
274 auto handler = std::make_shared<EventHandler>(runner);
275 auto event001 = InnerEvent::Get(EVENT_ID);
276
277 std::string eventName = handler->GetEventName(event001);
278 EXPECT_EQ(eventName, std::to_string(EVENT_ID));
279 }
280
281 /*
282 * @tc.name: GetEventName002
283 * @tc.desc: check when send event with param but has no task return event id
284 * @tc.type: FUNC
285 */
286 HWTEST_F(EmsEventHandlerTest, GetEventName002, TestSize.Level1)
287 {
288 auto runner = EventRunner::Create(true);
289 auto handler = std::make_shared<EventHandler>(runner);
290 auto event002 = InnerEvent::Get(EVENT_ID, EVENT_PARAM_ONE);
291
292 std::string eventName = handler->GetEventName(event002);
293 EXPECT_EQ(eventName, std::to_string(EVENT_ID));
294 }
295
296 /*
297 * @tc.name: GetEventName003
298 * @tc.desc: check when send event has task event name is "name" return event name "name"
299 * @tc.type: FUNC
300 */
301 HWTEST_F(EmsEventHandlerTest, GetEventName003, TestSize.Level1)
302 {
303 auto runner = EventRunner::Create(true);
304 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0202() 305 auto task = []() { ; };
306 auto event003 = InnerEvent::Get(task, THREAD_NAME_TEST1);
307
308 std::string eventName = handler->GetEventName(event003);
309 EXPECT_EQ(eventName, THREAD_NAME_TEST1);
310 }
311
312 /*
313 * @tc.name: GetEventName004
314 * @tc.desc: check when send event has task task name is "" return event name ""
315 * @tc.type: FUNC
316 */
317 HWTEST_F(EmsEventHandlerTest, GetEventName004, TestSize.Level1)
318 {
319 auto runner = EventRunner::Create(true);
320 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0302() 321 auto task = []() { ; };
322 auto event004 = InnerEvent::Get(task, THREAD_NAME_TEST2);
323
324 std::string eventName = handler->GetEventName(event004);
325 EXPECT_EQ(eventName, THREAD_NAME_TEST2);
326 }
327
328 /*
329 * @tc.name: GetEventName005
330 * @tc.desc: check when send event has task task name is special characters return event name is right
331 * @tc.type: FUNC
332 */
333 HWTEST_F(EmsEventHandlerTest, GetEventName005, TestSize.Level1)
334 {
335 auto runner = EventRunner::Create(true);
336 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0402() 337 auto task = []() { ; };
338 auto event005 = InnerEvent::Get(task, THREAD_NAME_TEST3);
339
340 std::string eventName = handler->GetEventName(event005);
341 EXPECT_EQ(eventName, THREAD_NAME_TEST3);
342 }
343
344 /*
345 * @tc.name: GetEventName006
346 * @tc.desc: check when send event has task task name is special characters return event name is right
347 * @tc.type: FUNC
348 */
349 HWTEST_F(EmsEventHandlerTest, GetEventName006, TestSize.Level1)
350 {
351 auto runner = EventRunner::Create(true);
352 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0502() 353 auto task = []() { ; };
354 auto event005 = InnerEvent::Get(task, THREAD_NAME_TEST4);
355
356 std::string eventName = handler->GetEventName(event005);
357 EXPECT_EQ(eventName, THREAD_NAME_TEST4);
358 }
359
360 /*
361 * @tc.name: GetEventRunner001
362 * @tc.desc: check get event runner success
363 * @tc.type: FUNC
364 */
365 HWTEST_F(EmsEventHandlerTest, GetEventRunner001, TestSize.Level1)
366 {
367 auto runner = EventRunner::Create(true);
368 auto handler = std::make_shared<EventHandler>(runner);
369
370 auto result = handler->GetEventRunner();
371 EXPECT_EQ(result, runner);
372 }
373
374 /*
375 * @tc.name: GetEventRunner002
376 * @tc.desc: check get event runner success
377 * @tc.type: FUNC
378 */
379 HWTEST_F(EmsEventHandlerTest, GetEventRunner002, TestSize.Level1)
380 {
381 auto runner = EventRunner::Create(false);
382 auto handler = std::make_shared<EventHandler>(runner);
383
384 auto result = handler->GetEventRunner();
385 EXPECT_EQ(result, runner);
386 }
387
388 /*
389 * @tc.name: GetEventRunner001
390 * @tc.desc: check get event runner success
391 * @tc.type: FUNC
392 */
393 HWTEST_F(EmsEventHandlerTest, GetEventRunner003, TestSize.Level1)
394 {
395 auto runner = EventRunner::Create(THREAD_NAME_TEST1);
396 auto handler = std::make_shared<EventHandler>(runner);
397
398 auto result = handler->GetEventRunner();
399 EXPECT_EQ(result, runner);
400 }
401
402 /*
403 * @tc.name: GetEventRunner002
404 * @tc.desc: check get event runner success
405 * @tc.type: FUNC
406 */
407 HWTEST_F(EmsEventHandlerTest, GetEventRunner004, TestSize.Level1)
408 {
409 auto runner = EventRunner::Create(THREAD_NAME_TEST2);
410 auto handler = std::make_shared<EventHandler>(runner);
411
412 auto result = handler->GetEventRunner();
413 EXPECT_EQ(result, runner);
414 }
415
416 /*
417 * @tc.name: GetEventRunner001
418 * @tc.desc: check get event runner success
419 * @tc.type: FUNC
420 */
421 HWTEST_F(EmsEventHandlerTest, GetEventRunner005, TestSize.Level1)
422 {
423 auto runner = EventRunner::Create(THREAD_NAME_TEST3);
424 auto handler = std::make_shared<EventHandler>(runner);
425
426 auto result = handler->GetEventRunner();
427 EXPECT_EQ(result, runner);
428 }
429
430 /*
431 * @tc.name: GetEventRunner002
432 * @tc.desc: check get event runner success
433 * @tc.type: FUNC
434 */
435 HWTEST_F(EmsEventHandlerTest, GetEventRunner006, TestSize.Level1)
436 {
437 auto runner = EventRunner::Create(THREAD_NAME_TEST4);
438 auto handler = std::make_shared<EventHandler>(runner);
439
440 auto result = handler->GetEventRunner();
441 EXPECT_EQ(result, runner);
442 }
443
444 /*
445 * @tc.name: GetEventRunner001
446 * @tc.desc: check get event runner success
447 * @tc.type: FUNC
448 */
449 HWTEST_F(EmsEventHandlerTest, GetEventRunner007, TestSize.Level1)
450 {
451 auto runner = EventRunner::Create(THREAD_NAME_TEST5);
452 auto handler = std::make_shared<EventHandler>(runner);
453
454 auto result = handler->GetEventRunner();
455 EXPECT_EQ(result, runner);
456 }
457
458 /**
459 * @tc.name: ProcessEvent001
460 * @tc.desc: Check process event success with the flag
461 * HITRACE_FLAG_INCLUDE_ASYNC.
462 * @tc.type: FUNC
463 */
464 HWTEST_F(EmsEventHandlerTest, ProcessEvent001, TestSize.Level1)
465 {
466 int flagParam = FLAG_ONE;
467 ProcessEventTest(flagParam);
468 }
469
470 /**
471 * @tc.name: ProcessEvent002
472 * @tc.desc: Check process event success with the flag
473 * HITRACE_FLAG_DONOT_CREATE_SPAN.
474 * @tc.type: FUNC
475 */
476 HWTEST_F(EmsEventHandlerTest, ProcessEvent002, TestSize.Level1)
477 {
478 int flagParam = FLAG_TWO;
479 ProcessEventTest(flagParam);
480 }
481
482 /**
483 * @tc.name: ProcessEvent003
484 * @tc.desc: Check process event success with the flag
485 * HITRACE_FLAG_TP_INFO
486 * @tc.type: FUNC
487 */
488 HWTEST_F(EmsEventHandlerTest, ProcessEvent003, TestSize.Level1)
489 {
490 int flagParam = FLAG_THREE;
491 ProcessEventTest(flagParam);
492 }
493
494 /**
495 * @tc.name: ProcessEvent004
496 * @tc.desc: Check process event success with the flag
497 * HITRACE_FLAG_NO_BE_INFO | HITRACE_FLAG_INCLUDE_ASYNC.
498 * @tc.type: FUNC
499 * @tc.type: FUNC
500 */
501 HWTEST_F(EmsEventHandlerTest, ProcessEvent004, TestSize.Level1)
502 {
503 int flagParam = FLAG_FOUR;
504 ProcessEventTest(flagParam);
505 }
506
507 /**
508 * @tc.name: ProcessEvent005
509 * @tc.desc: Check process event success with the flag
510 * HITRACE_FLAG_DONOT_ENABLE_LOG | HITRACE_FLAG_INCLUDE_ASYNC.
511 * @tc.type: FUNC
512 */
513 HWTEST_F(EmsEventHandlerTest, ProcessEvent005, TestSize.Level1)
514 {
515 int flagParam = FLAG_FIVE;
516 ProcessEventTest(flagParam);
517 }
518
519 /*
520 * @tc.name: HasEventWithID001
521 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
522 * sent and processed.
523 * @tc.type: FUNC
524 */
525 HWTEST_F(EmsEventHandlerTest, HasEventWithID001, TestSize.Level1)
526 {
527 auto runner = EventRunner::Create(true);
528 auto handler = std::make_shared<EventHandler>(runner);
529 auto object = std::make_shared<uint32_t>();
530 auto event = InnerEvent::Get(EVENT_ID_ONE, object);
531
532 handler->SendTimingEvent(event, FLAG_ONE);
533 usleep(DELAYWAITTIME);
534 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
535 EXPECT_FALSE(hasInnerEvent);
536 }
537
538 /*
539 * @tc.name: HasEventWithID002
540 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
541 * sent and processed.
542 * @tc.type: FUNC
543 */
544 HWTEST_F(EmsEventHandlerTest, HasEventWithID002, TestSize.Level1)
545 {
546 auto runner = EventRunner::Create(true);
547 auto handler = std::make_shared<EventHandler>(runner);
548 auto object = std::make_shared<uint32_t>();
549 auto event = InnerEvent::Get(EVENT_ID_TWO, object);
550
551 handler->SendTimingEvent(event, FLAG_TWO);
552 usleep(DELAYWAITTIME);
553 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
554 EXPECT_FALSE(hasInnerEvent);
555 }
556
557 /*
558 * @tc.name: HasEventWithID003
559 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
560 * sent and processed.
561 * @tc.type: FUNC
562 */
563 HWTEST_F(EmsEventHandlerTest, HasEventWithID003, TestSize.Level1)
564 {
565 auto runner = EventRunner::Create(true);
566 auto handler = std::make_shared<EventHandler>(runner);
567 auto object = std::make_shared<uint32_t>();
568 auto event = InnerEvent::Get(EVENT_ID_THREE, object);
569
570 handler->SendTimingEvent(event, FLAG_THREE);
571 usleep(DELAYWAITTIME);
572 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
573 EXPECT_FALSE(hasInnerEvent);
574 }
575
576 /*
577 * @tc.name: HasEventWithID004
578 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
579 * sent and processed.
580 * @tc.type: FUNC
581 */
582 HWTEST_F(EmsEventHandlerTest, HasEventWithID004, TestSize.Level1)
583 {
584 auto runner = EventRunner::Create(true);
585 auto handler = std::make_shared<EventHandler>(runner);
586 auto object = std::make_shared<uint32_t>();
587 auto event = InnerEvent::Get(EVENT_ID_FOUR, object);
588
589 handler->SendTimingEvent(event, FLAG_FOUR);
590 usleep(DELAYWAITTIME);
591 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FOUR);
592 EXPECT_FALSE(hasInnerEvent);
593 }
594
595 /*
596 * @tc.name: HasEventWithID005
597 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
598 * sent and processed.
599 * @tc.type: FUNC
600 */
601 HWTEST_F(EmsEventHandlerTest, HasEventWithID005, TestSize.Level1)
602 {
603 auto runner = EventRunner::Create(true);
604 auto handler = std::make_shared<EventHandler>(runner);
605 auto object = std::make_shared<uint32_t>();
606 auto event = InnerEvent::Get(EVENT_ID_FIVE, object);
607
608 handler->SendTimingEvent(event, FLAG_FIVE);
609 usleep(DELAYWAITTIME);
610 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
611 EXPECT_FALSE(hasInnerEvent);
612 }
613
614 /*
615 * @tc.name: HasEventWithID006
616 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
617 * sent and processed.
618 * @tc.type: FUNC
619 */
620 HWTEST_F(EmsEventHandlerTest, HasEventWithID006, TestSize.Level1)
621 {
622 auto runner = EventRunner::Create(true);
623 auto handler = std::make_shared<EventHandler>(runner);
624
625 handler->SendEvent(EVENT_ID_ONE, FLAG_ONE, 0);
626 usleep(DELAYWAITTIME);
627 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
628 EXPECT_FALSE(hasInnerEvent);
629 }
630
631 /*
632 * @tc.name: HasEventWithID007
633 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
634 * sent and processed.
635 * @tc.type: FUNC
636 */
637 HWTEST_F(EmsEventHandlerTest, HasEventWithID007, TestSize.Level1)
638 {
639 auto runner = EventRunner::Create(true);
640 auto handler = std::make_shared<EventHandler>(runner);
641
642 handler->SendEvent(EVENT_ID_TWO, FLAG_TWO, 0);
643 usleep(DELAYWAITTIME);
644 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
645 EXPECT_FALSE(hasInnerEvent);
646 }
647
648 /*
649 * @tc.name: HasEventWithID008
650 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
651 * sent and processed.
652 * @tc.type: FUNC
653 */
654 HWTEST_F(EmsEventHandlerTest, HasEventWithID008, TestSize.Level1)
655 {
656 auto runner = EventRunner::Create(true);
657 auto handler = std::make_shared<EventHandler>(runner);
658
659 handler->SendEvent(EVENT_ID_THREE, FLAG_THREE, 0);
660 usleep(DELAYWAITTIME);
661 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
662 EXPECT_FALSE(hasInnerEvent);
663 }
664
665 /*
666 * @tc.name: HasEventWithID009
667 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
668 * sent and processed.
669 * @tc.type: FUNC
670 */
671 HWTEST_F(EmsEventHandlerTest, HasEventWithID009, TestSize.Level1)
672 {
673 auto runner = EventRunner::Create(true);
674 auto handler = std::make_shared<EventHandler>(runner);
675
676 handler->SendEvent(EVENT_ID_FOUR, FLAG_FOUR, 0);
677 usleep(DELAYWAITTIME);
678 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FOUR);
679 EXPECT_FALSE(hasInnerEvent);
680 }
681
682 /*
683 * @tc.name: HasEventWithID010
684 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
685 * sent and processed.
686 * @tc.type: FUNC
687 */
688 HWTEST_F(EmsEventHandlerTest, HasEventWithID010, TestSize.Level1)
689 {
690 auto runner = EventRunner::Create(true);
691 auto handler = std::make_shared<EventHandler>(runner);
692
693 handler->SendEvent(EVENT_ID_FIVE, FLAG_FIVE, 0);
694 usleep(DELAYWAITTIME);
695 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
696 EXPECT_FALSE(hasInnerEvent);
697 }
698
699 /*
700 * @tc.name: HasEventWithID011
701 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
702 * sent and processed.
703 * @tc.type: FUNC
704 */
705 HWTEST_F(EmsEventHandlerTest, HasEventWithID011, TestSize.Level1)
706 {
707 auto runner = EventRunner::Create(true);
708 auto handler = std::make_shared<EventHandler>(runner);
709 auto object = std::make_shared<uint32_t>();
710 auto event = InnerEvent::Get(EVENT_ID_ONE, FLAG_ONE, object);
711
712 handler->SendEvent(event);
713 usleep(DELAYWAITTIME);
714 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
715 EXPECT_FALSE(hasInnerEvent);
716 }
717
718 /*
719 * @tc.name: HasEventWithID002
720 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
721 * sent and processed.
722 * @tc.type: FUNC
723 */
724 HWTEST_F(EmsEventHandlerTest, HasEventWithID012, TestSize.Level1)
725 {
726 auto runner = EventRunner::Create(true);
727 auto handler = std::make_shared<EventHandler>(runner);
728 auto object = std::make_shared<uint32_t>();
729 auto event = InnerEvent::Get(EVENT_ID_TWO, FLAG_ONE, object);
730
731 handler->SendEvent(event);
732 usleep(DELAYWAITTIME);
733 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
734 EXPECT_FALSE(hasInnerEvent);
735 }
736
737 /*
738 * @tc.name: HasEventWithID003
739 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
740 * sent and processed.
741 * @tc.type: FUNC
742 */
743 HWTEST_F(EmsEventHandlerTest, HasEventWithID013, TestSize.Level1)
744 {
745 auto runner = EventRunner::Create(true);
746 auto handler = std::make_shared<EventHandler>(runner);
747 auto object = std::make_shared<uint32_t>();
748 auto event = InnerEvent::Get(EVENT_ID_THREE, FLAG_ONE, object);
749
750 handler->SendEvent(event);
751 usleep(DELAYWAITTIME);
752 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
753 EXPECT_FALSE(hasInnerEvent);
754 }
755
756 /*
757 * @tc.name: HasEventWithID014
758 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
759 * sent and processed.
760 * @tc.type: FUNC
761 */
762 HWTEST_F(EmsEventHandlerTest, HasEventWithID014, TestSize.Level1)
763 {
764 auto runner = EventRunner::Create(true);
765 auto handler = std::make_shared<EventHandler>(runner);
766 auto object = std::make_shared<uint32_t>();
767 auto event = InnerEvent::Get(EVENT_ID_FOUR, FLAG_ONE, object);
768
769 handler->SendEvent(event);
770 usleep(DELAYWAITTIME);
771 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FOUR);
772 EXPECT_FALSE(hasInnerEvent);
773 }
774
775 /*
776 * @tc.name: HasEventWithID015
777 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
778 * sent and processed.
779 * @tc.type: FUNC
780 */
781 HWTEST_F(EmsEventHandlerTest, HasEventWithID015, TestSize.Level1)
782 {
783 auto runner = EventRunner::Create(true);
784 auto handler = std::make_shared<EventHandler>(runner);
785 auto object = std::make_shared<uint32_t>();
786 auto event = InnerEvent::Get(EVENT_ID_FOUR, FLAG_ONE, object);
787
788 handler->SendEvent(event);
789 usleep(DELAYWAITTIME);
790 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
791 EXPECT_FALSE(hasInnerEvent);
792 }
793
794 /*
795 * @tc.name: HasEventWithID016
796 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
797 * sent and processed.
798 * @tc.type: FUNC
799 */
800 HWTEST_F(EmsEventHandlerTest, HasEventWithID016, TestSize.Level1)
801 {
802 auto runner = EventRunner::Create(true);
803 auto handler = std::make_shared<EventHandler>(runner);
804 auto event = InnerEvent::Get(EVENT_ID_ONE);
805
806 handler->SendEvent(event, TestEventHandler::Priority::IMMEDIATE);
807 usleep(DELAYWAITTIME);
808 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
809 EXPECT_FALSE(hasInnerEvent);
810 }
811
812 /*
813 * @tc.name: HasEventWithID017
814 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
815 * sent and processed.
816 * @tc.type: FUNC
817 */
818 HWTEST_F(EmsEventHandlerTest, HasEventWithID017, TestSize.Level1)
819 {
820 auto runner = EventRunner::Create(true);
821 auto handler = std::make_shared<EventHandler>(runner);
822 auto event = InnerEvent::Get(EVENT_ID);
823
824 handler->SendEvent(event, TestEventHandler::Priority::IMMEDIATE);
825 usleep(DELAYWAITTIME);
826 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
827 EXPECT_FALSE(hasInnerEvent);
828 }
829
830 /*
831 * @tc.name: HasEventWithID018
832 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
833 * sent and processed.
834 * @tc.type: FUNC
835 */
836 HWTEST_F(EmsEventHandlerTest, HasEventWithID018, TestSize.Level1)
837 {
838 auto runner = EventRunner::Create(true);
839 auto handler = std::make_shared<EventHandler>(runner);
840 auto event = InnerEvent::Get(EVENT_ID);
841
842 handler->SendEvent(event, TestEventHandler::Priority::IDLE);
843 usleep(DELAYWAITTIME);
844 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
845 EXPECT_TRUE(hasInnerEvent);
846 }
847
848 /*
849 * @tc.name: HasEventWithID019
850 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
851 * sent and processed.
852 * @tc.type: FUNC
853 */
854 HWTEST_F(EmsEventHandlerTest, HasEventWithID019, TestSize.Level1)
855 {
856 auto runner = EventRunner::Create(true);
857 auto handler = std::make_shared<EventHandler>(runner);
858 auto event = InnerEvent::Get(EVENT_ID);
859
860 handler->SendEvent(event, TestEventHandler::Priority::HIGH);
861 usleep(DELAYWAITTIME);
862 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
863 EXPECT_FALSE(hasInnerEvent);
864 }
865
866 /*
867 * @tc.name: HasEventWithID020
868 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
869 * sent and processed.
870 * @tc.type: FUNC
871 */
872 HWTEST_F(EmsEventHandlerTest, HasEventWithID020, TestSize.Level1)
873 {
874 auto runner = EventRunner::Create(true);
875 auto handler = std::make_shared<EventHandler>(runner);
876 auto event = InnerEvent::Get(EVENT_ID);
877
878 handler->SendEvent(event, TestEventHandler::Priority::LOW);
879 usleep(DELAYWAITTIME);
880 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
881 EXPECT_FALSE(hasInnerEvent);
882 }
883
884 /*
885 * @tc.name: HasEventWithID021
886 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
887 * sent and processed.
888 * @tc.type: FUNC
889 */
890 HWTEST_F(EmsEventHandlerTest, HasEventWithID021, TestSize.Level1)
891 {
892 auto runner = EventRunner::Create(true);
893 auto handler = std::make_shared<EventHandler>(runner);
894 auto event = InnerEvent::Get(EVENT_ID);
895
896 handler->SendTimingEvent(EVENT_ID, FLAG_ONE);
897 usleep(DELAYWAITTIME);
898 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
899 EXPECT_FALSE(hasInnerEvent);
900 }
901
902 /*
903 * @tc.name: HasEventWithID022
904 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
905 * sent and processed.
906 * @tc.type: FUNC
907 */
908 HWTEST_F(EmsEventHandlerTest, HasEventWithID022, TestSize.Level1)
909 {
910 auto runner = EventRunner::Create(true);
911 auto handler = std::make_shared<EventHandler>(runner);
912 auto event = InnerEvent::Get(EVENT_ID);
913
914 handler->SendTimingEvent(EVENT_ID, FLAG_TWO);
915 usleep(DELAYWAITTIME);
916 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
917 EXPECT_FALSE(hasInnerEvent);
918 }
919
920 /*
921 * @tc.name: HasEventWithID023
922 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
923 * sent and processed.
924 * @tc.type: FUNC
925 */
926 HWTEST_F(EmsEventHandlerTest, HasEventWithID023, TestSize.Level1)
927 {
928 auto runner = EventRunner::Create(true);
929 auto handler = std::make_shared<EventHandler>(runner);
930 auto event = InnerEvent::Get(EVENT_ID);
931
932 handler->SendTimingEvent(EVENT_ID, FLAG_THREE);
933 usleep(DELAYWAITTIME);
934 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
935 EXPECT_FALSE(hasInnerEvent);
936 }
937
938 /*
939 * @tc.name: HasEventWithID024
940 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
941 * sent and processed.
942 * @tc.type: FUNC
943 */
944 HWTEST_F(EmsEventHandlerTest, HasEventWithID024, TestSize.Level1)
945 {
946 auto runner = EventRunner::Create(true);
947 auto handler = std::make_shared<EventHandler>(runner);
948 auto event = InnerEvent::Get(EVENT_ID);
949
950 handler->SendTimingEvent(EVENT_ID, FLAG_FOUR);
951 usleep(DELAYWAITTIME);
952 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
953 EXPECT_FALSE(hasInnerEvent);
954 }
955
956 /*
957 * @tc.name: HasEventWithID025
958 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
959 * sent and processed.
960 * @tc.type: FUNC
961 */
962 HWTEST_F(EmsEventHandlerTest, HasEventWithID025, TestSize.Level1)
963 {
964 auto runner = EventRunner::Create(true);
965 auto handler = std::make_shared<EventHandler>(runner);
966 auto event = InnerEvent::Get(EVENT_ID);
967
968 handler->SendTimingEvent(EVENT_ID, FLAG_FIVE);
969 usleep(DELAYWAITTIME);
970 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
971 EXPECT_FALSE(hasInnerEvent);
972 }
973
974 /*
975 * @tc.name: HasEventWithID026
976 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
977 * sent and processed.
978 * @tc.type: FUNC
979 */
980 HWTEST_F(EmsEventHandlerTest, HasEventWithID026, TestSize.Level1)
981 {
982 auto runner = EventRunner::Create(true);
983 auto handler = std::make_shared<EventHandler>(runner);
984 auto event = InnerEvent::Get(EVENT_ID);
985
986 handler->SendEvent(event, FLAG_ONE);
987 usleep(DELAYWAITTIME);
988 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
989 EXPECT_FALSE(hasInnerEvent);
990 }
991
992 /*
993 * @tc.name: HasEventWithID027
994 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
995 * sent and processed.
996 * @tc.type: FUNC
997 */
998 HWTEST_F(EmsEventHandlerTest, HasEventWithID027, TestSize.Level1)
999 {
1000 auto runner = EventRunner::Create(true);
1001 auto handler = std::make_shared<EventHandler>(runner);
1002 auto event = InnerEvent::Get(EVENT_ID);
1003
1004 handler->SendEvent(event, FLAG_TWO);
1005 usleep(DELAYWAITTIME);
1006 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1007 EXPECT_FALSE(hasInnerEvent);
1008 }
1009
1010 /*
1011 * @tc.name: HasEventWithID028
1012 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1013 * sent and processed.
1014 * @tc.type: FUNC
1015 */
1016 HWTEST_F(EmsEventHandlerTest, HasEventWithID028, TestSize.Level1)
1017 {
1018 auto runner = EventRunner::Create(true);
1019 auto handler = std::make_shared<EventHandler>(runner);
1020 auto event = InnerEvent::Get(EVENT_ID);
1021
1022 handler->SendEvent(event, FLAG_THREE);
1023 usleep(DELAYWAITTIME);
1024 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1025 EXPECT_FALSE(hasInnerEvent);
1026 }
1027
1028 /*
1029 * @tc.name: HasEventWithID029
1030 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1031 * sent and processed.
1032 * @tc.type: FUNC
1033 */
1034 HWTEST_F(EmsEventHandlerTest, HasEventWithID029, TestSize.Level1)
1035 {
1036 auto runner = EventRunner::Create(true);
1037 auto handler = std::make_shared<EventHandler>(runner);
1038 auto event = InnerEvent::Get(EVENT_ID);
1039
1040 handler->SendEvent(event, FLAG_FOUR);
1041 usleep(DELAYWAITTIME);
1042 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1043 EXPECT_FALSE(hasInnerEvent);
1044 }
1045
1046 /*
1047 * @tc.name: HasEventWithID030
1048 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1049 * sent and processed.
1050 * @tc.type: FUNC
1051 */
1052 HWTEST_F(EmsEventHandlerTest, HasEventWithID030, TestSize.Level1)
1053 {
1054 auto runner = EventRunner::Create(true);
1055 auto handler = std::make_shared<EventHandler>(runner);
1056 auto event = InnerEvent::Get(EVENT_ID);
1057
1058 handler->SendEvent(event, FLAG_FIVE);
1059 usleep(DELAYWAITTIME);
1060 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1061 EXPECT_FALSE(hasInnerEvent);
1062 }
1063
1064 /*
1065 * @tc.name: HasEventWithParam031
1066 * @tc.desc: check whether an event with the given id can be found among the events that have been
1067 * sent and not processed.
1068 * @tc.type: FUNC
1069 */
1070 HWTEST_F(EmsEventHandlerTest, HasEventWithID031, TestSize.Level1)
1071 {
1072 auto runner = EventRunner::Create(true);
1073 auto handler = std::make_shared<EventHandler>(runner);
1074 auto event = InnerEvent::Get(EVENT_ID_ONE);
1075
1076 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::LOW);
1077 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1078 EXPECT_TRUE(hasInnerEvent);
1079 uint64_t delaywaittime = 100000;
1080 usleep(delaywaittime);
1081 hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1082 EXPECT_FALSE(hasInnerEvent);
1083 }
1084
1085 /*
1086 * @tc.name: HasEventWithParam032
1087 * @tc.desc: check whether an event with the id can be found among the events that have been
1088 * sent and not processed.
1089 * @tc.type: FUNC
1090 */
1091 HWTEST_F(EmsEventHandlerTest, HasEventWithID032, TestSize.Level1)
1092 {
1093 auto runner = EventRunner::Create(true);
1094 auto handler = std::make_shared<EventHandler>(runner);
1095 auto event = InnerEvent::Get(EVENT_ID);
1096
1097 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::LOW);
1098 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1099 EXPECT_TRUE(hasInnerEvent);
1100 uint64_t delaywaittime = 100000;
1101 usleep(delaywaittime);
1102 hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1103 EXPECT_FALSE(hasInnerEvent);
1104 }
1105
1106 /*
1107 * @tc.name: HasEventWithParam033
1108 * @tc.desc: check whether an event with the id can be found among the events that have been
1109 * sent and not processed.
1110 * @tc.type: FUNC
1111 */
1112 HWTEST_F(EmsEventHandlerTest, HasEventWithID033, TestSize.Level1)
1113 {
1114 auto runner = EventRunner::Create(true);
1115 auto handler = std::make_shared<EventHandler>(runner);
1116 auto event = InnerEvent::Get(EVENT_ID);
1117
1118 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::HIGH);
1119 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1120 EXPECT_TRUE(hasInnerEvent);
1121 uint64_t delaywaittime = 100000;
1122 usleep(delaywaittime);
1123 hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1124 EXPECT_FALSE(hasInnerEvent);
1125 }
1126
1127 /*
1128 * @tc.name: HasEventWithParam034
1129 * @tc.desc: check whether an event with the id can be found among the events that have been
1130 * sent and not processed.
1131 * @tc.type: FUNC
1132 */
1133 HWTEST_F(EmsEventHandlerTest, HasEventWithID034, TestSize.Level1)
1134 {
1135 auto runner = EventRunner::Create(true);
1136 auto handler = std::make_shared<EventHandler>(runner);
1137 auto event = InnerEvent::Get(EVENT_ID);
1138
1139 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::IMMEDIATE);
1140 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1141 EXPECT_TRUE(hasInnerEvent);
1142 uint64_t delaywaittime = 100000;
1143 usleep(delaywaittime);
1144 hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1145 EXPECT_FALSE(hasInnerEvent);
1146 }
1147
1148 /*
1149 * @tc.name: HasEventWithParam035
1150 * @tc.desc: check whether an event with the id can be found among the events that have been
1151 * sent and not processed.
1152 * @tc.type: FUNC
1153 */
1154 HWTEST_F(EmsEventHandlerTest, HasEventWithID035, TestSize.Level1)
1155 {
1156 auto runner = EventRunner::Create(true);
1157 auto handler = std::make_shared<EventHandler>(runner);
1158 auto event = InnerEvent::Get(EVENT_ID);
1159
1160 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::IDLE);
1161 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1162 EXPECT_TRUE(hasInnerEvent);
1163 uint64_t delaywaittime = 100000;
1164 usleep(delaywaittime);
1165 hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1166 EXPECT_TRUE(hasInnerEvent);
1167 }
1168
1169 /*
1170 * @tc.name: HasEventWithID036
1171 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1172 * sent and processed.
1173 * @tc.type: FUNC
1174 */
1175 HWTEST_F(EmsEventHandlerTest, HasEventWithID036, TestSize.Level1)
1176 {
1177 auto runner = EventRunner::Create(true);
1178 auto handler = std::make_shared<EventHandler>(runner);
1179
1180 handler->SendEvent(EVENT_ID_ONE, TestEventHandler::Priority::IMMEDIATE);
1181 usleep(DELAYWAITTIME);
1182 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1183 EXPECT_FALSE(hasInnerEvent);
1184 }
1185
1186 /*
1187 * @tc.name: HasEventWithID037
1188 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1189 * sent and processed.
1190 * @tc.type: FUNC
1191 */
1192 HWTEST_F(EmsEventHandlerTest, HasEventWithID037, TestSize.Level1)
1193 {
1194 auto runner = EventRunner::Create(true);
1195 auto handler = std::make_shared<EventHandler>(runner);
1196
1197 handler->SendEvent(EVENT_ID, TestEventHandler::Priority::IMMEDIATE);
1198 usleep(DELAYWAITTIME);
1199 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1200 EXPECT_FALSE(hasInnerEvent);
1201 }
1202
1203 /*
1204 * @tc.name: HasEventWithID038
1205 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1206 * sent and processed.
1207 * @tc.type: FUNC
1208 */
1209 HWTEST_F(EmsEventHandlerTest, HasEventWithID038, TestSize.Level1)
1210 {
1211 auto runner = EventRunner::Create(true);
1212 auto handler = std::make_shared<EventHandler>(runner);
1213
1214 handler->SendEvent(EVENT_ID, TestEventHandler::Priority::IDLE);
1215 usleep(DELAYWAITTIME);
1216 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1217 EXPECT_TRUE(hasInnerEvent);
1218 }
1219
1220 /*
1221 * @tc.name: HasEventWithID039
1222 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1223 * sent and processed.
1224 * @tc.type: FUNC
1225 */
1226 HWTEST_F(EmsEventHandlerTest, HasEventWithID039, TestSize.Level1)
1227 {
1228 auto runner = EventRunner::Create(true);
1229 auto handler = std::make_shared<EventHandler>(runner);
1230 auto event = InnerEvent::Get(EVENT_ID);
1231
1232 handler->SendEvent(EVENT_ID, TestEventHandler::Priority::HIGH);
1233 usleep(DELAYWAITTIME);
1234 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1235 EXPECT_FALSE(hasInnerEvent);
1236 }
1237
1238 /*
1239 * @tc.name: HasEventWithID040
1240 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1241 * sent and processed.
1242 * @tc.type: FUNC
1243 */
1244 HWTEST_F(EmsEventHandlerTest, HasEventWithID040, TestSize.Level1)
1245 {
1246 auto runner = EventRunner::Create(true);
1247 auto handler = std::make_shared<EventHandler>(runner);
1248
1249 handler->SendEvent(EVENT_ID, TestEventHandler::Priority::LOW);
1250 usleep(DELAYWAITTIME);
1251 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1252 EXPECT_FALSE(hasInnerEvent);
1253 }
1254
1255 /*
1256 * @tc.name: HasEventWithID041
1257 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1258 * sent and processed.
1259 * @tc.type: FUNC
1260 */
1261 HWTEST_F(EmsEventHandlerTest, HasEventWithID041, TestSize.Level1)
1262 {
1263 auto runner = EventRunner::Create(true);
1264 auto handler = std::make_shared<EventHandler>(runner);
1265
1266 handler->SendEvent(EVENT_ID, FLAG_ONE, TestEventHandler::Priority::IMMEDIATE);
1267 usleep(DELAYWAITTIME);
1268 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1269 EXPECT_FALSE(hasInnerEvent);
1270 }
1271
1272 /*
1273 * @tc.name: HasEventWithID042
1274 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1275 * sent and processed.
1276 * @tc.type: FUNC
1277 */
1278 HWTEST_F(EmsEventHandlerTest, HasEventWithID042, TestSize.Level1)
1279 {
1280 auto runner = EventRunner::Create(true);
1281 auto handler = std::make_shared<EventHandler>(runner);
1282
1283 handler->SendEvent(EVENT_ID, FLAG_TWO, TestEventHandler::Priority::IMMEDIATE);
1284 usleep(DELAYWAITTIME);
1285 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1286 EXPECT_FALSE(hasInnerEvent);
1287 }
1288
1289 /*
1290 * @tc.name: HasEventWithID043
1291 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1292 * sent and processed.
1293 * @tc.type: FUNC
1294 */
1295 HWTEST_F(EmsEventHandlerTest, HasEventWithID043, TestSize.Level1)
1296 {
1297 auto runner = EventRunner::Create(true);
1298 auto handler = std::make_shared<EventHandler>(runner);
1299
1300 handler->SendEvent(EVENT_ID, FLAG_THREE, TestEventHandler::Priority::IDLE);
1301 usleep(DELAYWAITTIME);
1302 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1303 EXPECT_TRUE(hasInnerEvent);
1304 }
1305
1306 /*
1307 * @tc.name: HasEventWithID044
1308 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1309 * sent and processed.
1310 * @tc.type: FUNC
1311 */
1312 HWTEST_F(EmsEventHandlerTest, HasEventWithID044, TestSize.Level1)
1313 {
1314 auto runner = EventRunner::Create(true);
1315 auto handler = std::make_shared<EventHandler>(runner);
1316 auto event = InnerEvent::Get(EVENT_ID);
1317
1318 handler->SendEvent(EVENT_ID, FLAG_FOUR, TestEventHandler::Priority::HIGH);
1319 usleep(DELAYWAITTIME);
1320 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1321 EXPECT_FALSE(hasInnerEvent);
1322 }
1323
1324 /*
1325 * @tc.name: HasEventWithID045
1326 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1327 * sent and processed.
1328 * @tc.type: FUNC
1329 */
1330 HWTEST_F(EmsEventHandlerTest, HasEventWithID045, TestSize.Level1)
1331 {
1332 auto runner = EventRunner::Create(true);
1333 auto handler = std::make_shared<EventHandler>(runner);
1334
1335 handler->SendEvent(EVENT_ID, FLAG_FIVE, TestEventHandler::Priority::LOW);
1336 usleep(DELAYWAITTIME);
1337 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1338
1339 EXPECT_FALSE(hasInnerEvent);
1340 }
1341
1342 /*
1343 * @tc.name: HasEventWithID046
1344 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1345 * sent and processed.
1346 * @tc.type: FUNC
1347 */
1348 HWTEST_F(EmsEventHandlerTest, HasEventWithID046, TestSize.Level1)
1349 {
1350 auto runner = EventRunner::Create(true);
1351 auto handler = std::make_shared<EventHandler>(runner);
1352 auto event = InnerEvent::Get(EVENT_ID);
1353
1354 handler->SendSyncEvent(event, TestEventHandler::Priority::IMMEDIATE);
1355 usleep(DELAYWAITTIME);
1356 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1357 EXPECT_FALSE(hasInnerEvent);
1358 }
1359
1360 /*
1361 * @tc.name: HasEventWithID047
1362 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1363 * sent and processed.
1364 * @tc.type: FUNC
1365 */
1366 HWTEST_F(EmsEventHandlerTest, HasEventWithID047, TestSize.Level1)
1367 {
1368 auto runner = EventRunner::Create(true);
1369 auto handler = std::make_shared<EventHandler>(runner);
1370 auto event = InnerEvent::Get(EVENT_ID_ONE);
1371
1372 handler->SendSyncEvent(event, TestEventHandler::Priority::IMMEDIATE);
1373 usleep(DELAYWAITTIME);
1374 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1375 EXPECT_FALSE(hasInnerEvent);
1376 }
1377
1378 /*
1379 * @tc.name: HasEventWithID048
1380 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1381 * sent and processed.
1382 * @tc.type: FUNC
1383 */
1384 HWTEST_F(EmsEventHandlerTest, HasEventWithID048, TestSize.Level1)
1385 {
1386 auto runner = EventRunner::Create(true);
1387 auto handler = std::make_shared<EventHandler>(runner);
1388 auto event = InnerEvent::Get(EVENT_ID);
1389
1390 handler->SendSyncEvent(event, TestEventHandler::Priority::IDLE);
1391 usleep(DELAYWAITTIME);
1392 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1393 EXPECT_FALSE(hasInnerEvent);
1394 }
1395
1396 /*
1397 * @tc.name: HasEventWithID049
1398 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1399 * sent and processed.
1400 * @tc.type: FUNC
1401 */
1402 HWTEST_F(EmsEventHandlerTest, HasEventWithID049, TestSize.Level1)
1403 {
1404 auto runner = EventRunner::Create(true);
1405 auto handler = std::make_shared<EventHandler>(runner);
1406 auto event = InnerEvent::Get(EVENT_ID);
1407
1408 handler->SendSyncEvent(EVENT_ID, TestEventHandler::Priority::HIGH);
1409 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1410 EXPECT_FALSE(hasInnerEvent);
1411 }
1412
1413 /*
1414 * @tc.name: HasEventWithID050
1415 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1416 * sent and processed.
1417 * @tc.type: FUNC
1418 */
1419 HWTEST_F(EmsEventHandlerTest, HasEventWithID050, TestSize.Level1)
1420 {
1421 auto runner = EventRunner::Create(true);
1422 auto handler = std::make_shared<EventHandler>(runner);
1423 auto event = InnerEvent::Get(EVENT_ID);
1424
1425 handler->SendSyncEvent(EVENT_ID, TestEventHandler::Priority::LOW);
1426 usleep(DELAYWAITTIME);
1427 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1428 EXPECT_FALSE(hasInnerEvent);
1429 }
1430
1431 /*
1432 * @tc.name: HasEventWithID046
1433 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1434 * sent and processed.
1435 * @tc.type: FUNC
1436 */
1437 HWTEST_F(EmsEventHandlerTest, HasEventWithID051, TestSize.Level1)
1438 {
1439 auto runner = EventRunner::Create(true);
1440 auto handler = std::make_shared<EventHandler>(runner);
1441 auto event = InnerEvent::Get(EVENT_ID_ONE);
1442
1443 handler->SendSyncEvent(event);
1444 usleep(DELAYWAITTIME);
1445 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1446 EXPECT_FALSE(hasInnerEvent);
1447 }
1448
1449 /*
1450 * @tc.name: HasEventWithID052
1451 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1452 * sent and processed.
1453 * @tc.type: FUNC
1454 */
1455 HWTEST_F(EmsEventHandlerTest, HasEventWithID052, TestSize.Level1)
1456 {
1457 auto runner = EventRunner::Create(true);
1458 auto handler = std::make_shared<EventHandler>(runner);
1459 auto event = InnerEvent::Get(EVENT_ID_TWO);
1460
1461 handler->SendSyncEvent(event);
1462 usleep(DELAYWAITTIME);
1463 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
1464 EXPECT_FALSE(hasInnerEvent);
1465 }
1466
1467 /*
1468 * @tc.name: HasEventWithID053
1469 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1470 * sent and processed.
1471 * @tc.type: FUNC
1472 */
1473 HWTEST_F(EmsEventHandlerTest, HasEventWithID053, TestSize.Level1)
1474 {
1475 auto runner = EventRunner::Create(true);
1476 auto handler = std::make_shared<EventHandler>(runner);
1477 auto event = InnerEvent::Get(EVENT_ID_THREE);
1478
1479 handler->SendSyncEvent(event);
1480 usleep(DELAYWAITTIME);
1481 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
1482 EXPECT_FALSE(hasInnerEvent);
1483 }
1484
1485 /*
1486 * @tc.name: HasEventWithID054
1487 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1488 * sent and processed.
1489 * @tc.type: FUNC
1490 */
1491 HWTEST_F(EmsEventHandlerTest, HasEventWithID054, TestSize.Level1)
1492 {
1493 auto runner = EventRunner::Create(true);
1494 auto handler = std::make_shared<EventHandler>(runner);
1495 auto event = InnerEvent::Get(EVENT_ID_FOUR);
1496
1497 handler->SendSyncEvent(event);
1498 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FOUR);
1499 EXPECT_FALSE(hasInnerEvent);
1500 }
1501
1502 /*
1503 * @tc.name: HasEventWithID055
1504 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1505 * sent and processed.
1506 * @tc.type: FUNC
1507 */
1508 HWTEST_F(EmsEventHandlerTest, HasEventWithID055, TestSize.Level1)
1509 {
1510 auto runner = EventRunner::Create(true);
1511 auto handler = std::make_shared<EventHandler>(runner);
1512 auto event = InnerEvent::Get(EVENT_ID_FIVE);
1513
1514 handler->SendSyncEvent(event);
1515 usleep(DELAYWAITTIME);
1516 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
1517 EXPECT_FALSE(hasInnerEvent);
1518 }
1519
1520 /*
1521 * @tc.name: HasEventWithID056
1522 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1523 * sent and processed.
1524 * @tc.type: FUNC
1525 */
1526 HWTEST_F(EmsEventHandlerTest, HasEventWithID056, TestSize.Level1)
1527 {
1528 auto runner = EventRunner::Create(true);
1529 auto handler = std::make_shared<EventHandler>(runner);
1530
1531 handler->SendSyncEvent(EVENT_ID_ONE, TestEventHandler::Priority::IMMEDIATE);
1532 usleep(DELAYWAITTIME);
1533 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1534 EXPECT_FALSE(hasInnerEvent);
1535 }
1536
1537 /*
1538 * @tc.name: HasEventWithID057
1539 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1540 * sent and processed.
1541 * @tc.type: FUNC
1542 */
1543 HWTEST_F(EmsEventHandlerTest, HasEventWithID057, TestSize.Level1)
1544 {
1545 auto runner = EventRunner::Create(true);
1546 auto handler = std::make_shared<EventHandler>(runner);
1547
1548 handler->SendSyncEvent(EVENT_ID_TWO, TestEventHandler::Priority::IMMEDIATE);
1549 usleep(DELAYWAITTIME);
1550 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
1551 EXPECT_FALSE(hasInnerEvent);
1552 }
1553
1554 /*
1555 * @tc.name: HasEventWithID058
1556 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1557 * sent and processed.
1558 * @tc.type: FUNC
1559 */
1560 HWTEST_F(EmsEventHandlerTest, HasEventWithID058, TestSize.Level1)
1561 {
1562 auto runner = EventRunner::Create(true);
1563 auto handler = std::make_shared<EventHandler>(runner);
1564
1565 handler->SendSyncEvent(EVENT_ID_THREE, TestEventHandler::Priority::IDLE);
1566 usleep(DELAYWAITTIME);
1567 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
1568 EXPECT_FALSE(hasInnerEvent);
1569 }
1570
1571 /*
1572 * @tc.name: HasEventWithID059
1573 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1574 * sent and processed.
1575 * @tc.type: FUNC
1576 */
1577 HWTEST_F(EmsEventHandlerTest, HasEventWithID059, TestSize.Level1)
1578 {
1579 auto runner = EventRunner::Create(true);
1580 auto handler = std::make_shared<EventHandler>(runner);
1581
1582 handler->SendSyncEvent(EVENT_ID_FOUR, TestEventHandler::Priority::HIGH);
1583 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1584 EXPECT_FALSE(hasInnerEvent);
1585 }
1586
1587 /*
1588 * @tc.name: HasEventWithID060
1589 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1590 * sent and processed.
1591 * @tc.type: FUNC
1592 */
1593 HWTEST_F(EmsEventHandlerTest, HasEventWithID060, TestSize.Level1)
1594 {
1595 auto runner = EventRunner::Create(true);
1596 auto handler = std::make_shared<EventHandler>(runner);
1597
1598 handler->SendSyncEvent(EVENT_ID_FIVE, TestEventHandler::Priority::LOW);
1599 usleep(DELAYWAITTIME);
1600 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
1601 EXPECT_FALSE(hasInnerEvent);
1602 }
1603
1604 /*
1605 * @tc.name: HasEventWithID061
1606 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1607 * sent and processed.
1608 * @tc.type: FUNC
1609 */
1610 HWTEST_F(EmsEventHandlerTest, HasEventWithID061, TestSize.Level1)
1611 {
1612 auto runner = EventRunner::Create(true);
1613 auto handler = std::make_shared<EventHandler>(runner);
1614
1615 handler->SendSyncEvent(EVENT_ID_ONE);
1616 usleep(DELAYWAITTIME);
1617 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1618 EXPECT_FALSE(hasInnerEvent);
1619 }
1620
1621 /*
1622 * @tc.name: HasEventWithID062
1623 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1624 * sent and processed.
1625 * @tc.type: FUNC
1626 */
1627 HWTEST_F(EmsEventHandlerTest, HasEventWithID062, TestSize.Level1)
1628 {
1629 auto runner = EventRunner::Create(true);
1630 auto handler = std::make_shared<EventHandler>(runner);
1631
1632 handler->SendSyncEvent(EVENT_ID_TWO);
1633 usleep(DELAYWAITTIME);
1634 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
1635 EXPECT_FALSE(hasInnerEvent);
1636 }
1637
1638 /*
1639 * @tc.name: HasEventWithID063
1640 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1641 * sent and processed.
1642 * @tc.type: FUNC
1643 */
1644 HWTEST_F(EmsEventHandlerTest, HasEventWithID063, TestSize.Level1)
1645 {
1646 auto runner = EventRunner::Create(true);
1647 auto handler = std::make_shared<EventHandler>(runner);
1648
1649 handler->SendSyncEvent(EVENT_ID_THREE);
1650 usleep(DELAYWAITTIME);
1651 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
1652 EXPECT_FALSE(hasInnerEvent);
1653 }
1654
1655 /*
1656 * @tc.name: HasEventWithID064
1657 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1658 * sent and processed.
1659 * @tc.type: FUNC
1660 */
1661 HWTEST_F(EmsEventHandlerTest, HasEventWithID064, TestSize.Level1)
1662 {
1663 auto runner = EventRunner::Create(true);
1664 auto handler = std::make_shared<EventHandler>(runner);
1665
1666 handler->SendSyncEvent(EVENT_ID_FOUR);
1667 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1668 EXPECT_FALSE(hasInnerEvent);
1669 }
1670
1671 /*
1672 * @tc.name: HasEventWithID065
1673 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1674 * sent and processed.
1675 * @tc.type: FUNC
1676 */
1677 HWTEST_F(EmsEventHandlerTest, HasEventWithID065, TestSize.Level1)
1678 {
1679 auto runner = EventRunner::Create(true);
1680 auto handler = std::make_shared<EventHandler>(runner);
1681
1682 handler->SendSyncEvent(EVENT_ID_FIVE);
1683 usleep(DELAYWAITTIME);
1684 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
1685 EXPECT_FALSE(hasInnerEvent);
1686 }
1687
1688 /*
1689 * @tc.name: HasEventWithID066
1690 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1691 * sent and processed.
1692 * @tc.type: FUNC
1693 */
1694 HWTEST_F(EmsEventHandlerTest, HasEventWithID066, TestSize.Level1)
1695 {
1696 auto runner = EventRunner::Create(true);
1697 auto handler = std::make_shared<EventHandler>(runner);
1698 auto event = InnerEvent::Get(EVENT_ID);
1699
1700 handler->SendTimingEvent(event, FLAG_ONE, TestEventHandler::Priority::IMMEDIATE);
1701 usleep(DELAYWAITTIME);
1702 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1703 EXPECT_FALSE(hasInnerEvent);
1704 }
1705
1706 /*
1707 * @tc.name: HasEventWithID067
1708 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1709 * sent and processed.
1710 * @tc.type: FUNC
1711 */
1712 HWTEST_F(EmsEventHandlerTest, HasEventWithID067, TestSize.Level1)
1713 {
1714 auto runner = EventRunner::Create(true);
1715 auto handler = std::make_shared<EventHandler>(runner);
1716 auto event = InnerEvent::Get(EVENT_ID);
1717
1718 handler->SendTimingEvent(event, FLAG_TWO, TestEventHandler::Priority::IMMEDIATE);
1719 usleep(DELAYWAITTIME);
1720 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1721 EXPECT_FALSE(hasInnerEvent);
1722 }
1723
1724 /*
1725 * @tc.name: HasEventWithID068
1726 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1727 * sent and processed.
1728 * @tc.type: FUNC
1729 */
1730 HWTEST_F(EmsEventHandlerTest, HasEventWithID068, TestSize.Level1)
1731 {
1732 auto runner = EventRunner::Create(true);
1733 auto handler = std::make_shared<EventHandler>(runner);
1734 auto event = InnerEvent::Get(EVENT_ID);
1735
1736 handler->SendTimingEvent(event, FLAG_THREE, TestEventHandler::Priority::IMMEDIATE);
1737 usleep(DELAYWAITTIME);
1738 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1739 EXPECT_FALSE(hasInnerEvent);
1740 }
1741
1742 /*
1743 * @tc.name: HasEventWithID069
1744 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1745 * sent and processed.
1746 * @tc.type: FUNC
1747 */
1748 HWTEST_F(EmsEventHandlerTest, HasEventWithID069, TestSize.Level1)
1749 {
1750 auto runner = EventRunner::Create(true);
1751 auto handler = std::make_shared<EventHandler>(runner);
1752 auto event = InnerEvent::Get(EVENT_ID);
1753
1754 handler->SendTimingEvent(event, FLAG_FOUR, TestEventHandler::Priority::IMMEDIATE);
1755 usleep(DELAYWAITTIME);
1756 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1757 EXPECT_FALSE(hasInnerEvent);
1758 }
1759
1760 /*
1761 * @tc.name: HasEventWithID070
1762 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1763 * sent and processed.
1764 * @tc.type: FUNC
1765 */
1766 HWTEST_F(EmsEventHandlerTest, HasEventWithID070, TestSize.Level1)
1767 {
1768 auto runner = EventRunner::Create(true);
1769 auto handler = std::make_shared<EventHandler>(runner);
1770 auto event = InnerEvent::Get(EVENT_ID);
1771
1772 handler->SendTimingEvent(event, FLAG_FIVE, TestEventHandler::Priority::IMMEDIATE);
1773 usleep(DELAYWAITTIME);
1774 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID);
1775 EXPECT_FALSE(hasInnerEvent);
1776 }
1777
1778 /*
1779 * @tc.name: HasEventWithID071
1780 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1781 * sent and processed.
1782 * @tc.type: FUNC
1783 */
1784 HWTEST_F(EmsEventHandlerTest, HasEventWithID071, TestSize.Level1)
1785 {
1786 auto runner = EventRunner::Create(true);
1787 auto handler = std::make_shared<EventHandler>(runner);
1788
1789 handler->SendTimingEvent(EVENT_ID_ONE, FLAG_ONE, TestEventHandler::Priority::IMMEDIATE);
1790 usleep(DELAYWAITTIME);
1791 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_ONE);
1792 EXPECT_FALSE(hasInnerEvent);
1793 }
1794
1795 /*
1796 * @tc.name: HasEventWithID072
1797 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1798 * sent and processed.
1799 * @tc.type: FUNC
1800 */
1801 HWTEST_F(EmsEventHandlerTest, HasEventWithID072, TestSize.Level1)
1802 {
1803 auto runner = EventRunner::Create(true);
1804 auto handler = std::make_shared<EventHandler>(runner);
1805
1806 handler->SendTimingEvent(EVENT_ID_TWO, FLAG_TWO, TestEventHandler::Priority::IMMEDIATE);
1807 usleep(DELAYWAITTIME);
1808 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_TWO);
1809 EXPECT_FALSE(hasInnerEvent);
1810 }
1811
1812 /*
1813 * @tc.name: HasEventWithID073
1814 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1815 * sent and processed.
1816 * @tc.type: FUNC
1817 */
1818 HWTEST_F(EmsEventHandlerTest, HasEventWithID073, TestSize.Level1)
1819 {
1820 auto runner = EventRunner::Create(true);
1821 auto handler = std::make_shared<EventHandler>(runner);
1822
1823 handler->SendTimingEvent(EVENT_ID_THREE, FLAG_THREE, TestEventHandler::Priority::IMMEDIATE);
1824 usleep(DELAYWAITTIME);
1825 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_THREE);
1826 EXPECT_FALSE(hasInnerEvent);
1827 }
1828
1829 /*
1830 * @tc.name: HasEventWithID074
1831 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1832 * sent and processed.
1833 * @tc.type: FUNC
1834 */
1835 HWTEST_F(EmsEventHandlerTest, HasEventWithID074, TestSize.Level1)
1836 {
1837 auto runner = EventRunner::Create(true);
1838 auto handler = std::make_shared<EventHandler>(runner);
1839
1840 handler->SendTimingEvent(EVENT_ID_FOUR, FLAG_FOUR, TestEventHandler::Priority::IMMEDIATE);
1841 usleep(DELAYWAITTIME);
1842 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FOUR);
1843 EXPECT_FALSE(hasInnerEvent);
1844 }
1845
1846 /*
1847 * @tc.name: HasEventWithID075
1848 * @tc.desc: check whether an event with the given ID can not be found among the events that have been
1849 * sent and processed.
1850 * @tc.type: FUNC
1851 */
1852 HWTEST_F(EmsEventHandlerTest, HasEventWithID075, TestSize.Level1)
1853 {
1854 auto runner = EventRunner::Create(true);
1855 auto handler = std::make_shared<EventHandler>(runner);
1856
1857 handler->SendTimingEvent(EVENT_ID_FIVE, FLAG_FIVE, TestEventHandler::Priority::IMMEDIATE);
1858 usleep(DELAYWAITTIME);
1859 bool hasInnerEvent = handler->HasInnerEvent(EVENT_ID_FIVE);
1860 EXPECT_FALSE(hasInnerEvent);
1861 }
1862
1863 /*
1864 * @tc.name: HasEventWithID076
1865 * @tc.desc: check when runner is null ptr Has Inner Event process fail
1866 * @tc.type: FUNC
1867 */
1868 HWTEST_F(EmsEventHandlerTest, HasEventWithID076, TestSize.Level1)
1869 {
1870 auto runner = EventRunner::Create(true);
1871
1872 auto event = InnerEvent::Get(EVENT_ID);
1873
1874 bool hasInnerEvent = runner->GetEventQueue()->HasInnerEvent(nullptr, EVENT_ID);
1875 EXPECT_FALSE(hasInnerEvent);
1876 }
1877
1878 /*
1879 * @tc.name: HasEventWithParam001
1880 * @tc.desc: check whether an event with the given param can be found among the events that have been
1881 * sent but not processed.
1882 * @tc.type: FUNC
1883 */
1884 HWTEST_F(EmsEventHandlerTest, HasEventWithParam001, TestSize.Level1)
1885 {
1886 auto runner = EventRunner::Create(true);
1887 auto handler = std::make_shared<EventHandler>(runner);
1888 auto event = InnerEvent::Get(EVENT_ID, EVENT_PARAM_ONE);
1889
1890 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::LOW);
1891 bool hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_ONE);
1892 EXPECT_TRUE(hasInnerEvent);
1893 usleep(DELAYWAITTIME);
1894 hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_ONE);
1895 EXPECT_FALSE(hasInnerEvent);
1896 }
1897
1898 /*
1899 * @tc.name: HasEventWithParam002
1900 * @tc.desc: check whether an event with the given param can be found among the events that have been
1901 * sent but not processed.
1902 * @tc.type: FUNC
1903 */
1904 HWTEST_F(EmsEventHandlerTest, HasEventWithParam002, TestSize.Level1)
1905 {
1906 auto runner = EventRunner::Create(true);
1907 auto handler = std::make_shared<EventHandler>(runner);
1908 auto event = InnerEvent::Get(EVENT_ID, EVENT_PARAM_TWO);
1909
1910 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::HIGH);
1911 bool hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_TWO);
1912 EXPECT_TRUE(hasInnerEvent);
1913 usleep(DELAYWAITTIME);
1914 hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_TWO);
1915 EXPECT_FALSE(hasInnerEvent);
1916 }
1917
1918 /*
1919 * @tc.name: HasEventWithParam003
1920 * @tc.desc: check whether an event with the given param can be found among the events that have been
1921 * sent but not processed.
1922 * @tc.type: FUNC
1923 */
1924 HWTEST_F(EmsEventHandlerTest, HasEventWithParam003, TestSize.Level1)
1925 {
1926 auto runner = EventRunner::Create(true);
1927 auto handler = std::make_shared<EventHandler>(runner);
1928 auto event = InnerEvent::Get(EVENT_ID, EVENT_PARAM_THREE);
1929
1930 handler->SendEvent(event, DELAY_TIME, TestEventHandler::Priority::IMMEDIATE);
1931 bool hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_THREE);
1932 EXPECT_TRUE(hasInnerEvent);
1933 usleep(DELAYWAITTIME);
1934 hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_THREE);
1935 EXPECT_FALSE(hasInnerEvent);
1936 }
1937
1938 /*
1939 * @tc.name: HasEventWithParam004
1940 * @tc.desc: check when runner is null ptr Has Inner Event process fail
1941 * @tc.type: FUNC
1942 */
1943 HWTEST_F(EmsEventHandlerTest, HasEventWithParam004, TestSize.Level1)
1944 {
1945 auto handler = std::make_shared<EventHandler>(nullptr);
1946 auto event = InnerEvent::Get(EVENT_PARAM_FOUR);
1947
1948 bool hasInnerEvent = handler->HasInnerEvent(EVENT_PARAM_FOUR);
1949 EXPECT_FALSE(hasInnerEvent);
1950 }
1951
1952 /*
1953 * @tc.name: HasEventWithParam005
1954 * @tc.desc: check when runner is null ptr Has Inner Event process fail
1955 * @tc.type: FUNC
1956 */
1957 HWTEST_F(EmsEventHandlerTest, HasEventWithParam005, TestSize.Level1)
1958 {
1959 auto runner = EventRunner::Create(true);
1960
1961 auto event = InnerEvent::Get(EVENT_PARAM_FIVE);
1962
1963 bool hasInnerEvent = runner->GetEventQueue()->HasInnerEvent(nullptr, EVENT_PARAM_FIVE);
1964 EXPECT_FALSE(hasInnerEvent);
1965 }
1966
1967 /*
1968 * @tc.name: RemoveAllEvents001
1969 * @tc.desc: remove all the events which belong to one handler
1970 * @tc.type: FUNC
1971 */
1972 HWTEST_F(EmsEventHandlerTest, RemoveAllEvents001, TestSize.Level1)
1973 {
1974 auto runner = EventRunner::Create(true);
1975 auto handler = std::make_shared<EventHandler>(runner);
1976 std::atomic<bool> taskCalled(false);
__anonce1bdb5b0602() 1977 auto f = [&taskCalled]() { taskCalled.store(true); };
1978
1979 if (handler->PostTask(f, DELAY_TIME, EventHandler::Priority::LOW)) {
1980 handler->RemoveAllEvents();
1981 usleep(DELAYWAITTIME);
1982 auto called = taskCalled.load();
1983 EXPECT_FALSE(called);
1984 }
1985 }
1986
1987 /*
1988 * @tc.name: RemoveAllEvents002
1989 * @tc.desc: remove all the events which belong to one handler
1990 * @tc.type: FUNC
1991 */
1992 HWTEST_F(EmsEventHandlerTest, RemoveAllEvents002, TestSize.Level1)
1993 {
1994 auto runner = EventRunner::Create(true);
1995 auto handler = std::make_shared<EventHandler>(runner);
1996 std::atomic<bool> taskCalled(false);
__anonce1bdb5b0702() 1997 auto f = [&taskCalled]() { taskCalled.store(true); };
1998
1999 if (handler->PostTask(f, DELAY_TIME, EventHandler::Priority::HIGH)) {
2000 handler->RemoveAllEvents();
2001 usleep(DELAYWAITTIME);
2002 auto called = taskCalled.load();
2003 EXPECT_FALSE(called);
2004 }
2005 }
2006
2007 /*
2008 * @tc.name: RemoveAllEvents003
2009 * @tc.desc: remove all the events which belong to one handler
2010 * @tc.type: FUNC
2011 */
2012 HWTEST_F(EmsEventHandlerTest, RemoveAllEvents003, TestSize.Level1)
2013 {
2014 auto runner = EventRunner::Create(true);
2015 auto handler = std::make_shared<EventHandler>(runner);
2016 std::atomic<bool> taskCalled(false);
__anonce1bdb5b0802() 2017 auto f = [&taskCalled]() { taskCalled.store(true); };
2018
2019 if (handler->PostTask(f, DELAY_TIME, EventHandler::Priority::IMMEDIATE)) {
2020 handler->RemoveAllEvents();
2021 usleep(DELAYWAITTIME);
2022 auto called = taskCalled.load();
2023 EXPECT_FALSE(called);
2024 }
2025 }
2026
2027 /*
2028 * @tc.name: RemoveAllEvents004
2029 * @tc.desc: remove all the events which belong to one handler
2030 * @tc.type: FUNC
2031 */
2032 HWTEST_F(EmsEventHandlerTest, RemoveAllEvents004, TestSize.Level1)
2033 {
2034 auto runner = EventRunner::Create(true);
2035 auto handler = std::make_shared<EventHandler>(runner);
2036 std::atomic<bool> taskCalled(false);
__anonce1bdb5b0902() 2037 auto f = [&taskCalled]() { taskCalled.store(true); };
2038
2039 if (handler->PostTask(f, DELAY_TIME, EventHandler::Priority::IDLE)) {
2040 handler->RemoveAllEvents();
2041 usleep(DELAYWAITTIME);
2042 auto called = taskCalled.load();
2043 EXPECT_FALSE(called);
2044 }
2045 }
2046
2047 /*
2048 * @tc.name: RemoveAllEvents005
2049 * @tc.desc: check when runner is null ptr remove all events process fail
2050 * @tc.type: FUNC
2051 */
2052 HWTEST_F(EmsEventHandlerTest, RemoveAllEvents005, TestSize.Level1)
2053 {
2054 auto handler = std::make_shared<EventHandler>(nullptr);
2055 std::atomic<bool> taskCalled(false);
__anonce1bdb5b0a02() 2056 auto f = [&taskCalled]() { taskCalled.store(true); };
2057
2058 if (handler->PostTask(f, DELAY_TIME, EventHandler::Priority::IMMEDIATE)) {
2059 handler->RemoveAllEvents();
2060 usleep(DELAYWAITTIME);
2061 auto called = taskCalled.load();
2062 EXPECT_TRUE(called);
2063 }
2064 }
2065
2066 /*
2067 * @tc.name: RemoveEvent001
2068 * @tc.desc: remove event success
2069 * @tc.type: FUNC
2070 */
2071 HWTEST_F(EmsEventHandlerTest, RemoveEventID001, TestSize.Level1)
2072 {
2073 auto runner = EventRunner::Create(true);
2074 auto handler = std::make_shared<MyEventHandler>(runner);
2075 auto event = InnerEvent::Get(EVENT_ID);
2076
2077 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::LOW);
2078 handler->RemoveEvent(EVENT_ID);
2079 usleep(DELAYWAITTIME);
2080 auto ran = eventRan.load();
2081 EXPECT_FALSE(ran);
2082 }
2083
2084 /*
2085 * @tc.name: RemoveEvent002
2086 * @tc.desc: remove event success
2087 * @tc.type: FUNC
2088 */
2089 HWTEST_F(EmsEventHandlerTest, RemoveEventID002, TestSize.Level1)
2090 {
2091 auto runner = EventRunner::Create(true);
2092 auto handler = std::make_shared<MyEventHandler>(runner);
2093 auto event = InnerEvent::Get(EVENT_ID);
2094
2095 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::IMMEDIATE);
2096 handler->RemoveEvent(EVENT_ID);
2097 usleep(DELAYWAITTIME);
2098 auto ran = eventRan.load();
2099 EXPECT_FALSE(ran);
2100 }
2101
2102 /*
2103 * @tc.name: RemoveEvent003
2104 * @tc.desc: remove event success
2105 * @tc.type: FUNC
2106 */
2107 HWTEST_F(EmsEventHandlerTest, RemoveEventID003, TestSize.Level1)
2108 {
2109 auto runner = EventRunner::Create(true);
2110 auto handler = std::make_shared<MyEventHandler>(runner);
2111 auto event = InnerEvent::Get(EVENT_ID);
2112
2113 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::HIGH);
2114 handler->RemoveEvent(EVENT_ID);
2115 usleep(DELAYWAITTIME);
2116 auto ran = eventRan.load();
2117 EXPECT_FALSE(ran);
2118 }
2119
2120 /*
2121 * @tc.name: RemoveEvent004
2122 * @tc.desc: remove event success
2123 * @tc.type: FUNC
2124 */
2125 HWTEST_F(EmsEventHandlerTest, RemoveEventID004, TestSize.Level1)
2126 {
2127 auto runner = EventRunner::Create(true);
2128 auto handler = std::make_shared<MyEventHandler>(runner);
2129 auto event = InnerEvent::Get(EVENT_ID);
2130
2131 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::IDLE);
2132 handler->RemoveEvent(EVENT_ID);
2133 usleep(DELAYWAITTIME);
2134 auto ran = eventRan.load();
2135 EXPECT_FALSE(ran);
2136 }
2137
2138 /*
2139 * @tc.name: RemoveEvent005
2140 * @tc.desc: check when runner is null ptr remove event process fail
2141 * @tc.type: FUNC
2142 */
2143 HWTEST_F(EmsEventHandlerTest, RemoveEventID005, TestSize.Level1)
2144 {
2145 auto handler = std::make_shared<EventHandler>(nullptr);
2146 handler->RemoveEvent(EVENT_ID);
2147 usleep(DELAYWAITTIME);
2148 auto ran = eventRan.load();
2149 EXPECT_FALSE(ran);
2150 }
2151
2152 /*
2153 * @tc.name: RemoveEvent001
2154 * @tc.desc: remove event success
2155 * @tc.type: FUNC
2156 */
2157 HWTEST_F(EmsEventHandlerTest, RemoveEventIDParam001, TestSize.Level1)
2158 {
2159 auto runner = EventRunner::Create(true);
2160 auto handler = std::make_shared<EventHandler>(runner);
2161 auto event = InnerEvent::Get(EVENT_ID, FLAG_ONE);
2162
2163 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::LOW);
2164 handler->RemoveEvent(EVENT_ID, FLAG_ONE);
2165 usleep(DELAYWAITTIME);
2166 auto ran = eventRan.load();
2167 EXPECT_FALSE(ran);
2168 }
2169
2170 /*
2171 * @tc.name: RemoveEvent002
2172 * @tc.desc: remove event success
2173 * @tc.type: FUNC
2174 */
2175 HWTEST_F(EmsEventHandlerTest, RemoveEventIDParam002, TestSize.Level1)
2176 {
2177 auto runner = EventRunner::Create(true);
2178 auto handler = std::make_shared<EventHandler>(runner);
2179 auto event = InnerEvent::Get(EVENT_ID, FLAG_TWO);
2180
2181 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::IMMEDIATE);
2182 handler->RemoveEvent(EVENT_ID, FLAG_TWO);
2183 usleep(DELAYWAITTIME);
2184 auto ran = eventRan.load();
2185 EXPECT_FALSE(ran);
2186 }
2187
2188 /*
2189 * @tc.name: RemoveEvent003
2190 * @tc.desc: remove event success
2191 * @tc.type: FUNC
2192 */
2193 HWTEST_F(EmsEventHandlerTest, RemoveEventIDParam003, TestSize.Level1)
2194 {
2195 auto runner = EventRunner::Create(true);
2196 auto handler = std::make_shared<EventHandler>(runner);
2197 auto event = InnerEvent::Get(EVENT_ID, FLAG_THREE);
2198
2199 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::HIGH);
2200 handler->RemoveEvent(EVENT_ID, FLAG_THREE);
2201 usleep(DELAYWAITTIME);
2202 auto ran = eventRan.load();
2203 EXPECT_FALSE(ran);
2204 }
2205
2206 /*
2207 * @tc.name: RemoveEvent004
2208 * @tc.desc: remove event success
2209 * @tc.type: FUNC
2210 */
2211 HWTEST_F(EmsEventHandlerTest, RemoveEventIDParam004, TestSize.Level1)
2212 {
2213 auto runner = EventRunner::Create(true);
2214 auto handler = std::make_shared<EventHandler>(runner);
2215 auto event = InnerEvent::Get(EVENT_ID, FLAG_FOUR);
2216
2217 handler->SendEvent(event, DELAY_TIME, EventHandler::Priority::IDLE);
2218 handler->RemoveEvent(EVENT_ID, FLAG_FOUR);
2219 usleep(DELAYWAITTIME);
2220 auto ran = eventRan.load();
2221 EXPECT_FALSE(ran);
2222 }
2223
2224 /*
2225 * @tc.name: RemoveEvent005
2226 * @tc.desc: check when runner is null ptr remove event process fail
2227 * @tc.type: FUNC
2228 */
2229 HWTEST_F(EmsEventHandlerTest, RemoveEventIDParam005, TestSize.Level1)
2230 {
2231 auto handler = std::make_shared<EventHandler>(nullptr);
2232 handler->RemoveEvent(EVENT_ID, FLAG_FIVE);
2233 usleep(DELAYWAITTIME);
2234 auto ran = eventRan.load();
2235 EXPECT_FALSE(ran);
2236 }
2237
2238 /*
2239 * @tc.name: IsIdle
2240 * @tc.desc: check when idle IsIdle return true
2241 * @tc.type: FUNC
2242 */
2243 HWTEST_F(EmsEventHandlerTest, IsIdle001, TestSize.Level1)
2244 {
2245 auto runner = EventRunner::Create(true);
2246 auto handler = std::make_shared<EventHandler>(runner);
2247 bool ret = handler->IsIdle();
2248 EXPECT_TRUE(ret);
2249 }
2250
2251 /*
2252 * @tc.name: IsIdle
2253 * @tc.desc: check when idle IsIdle return false
2254 * @tc.type: FUNC
2255 */
2256 HWTEST_F(EmsEventHandlerTest, IsIdle002, TestSize.Level1)
2257 {
2258 auto runner = EventRunner::Create(true);
2259 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0b02() 2260 auto task = []() { ; };
2261
2262 handler->PostTask(task, FLAG_ONE, EventHandler::Priority::IMMEDIATE);
2263 bool ret = handler->IsIdle();
2264 EXPECT_TRUE(ret);
2265 }
2266
2267 /*
2268 * @tc.name: IsIdle
2269 * @tc.desc: check when idle IsIdle return false
2270 * @tc.type: FUNC
2271 */
2272 HWTEST_F(EmsEventHandlerTest, IsIdle003, TestSize.Level1)
2273 {
2274 auto runner = EventRunner::Create(true);
2275 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0c02() 2276 auto task = []() { ; };
2277
2278 handler->PostTask(task, FLAG_TWO, EventHandler::Priority::LOW);
2279 bool ret = handler->IsIdle();
2280 EXPECT_TRUE(ret);
2281 }
2282
2283 /*
2284 * @tc.name: IsIdle
2285 * @tc.desc: check when idle IsIdle return false
2286 * @tc.type: FUNC
2287 */
2288 HWTEST_F(EmsEventHandlerTest, IsIdle004, TestSize.Level1)
2289 {
2290 auto runner = EventRunner::Create(true);
2291 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0d02() 2292 auto task = []() { ; };
2293
2294 handler->PostTask(task, FLAG_THREE, EventHandler::Priority::HIGH);
2295 bool ret = handler->IsIdle();
2296 EXPECT_TRUE(ret);
2297 }
2298
2299 /*
2300 * @tc.name: IsIdle
2301 * @tc.desc: check when idle IsIdle return false
2302 * @tc.type: FUNC
2303 */
2304 HWTEST_F(EmsEventHandlerTest, IsIdle005, TestSize.Level1)
2305 {
2306 auto runner = EventRunner::Create(true);
2307 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0e02() 2308 auto task = []() { ; };
2309
2310 handler->PostTask(task, FLAG_THREE, EventHandler::Priority::IDLE);
2311 bool ret = handler->IsIdle();
2312 EXPECT_TRUE(ret);
2313 }
2314
2315 /*
2316 * @tc.name: Dump001
2317 * @tc.desc: Check Dump
2318 * @tc.type: FUNC
2319 */
2320 HWTEST_F(EmsEventHandlerTest, Dump001, TestSize.Level1)
2321 {
2322 /**
2323 * @tc.setup: init runner and handler
2324 */
2325 auto runner = EventRunner::Create(true);
2326 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b0f02() 2327 auto task = []() { ; };
2328 auto event = InnerEvent::Get(task, THREAD_NAME_TEST4);
2329 DumpTest dumptest;
2330
2331 usleep(100 * 1000);
2332 handler->Dump(dumptest);
2333 EXPECT_TRUE(g_isDump);
2334 }
2335
2336 /*
2337 * @tc.name: Dump002
2338 * @tc.desc: Check Dump after post task
2339 * @tc.type: FUNC
2340 */
2341 HWTEST_F(EmsEventHandlerTest, Dump002, TestSize.Level1)
2342 {
2343 g_isDump = false;
2344 /**
2345 * @tc.setup: init runner and handler
2346 */
2347 auto runner = EventRunner::Create(true);
2348 auto handler = std::make_shared<EventHandler>(runner);
__anonce1bdb5b1002() 2349 auto task = []() { ; };
2350 DumpTest dumptest;
2351
2352 handler->PostTask(task, DELAY_TIME, EventQueue::Priority::LOW);
2353 usleep(100 * 1000);
2354 handler->Dump(dumptest);
2355 EXPECT_TRUE(g_isDump);
2356 }
2357
2358 /*
2359 * @tc.name: Dump003
2360 * @tc.desc: Check Dump after send event with event id
2361 * @tc.type: FUNC
2362 */
2363 HWTEST_F(EmsEventHandlerTest, Dump003, TestSize.Level1)
2364 {
2365 g_isDump = false;
2366 auto runner = EventRunner::Create(true);
2367 auto handler = std::make_shared<EventHandler>(runner);
2368 auto event = InnerEvent::Get(EVENT_ID);
2369 DumpTest dumptest;
2370 handler->SendEvent(event, DELAY_TIME, EventQueue::Priority::LOW);
2371 usleep(100 * 1000);
2372 handler->Dump(dumptest);
2373 EXPECT_TRUE(g_isDump);
2374 }
2375
2376 /*
2377 * @tc.name: Dump004
2378 * @tc.desc: Check Dump after send event with event id and param
2379 * @tc.type: FUNC
2380 */
2381 HWTEST_F(EmsEventHandlerTest, Dump004, TestSize.Level1)
2382 {
2383 g_isDump = false;
2384 auto runner = EventRunner::Create(true);
2385 auto handler = std::make_shared<EventHandler>(runner);
2386 auto event = InnerEvent::Get(EVENT_ID, FLAG_FOUR);
2387 DumpTest dumptest;
2388 handler->SendEvent(event, DELAY_TIME, EventQueue::Priority::LOW);
2389 usleep(100 * 1000);
2390 handler->Dump(dumptest);
2391 EXPECT_TRUE(g_isDump);
2392 }
2393
2394 /*
2395 * @tc.name: Dump005
2396 * @tc.desc: check when send event and post task dump success
2397 * @tc.type: FUNC
2398 */
2399 HWTEST_F(EmsEventHandlerTest, Dump005, TestSize.Level1)
2400 {
2401 g_isDump = false;
2402 auto runner = EventRunner::Create(true);
2403 auto handler = std::make_shared<EventHandler>(runner);
2404 auto event = InnerEvent::Get(EVENT_ID, FLAG_FIVE);
__anonce1bdb5b1102() 2405 auto task = []() { ; };
2406 DumpTest dumptest;
2407 handler->SendEvent(event, DELAY_TIME, EventQueue::Priority::LOW);
2408 handler->PostTask(task, DELAY_TIME * 2, EventQueue::Priority::LOW);
2409 usleep(100 * 1000);
2410 handler->Dump(dumptest);
2411 EXPECT_TRUE(g_isDump);
2412 }
2413
2414 /**
2415 * @tc.name: DistributeEvent001
2416 * @tc.desc: Distribute an event
2417 * @tc.type: FUNC
2418 */
2419 HWTEST_F(EmsEventHandlerTest, DistributeEvent001, TestSize.Level1)
2420 {
2421 auto event = InnerEvent::Get(EVENT_ID);
2422 auto myRunner = EventRunner::Create(false);
2423 auto handler = std::make_shared<MyEventHandler>(myRunner);
2424
2425 handler->DistributeEvent(event);
2426 bool result = CommonUtils::EventRunGet();
2427 EXPECT_TRUE(result);
2428 }
2429
2430 /**
2431 * @tc.name: DistributeEvent002
2432 * @tc.desc: Distribute an event
2433 * @tc.type: FUNC
2434 */
2435 HWTEST_F(EmsEventHandlerTest, DistributeEvent002, TestSize.Level1)
2436 {
2437 auto event = InnerEvent::Get();
2438 auto myRunner = EventRunner::Create(false);
2439 auto handler = std::make_shared<MyEventHandler>(myRunner);
2440
2441 handler->DistributeEvent(event);
2442 bool result = CommonUtils::EventRunGet();
2443 EXPECT_TRUE(result);
2444 }
2445
2446 /**
2447 * @tc.name: DistributeEvent003
2448 * @tc.desc: Distribute an event
2449 * @tc.type: FUNC
2450 */
2451 HWTEST_F(EmsEventHandlerTest, DistributeEvent003, TestSize.Level1)
2452 {
2453 auto event = InnerEvent::Get(EVENT_ID, FLAG_ONE);
2454 auto myRunner = EventRunner::Create(false);
2455 auto handler = std::make_shared<MyEventHandler>(myRunner);
2456
2457 handler->DistributeEvent(event);
2458 bool result = CommonUtils::EventRunGet();
2459 EXPECT_TRUE(result);
2460 }
2461
2462 /**
2463 * @tc.name: DistributeEvent004
2464 * @tc.desc: Distribute a task
2465 * @tc.type: FUNC
2466 */
2467 HWTEST_F(EmsEventHandlerTest, DistributeEvent004, TestSize.Level1)
2468 {
__anonce1bdb5b1202() 2469 auto f = []() { CommonUtils::TaskCalledSet(true); };
2470 auto event = InnerEvent::Get(f);
2471 auto myRunner = EventRunner::Create(false);
2472 auto handler = std::make_shared<MyEventHandler>(myRunner);
2473
2474 handler->DistributeEvent(event);
2475 bool result = CommonUtils::TaskCalledGet();
2476 EXPECT_TRUE(result);
2477 }
2478
2479 /**
2480 * @tc.name: DistributeEvent005
2481 * @tc.desc: Distribute a null event
2482 * @tc.type: FUNC
2483 */
2484 HWTEST_F(EmsEventHandlerTest, DistributeEvent005, TestSize.Level1)
2485 {
2486 auto myRunner = EventRunner::Create(false);
2487 auto handler = std::make_shared<MyEventHandler>(myRunner);
2488 auto nullPtr = InnerEvent::Pointer(nullptr, nullptr);
2489
2490 handler->DistributeEvent(nullPtr);
2491 bool result = CommonUtils::EventRunGet();
2492 EXPECT_FALSE(result);
2493 }
2494
2495 /**
2496 * @tc.name: CurrentHandler001
2497 * @tc.desc: Get current handler when handler running
2498 * @tc.type: FUNC
2499 */
2500 HWTEST_F(EmsEventHandlerTest, CurrentHandler001, TestSize.Level1)
2501 {
2502 auto myRunner = EventRunner::Create();
2503 auto handler = std::make_shared<MyEventHandler>(myRunner);
2504 std::shared_ptr<EventHandler> myHandler;
__anonce1bdb5b1302() 2505 auto f = [&]() { myHandler = handler->Current(); };
2506
2507 handler->PostTask(f);
2508 uint32_t sleepTime = 20000;
2509 usleep(sleepTime);
2510 EXPECT_EQ(handler, myHandler);
2511 }
2512
2513 /**
2514 * @tc.name: CurrentHandler002
2515 * @tc.desc: Get current handler when handler running
2516 * @tc.type: FUNC
2517 */
2518 HWTEST_F(EmsEventHandlerTest, CurrentHandler002, TestSize.Level1)
2519 {
2520 auto myRunner = EventRunner::Create(true);
2521 auto handler = std::make_shared<MyEventHandler>(myRunner);
2522 std::shared_ptr<EventHandler> myHandler;
__anonce1bdb5b1402() 2523 auto f = [&]() { myHandler = handler->Current(); };
2524
2525 handler->PostTask(f);
2526 uint32_t sleepTime = 20000;
2527 usleep(sleepTime);
2528 EXPECT_EQ(handler, myHandler);
2529 }
2530
2531 /**
2532 * @tc.name: CurrentHandler003
2533 * @tc.desc: Get current handler when handler running
2534 * @tc.type: FUNC
2535 */
2536 HWTEST_F(EmsEventHandlerTest, CurrentHandler003, TestSize.Level1)
2537 {
2538 auto myRunner = EventRunner::Create(THREAD_NAME_TEST1);
2539 auto handler = std::make_shared<MyEventHandler>(myRunner);
2540 std::shared_ptr<EventHandler> myHandler;
__anonce1bdb5b1502() 2541 auto f = [&]() { myHandler = handler->Current(); };
2542
2543 handler->PostTask(f);
2544 uint32_t sleepTime = 20000;
2545 usleep(sleepTime);
2546 EXPECT_EQ(handler, myHandler);
2547 }
2548
2549 /**
2550 * @tc.name: CurrentHandler004
2551 * @tc.desc: Get current handler when handler not running
2552 * @tc.type: FUNC
2553 */
2554 HWTEST_F(EmsEventHandlerTest, CurrentHandler004, TestSize.Level1)
2555 {
2556 auto myRunner = EventRunner::Create();
2557 auto handler = std::make_shared<MyEventHandler>(myRunner);
2558 std::shared_ptr<EventHandler> myHandler = handler->Current();
2559
2560 EXPECT_EQ(nullptr, myHandler);
2561 }
2562
2563 /**
2564 * @tc.name: CurrentHandler005
2565 * @tc.desc: Get current handler when handler running
2566 * @tc.type: FUNC
2567 */
2568 HWTEST_F(EmsEventHandlerTest, CurrentHandler005, TestSize.Level1)
2569 {
2570 auto myRunner = EventRunner::Create(THREAD_NAME_TEST2);
2571 auto handler = std::make_shared<MyEventHandler>(myRunner);
2572 std::shared_ptr<EventHandler> myHandler;
__anonce1bdb5b1602() 2573 auto f = [&]() { myHandler = handler->Current(); };
2574
2575 handler->PostTask(f);
2576 uint32_t sleepTime = 20000;
2577 usleep(sleepTime);
2578 EXPECT_EQ(handler, myHandler);
2579 }
2580