• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "event_handler_test_common.h"
17 
18 namespace OHOS {
19 namespace AppExecFwk {
20 std::atomic<bool> CommonUtils::eventRun_ {false};
21 std::atomic<bool> CommonUtils::taskCalled_ {false};
22 std::atomic<uint32_t> CommonUtils::eventRunTimes_ {0};
23 
MyEventHandler(const std::shared_ptr<EventRunner> & runner)24 MyEventHandler::MyEventHandler(const std::shared_ptr<EventRunner> &runner) : EventHandler(runner)
25 {}
26 
~MyEventHandler()27 MyEventHandler::~MyEventHandler()
28 {}
29 
ProcessEvent(const InnerEvent::Pointer & event)30 void MyEventHandler::ProcessEvent(const InnerEvent::Pointer &event)
31 {
32     auto eventId = event->GetInnerEventId();
33     if (eventId == STOP_EVENT_ID) {
34         GetEventRunner()->Stop();
35     }
36 
37     if (eventId == RUN_EVENT_ID) {
38         CommonUtils::EventRunSet(true);
39         CommonUtils::EventRunCountIncrement();
40     }
41 }
42 }  // namespace AppExecFwk
43 }  // namespace OHOS