• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "manage_inject_device.h"
18 #include "msg_head.h"
19 #include "processing_keyboard_device.h"
20 #include "proto.h"
21 
22 namespace {
23     using namespace testing::ext;
24     using namespace OHOS::MMI;
25     using namespace std;
26 class ProcessingPadDeviceTest : public testing::Test {
27 public:
SetUpTestCase(void)28     static void SetUpTestCase(void) {}
TearDownTestCase(void)29     static void TearDownTestCase(void) {}
30 };
31 
32 HWTEST_F(ProcessingPadDeviceTest, Test_TransformJsonDataToInputData, TestSize.Level1)
33 {
34     const string path = "/data/json/Test_TransformPadJsonDataToInputData.json";
35     string startDeviceCmd = "mmi-virtual-device-manager start touchpad & ";
36     string closeDeviceCmd = "mmi-virtual-device-manager close all";
37     system(startDeviceCmd.c_str());
38     std::this_thread::sleep_for(std::chrono::seconds(1));
39     std::ifstream reader(path);
40     if (!reader.is_open()) {
41         std::this_thread::sleep_for(std::chrono::seconds(1));
42         system(closeDeviceCmd.c_str());
43         ASSERT_TRUE(false) << "can not open " << path;
44     }
45     Json inputEventArrays;
46     reader >> inputEventArrays;
47     reader.close();
48     ManageInjectDevice manageInjectDevice;
49     auto ret = manageInjectDevice.TransformJsonData(inputEventArrays);
50     system(startDeviceCmd.c_str());
51     std::this_thread::sleep_for(std::chrono::seconds(1));
52     EXPECT_EQ(ret, RET_OK);
53 }
54 } // namespace