1 /* 2 * Copyright (c) 2021-2024 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, OHOS::HiviewDFX::Event::MessageType type); 35 static constexpr int EVENT_ID_0 = 0; 36 static constexpr int EVENT_ID_1 = 1; 37 static constexpr int EVENT_ID_2 = 2; 38 static constexpr int EVENT_ID_3 = 3; 39 static constexpr int EVENT_ID_4 = 4; 40 static constexpr int EVENT_ID_5 = 5; 41 42 private: 43 OHOS::HiviewDFX::HiviewPlatform platform; 44 }; 45 46 class ExtendEventListener : public OHOS::HiviewDFX::EventListener { 47 public: ExtendEventListener(const std::string & name)48 explicit ExtendEventListener(const std::string& name) : unorderEventCount_(0), name_(name){}; ~ExtendEventListener()49 ~ExtendEventListener(){}; 50 void OnUnorderedEvent(const OHOS::HiviewDFX::Event &msg) override; 51 std::string GetListenerName() override; 52 std::map<std::string, std::string> processedUnorderedEvents_; 53 uint32_t unorderEventCount_; 54 55 private: 56 std::string name_; 57 }; 58 #endif // HIVIEW_PLATFORM_EVENT_DISPATCH_QUEUE_TEST_H 59