• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "key_event_input_subscribe_manager.h"
19 #include <cinttypes>
20 #include "bytrace_adapter.h"
21 #include "define_multimodal.h"
22 #include "error_multimodal.h"
23 #include "multimodal_event_handler.h"
24 
25 #undef MMI_LOG_TAG
26 #define MMI_LOG_TAG "KeyEventInputSubscribeManagerTest"
27 
28 namespace OHOS {
29 namespace MMI {
30 namespace {
31 constexpr int32_t INVALID_SUBSCRIBE_ID { -1 };
32 using namespace testing::ext;
33 } // namespace
34 
35 class KeyEventInputSubscribeManagerTest : public testing::Test {
36 public:
SetUpTestCase(void)37     static void SetUpTestCase(void) {}
TearDownTestCase(void)38     static void TearDownTestCase(void) {}
39 };
40 /**
41  * @tc.name: KeyEventInputSubscribeManagerTest_SubscribeKeyEvent001
42  * @tc.desc: Verify SubscribeKeyEvent
43  * @tc.type: FUNC
44  * @tc.require:
45  */
46 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_SubscribeKeyEvent001,
47     TestSize.Level1)
48 {
49     KeyEventInputSubscribeManager manager;
50     std::set<int32_t> preKeys;
51     preKeys.insert(1);
52     preKeys.insert(2);
53     preKeys.insert(3);
54     preKeys.insert(4);
55     preKeys.insert(5);
56 
57     std::shared_ptr<KeyOption> keyOption = std::make_shared<KeyOption>();
58     ASSERT_NE(keyOption, nullptr);
59     keyOption->SetPreKeys(preKeys);
60 
__anon5a9efd290202(std::shared_ptr<KeyEvent> event) 61     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
62         MMI_HILOGD("Add monitor success");
63     };
64     auto ret = manager.SubscribeKeyEvent(keyOption, myCallback);
65     EXPECT_EQ(ret, INVALID_SUBSCRIBE_ID);
66 }
67 
68 /**
69  * @tc.name: KeyEventInputSubscribeManagerTest_UnsubscribeKeyEvent001
70  * @tc.desc: Verify UnsubscribeKeyEvent
71  * @tc.type: FUNC
72  * @tc.require:
73  */
74 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_UnsubscribeKeyEvent001,
75     TestSize.Level1)
76 {
77     KeyEventInputSubscribeManager manager;
78     int32_t subscribeId = -1;
79     auto ret = manager.UnsubscribeKeyEvent(subscribeId);
80     EXPECT_EQ(ret, RET_ERR);
81 
82     subscribeId = 1;
83     ret = manager.UnsubscribeKeyEvent(subscribeId);
84     EXPECT_EQ(ret, RET_ERR);
85 }
86 
87 /**
88  * @tc.name: KeyEventInputSubscribeManagerTest_SubscribeHotkey002
89  * @tc.desc: Verify SubscribeHotkey
90  * @tc.type: FUNC
91  * @tc.require:
92  */
93 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_SubscribeHotkey002,
94     TestSize.Level1)
95 {
96     std::set<int32_t> preKeys;
97     preKeys.insert(1);
98     preKeys.insert(2);
99     preKeys.insert(3);
100     preKeys.insert(4);
101     preKeys.insert(5);
102 
103     std::shared_ptr<KeyOption> keyOption = std::make_shared<KeyOption>();
104     ASSERT_NE(keyOption, nullptr);
105     keyOption->SetPreKeys(preKeys);
106 
__anon5a9efd290302(std::shared_ptr<KeyEvent> event) 107     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
108         MMI_HILOGD("Add monitor success");
109     };
110     KeyEventInputSubscribeManager manager;
111     auto ret = manager.SubscribeHotkey(keyOption, myCallback);
112     EXPECT_EQ(ret, INVALID_SUBSCRIBE_ID);
113 }
114 
115 /**
116  * @tc.name: KeyEventInputSubscribeManagerTest_UnsubscribeHotkey001
117  * @tc.desc: Verify UnsubscribeHotkey
118  * @tc.type: FUNC
119  * @tc.require:
120  */
121 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_UnsubscribeHotkey001,
122     TestSize.Level1)
123 {
124     KeyEventInputSubscribeManager manager;
125     int32_t subscribeId = -1;
126     auto ret = manager.UnsubscribeHotkey(subscribeId);
127     EXPECT_EQ(ret, RET_ERR);
128 
129     subscribeId = 1;
130     ret = manager.UnsubscribeHotkey(subscribeId);
131     EXPECT_EQ(ret, RET_ERR);
132 }
133 
134 /**
135  * @tc.name: KeyEventInputSubscribeManagerTest_OnSubscribeKeyEventCallback001
136  * @tc.desc: Verify OnSubscribeKeyEventCallback
137  * @tc.type: FUNC
138  * @tc.require:
139  */
140 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_OnSubscribeKeyEventCallback001,
141     TestSize.Level1)
142 {
143     KeyEventInputSubscribeManager manager;
144     std::shared_ptr<KeyEvent> event = KeyEvent::Create();
145     EXPECT_NE(event, nullptr);
146     int32_t subscribeId = -1;
147     EXPECT_EQ(manager.OnSubscribeKeyEventCallback(event, subscribeId), RET_ERR);
148 }
149 
150 /**
151  * @tc.name: KeyEventInputSubscribeManagerTest_GetSubscribeKeyEvent001
152  * @tc.desc: Verify GetSubscribeKeyEvent
153  * @tc.type: FUNC
154  * @tc.require:
155  */
156 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_GetSubscribeKeyEvent001,
157     TestSize.Level1)
158 {
159     KeyEventInputSubscribeManager manager;
160     int32_t subscribeId = -1;
161     EXPECT_EQ(manager.GetSubscribeKeyEvent(subscribeId), nullptr);
162 }
163 
164 /**
165  * @tc.name: KeyEventInputSubscribeManagerTest_SubscribeKeyEventInfo001
166  * @tc.desc: Verify SubscribeKeyEventInfo
167  * @tc.type: FUNC
168  * @tc.require:
169  */
170 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_SubscribeKeyEventInfo001,
171     TestSize.Level1)
172 {
173     KeyEventInputSubscribeManager manager;
174     std::shared_ptr<KeyOption> keyOption = std::make_shared<KeyOption>();
175     EXPECT_NE(keyOption, nullptr);
176 
__anon5a9efd290402(std::shared_ptr<KeyEvent> event) 177     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
178         MMI_HILOGD("Add monitor success");
179     };
180 
181     manager.subscribeIdManager_ = std::numeric_limits<int32_t>::max();
182     KeyEventInputSubscribeManager::SubscribeKeyEventInfo info1(keyOption, myCallback);
183     EXPECT_EQ(info1.GetSubscribeId(), -1);
184 
185     KeyEventInputSubscribeManager::SubscribeKeyEventInfo info2(info1);
186     EXPECT_EQ(info2.GetSubscribeId(), -1);
187 
188     std::shared_ptr<KeyOption> keyOptionNull;
189     std::function<void(std::shared_ptr<KeyEvent>)> myCallbackNull;
190     KeyEventInputSubscribeManager::SubscribeKeyEventInfo info3(keyOptionNull, myCallbackNull);
191     EXPECT_TRUE(info3 < info1);
192     EXPECT_FALSE(info1 < info3);
193     EXPECT_FALSE(info1 < info2);
194 
195     KeyEventInputSubscribeManager::SubscribeKeyEventInfo info4 = info1;
196     EXPECT_EQ(info4.GetSubscribeId(), -1);
197     manager.subscribeIdManager_ = 0;
198 }
199 
200 #ifdef OHOS_BUILD_ENABLE_KEY_PRESSED_HANDLER
201 /**
202  * @tc.name: KeyEventInputSubscribeManagerTest_SubscribeKeyMonitor001
203  * @tc.desc: Verify SubscribeKeyMonitor
204  * @tc.type: FUNC
205  * @tc.require:
206  */
207 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_SubscribeKeyMonitor001,
208     TestSize.Level1)
209 {
210     KeyEventInputSubscribeManager manager;
211     KeyMonitorOption keyOption;
212     keyOption.SetKey(KeyEvent::KEYCODE_VOLUME_UP);
213     keyOption.SetAction(KeyEvent::KEY_ACTION_UP);
214     keyOption.SetRepeat(false);
215 
__anon5a9efd290502(std::shared_ptr<KeyEvent> event) 216     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
217         MMI_HILOGD("Add monitor success");
218     };
219     auto rlt1 = manager.SubscribeKeyMonitor(keyOption, myCallback);
220     EXPECT_NE(rlt1, 0);
221 }
222 
223 /**
224  * @tc.name: KeyEventInputSubscribeManagerTest_SubscribeKeyMonitor002
225  * @tc.desc: Verify SubscribeKeyMonitor
226  * @tc.type: FUNC
227  * @tc.require:
228  */
229 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_SubscribeKeyMonitor002,
230     TestSize.Level1)
231 {
232     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
233     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
234     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
235     monitorId.isRepeat_ = false;
236 
__anon5a9efd290602(std::shared_ptr<KeyEvent> event) 237     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
238         MMI_HILOGD("Add monitor success");
239     };
240 
241     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
242     KeyEventInputSubscribeManager::Monitor monitor;
243     monitor.callback_ = myCallback;
244 
245     int32_t id = 1;
246     monitors.emplace(id, monitor);
247 
248     KeyEventInputSubscribeManager manager;
249     manager.monitors_.emplace(monitorId, monitors);
250     manager.subscribeIdManager_ = 0;
251 
252     KeyMonitorOption keyOption;
253     keyOption.SetKey(KeyEvent::KEYCODE_VOLUME_UP);
254     keyOption.SetAction(KeyEvent::KEY_ACTION_UP);
255     keyOption.SetRepeat(false);
256 
257     auto rlt = manager.SubscribeKeyMonitor(keyOption, myCallback);
258     EXPECT_EQ(rlt, 0);
259 }
260 
261 /**
262  * @tc.name: KeyEventInputSubscribeManagerTest_UnsubscribeKeyMonitor001
263  * @tc.desc: Verify UnsubscribeKeyMonitor
264  * @tc.type: FUNC
265  * @tc.require:
266  */
267 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_UnsubscribeKeyMonitor001,
268     TestSize.Level1)
269 {
270     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
271     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
272     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
273     monitorId.isRepeat_ = false;
274 
__anon5a9efd290702(std::shared_ptr<KeyEvent> event) 275     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
276         MMI_HILOGD("Add monitor success");
277     };
278 
279     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
280     KeyEventInputSubscribeManager::Monitor monitor;
281     monitor.callback_ = myCallback;
282 
283     int32_t id1 = 1;
284     int32_t id2 = 2;
285     monitors.emplace(id1, monitor);
286     monitors.emplace(id2, monitor);
287 
288     KeyEventInputSubscribeManager manager;
289     manager.monitors_.emplace(monitorId, monitors);
290     int32_t subscriberId = -1;
291 
292     auto rlt = manager.UnsubscribeKeyMonitor(subscriberId);
293     EXPECT_EQ(rlt, -PARAM_INPUT_INVALID);
294 
295     subscriberId = id1;
296     rlt = manager.UnsubscribeKeyMonitor(subscriberId);
297     EXPECT_EQ(rlt, RET_OK);
298 
299     subscriberId = id2;
300     rlt = manager.UnsubscribeKeyMonitor(subscriberId);
301     MMI_HILOGI("UnsubscribeKeyMonitor ret:%{public}d", rlt);
302 }
303 
304 /**
305  * @tc.name: KeyEventInputSubscribeManagerTest_CheckKeyMonitors001
306  * @tc.desc: Verify CheckKeyMonitors
307  * @tc.type: FUNC
308  * @tc.require:
309  */
310 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_CheckKeyMonitors001,
311     TestSize.Level1)
312 {
313     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
314     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
315     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
316     monitorId.isRepeat_ = false;
317 
__anon5a9efd290802(std::shared_ptr<KeyEvent> event) 318     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
319         MMI_HILOGD("Add monitor success");
320     };
321 
322     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
323     KeyEventInputSubscribeManager::Monitor monitor;
324     monitor.callback_ = myCallback;
325 
326     int32_t id = 1;
327     monitors.emplace(id, monitor);
328 
329     KeyEventInputSubscribeManager manager;
330     manager.monitors_.emplace(monitorId, monitors);
331 
332     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
333     EXPECT_NE(keyEvent, nullptr);
334     keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_DOWN);
335     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
336     keyEvent->SetRepeatKey(true);
337 
338     auto keyMonitors = manager.CheckKeyMonitors(keyEvent);
339     EXPECT_EQ(keyMonitors.size(), 0);
340 
341     keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
342     keyMonitors = manager.CheckKeyMonitors(keyEvent);
343     EXPECT_EQ(keyMonitors.size(), 0);
344 
345     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
346     keyMonitors = manager.CheckKeyMonitors(keyEvent);
347     EXPECT_EQ(keyMonitors.size(), 1);
348 }
349 
350 /**
351  * @tc.name: KeyEventInputSubscribeManagerTest_CheckKeyMonitors002
352  * @tc.desc: Verify CheckKeyMonitors
353  * @tc.type: FUNC
354  * @tc.require:
355  */
356 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_CheckKeyMonitors002,
357     TestSize.Level1)
358 {
359     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
360     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_DOWN;
361     monitorId.action_ = KeyEvent::KEY_ACTION_DOWN;
362     monitorId.isRepeat_ = false;
363 
__anon5a9efd290902(std::shared_ptr<KeyEvent> event) 364     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
365         MMI_HILOGD("Add monitor success");
366     };
367 
368     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
369     KeyEventInputSubscribeManager::Monitor monitor;
370     monitor.callback_ = myCallback;
371 
372     int32_t id = 1;
373     monitors.emplace(id, monitor);
374 
375     KeyEventInputSubscribeManager manager;
376     manager.monitors_.emplace(monitorId, monitors);
377 
378     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
379     EXPECT_NE(keyEvent, nullptr);
380     keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_DOWN);
381     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
382     keyEvent->SetRepeatKey(true);
383 
384     auto keyMonitors = manager.CheckKeyMonitors(keyEvent);
385     EXPECT_EQ(keyMonitors.size(), 0);
386 
387     keyEvent->SetRepeatKey(false);
388     keyMonitors = manager.CheckKeyMonitors(keyEvent);
389     EXPECT_EQ(keyMonitors.size(), 1);
390 }
391 
392 /**
393  * @tc.name: KeyEventInputSubscribeManagerTest_CheckKeyMonitors003
394  * @tc.desc: Verify CheckKeyMonitors
395  * @tc.type: FUNC
396  * @tc.require:
397  */
398 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_CheckKeyMonitors003,
399     TestSize.Level1)
400 {
401     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
402     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
403     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
404     monitorId.isRepeat_ = true;
405 
__anon5a9efd290a02(std::shared_ptr<KeyEvent> event) 406     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
407         MMI_HILOGD("Add monitor success");
408     };
409 
410     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
411     KeyEventInputSubscribeManager::Monitor monitor;
412     monitor.callback_ = myCallback;
413 
414     int32_t id = 1;
415     monitors.emplace(id, monitor);
416 
417     KeyEventInputSubscribeManager manager;
418     manager.monitors_.emplace(monitorId, monitors);
419 
420     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
421     EXPECT_NE(keyEvent, nullptr);
422     keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
423     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
424     keyEvent->SetRepeatKey(true);
425 
426     auto keyMonitors = manager.CheckKeyMonitors(keyEvent);
427     EXPECT_EQ(keyMonitors.size(), 1);
428 }
429 
430 /**
431  * @tc.name: KeyEventInputSubscribeManagerTest_OnSubscribeKeyMonitor001
432  * @tc.desc: Verify OnSubscribeKeyMonitor
433  * @tc.type: FUNC
434  * @tc.require:
435  */
436 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_OnSubscribeKeyMonitor001,
437     TestSize.Level1)
438 {
439     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
440     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
441     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
442     monitorId.isRepeat_ = true;
443 
__anon5a9efd290b02(std::shared_ptr<KeyEvent> event) 444     auto myCallback = [](std::shared_ptr<KeyEvent> event) {
445         MMI_HILOGD("Add monitor success");
446     };
447 
448     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
449     KeyEventInputSubscribeManager::Monitor monitor;
450     monitor.callback_ = myCallback;
451 
452     int32_t id = 1;
453     monitors.emplace(id, monitor);
454 
455     KeyEventInputSubscribeManager manager;
456     manager.monitors_.emplace(monitorId, monitors);
457 
458     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
459     EXPECT_NE(keyEvent, nullptr);
460     keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
461     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
462     keyEvent->SetRepeatKey(true);
463     auto ret = manager.OnSubscribeKeyMonitor(keyEvent);
464     EXPECT_EQ(ret, RET_OK);
465 }
466 
467 /**
468  * @tc.name: KeyEventInputSubscribeManagerTest_OnSubscribeKeyMonitor002
469  * @tc.desc: Verify OnSubscribeKeyMonitor
470  * @tc.type: FUNC
471  * @tc.require:
472  */
473 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_OnSubscribeKeyMonitor002,
474     TestSize.Level1)
475 {
476     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
477     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
478     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
479     monitorId.isRepeat_ = true;
480 
481     KeyEventInputSubscribeManager::Monitor monitor;
482 
483     int32_t id = 1;
484     std::map<int32_t, KeyEventInputSubscribeManager::Monitor> monitors;
485     monitors.emplace(id, monitor);
486 
487     KeyEventInputSubscribeManager manager;
488     manager.monitors_.emplace(monitorId, monitors);
489 
490     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
491     EXPECT_NE(keyEvent, nullptr);
492     keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
493     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
494     keyEvent->SetRepeatKey(true);
495     auto ret = manager.OnSubscribeKeyMonitor(keyEvent);
496     EXPECT_EQ(ret, RET_OK);
497 }
498 
499 /**
500  * @tc.name: KeyEventInputSubscribeManagerTest_MonitorIdentity001
501  * @tc.desc: Verify MonitorIdentity
502  * @tc.type: FUNC
503  * @tc.require:
504  */
505 HWTEST_F(KeyEventInputSubscribeManagerTest, KeyEventInputSubscribeManagerTest_MonitorIdentity001,
506     TestSize.Level1)
507 {
508     KeyEventInputSubscribeManager::MonitorIdentity monitorId;
509     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_UP;
510     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
511     monitorId.isRepeat_ = true;
512 
513     KeyEventInputSubscribeManager::MonitorIdentity monitorId2;
514     monitorId2.key_ = KeyEvent::KEYCODE_VOLUME_UP;
515     monitorId2.action_ = KeyEvent::KEY_ACTION_UP;
516     monitorId2.isRepeat_ = true;
517 
518     EXPECT_FALSE(monitorId < monitorId2);
519 
520     monitorId.isRepeat_ = false;
521     EXPECT_TRUE(monitorId < monitorId2);
522 
523     monitorId.isRepeat_ = true;
524     monitorId.action_ = KeyEvent::KEY_ACTION_DOWN;
525     EXPECT_TRUE(monitorId < monitorId2);
526 
527     monitorId.action_ = KeyEvent::KEY_ACTION_UP;
528     monitorId.key_ = KeyEvent::KEYCODE_VOLUME_DOWN;
529     EXPECT_FALSE(monitorId < monitorId2);
530 }
531 #endif
532 } // namespace MMI
533 } // namespace OHOS