• 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 #include "pointers_input_device.h"
18 #include <unistd.h>
19 #include "log/log.h"
20 #include "common/input_device_manager.h"
21 #include "ui_rotation.h"
22 
23 using namespace testing::ext;
24 using namespace Updater;
25 
26 namespace UpdaterUt {
27 class PointersInputDeviceUnitTest : public testing::Test {
28 public:
SetUpTestCase(void)29     static void SetUpTestCase(void) {}
TearDownTestCase(void)30     static void TearDownTestCase(void) {}
SetUp()31     void SetUp() override {}
TearDown()32     void TearDown() override {}
33 };
34 
35 HWTEST_F(PointersInputDeviceUnitTest, test_pointers_input_read, TestSize.Level0)
36 {
37     OHOS::DeviceData data;
38     EXPECT_FALSE(PointersInputDevice::GetInstance().Read(data));
39 }
40 
41 HWTEST_F(PointersInputDeviceUnitTest, test_handle_point_event, TestSize.Level0)
42 {
43     uint32_t type = 0;
44     input_event ev = {.type = EV_ABS, .code = ABS_MT_POSITION_X};
45     HandlePointersEvent(ev, type);
46     ev.code = ABS_MT_POSITION_Y;
47     EXPECT_EQ(PointersInputDevice::GetInstance().HandlePointEvent(ev, type), 0);
48     ev.code = ABS_MT_TRACKING_ID;
49     EXPECT_EQ(PointersInputDevice::GetInstance().HandlePointEvent(ev, type), 0);
50     ev.code = BTN_TOUCH;
51     ev.type = EV_KEY;
52     EXPECT_EQ(PointersInputDevice::GetInstance().HandlePointEvent(ev, type), 0);
53 }
54 }