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 std::vector<std::string> CommonUtils::threads_ = {}; 24 MyEventHandler(const std::shared_ptr<EventRunner> & runner)25MyEventHandler::MyEventHandler(const std::shared_ptr<EventRunner> &runner) : EventHandler(runner) 26 {} 27 ~MyEventHandler()28MyEventHandler::~MyEventHandler() 29 {} 30 ProcessEvent(const InnerEvent::Pointer & event)31void MyEventHandler::ProcessEvent(const InnerEvent::Pointer &event) 32 { 33 auto eventId = event->GetInnerEventId(); 34 if (eventId == STOP_EVENT_ID) { 35 GetEventRunner()->Stop(); 36 } 37 38 if (eventId == RUN_EVENT_ID) { 39 CommonUtils::EventRunSet(true); 40 CommonUtils::EventRunCountIncrement(); 41 } 42 } 43 } // namespace AppExecFwk 44 } // namespace OHOS 45