• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
16 #include <gtest/gtest.h>
17 
18 #include "delegate_interface.h"
19 #include "error_multimodal.h"
20 
21 #include "mmi_log.h"
22 
23 #undef MMI_LOG_TAG
24 #define MMI_LOG_TAG "DelegateInterfaceTest"
25 namespace OHOS {
26 namespace MMI {
27 namespace {
28 using namespace testing::ext;
29 } // namespace
30 
31 class DelegateInterfaceTest : public testing::Test {
32 public:
SetUpTestCase(void)33     static void SetUpTestCase(void) {}
TearDownTestCase(void)34     static void TearDownTestCase(void) {}
35 };
36 
37 /**
38  * @tc.name: DelegateInterfaceTest_GetDeviceTags_01
39  * @tc.desc: Test the function GetDeviceTags
40  * @tc.type: FUNC
41  * @tc.require:
42  */
43 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetDeviceTags_01, TestSize.Level1)
44 {
45     CALL_TEST_DEBUG;
__anonf9d53a2d0202(DTaskCallback cb) 46     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
47         return 0;
48     };
__anonf9d53a2d0302(DTaskCallback cb) 49     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
50         return 0;
51     };
52     DelegateInterface delegateInterface(delegate, asyncFun);
53     InputHandlerType type = InputHandlerType::MONITOR;
54     uint32_t ret = delegateInterface.GetDeviceTags(type);
55     EXPECT_EQ(ret, 0);
56 
57     type = InputHandlerType::NONE;
58     EXPECT_TRUE(delegateInterface.handlers_.empty());
59     uint32_t ret2 = delegateInterface.GetDeviceTags(type);
60     EXPECT_EQ(ret2, 0);
61 }
62 
63 /**
64  * @tc.name: DelegateInterfaceTest_GetDeviceTags_02
65  * @tc.desc: Test the function GetDeviceTags
66  * @tc.type: FUNC
67  * @tc.require:
68  */
69 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetDeviceTags_02, TestSize.Level1)
70 {
71     CALL_TEST_DEBUG;
__anonf9d53a2d0402(DTaskCallback cb) 72     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
73         return 0;
74     };
__anonf9d53a2d0502(DTaskCallback cb) 75     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
76         return 0;
77     };
78     DelegateInterface delegateInterface(delegate, asyncFun);
79     InputHandlerType type = InputHandlerType::INTERCEPTOR;
80     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
81     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
82     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
83     delegateInterface.handlers_.insert({MONITOR, handler2});
84     EXPECT_FALSE(delegateInterface.handlers_.empty());
85     uint32_t ret1 = delegateInterface.GetDeviceTags(type);
86     EXPECT_EQ(ret1, 2);
87 
88     type = InputHandlerType::NONE;
89     uint32_t ret2 = delegateInterface.GetDeviceTags(type);
90     EXPECT_EQ(ret2, 0);
91 }
92 
93 /**
94  * @tc.name: DelegateInterfaceTest_RemoveLocal_01
95  * @tc.desc: Test the function RemoveLocal
96  * @tc.type: FUNC
97  * @tc.require:
98  */
99 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_RemoveLocal_01, TestSize.Level1)
100 {
101     CALL_TEST_DEBUG;
__anonf9d53a2d0602(DTaskCallback cb) 102     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
103         return 0;
104     };
__anonf9d53a2d0702(DTaskCallback cb) 105     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
106         return 0;
107     };
108     DelegateInterface delegateInterface(delegate, asyncFun);
109     InputHandlerType type = InputHandlerType::NONE;
110     std::string name = "handler";
111     uint32_t deviceTags = 1;
112     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
113     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
114     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
115     delegateInterface.handlers_.insert({MONITOR, handler2});
116     ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveLocal(type, name, deviceTags));
117 
118     type = InputHandlerType::INTERCEPTOR;
119     name = "handler3";
120     ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveLocal(type, name, deviceTags));
121 
122     type = InputHandlerType::INTERCEPTOR;
123     name = "handler1";
124     ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveLocal(type, name, deviceTags));
125 }
126 
127 /**
128  * @tc.name: DelegateInterfaceTest_GetPriority_01
129  * @tc.desc: Test the function GetPriority
130  * @tc.type: FUNC
131  * @tc.require:
132  */
133 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetPriority_01, TestSize.Level1)
134 {
135     CALL_TEST_DEBUG;
__anonf9d53a2d0802(DTaskCallback cb) 136     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
137         return 0;
138     };
__anonf9d53a2d0902(DTaskCallback cb) 139     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
140         return 0;
141     };
142     DelegateInterface delegateInterface(delegate, asyncFun);
143     InputHandlerType type = InputHandlerType::INTERCEPTOR;
144     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
145     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
146     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
147     delegateInterface.handlers_.insert({MONITOR, handler2});
148 
149     int32_t ret = delegateInterface.GetPriority(type);
150     EXPECT_EQ(ret, 1);
151 
152     type = InputHandlerType::NONE;
153     int32_t ret2 = delegateInterface.GetPriority(type);
154     EXPECT_EQ(ret2, 500);
155 }
156 
157 /**
158  * @tc.name: DelegateInterfaceTest_GetEventType_01
159  * @tc.desc: Test the function GetEventType
160  * @tc.type: FUNC
161  * @tc.require:
162  */
163 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetEventType_01, TestSize.Level1)
164 {
165     CALL_TEST_DEBUG;
__anonf9d53a2d0a02(DTaskCallback cb) 166     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
167         return 0;
168     };
__anonf9d53a2d0b02(DTaskCallback cb) 169     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
170         return 0;
171     };
172     DelegateInterface delegateInterface(delegate, asyncFun);
173     InputHandlerType type = InputHandlerType::MONITOR;
174     EXPECT_TRUE(delegateInterface.handlers_.empty());
175     uint32_t ret = delegateInterface.GetEventType(type);
176     EXPECT_EQ(ret, 0);
177 }
178 
179 /**
180  * @tc.name: DelegateInterfaceTest_GetEventType_02
181  * @tc.desc: Test the function GetEventType
182  * @tc.type: FUNC
183  * @tc.require:
184  */
185 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_GetEventType_02, TestSize.Level1)
186 {
187     CALL_TEST_DEBUG;
__anonf9d53a2d0c02(DTaskCallback cb) 188     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
189         return 0;
190     };
__anonf9d53a2d0d02(DTaskCallback cb) 191     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
192         return 0;
193     };
194     DelegateInterface delegateInterface(delegate, asyncFun);
195     InputHandlerType type = InputHandlerType::MONITOR;
196     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
197     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
198     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
199     delegateInterface.handlers_.insert({MONITOR, handler2});
200     uint32_t ret = delegateInterface.GetEventType(type);
201     EXPECT_EQ(ret, 2);
202 }
203 
204 /**
205  * @tc.name: DelegateInterfaceTest_OnPostSyncTask_01
206  * @tc.desc: Test the function OnPostSyncTask
207  * @tc.type: FUNC
208  * @tc.require:
209  */
210 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnPostSyncTask_01, TestSize.Level1)
211 {
212     CALL_TEST_DEBUG;
__anonf9d53a2d0e02(DTaskCallback cb) 213     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
214         return 0;
215     };
__anonf9d53a2d0f02(DTaskCallback cb) 216     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
217         return 0;
218     };
219     DelegateInterface delegateInterface(delegate, asyncFun);
__anonf9d53a2d1002() 220     DTaskCallback myCallback = []() -> int32_t {
221         return RET_OK;
222     };
223     uint32_t ret = delegateInterface.OnPostSyncTask(myCallback);
224     EXPECT_EQ(ret, RET_OK);
225 }
226 
227 /**
228  * @tc.name: DelegateInterfaceTest_OnInputEventHandler_01
229  * @tc.desc: Test the function OnInputEventHandler
230  * @tc.type: FUNC
231  * @tc.require:
232  */
233 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnInputEventHandler_01, TestSize.Level1)
234 {
235     CALL_TEST_DEBUG;
__anonf9d53a2d1102(DTaskCallback cb) 236     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
237         return 0;
238     };
__anonf9d53a2d1202(DTaskCallback cb) 239     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
240         return 0;
241     };
242     DelegateInterface delegateInterface(delegate, asyncFun);
243     std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
244     ASSERT_NE(pointerEvent, nullptr);
245 
246     InputHandlerType type = InputHandlerType::NONE;
247     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
248     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
249     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
250     delegateInterface.handlers_.insert({MONITOR, handler2});
251     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
252 #ifdef OHOS_BUILD_ENABLE_MONITOR
253     type = InputHandlerType::MONITOR;
254     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
255 #endif // OHOS_BUILD_ENABLE_MONITOR
256 
257 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
258     type = InputHandlerType::INTERCEPTOR;
259     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
260 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR
261 }
262 
263 /**
264  * @tc.name: DelegateInterfaceTest_AddHandler_01
265  * @tc.desc: Test the function AddHandler
266  * @tc.type: FUNC
267  * @tc.require:
268  */
269 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_AddHandler_01, TestSize.Level1)
270 {
271     CALL_TEST_DEBUG;
__anonf9d53a2d1302(DTaskCallback cb) 272     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
273         return 0;
274     };
__anonf9d53a2d1402(DTaskCallback cb) 275     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
276         return 0;
277     };
278     DelegateInterface delegateInterface(delegate, asyncFun);
279     DelegateInterface::HandlerSummary summary;
280     summary.handlerName = "handler1";
__anonf9d53a2d1502(std::shared_ptr<PointerEvent> event) 281     auto callback = [](std::shared_ptr<PointerEvent> event) -> int32_t {
282         return RET_OK;
283     };
284     summary.cb = callback;
285     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
286     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
287     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
288     delegateInterface.handlers_.insert({MONITOR, handler2});
289 
290     InputHandlerType type = InputHandlerType::MONITOR;
291     int32_t ret = delegateInterface.AddHandler(type, summary);
292     EXPECT_EQ(ret, RET_OK);
293 
294     summary.handlerName = "handler";
295     int32_t ret2 = delegateInterface.AddHandler(type, summary);
296     EXPECT_EQ(ret2, RET_OK);
297 }
298 
299 /**
300  * @tc.name: DelegateInterfaceTest_AddHandler_02
301  * @tc.desc: Test the function AddHandler
302  * @tc.type: FUNC
303  * @tc.require:
304  */
305 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_AddHandler_02, TestSize.Level1)
306 {
307     CALL_TEST_DEBUG;
__anonf9d53a2d1602(DTaskCallback cb) 308     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
309         return 0;
310     };
__anonf9d53a2d1702(DTaskCallback cb) 311     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
312         return 0;
313     };
314     DelegateInterface delegateInterface(delegate, asyncFun);
315     DelegateInterface::HandlerSummary summary;
316     summary.handlerName = "handler";
__anonf9d53a2d1802(std::shared_ptr<PointerEvent> event) 317     auto callback = [](std::shared_ptr<PointerEvent> event) -> int32_t {
318         return RET_OK;
319     };
320     summary.cb = callback;
321     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
322     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
323     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
324     delegateInterface.handlers_.insert({MONITOR, handler2});
325 
326     InputHandlerType type = InputHandlerType::MONITOR;
327     HandleEventType currentType = delegateInterface.GetEventType(type);
328     type = InputHandlerType::INTERCEPTOR;
329     HandleEventType newType = delegateInterface.GetEventType(type);
330     EXPECT_TRUE(currentType != newType);
331 
332     uint32_t currentTags = delegateInterface.GetDeviceTags(type);
333     summary.deviceTags = 1;
334     EXPECT_TRUE((currentTags & summary.deviceTags) != summary.deviceTags);
335 
336     int32_t ret = delegateInterface.AddHandler(type, summary);
337     EXPECT_EQ(ret, ERROR_NULL_POINTER);
338 
339     type = InputHandlerType::MONITOR;
340     currentType = delegateInterface.GetEventType(type);
341     newType = delegateInterface.GetEventType(type);
342     EXPECT_FALSE(currentType != newType);
343     int32_t ret2 = delegateInterface.AddHandler(type, summary);
344     EXPECT_EQ(ret2, RET_OK);
345 }
346 
347 /**
348  * @tc.name: DelegateInterfaceTest_OnPostAsyncTask_01
349  * @tc.desc: Test the function OnPostAsyncTask
350  * @tc.type: FUNC
351  * @tc.require:
352  */
353 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnPostAsyncTask_01, TestSize.Level1)
354 {
355     CALL_TEST_DEBUG;
__anonf9d53a2d1902(DTaskCallback cb) 356     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
357         return 0;
358     };
__anonf9d53a2d1a02(DTaskCallback cb) 359     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
360         return 0;
361     };
362     DelegateInterface delegateInterface(delegate, asyncFun);
__anonf9d53a2d1b02() 363     DTaskCallback myCallback = []() -> int32_t {
364         return RET_OK;
365     };
366     int32_t ret = delegateInterface.OnPostAsyncTask(myCallback);
367     EXPECT_EQ(ret, RET_OK);
368 }
369 /**
370  * @tc.name: DelegateInterfaceTest_OnPostAsyncTask_02
371  * @tc.desc: Test the function OnPostAsyncTask
372  * @tc.type: FUNC
373  * @tc.require:
374  */
375 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnPostAsyncTask_02, TestSize.Level1)
376 {
377     CALL_TEST_DEBUG;
__anonf9d53a2d1c02(DTaskCallback cb) 378     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
379         return 0;
380     };
__anonf9d53a2d1d02(DTaskCallback cb) 381     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
382         return 0;
383     };
384     DelegateInterface delegateInterface(delegate, asyncFun);
__anonf9d53a2d1e02() 385     DTaskCallback myCallback = []() -> int32_t {
386         return RET_ERR;
387     };
388     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnPostAsyncTask(myCallback));
389 }
390 
391 /**
392  * @tc.name: DelegateInterfaceTest_OnPostSyncTask_02
393  * @tc.desc: Test the function OnPostSyncTask
394  * @tc.type: FUNC
395  * @tc.require:
396  */
397 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnPostSyncTask_02, TestSize.Level1)
398 {
399     CALL_TEST_DEBUG;
__anonf9d53a2d1f02(DTaskCallback cb) 400     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
401         return 0;
402     };
__anonf9d53a2d2002(DTaskCallback cb) 403     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
404         return 0;
405     };
406     DelegateInterface delegateInterface(delegate, asyncFun);
__anonf9d53a2d2102() 407     DTaskCallback myCallback = []() -> int32_t {
408         return RET_ERR;
409     };
410     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnPostSyncTask(myCallback));
411 }
412 
413 /**
414  * @tc.name: DelegateInterfaceTest_OnInputEventHandler_02
415  * @tc.desc: Test the function OnInputEventHandler
416  * @tc.type: FUNC
417  * @tc.require:
418  */
419 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_OnInputEventHandler_02, TestSize.Level1)
420 {
421     CALL_TEST_DEBUG;
__anonf9d53a2d2202(DTaskCallback cb) 422     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
423         return 0;
424     };
__anonf9d53a2d2302(DTaskCallback cb) 425     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
426         return 0;
427     };
428     DelegateInterface delegateInterface(delegate, asyncFun);
429     std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
430     ASSERT_NE(pointerEvent, nullptr);
431 
432     InputHandlerType type = InputHandlerType::NONE;
433     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
434     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
435     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
436     delegateInterface.handlers_.insert({MONITOR, handler2});
437     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
438 #ifdef OHOS_BUILD_ENABLE_MONITOR
439     type = InputHandlerType::MONITOR;
440     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
441 #endif // OHOS_BUILD_ENABLE_MONITOR
442 
443 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
444     type = InputHandlerType::INTERCEPTOR;
445     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
446 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR
__anonf9d53a2d2402(std::shared_ptr<PointerEvent> event) 447     auto callback = [](std::shared_ptr<PointerEvent> event) -> int32_t {
448         return RET_OK;
449     };
450     handler1.cb = callback;
451     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
452     handler1.mode = HandlerMode::ASYNC;
453     ASSERT_NO_FATAL_FAILURE(delegateInterface.OnInputEventHandler(type, pointerEvent));
454 }
455 
456 /**
457  * @tc.name: DelegateInterfaceTest_RemoveHandler_01
458  * @tc.desc: Test the function RemoveHandler
459  * @tc.type: FUNC
460  * @tc.require:
461  */
462 HWTEST_F(DelegateInterfaceTest, DelegateInterfaceTest_RemoveHandler_01, TestSize.Level1)
463 {
464     CALL_TEST_DEBUG;
__anonf9d53a2d2502(DTaskCallback cb) 465     std::function<int32_t(DTaskCallback)> delegate = [](DTaskCallback cb) -> int32_t {
466         return 0;
467     };
__anonf9d53a2d2602(DTaskCallback cb) 468     std::function<int32_t(DTaskCallback)> asyncFun = [this](DTaskCallback cb) -> int32_t {
469         return 0;
470     };
471     DelegateInterface delegateInterface(delegate, asyncFun);
472     DelegateInterface::HandlerSummary summary;
473     summary.handlerName = "handler1";
__anonf9d53a2d2702(std::shared_ptr<PointerEvent> event) 474     auto callback = [](std::shared_ptr<PointerEvent> event) -> int32_t {
475         return RET_OK;
476     };
477     summary.cb = callback;
478     DelegateInterface::HandlerSummary handler1 = {"handler1", 0x1, HandlerMode::SYNC, 1, 2};
479     DelegateInterface::HandlerSummary handler2 = {"handler2", 0x2, HandlerMode::ASYNC, 2, 3};
480     delegateInterface.handlers_.insert({INTERCEPTOR, handler1});
481     delegateInterface.handlers_.insert({MONITOR, handler2});
482 
483     InputHandlerType type = InputHandlerType::MONITOR;
484     delegateInterface.AddHandler(type, summary);
485     ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveHandler(type, summary.handlerName));
486     type = InputHandlerType::INTERCEPTOR;
487     ASSERT_NO_FATAL_FAILURE(delegateInterface.RemoveHandler(type, summary.handlerName));
488 }
489 
490 } // namespace MMI
491 } // namespace OHOS