1 /*
2  * Copyright (C) 2023-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 #include <chrono>
18 #include <fstream>
19 #include <filesystem>
20 
21 #include "key_command_handler.h"
22 #include "input_event_handler.h"
23 #include "mmi_log.h"
24 #include "timer_manager.h"
25 
26 // Ability manager stub header
27 #include "ability_manager_client.h"
28 #include "display_event_monitor.h"
29 
30 #undef MMI_LOG_TAG
31 #define MMI_LOG_TAG "TwoFingerLongTouchTest"
32 
33 namespace OHOS {
34 namespace MMI {
35 
36 namespace {
37 using namespace testing::ext;
38 constexpr std::chrono::milliseconds WAIT_TIME_MS(50);
39 
40 const std::string TEST_DIR = "/data/test";
41 const std::string TEST_JSON = "/data/test/test.json";
42 
43 const std::string BINDLE_NAME = "bindle_name";
44 const std::string ABILITY_NAME = "test_ability";
45 const std::string ACTION = "some_action";
46 const std::string TYPE = "some_type";
47 const std::string DEVICE_ID = "device_id";
48 const std::string URI = "uri";
49 const std::string ENTITY = "entity";
50 const std::string KEY = "key";
51 const std::string VALUE = "value";
52 
53 constexpr unsigned ENTITY_NUM = 2;
54 constexpr unsigned PARAMETERS_NUM = 2;
55 constexpr int32_t DEFX = 50;
56 constexpr int32_t DEFY = 50;
57 constexpr int32_t LESS_THEN_THRESHOLD = 10;
58 constexpr int32_t GREATER_THEN_THRESHOLD = 20;
59 } // namespace
60 
61 class TestCommandHandler final : public IInputEventHandler {
62 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent)63     virtual void HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent) {}
64 #endif // OHOS_BUILD_ENABLE_KEYBOARD
65 #ifdef OHOS_BUILD_ENABLE_POINTER
HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent)66     virtual void HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent) {}
67 #endif // OHOS_BUILD_ENABLE_POINTER
68 #ifdef OHOS_BUILD_ENABLE_TOUCH
HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent)69     virtual void HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent) {}
70 #endif // OHOS_BUILD_ENABLE_TOUCH
71 };
72 
73 const std::string ABILITY_CONFIG_JSON = \
74 "{\n" \
75 "    \"Shortkeys\": [\n" \
76 "    ],\n" \
77 "    \"Sequences\" : [\n" \
78 "    ],\n" \
79 "    \"TwoFingerGesture\" : {\n" \
80 "        \"abilityStartDelay\" : 20,\n" \
81 "        \"ability\" : {\n" \
82 "            \"bundleName\" : \"bindle_name\",\n" \
83 "            \"abilityName\" : \"test_ability\",\n" \
84 "            \"action\" : \"some_action\",\n" \
85 "            \"type\" : \"some_type\",\n" \
86 "            \"deviceId\" : \"device_id\",\n" \
87 "            \"uri\" : \"uri\",\n" \
88 "            \"entities\" : [\n" \
89 "                \"entity1\",\n" \
90 "                \"entity2\"\n" \
91 "            ],\n" \
92 "            \"params\" : [\n" \
93 "                {\n" \
94 "                    \"key\" : \"key1\",\n" \
95 "                    \"value\" : \"value1\"\n" \
96 "                },\n" \
97 "                {\n" \
98 "                    \"key\" : \"key2\",\n" \
99 "                    \"value\" : \"value2\"\n" \
100 "                }\n" \
101 "            ]\n" \
102 "        }\n" \
103 "    }\n" \
104 "}\n";
105 
106 class TwoFingerLongTouchTest : public testing::Test {
107 public:
108     std::shared_ptr<TestCommandHandler> eventTestCommandHandler_ { nullptr };
109     std::shared_ptr<KeyCommandHandler> eventKeyCommandHandler_ { nullptr };
110     void SetupKeyCommandHandler();
111     std::shared_ptr<PointerEvent> SetupPointerEvent(int32_t action, int32_t pointerId, int32_t finger_num,
112                                                     int32_t dispX = DEFX, int32_t dispY = DEFY);
113     bool CreateTestJson(const std::string &contentJson);
114     void Delay(std::chrono::milliseconds delayMs);
115     static void AbilityCallback(const AAFwk::Want &want, ErrCode err);
116 
SetUpTestCase(void)117     static void SetUpTestCase(void) {}
TearDownTestCase(void)118     static void TearDownTestCase(void) {}
119 
TwoFingerLongTouchTest()120     TwoFingerLongTouchTest()
121     {
122         SetupKeyCommandHandler();
123         CreateTestJson(ABILITY_CONFIG_JSON);
124     }
125 
~TwoFingerLongTouchTest()126     ~TwoFingerLongTouchTest() {}
127 
128     static inline bool abilityStarted_;
129     static inline ErrCode err_;
130 };
131 
SetupKeyCommandHandler()132 void TwoFingerLongTouchTest::SetupKeyCommandHandler()
133 {
134     eventTestCommandHandler_ = std::make_shared<TestCommandHandler>();
135     eventKeyCommandHandler_ = std::make_shared<KeyCommandHandler>();
136     eventKeyCommandHandler_->SetNext(eventTestCommandHandler_);
137 
138     AAFwk::AbilityManagerClient::GetInstance()->SetCallback(TwoFingerLongTouchTest::AbilityCallback);
139 
140     abilityStarted_ = false;
141     err_ = ERR_OK;
142 }
143 
SetupPointerEvent(int32_t action, int32_t pointerId, int32_t finger_num, int32_t dispX, int32_t dispY)144 std::shared_ptr<PointerEvent> TwoFingerLongTouchTest::SetupPointerEvent(int32_t action,
145                                                                         int32_t pointerId,
146                                                                         int32_t finger_num,
147                                                                         int32_t dispX, int32_t dispY)
148 {
149     constexpr int32_t twoFinger = 2;
150     constexpr int32_t coordOffset = 25;
151     std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
152     CHKPP(pointerEvent);
153     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
154     pointerEvent->SetPointerAction(action);
155 
156     pointerEvent->SetPointerId(pointerId);
157 
158     PointerEvent::PointerItem item1;
159     item1.SetPointerId(0);
160     item1.SetDisplayX(dispX);
161     item1.SetDisplayY(dispY);
162     pointerEvent->AddPointerItem(item1);
163 
164     if (finger_num == twoFinger) {
165         PointerEvent::PointerItem item2;
166         item2.SetPointerId(1);
167         item2.SetDisplayX(dispX + coordOffset);
168         item2.SetDisplayY(dispY + coordOffset);
169         pointerEvent->AddPointerItem(item2);
170     }
171 
172     return pointerEvent;
173 }
174 
CreateTestJson(const std::string &contentJson)175 bool TwoFingerLongTouchTest::CreateTestJson(const std::string &contentJson)
176 {
177     // Check test directory presence and create it if required
178     if (!std::filesystem::exists(TEST_DIR)) {
179         if (!std::filesystem::create_directory(TEST_DIR)) {
180             return false;
181         }
182     }
183 
184     std::fstream file;
185     file.open(TEST_JSON, std::ios::out | std::ios::trunc);
186 
187     if (!file.is_open()) {
188         return false;
189     }
190     file << contentJson;
191 
192     file.close();
193 
194     return true;
195 }
196 
Delay(std::chrono::milliseconds delayMs)197 void TwoFingerLongTouchTest::Delay(std::chrono::milliseconds delayMs)
198 {
199     std::this_thread::sleep_for(delayMs);
200 }
201 
AbilityCallback(const AAFwk::Want &want, ErrCode err)202 void TwoFingerLongTouchTest::AbilityCallback(const AAFwk::Want &want, ErrCode err)
203 {
204     EXPECT_EQ(want.bundleName_, BINDLE_NAME);
205     EXPECT_EQ(want.abilityName_, ABILITY_NAME);
206     EXPECT_EQ(want.action_, ACTION);
207     EXPECT_EQ(want.type_, TYPE);
208     EXPECT_EQ(want.deviceId_, DEVICE_ID);
209     EXPECT_EQ(want.uri_, URI);
210 
211     EXPECT_EQ(want.entities_.size(), ENTITY_NUM);
212     if (want.entities_.size() == ENTITY_NUM) {
213         for (unsigned i = 0; i < want.entities_.size(); ++i) {
214             std::string entity = want.entities_[i];
215             std::string expected = ENTITY.data() + std::to_string(i + 1);
216             EXPECT_EQ(entity, expected);
217         }
218     }
219 
220     EXPECT_EQ(want.params_.size(), PARAMETERS_NUM);
221     if (want.params_.size() == PARAMETERS_NUM) {
222         for (unsigned i = 0; i < want.params_.size(); ++i) {
223             std::string key = KEY.data() + std::to_string(i + 1);
224             std::string value = VALUE.data() + std::to_string(i + 1);
225             auto item = want.params_.find(key);
226             EXPECT_NE(item, want.params_.end());
227 
228             if (item != want.params_.end()) {
229                 EXPECT_EQ(item->first, key);
230                 EXPECT_EQ(item->second, value);
231             }
232         }
233     }
234 
235     TwoFingerLongTouchTest::abilityStarted_ = true;
236     TwoFingerLongTouchTest::err_ = err;
237 }
238 
239 /**
240  * @tc.name: TwoFingerLongTouchTest_001
241  * @tc.desc: Test two finger long touch pointer event
242  * @tc.type: FUNC
243  * @tc.require:
244  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_001, TestSize.Level1)245 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_001, TestSize.Level1)
246 {
247     CALL_TEST_DEBUG;
248     ASSERT_NE(eventTestCommandHandler_, nullptr);
249     ASSERT_NE(eventKeyCommandHandler_, nullptr);
250     abilityStarted_ = false;
251 
252     auto pointerEvent1 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 2);
253     ASSERT_NE(pointerEvent1, nullptr);
254     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent1);
255 
256     Delay(WAIT_TIME_MS);
257     TimerMgr->ProcessTimers();
258 
259     auto pointerEvent2 = SetupPointerEvent(PointerEvent::POINTER_ACTION_UP, 0, 2);
260     ASSERT_NE(pointerEvent2, nullptr);
261     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent2);
262 
263     EXPECT_TRUE(abilityStarted_);
264     EXPECT_EQ(ERR_OK, err_);
265 }
266 
267 /**
268  * @tc.name: TwoFingerLongTouchTest_002
269  * @tc.desc: Test one finger long touch pointer event
270  * @tc.type: FUNC
271  * @tc.require:
272  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_002, TestSize.Level1)273 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_002, TestSize.Level1)
274 {
275     CALL_TEST_DEBUG;
276     ASSERT_NE(eventTestCommandHandler_, nullptr);
277     ASSERT_NE(eventKeyCommandHandler_, nullptr);
278     abilityStarted_ = false;
279 
280     auto pointerEvent1 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 1);
281     ASSERT_NE(pointerEvent1, nullptr);
282     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent1);
283 
284     Delay(WAIT_TIME_MS);
285     TimerMgr->ProcessTimers();
286 
287     auto pointerEvent2 = SetupPointerEvent(PointerEvent::POINTER_ACTION_UP, 0, 1);
288     ASSERT_NE(pointerEvent2, nullptr);
289     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent2);
290 
291     EXPECT_FALSE(abilityStarted_);
292 }
293 
294 /**
295  * @tc.name: TwoFingerLongTouchTest_003
296  * @tc.desc: Test two finger long touch gesture interruption
297  * @tc.type: FUNC
298  * @tc.require:
299  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_003, TestSize.Level1)300 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_003, TestSize.Level1)
301 {
302     CALL_TEST_DEBUG;
303     ASSERT_NE(eventTestCommandHandler_, nullptr);
304     ASSERT_NE(eventKeyCommandHandler_, nullptr);
305     abilityStarted_ = false;
306 
307     auto pointerEvent1 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 2);
308     ASSERT_NE(pointerEvent1, nullptr);
309     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent1);
310 
311     auto pointerEvent2 = SetupPointerEvent(PointerEvent::POINTER_ACTION_UP, 0, 2);
312     ASSERT_NE(pointerEvent2, nullptr);
313     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent2);
314 
315     Delay(WAIT_TIME_MS);
316     TimerMgr->ProcessTimers();
317 
318     EXPECT_FALSE(abilityStarted_);
319 }
320 
321 /**
322  * @tc.name: TwoFingerLongTouchTest_004
323  * @tc.desc: Test two finger long touch gesture moving inside threshold
324  *           (And one more unregistered event outside of threshold)
325  * @tc.type: FUNC
326  * @tc.require:
327  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_004, TestSize.Level1)328 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_004, TestSize.Level1)
329 {
330     CALL_TEST_DEBUG;
331     ASSERT_NE(eventTestCommandHandler_, nullptr);
332     ASSERT_NE(eventKeyCommandHandler_, nullptr);
333     abilityStarted_ = false;
334 
335     auto pointerEvent1 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 1);
336     ASSERT_NE(pointerEvent1, nullptr);
337     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent1);
338 
339     auto pointerEvent2 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 2);
340     ASSERT_NE(pointerEvent2, nullptr);
341     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent2);
342 
343     auto pointerEvent3 = SetupPointerEvent(PointerEvent::POINTER_ACTION_MOVE, 0, 2,
344                                            DEFX + LESS_THEN_THRESHOLD, DEFY + LESS_THEN_THRESHOLD);
345     ASSERT_NE(pointerEvent3, nullptr);
346     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent3);
347 
348     auto pointerEvent4 = SetupPointerEvent(PointerEvent::POINTER_ACTION_MOVE, 2, 1,
349                                            DEFX + GREATER_THEN_THRESHOLD, DEFY + GREATER_THEN_THRESHOLD);
350     ASSERT_NE(pointerEvent4, nullptr);
351     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent4);
352 
353     Delay(WAIT_TIME_MS);
354     TimerMgr->ProcessTimers();
355 
356     EXPECT_TRUE(abilityStarted_);
357     EXPECT_EQ(ERR_OK, err_);
358 }
359 
360 /**
361  * @tc.name: TwoFingerLongTouchTest_005
362  * @tc.desc: Test two finger long touch gesture moving outside threshold
363  * @tc.type: FUNC
364  * @tc.require:
365  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_005, TestSize.Level1)366 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_005, TestSize.Level1)
367 {
368     CALL_TEST_DEBUG;
369     ASSERT_NE(eventTestCommandHandler_, nullptr);
370     ASSERT_NE(eventKeyCommandHandler_, nullptr);
371     abilityStarted_ = false;
372 
373     auto pointerEvent1 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 1);
374     ASSERT_NE(pointerEvent1, nullptr);
375     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent1);
376 
377     auto pointerEvent2 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 2);
378     ASSERT_NE(pointerEvent2, nullptr);
379     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent2);
380 
381     auto pointerEvent3 = SetupPointerEvent(PointerEvent::POINTER_ACTION_MOVE, 0, 2,
382                                            DEFX + GREATER_THEN_THRESHOLD, DEFY + GREATER_THEN_THRESHOLD);
383     ASSERT_NE(pointerEvent3, nullptr);
384     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent3);
385 
386     Delay(WAIT_TIME_MS);
387     TimerMgr->ProcessTimers();
388 
389     EXPECT_FALSE(abilityStarted_);
390 }
391 
392 /**
393  * @tc.name: TwoFingerLongTouchTest_006
394  * @tc.desc: Test to return error while ability is launching
395  * @tc.type: FUNC
396  * @tc.require:
397  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_006, TestSize.Level1)398 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_006, TestSize.Level1)
399 {
400     CALL_TEST_DEBUG;
401     ASSERT_NE(eventTestCommandHandler_, nullptr);
402     ASSERT_NE(eventKeyCommandHandler_, nullptr);
403     abilityStarted_ = false;
404 
405     AAFwk::AbilityManagerClient::GetInstance()->SetErrCode(ERR_INVALID_OPERATION);
406 
407     auto pointerEvent1 = SetupPointerEvent(PointerEvent::POINTER_ACTION_DOWN, 0, 2);
408     ASSERT_NE(pointerEvent1, nullptr);
409     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent1);
410 
411     Delay(WAIT_TIME_MS);
412     TimerMgr->ProcessTimers();
413 
414     auto pointerEvent2 = SetupPointerEvent(PointerEvent::POINTER_ACTION_UP, 0, 2);
415     ASSERT_NE(pointerEvent2, nullptr);
416     eventKeyCommandHandler_->HandleTouchEvent(pointerEvent2);
417 
418     AAFwk::AbilityManagerClient::GetInstance()->SetErrCode(ERR_OK);
419 
420     EXPECT_TRUE(abilityStarted_);
421     EXPECT_EQ(ERR_INVALID_OPERATION, err_);
422 }
423 
424 const std::string TEST_JSON_1 = "";
425 const std::string TEST_JSON_2 =
426     "{ \"TwoFingerGesture\" : [] }\n";
427 const std::string TEST_JSON_3 =
428     "{ \"TwoFingerGesture\" : {} }\n";
429 const std::string TEST_JSON_4 =
430     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200} }\n";
431 const std::string TEST_JSON_5 =
432     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : -1} }\n";
433 const std::string TEST_JSON_6 =
434     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : \"abc\"} }\n";
435 const std::string TEST_JSON_7 =
436     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : []} }\n";
437 const std::string TEST_JSON_8 =
438     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"bundleName\"}} }\n";
439 const std::string TEST_JSON_9 =
440     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"entities\" : {}}} }\n";
441 const std::string TEST_JSON_10 =
442     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"entities\" : [123]}} }\n";
443 const std::string TEST_JSON_11 =
444     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"params\" : {}}} }\n";
445 const std::string TEST_JSON_12 =
446     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"params\" : [[]]}} }\n";
447 const std::string TEST_JSON_13 =
448     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"params\" : [{}]}} }\n";
449 const std::string TEST_JSON_14 =
450     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {\"params\" : [{\"key\" : \"key1\"}]}} }\n";
451 const std::string TEST_JSON_15 =
452     "{ \"TwoFingerGesture\" : {\"abilityStartDelay\" : 200, \"ability\" : {}} }\n";
453 
454 /**
455  * @tc.name: TwoFingerLongTouchTest_007
456  * @tc.desc: Test JSON parsing error branches
457  * @tc.type: FUNC
458  * @tc.require:
459  */
HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_007, TestSize.Level1)460 HWTEST_F(TwoFingerLongTouchTest, TwoFingerLongTouchTest_007, TestSize.Level1)
461 {
462     CALL_TEST_DEBUG;
463     ASSERT_NE(eventTestCommandHandler_, nullptr);
464     ASSERT_NE(eventKeyCommandHandler_, nullptr);
465     abilityStarted_ = false;
466 
467     ASSERT_TRUE(CreateTestJson(TEST_JSON_1));
468     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
469 
470     ASSERT_TRUE(CreateTestJson(TEST_JSON_2));
471     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
472 
473     ASSERT_TRUE(CreateTestJson(TEST_JSON_3));
474     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
475 
476     ASSERT_TRUE(CreateTestJson(TEST_JSON_4));
477     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
478 
479     ASSERT_TRUE(CreateTestJson(TEST_JSON_5));
480     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
481 
482     ASSERT_TRUE(CreateTestJson(TEST_JSON_6));
483     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
484 
485     ASSERT_TRUE(CreateTestJson(TEST_JSON_7));
486     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
487 
488     ASSERT_TRUE(CreateTestJson(TEST_JSON_8));
489     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
490 
491     ASSERT_TRUE(CreateTestJson(TEST_JSON_9));
492     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
493 
494     ASSERT_TRUE(CreateTestJson(TEST_JSON_10));
495     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
496 
497     ASSERT_TRUE(CreateTestJson(TEST_JSON_11));
498     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
499 
500     ASSERT_TRUE(CreateTestJson(TEST_JSON_12));
501     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
502 
503     ASSERT_TRUE(CreateTestJson(TEST_JSON_13));
504     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
505 
506     ASSERT_TRUE(CreateTestJson(TEST_JSON_14));
507     ASSERT_FALSE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
508 
509     ASSERT_TRUE(CreateTestJson(TEST_JSON_15));
510     ASSERT_TRUE(eventKeyCommandHandler_->ParseJson(TEST_JSON));
511 }
512 } // namespace MMI
513 } // namespace OHOS
514