Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / events / ozone / evdev / event_device_info_unittest.cc
blob7cad86b21c2eeafc2c5ccb8a995896a4208e5ce9
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/format_macros.h"
6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/events/ozone/evdev/event_device_info.h"
12 #include "ui/events/ozone/evdev/event_device_test_util.h"
13 #include "ui/events/ozone/evdev/event_device_util.h"
15 namespace ui {
17 class EventDeviceInfoTest : public testing::Test {
18 public:
19 EventDeviceInfoTest();
21 private:
22 DISALLOW_COPY_AND_ASSIGN(EventDeviceInfoTest);
25 EventDeviceInfoTest::EventDeviceInfoTest() {
28 TEST_F(EventDeviceInfoTest, BasicCrosKeyboard) {
29 EventDeviceInfo devinfo;
30 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkKeyboard, &devinfo));
32 EXPECT_TRUE(devinfo.HasKeyboard());
33 EXPECT_FALSE(devinfo.HasMouse());
34 EXPECT_FALSE(devinfo.HasTouchpad());
35 EXPECT_FALSE(devinfo.HasTouchscreen());
36 EXPECT_FALSE(devinfo.HasTablet());
39 TEST_F(EventDeviceInfoTest, BasicCrosTouchscreen) {
40 EventDeviceInfo devinfo;
41 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen, &devinfo));
43 EXPECT_FALSE(devinfo.HasKeyboard());
44 EXPECT_FALSE(devinfo.HasMouse());
45 EXPECT_FALSE(devinfo.HasTouchpad());
46 EXPECT_TRUE(devinfo.HasTouchscreen());
47 EXPECT_FALSE(devinfo.HasTablet());
50 TEST_F(EventDeviceInfoTest, BasicCrosTouchpad) {
51 EventDeviceInfo devinfo;
52 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchpad, &devinfo));
54 EXPECT_FALSE(devinfo.HasKeyboard());
55 EXPECT_FALSE(devinfo.HasMouse());
56 EXPECT_TRUE(devinfo.HasTouchpad());
57 EXPECT_FALSE(devinfo.HasTouchscreen());
58 EXPECT_FALSE(devinfo.HasTablet());
61 TEST_F(EventDeviceInfoTest, BasicUsbKeyboard) {
62 EventDeviceInfo devinfo;
63 EXPECT_TRUE(CapabilitiesToDeviceInfo(kHpUsbKeyboard, &devinfo));
65 EXPECT_TRUE(devinfo.HasKeyboard());
66 EXPECT_FALSE(devinfo.HasMouse());
67 EXPECT_FALSE(devinfo.HasTouchpad());
68 EXPECT_FALSE(devinfo.HasTouchscreen());
69 EXPECT_FALSE(devinfo.HasTablet());
72 TEST_F(EventDeviceInfoTest, BasicUsbKeyboard_Extra) {
73 EventDeviceInfo devinfo;
74 EXPECT_TRUE(CapabilitiesToDeviceInfo(kHpUsbKeyboard_Extra, &devinfo));
76 EXPECT_FALSE(devinfo.HasKeyboard()); // Has keys, but not a full keyboard.
77 EXPECT_FALSE(devinfo.HasMouse());
78 EXPECT_FALSE(devinfo.HasTouchpad());
79 EXPECT_FALSE(devinfo.HasTouchscreen());
80 EXPECT_FALSE(devinfo.HasTablet());
83 TEST_F(EventDeviceInfoTest, BasicUsbMouse) {
84 EventDeviceInfo devinfo;
85 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLogitechUsbMouse, &devinfo));
87 EXPECT_FALSE(devinfo.HasKeyboard());
88 EXPECT_TRUE(devinfo.HasMouse());
89 EXPECT_FALSE(devinfo.HasTouchpad());
90 EXPECT_FALSE(devinfo.HasTouchscreen());
91 EXPECT_FALSE(devinfo.HasTablet());
94 TEST_F(EventDeviceInfoTest, BasicUsbTouchscreen) {
95 EventDeviceInfo devinfo;
96 EXPECT_TRUE(CapabilitiesToDeviceInfo(kMimoTouch2Touchscreen, &devinfo));
98 EXPECT_FALSE(devinfo.HasKeyboard());
99 EXPECT_FALSE(devinfo.HasMouse());
100 EXPECT_FALSE(devinfo.HasTouchpad());
101 EXPECT_TRUE(devinfo.HasTouchscreen());
102 EXPECT_FALSE(devinfo.HasTablet());
105 TEST_F(EventDeviceInfoTest, BasicUsbTablet) {
106 EventDeviceInfo devinfo;
107 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWacomIntuosPtS_Pen, &devinfo));
109 EXPECT_FALSE(devinfo.HasKeyboard());
110 EXPECT_FALSE(devinfo.HasMouse());
111 EXPECT_FALSE(devinfo.HasTouchpad());
112 EXPECT_FALSE(devinfo.HasTouchscreen());
113 EXPECT_TRUE(devinfo.HasTablet());
116 TEST_F(EventDeviceInfoTest, BasicUsbTouchpad) {
117 EventDeviceInfo devinfo;
118 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWacomIntuosPtS_Finger, &devinfo));
120 EXPECT_FALSE(devinfo.HasKeyboard());
121 EXPECT_FALSE(devinfo.HasMouse());
122 EXPECT_TRUE(devinfo.HasTouchpad());
123 EXPECT_FALSE(devinfo.HasTouchscreen());
124 EXPECT_FALSE(devinfo.HasTablet());
127 TEST_F(EventDeviceInfoTest, HybridKeyboardWithMouse) {
128 EventDeviceInfo devinfo;
129 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLogitechTouchKeyboardK400, &devinfo));
131 // The touchpad actually exposes mouse (relative) Events.
132 EXPECT_TRUE(devinfo.HasKeyboard());
133 EXPECT_TRUE(devinfo.HasMouse());
134 EXPECT_FALSE(devinfo.HasTouchpad());
135 EXPECT_FALSE(devinfo.HasTouchscreen());
136 EXPECT_FALSE(devinfo.HasTablet());
139 TEST_F(EventDeviceInfoTest, AbsoluteMouseTouchscreen) {
140 EventDeviceInfo devinfo;
141 EXPECT_TRUE(CapabilitiesToDeviceInfo(kElo_TouchSystems_2700, &devinfo));
143 // This touchscreen uses BTN_LEFT for touch contact.
144 EXPECT_FALSE(devinfo.HasKeyboard());
145 EXPECT_FALSE(devinfo.HasMouse());
146 EXPECT_FALSE(devinfo.HasTouchpad());
147 EXPECT_TRUE(devinfo.HasTouchscreen());
148 EXPECT_FALSE(devinfo.HasTablet());
151 TEST_F(EventDeviceInfoTest, OnScreenStylus) {
152 EventDeviceInfo devinfo;
153 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus, &devinfo));
155 EXPECT_FALSE(devinfo.HasKeyboard());
156 EXPECT_FALSE(devinfo.HasMouse());
157 EXPECT_FALSE(devinfo.HasTouchpad());
158 EXPECT_TRUE(devinfo.HasTouchscreen());
159 EXPECT_FALSE(devinfo.HasTablet());
162 } // namespace ui