1 /* 2 * Copyright (c) 2021 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 #ifndef HIVIEW_PLATFORM_EVENT_DISPATCH_QUEUE_TEST_H 16 #define HIVIEW_PLATFORM_EVENT_DISPATCH_QUEUE_TEST_H 17 18 #include <map> 19 #include <memory> 20 21 #include <gtest/gtest.h> 22 23 #include "event.h" 24 #include "event_dispatch_queue.h" 25 #include "hiview_platform.h" 26 27 class EventDispatchQueueTest : public testing::Test { 28 public: EventDispatchQueueTest()29 EventDispatchQueueTest() {}; ~EventDispatchQueueTest()30 ~EventDispatchQueueTest() {}; 31 void SetUp(); 32 void TearDown(); 33 std::shared_ptr<OHOS::HiviewDFX::Event> CreateEvent(const std::string& name, int32_t id, 34 const std::string& message, 35 OHOS::HiviewDFX::Event::MessageType type); 36 static constexpr int EVENT_ID_0 = 0; 37 static constexpr int EVENT_ID_1 = 1; 38 static constexpr int EVENT_ID_2 = 2; 39 static constexpr int EVENT_ID_3 = 3; 40 static constexpr int EVENT_ID_4 = 4; 41 static constexpr int EVENT_ID_5 = 5; 42 }; 43 44 class ExtendEventListener : public OHOS::HiviewDFX::EventListener { 45 public: ExtendEventListener(const std::string & name)46 explicit ExtendEventListener(const std::string& name) : unorderEventCount_(0), name_(name){}; ~ExtendEventListener()47 ~ExtendEventListener(){}; 48 void OnUnorderedEvent(const OHOS::HiviewDFX::Event &msg) override; 49 std::string GetListenerName() override; 50 std::map<std::string, std::string> processedUnorderedEvents_; 51 uint32_t unorderEventCount_; 52 53 private: 54 std::string name_; 55 }; 56 #endif // HIVIEW_PLATFORM_EVENT_DISPATCH_QUEUE_TEST_H 57