1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at 6c29fa5a6Sopenharmony_ci * 7c29fa5a6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c29fa5a6Sopenharmony_ci * 9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and 13c29fa5a6Sopenharmony_ci * limitations under the License. 14c29fa5a6Sopenharmony_ci */ 15c29fa5a6Sopenharmony_ci 16c29fa5a6Sopenharmony_ci#include <gtest/gtest.h> 17c29fa5a6Sopenharmony_ci 18c29fa5a6Sopenharmony_ci#include "delegate_interface.h" 19c29fa5a6Sopenharmony_ci#include "error_multimodal.h" 20c29fa5a6Sopenharmony_ci 21c29fa5a6Sopenharmony_ci#include "mmi_log.h" 22c29fa5a6Sopenharmony_ci 23c29fa5a6Sopenharmony_ci#undef MMI_LOG_TAG 24c29fa5a6Sopenharmony_ci#define MMI_LOG_TAG "DelegateInterfaceTest" 25c29fa5a6Sopenharmony_cinamespace OHOS { 26c29fa5a6Sopenharmony_cinamespace MMI { 27c29fa5a6Sopenharmony_cinamespace { 28c29fa5a6Sopenharmony_ciusing namespace testing::ext; 29c29fa5a6Sopenharmony_ci} // namespace 30c29fa5a6Sopenharmony_ci 31c29fa5a6Sopenharmony_ciclass DelegateInterfaceTest : public testing::Test { 32c29fa5a6Sopenharmony_cipublic: 33c29fa5a6Sopenharmony_ci static void SetUpTestCase(void) {} 34c29fa5a6Sopenharmony_ci static void TearDownTestCase(void) {} 35c29fa5a6Sopenharmony_ci}; 36c29fa5a6Sopenharmony_ci 37c29fa5a6Sopenharmony_ci/** 38c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_GetDeviceTags_01 39c29fa5a6Sopenharmony_ci * @tc.desc: Test the function GetDeviceTags 40c29fa5a6Sopenharmony_ci * @tc.type: FUNC 41c29fa5a6Sopenharmony_ci * @tc.require: 42c29fa5a6Sopenharmony_ci */ 43c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetDeviceTags_01, TestSize.Level1) 44c29fa5a6Sopenharmony_ci{ 45c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 46c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 47c29fa5a6Sopenharmony_ci return 0; 48c29fa5a6Sopenharmony_ci }; 49c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 50c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::MONITOR; 51c29fa5a6Sopenharmony_ci uint32_t ret = delegateInterface.GetDeviceTags(type); 52c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, 0); 53c29fa5a6Sopenharmony_ci 54c29fa5a6Sopenharmony_ci type = InputHandlerType::NONE; 55c29fa5a6Sopenharmony_ci EXPECT_TRUE(delegateInterface.handlers.empty()); 56c29fa5a6Sopenharmony_ci uint32_t ret2 = delegateInterface.GetDeviceTags(type); 57c29fa5a6Sopenharmony_ci EXPECT_EQ(ret2, 0); 58c29fa5a6Sopenharmony_ci} 59c29fa5a6Sopenharmony_ci 60c29fa5a6Sopenharmony_ci/** 61c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_GetDeviceTags_02 62c29fa5a6Sopenharmony_ci * @tc.desc: Test the function GetDeviceTags 63c29fa5a6Sopenharmony_ci * @tc.type: FUNC 64c29fa5a6Sopenharmony_ci * @tc.require: 65c29fa5a6Sopenharmony_ci */ 66c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetDeviceTags_02, TestSize.Level1) 67c29fa5a6Sopenharmony_ci{ 68c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 69c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 70c29fa5a6Sopenharmony_ci return 0; 71c29fa5a6Sopenharmony_ci }; 72c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 73c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::INTERCEPTOR; 74c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 75c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 76c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 77c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 78c29fa5a6Sopenharmony_ci EXPECT_FALSE(delegateInterface.handlers.empty()); 79c29fa5a6Sopenharmony_ci uint32_t ret1 = delegateInterface.GetDeviceTags(type); 80c29fa5a6Sopenharmony_ci EXPECT_EQ(ret1, 2); 81c29fa5a6Sopenharmony_ci 82c29fa5a6Sopenharmony_ci type = InputHandlerType::NONE; 83c29fa5a6Sopenharmony_ci uint32_t ret2 = delegateInterface.GetDeviceTags(type); 84c29fa5a6Sopenharmony_ci EXPECT_EQ(ret2, 0); 85c29fa5a6Sopenharmony_ci} 86c29fa5a6Sopenharmony_ci 87c29fa5a6Sopenharmony_ci/** 88c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_RemoveLocal_01 89c29fa5a6Sopenharmony_ci * @tc.desc: Test the function RemoveLocal 90c29fa5a6Sopenharmony_ci * @tc.type: FUNC 91c29fa5a6Sopenharmony_ci * @tc.require: 92c29fa5a6Sopenharmony_ci */ 93c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_RemoveLocal_01, TestSize.Level1) 94c29fa5a6Sopenharmony_ci{ 95c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 96c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 97c29fa5a6Sopenharmony_ci return 0; 98c29fa5a6Sopenharmony_ci }; 99c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 100c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::NONE; 101c29fa5a6Sopenharmony_ci std::string name = "handler"; 102c29fa5a6Sopenharmony_ci uint32_t deviceTags = 1; 103c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 104c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 105c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 106c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 107c29fa5a6Sopenharmony_ci ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveLocal(type, name, deviceTags)); 108c29fa5a6Sopenharmony_ci 109c29fa5a6Sopenharmony_ci type = InputHandlerType::INTERCEPTOR; 110c29fa5a6Sopenharmony_ci name = "handler3"; 111c29fa5a6Sopenharmony_ci ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveLocal(type, name, deviceTags)); 112c29fa5a6Sopenharmony_ci 113c29fa5a6Sopenharmony_ci type = InputHandlerType::INTERCEPTOR; 114c29fa5a6Sopenharmony_ci name = "handler1"; 115c29fa5a6Sopenharmony_ci ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveLocal(type, name, deviceTags)); 116c29fa5a6Sopenharmony_ci} 117c29fa5a6Sopenharmony_ci 118c29fa5a6Sopenharmony_ci/** 119c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_GetPriority_01 120c29fa5a6Sopenharmony_ci * @tc.desc: Test the function GetPriority 121c29fa5a6Sopenharmony_ci * @tc.type: FUNC 122c29fa5a6Sopenharmony_ci * @tc.require: 123c29fa5a6Sopenharmony_ci */ 124c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetPriority_01, TestSize.Level1) 125c29fa5a6Sopenharmony_ci{ 126c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 127c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 128c29fa5a6Sopenharmony_ci return 0; 129c29fa5a6Sopenharmony_ci }; 130c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 131c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::INTERCEPTOR; 132c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 133c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 134c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 135c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 136c29fa5a6Sopenharmony_ci 137c29fa5a6Sopenharmony_ci int32_t ret = delegateInterface.GetPriority(type); 138c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, 1); 139c29fa5a6Sopenharmony_ci 140c29fa5a6Sopenharmony_ci type = InputHandlerType::NONE; 141c29fa5a6Sopenharmony_ci int32_t ret2 = delegateInterface.GetPriority(type); 142c29fa5a6Sopenharmony_ci EXPECT_EQ(ret2, 500); 143c29fa5a6Sopenharmony_ci} 144c29fa5a6Sopenharmony_ci 145c29fa5a6Sopenharmony_ci/** 146c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_GetEventType_01 147c29fa5a6Sopenharmony_ci * @tc.desc: Test the function GetEventType 148c29fa5a6Sopenharmony_ci * @tc.type: FUNC 149c29fa5a6Sopenharmony_ci * @tc.require: 150c29fa5a6Sopenharmony_ci */ 151c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetEventType_01, TestSize.Level1) 152c29fa5a6Sopenharmony_ci{ 153c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 154c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 155c29fa5a6Sopenharmony_ci return 0; 156c29fa5a6Sopenharmony_ci }; 157c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 158c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::MONITOR; 159c29fa5a6Sopenharmony_ci EXPECT_TRUE(delegateInterface.handlers.empty()); 160c29fa5a6Sopenharmony_ci uint32_t ret = delegateInterface.GetEventType(type); 161c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, 0); 162c29fa5a6Sopenharmony_ci} 163c29fa5a6Sopenharmony_ci 164c29fa5a6Sopenharmony_ci/** 165c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_GetEventType_02 166c29fa5a6Sopenharmony_ci * @tc.desc: Test the function GetEventType 167c29fa5a6Sopenharmony_ci * @tc.type: FUNC 168c29fa5a6Sopenharmony_ci * @tc.require: 169c29fa5a6Sopenharmony_ci */ 170c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetEventType_02, TestSize.Level1) 171c29fa5a6Sopenharmony_ci{ 172c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 173c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 174c29fa5a6Sopenharmony_ci return 0; 175c29fa5a6Sopenharmony_ci }; 176c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 177c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::MONITOR; 178c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 179c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 180c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 181c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 182c29fa5a6Sopenharmony_ci uint32_t ret = delegateInterface.GetEventType(type); 183c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, 2); 184c29fa5a6Sopenharmony_ci} 185c29fa5a6Sopenharmony_ci 186c29fa5a6Sopenharmony_ci/** 187c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_OnPostSyncTask_01 188c29fa5a6Sopenharmony_ci * @tc.desc: Test the function OnPostSyncTask 189c29fa5a6Sopenharmony_ci * @tc.type: FUNC 190c29fa5a6Sopenharmony_ci * @tc.require: 191c29fa5a6Sopenharmony_ci */ 192c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnPostSyncTask_01, TestSize.Level1) 193c29fa5a6Sopenharmony_ci{ 194c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 195c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 196c29fa5a6Sopenharmony_ci return 0; 197c29fa5a6Sopenharmony_ci }; 198c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 199c29fa5a6Sopenharmony_ci DTaskCallback myCallback = []() -> int32_t { 200c29fa5a6Sopenharmony_ci return RET_OK; 201c29fa5a6Sopenharmony_ci }; 202c29fa5a6Sopenharmony_ci uint32_t ret = delegateInterface.OnPostSyncTask(myCallback); 203c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, RET_OK); 204c29fa5a6Sopenharmony_ci} 205c29fa5a6Sopenharmony_ci 206c29fa5a6Sopenharmony_ci/** 207c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_OnInputEventHandler_01 208c29fa5a6Sopenharmony_ci * @tc.desc: Test the function OnInputEventHandler 209c29fa5a6Sopenharmony_ci * @tc.type: FUNC 210c29fa5a6Sopenharmony_ci * @tc.require: 211c29fa5a6Sopenharmony_ci */ 212c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnInputEventHandler_01, TestSize.Level1) 213c29fa5a6Sopenharmony_ci{ 214c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 215c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 216c29fa5a6Sopenharmony_ci return 0; 217c29fa5a6Sopenharmony_ci }; 218c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 219c29fa5a6Sopenharmony_ci std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create(); 220c29fa5a6Sopenharmony_ci ASSERT_NE(pointerEvent, nullptr); 221c29fa5a6Sopenharmony_ci 222c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::NONE; 223c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 224c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 225c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 226c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 227c29fa5a6Sopenharmony_ci ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent)); 228c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_MONITOR 229c29fa5a6Sopenharmony_ci type = InputHandlerType::MONITOR; 230c29fa5a6Sopenharmony_ci ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent)); 231c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_MONITOR 232c29fa5a6Sopenharmony_ci 233c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_INTERCEPTOR 234c29fa5a6Sopenharmony_ci type = InputHandlerType::INTERCEPTOR; 235c29fa5a6Sopenharmony_ci ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent)); 236c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_INTERCEPTOR 237c29fa5a6Sopenharmony_ci} 238c29fa5a6Sopenharmony_ci 239c29fa5a6Sopenharmony_ci/** 240c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_AddHandler_01 241c29fa5a6Sopenharmony_ci * @tc.desc: Test the function AddHandler 242c29fa5a6Sopenharmony_ci * @tc.type: FUNC 243c29fa5a6Sopenharmony_ci * @tc.require: 244c29fa5a6Sopenharmony_ci */ 245c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_AddHandler_01, TestSize.Level1) 246c29fa5a6Sopenharmony_ci{ 247c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 248c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 249c29fa5a6Sopenharmony_ci return 0; 250c29fa5a6Sopenharmony_ci }; 251c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 252c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary summary; 253c29fa5a6Sopenharmony_ci summary.handlerName = "handler1"; 254c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 255c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 256c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 257c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 258c29fa5a6Sopenharmony_ci 259c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::MONITOR; 260c29fa5a6Sopenharmony_ci int32_t ret = delegateInterface.AddHandler(type, summary); 261c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, ERROR_NULL_POINTER); 262c29fa5a6Sopenharmony_ci 263c29fa5a6Sopenharmony_ci summary.handlerName = "handler"; 264c29fa5a6Sopenharmony_ci int32_t ret2 = delegateInterface.AddHandler(type, summary); 265c29fa5a6Sopenharmony_ci EXPECT_EQ(ret2, ERROR_NULL_POINTER); 266c29fa5a6Sopenharmony_ci} 267c29fa5a6Sopenharmony_ci 268c29fa5a6Sopenharmony_ci/** 269c29fa5a6Sopenharmony_ci * @tc.name: DelegateInterfaceTest_AddHandler_02 270c29fa5a6Sopenharmony_ci * @tc.desc: Test the function AddHandler 271c29fa5a6Sopenharmony_ci * @tc.type: FUNC 272c29fa5a6Sopenharmony_ci * @tc.require: 273c29fa5a6Sopenharmony_ci */ 274c29fa5a6Sopenharmony_ciHWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_AddHandler_02, TestSize.Level1) 275c29fa5a6Sopenharmony_ci{ 276c29fa5a6Sopenharmony_ci CALL_TEST_DEBUG; 277c29fa5a6Sopenharmony_ci std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t { 278c29fa5a6Sopenharmony_ci return 0; 279c29fa5a6Sopenharmony_ci }; 280c29fa5a6Sopenharmony_ci DelegateInterface delegateInterface(delegate); 281c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary summary; 282c29fa5a6Sopenharmony_ci summary.handlerName = "handler"; 283c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2}; 284c29fa5a6Sopenharmony_ci DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3}; 285c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({INTERCEPTOR, handler1}); 286c29fa5a6Sopenharmony_ci delegateInterface.handlers.insert({MONITOR, handler2}); 287c29fa5a6Sopenharmony_ci 288c29fa5a6Sopenharmony_ci InputHandlerType type = InputHandlerType::MONITOR; 289c29fa5a6Sopenharmony_ci HandleEventType currentType = delegateInterface.GetEventType(type); 290c29fa5a6Sopenharmony_ci type = InputHandlerType::INTERCEPTOR; 291c29fa5a6Sopenharmony_ci HandleEventType newType = delegateInterface.GetEventType(type); 292c29fa5a6Sopenharmony_ci EXPECT_TRUE(currentType != newType); 293c29fa5a6Sopenharmony_ci 294c29fa5a6Sopenharmony_ci uint32_t currentTags = delegateInterface.GetDeviceTags(type); 295c29fa5a6Sopenharmony_ci summary.deviceTags = 1; 296c29fa5a6Sopenharmony_ci EXPECT_TRUE((currentTags & summary.deviceTags) != summary.deviceTags); 297c29fa5a6Sopenharmony_ci 298c29fa5a6Sopenharmony_ci int32_t ret = delegateInterface.AddHandler(type, summary); 299c29fa5a6Sopenharmony_ci EXPECT_EQ(ret, ERROR_NULL_POINTER); 300c29fa5a6Sopenharmony_ci 301c29fa5a6Sopenharmony_ci type = InputHandlerType::MONITOR; 302c29fa5a6Sopenharmony_ci currentType = delegateInterface.GetEventType(type); 303c29fa5a6Sopenharmony_ci newType = delegateInterface.GetEventType(type); 304c29fa5a6Sopenharmony_ci EXPECT_FALSE(currentType != newType); 305c29fa5a6Sopenharmony_ci int32_t ret2 = delegateInterface.AddHandler(type, summary); 306c29fa5a6Sopenharmony_ci EXPECT_EQ(ret2, ERROR_NULL_POINTER); 307c29fa5a6Sopenharmony_ci} 308c29fa5a6Sopenharmony_ci} // namespace MMI 309c29fa5a6Sopenharmony_ci} // namespace OHOS