1 /* 2 * Copyright (c) 2021 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 "input_manager.h" 18 #include "input_manager_command.h" 19 20 namespace { 21 using namespace testing::ext; 22 using namespace OHOS::MMI; 23 using namespace std; 24 class InjectEventTest : public testing::Test { 25 public: SetUpTestCase(void)26 static void SetUpTestCase(void) {} TearDownTestCase(void)27 static void TearDownTestCase(void) {} 28 }; 29 30 /** 31 * @tc.name:InjectEvent_InjectMouse_001 32 * @tc.desc: test inject mouse move interface 33 * @tc.type: FUNC 34 * @tc.require: AR000GJN3F 35 */ 36 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_001, TestSize.Level1) 37 { 38 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 39 char command1[] = {"input"}; 40 char command2[] = {"-M"}; 41 char command3[] = {"-m"}; 42 char command4[] = {"10"}; 43 char command5[] = {"12"}; 44 char *argv[] = {command1, command2, command3, command4, command5}; 45 int32_t result = inputManagerCommand->ParseCommand(5, argv); 46 EXPECT_EQ(OHOS::ERR_OK, result); 47 } 48 49 /** 50 * @tc.name:InjectEvent_InjectMouse_002 51 * @tc.desc: test inject mouse down interface 52 * @tc.type: FUNC 53 * @tc.require: SR000GGQBJ 54 */ 55 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_002, TestSize.Level1) 56 { 57 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 58 char command1[] = {"input"}; 59 char command2[] = {"-M"}; 60 char command3[] = {"-d"}; 61 char command4[] = {"1"}; 62 char *argv[] = {command1, command2, command3, command4}; 63 int32_t result = inputManagerCommand->ParseCommand(4, argv); 64 EXPECT_EQ(OHOS::ERR_OK, result); 65 } 66 67 /** 68 * @tc.name:InjectEvent_InjectMouse_003 69 * @tc.desc: test inject mouse scroll interface 70 * @tc.type: FUNC 71 * @tc.require: SR000GGQBJ 72 */ 73 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_003, TestSize.Level1) 74 { 75 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 76 char command1[] = {"input"}; 77 char command2[] = {"-M"}; 78 char command3[] = {"-s"}; 79 char command4[] = {"50"}; 80 char *argv[] = {command1, command2, command3, command4}; 81 int32_t result = inputManagerCommand->ParseCommand(4, argv); 82 EXPECT_EQ(OHOS::ERR_OK, result); 83 } 84 85 /** 86 * @tc.name:InjectEvent_InjectMouse_004 87 * @tc.desc: test inject mouse click interface 88 * @tc.type: FUNC 89 * @tc.require: SR000GGQBJ 90 */ 91 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_004, TestSize.Level1) 92 { 93 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 94 char command1[] = {"input"}; 95 char command2[] = {"-M"}; 96 char command3[] = {"-c"}; 97 char command4[] = {"1"}; 98 char *argv[] = {command1, command2, command3, command4}; 99 int32_t result = inputManagerCommand->ParseCommand(4, argv); 100 EXPECT_EQ(OHOS::ERR_OK, result); 101 } 102 103 /** 104 * @tc.name:InjectEvent_InjectMouse_005 105 * @tc.desc: test inject mouse up interface 106 * @tc.type: FUNC 107 * @tc.require: SR000GGQBJ 108 */ 109 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_005, TestSize.Level1) 110 { 111 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 112 char command1[] = {"input"}; 113 char command2[] = {"-M"}; 114 char command3[] = {"-u"}; 115 char command4[] = {"1"}; 116 char *argv[] = {command1, command2, command3, command4}; 117 int32_t result = inputManagerCommand->ParseCommand(4, argv); 118 EXPECT_EQ(OHOS::ERR_OK, result); 119 } 120 121 /** 122 * @tc.name:InjectEvent_InjectKey_001 123 * @tc.desc: test inject key down interface 124 * @tc.type: FUNC 125 * @tc.require: SR000GGQBJ 126 */ 127 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_001, TestSize.Level1) 128 { 129 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 130 char command1[] = {"input"}; 131 char command2[] = {"-K"}; 132 char command3[] = {"-d"}; 133 char command4[] = {"1"}; 134 char *argv[] = {command1, command2, command3, command4}; 135 int32_t result = inputManagerCommand->ParseCommand(4, argv); 136 EXPECT_EQ(OHOS::ERR_OK, result); 137 } 138 139 /** 140 * @tc.name:InjectEvent_InjectKey_002 141 * @tc.desc: test inject key down interface 142 * @tc.type: FUNC 143 * @tc.require: SR000GGQBJ 144 */ 145 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_002, TestSize.Level1) 146 { 147 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 148 char command1[] = {"input"}; 149 char command2[] = {"-K"}; 150 char command3[] = {"-d"}; 151 char command4[] = {"1"}; 152 char command5[] = {"-d"}; 153 char command6[] = {"2"}; 154 char *argv[] = {command1, command2, command3, command4, command5, command6}; 155 int32_t result = inputManagerCommand->ParseCommand(6, argv); 156 EXPECT_EQ(OHOS::ERR_OK, result); 157 } 158 159 /** 160 * @tc.name:InjectEvent_InjectKey_003 161 * @tc.desc: test inject key up interface 162 * @tc.type: FUNC 163 * @tc.require: SR000GGQBJ 164 */ 165 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_003, TestSize.Level1) 166 { 167 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 168 char command1[] = {"input"}; 169 char command2[] = {"-K"}; 170 char command3[] = {"-d"}; 171 char command4[] = {"1"}; 172 char command5[] = {"-u"}; 173 char command6[] = {"1"}; 174 char *argv[] = {command1, command2, command3, command4, command5, command6}; 175 int32_t result = inputManagerCommand->ParseCommand(6, argv); 176 EXPECT_EQ(OHOS::ERR_OK, result); 177 } 178 179 /** 180 * @tc.name:InjectEvent_InjectTouch_001 181 * @tc.desc: test inject touch move interface 182 * @tc.type: FUNC 183 * @tc.require: SR000GGQBJ 184 */ 185 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_001, TestSize.Level1) 186 { 187 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 188 char command1[] = {"input"}; 189 char command2[] = {"-T"}; 190 char command3[] = {"-m"}; 191 char command4[] = {"10"}; 192 char command5[] = {"12"}; 193 char command6[] = {"13"}; 194 char command7[] = {"14"}; 195 char *argv[] = {command1, command2, command3, command4, command5, command6, command7}; 196 int32_t result = inputManagerCommand->ParseCommand(7, argv); 197 EXPECT_EQ(OHOS::ERR_OK, result); 198 } 199 200 /** 201 * @tc.name:InjectEvent_InjectTouch_002 202 * @tc.desc: test inject touch down interface 203 * @tc.type: FUNC 204 * @tc.require: SR000GGQBJ 205 */ 206 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_002, TestSize.Level1) 207 { 208 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 209 char command1[] = {"input"}; 210 char command2[] = {"-T"}; 211 char command3[] = {"-m"}; 212 char command4[] = {"10"}; 213 char command5[] = {"12"}; 214 char *argv[] = {command1, command2, command3, command4, command5}; 215 int32_t result = inputManagerCommand->ParseCommand(5, argv); 216 EXPECT_EQ(OHOS::ERR_OK, result); 217 } 218 219 /** 220 * @tc.name:InjectEvent_InjectTouch_003 221 * @tc.desc: test inject touch up interface 222 * @tc.type: FUNC 223 * @tc.require: SR000GGQBJ 224 */ 225 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_003, TestSize.Level1) 226 { 227 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>(); 228 char command1[] = {"input"}; 229 char command2[] = {"-T"}; 230 char command3[] = {"-u"}; 231 char command4[] = {"10"}; 232 char command5[] = {"12"}; 233 char *argv[] = {command1, command2, command3, command4, command5}; 234 int32_t result = inputManagerCommand->ParseCommand(5, argv); 235 EXPECT_EQ(OHOS::ERR_OK, result); 236 } 237 }