• 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 "input_monitor_manager.h"
19 #include "input_handler_type.h"
20 #include "tablet_event_input_subscribe_manager.h"
21 #include "mmi_log.h"
22 
23 
24 #undef MMI_LOG_TAG
25 #define MMI_LOG_TAG "InputMonitorManagerTest"
26 
27 namespace OHOS {
28 namespace MMI {
29 namespace {
30 using namespace testing::ext;
31 } // namespace
32 
33 class InputMonitorManagerTest : public testing::Test {
34 public:
SetUpTestCase(void)35     static void SetUpTestCase(void) {}
TearDownTestCase(void)36     static void TearDownTestCase(void) {}
37 };
38 
39 /**
40  * @tc.name: MarkConsumed_Test_001
41  * @tc.desc: Test MarkConsumed
42  * @tc.type: FUNC
43  * @tc.require:
44  */
45 HWTEST_F(InputMonitorManagerTest, MarkConsumed_Test_001, TestSize.Level1)
46 {
47     CALL_TEST_DEBUG;
48     int32_t monitorId = 1;
49     int32_t eventId = 2;
50     ASSERT_NO_FATAL_FAILURE(IMonitorMgr.MarkConsumed(monitorId, eventId));
51 }
52 
53 /**
54  * @tc.name: CheckMonitorValid_ShouldReturnTrue_001
55  * @tc.desc: Test CheckMonitorValid
56  * @tc.type: FUNC
57  * @tc.require:
58  */
59 HWTEST_F(InputMonitorManagerTest, CheckMonitorValid_ShouldReturnTrue_001, TestSize.Level1)
60 {
61     CALL_TEST_DEBUG;
62     EXPECT_TRUE(IMonitorMgr.CheckMonitorValid(TOUCH_GESTURE_TYPE_SWIPE, ALL_FINGER_COUNT));
63 }
64 
65 /**
66  * @tc.name: CheckMonitorValid_ShouldReturnTrue_002
67  * @tc.desc: Test CheckMonitorValid
68  * @tc.type: FUNC
69  * @tc.require:
70  */
71 HWTEST_F(InputMonitorManagerTest, CheckMonitorValid_ShouldReturnTrue_002, TestSize.Level1)
72 {
73     CALL_TEST_DEBUG;
74     EXPECT_FALSE(IMonitorMgr.CheckMonitorValid(TOUCH_GESTURE_TYPE_SWIPE, INVALID_HANDLER_ID));
75 }
76 
77  /**
78  * @tc.name: CheckMonitorValid_ShouldReturnTrue_003
79  * @tc.desc: Test CheckMonitorValid
80  * @tc.type: FUNC
81  * @tc.require:
82  */
83 HWTEST_F(InputMonitorManagerTest, CheckMonitorValid_ShouldReturnTrue_003, TestSize.Level1)
84 {
85     CALL_TEST_DEBUG;
86     EXPECT_TRUE(IMonitorMgr.CheckMonitorValid(TOUCH_GESTURE_TYPE_PINCH, MAX_FINGERS_COUNT));
87 }
88 
89  /**
90  * @tc.name: CheckMonitorValid_ShouldReturnTrue_004
91  * @tc.desc: Test CheckMonitorValid
92  * @tc.type: FUNC
93  * @tc.require:
94  */
95 
96 HWTEST_F(InputMonitorManagerTest, CheckMonitorValid_ShouldReturnTrue_004, TestSize.Level1)
97 {
98     CALL_TEST_DEBUG;
99     EXPECT_FALSE(IMonitorMgr.CheckMonitorValid(TOUCH_GESTURE_TYPE_SWIPE, ERROR_EXCEED_MAX_COUNT));
100 }
101 
102  /**
103  * @tc.name: CheckMonitorValid_ShouldReturnTrue_005
104  * @tc.desc: Test CheckMonitorValid
105  * @tc.type: FUNC
106  * @tc.require:
107  */
108 
109 HWTEST_F(InputMonitorManagerTest, CheckMonitorValid_ShouldReturnTrue_005, TestSize.Level1)
110 {
111     CALL_TEST_DEBUG;
112     EXPECT_FALSE(IMonitorMgr.CheckMonitorValid(TOUCH_GESTURE_TYPE_NONE, FOUR_FINGER_COUNT));
113 }
114 
115 } // namespace MMI
116 } // namespace OHOS