Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: ash/touch/touchscreen_util_unittest.cc

Issue 618283003: Adds special support to the device manager for keyboards devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to master. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/touch/touchscreen_util.cc ('k') | ui/events/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string>
5 #include <vector> 6 #include <vector>
6 7
7 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
8 #include "ash/touch/touchscreen_util.h" 9 #include "ash/touch/touchscreen_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/events/input_device.h"
10 12
11 namespace ash { 13 namespace ash {
12 14
13 class TouchscreenUtilTest : public testing::Test { 15 class TouchscreenUtilTest : public testing::Test {
14 public: 16 public:
15 TouchscreenUtilTest() {} 17 TouchscreenUtilTest() {}
16 virtual ~TouchscreenUtilTest() {} 18 virtual ~TouchscreenUtilTest() {}
17 19
18 virtual void SetUp() override { 20 virtual void SetUp() override {
19 // Internal display will always match to internal touchscreen. If internal 21 // Internal display will always match to internal touchscreen. If internal
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 std::vector<ui::TouchscreenDevice> devices; 71 std::vector<ui::TouchscreenDevice> devices;
70 AssociateTouchscreens(&displays_, devices); 72 AssociateTouchscreens(&displays_, devices);
71 73
72 for (size_t i = 0; i < displays_.size(); ++i) 74 for (size_t i = 0; i < displays_.size(); ++i)
73 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, 75 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId,
74 displays_[i].touch_device_id()); 76 displays_[i].touch_device_id());
75 } 77 }
76 78
77 TEST_F(TouchscreenUtilTest, OneToOneMapping) { 79 TEST_F(TouchscreenUtilTest, OneToOneMapping) {
78 std::vector<ui::TouchscreenDevice> devices; 80 std::vector<ui::TouchscreenDevice> devices;
79 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(800, 600), false)); 81 devices.push_back(ui::TouchscreenDevice(
80 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(1024, 768), false)); 82 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(800, 600)));
83 devices.push_back(ui::TouchscreenDevice(
84 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1024, 768)));
81 85
82 AssociateTouchscreens(&displays_, devices); 86 AssociateTouchscreens(&displays_, devices);
83 87
84 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
85 EXPECT_EQ(1, displays_[1].touch_device_id()); 89 EXPECT_EQ(1u, displays_[1].touch_device_id());
86 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 90 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
87 EXPECT_EQ(2, displays_[3].touch_device_id()); 91 EXPECT_EQ(2u, displays_[3].touch_device_id());
88 } 92 }
89 93
90 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { 94 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) {
91 std::vector<ui::TouchscreenDevice> devices; 95 std::vector<ui::TouchscreenDevice> devices;
92 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(1024, 768), false)); 96 devices.push_back(ui::TouchscreenDevice(
97 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1024, 768)));
93 98
94 AssociateTouchscreens(&displays_, devices); 99 AssociateTouchscreens(&displays_, devices);
95 100
96 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 101 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
97 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); 102 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id());
98 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 103 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
99 EXPECT_EQ(2, displays_[3].touch_device_id()); 104 EXPECT_EQ(2u, displays_[3].touch_device_id());
100 } 105 }
101 106
102 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { 107 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) {
103 std::vector<ui::TouchscreenDevice> devices; 108 std::vector<ui::TouchscreenDevice> devices;
104 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(801, 600), false)); 109 devices.push_back(ui::TouchscreenDevice(
105 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(1023, 768), false)); 110 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(801, 600)));
111 devices.push_back(ui::TouchscreenDevice(
112 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1023, 768)));
106 113
107 AssociateTouchscreens(&displays_, devices); 114 AssociateTouchscreens(&displays_, devices);
108 115
109 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 116 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
110 EXPECT_EQ(1, displays_[1].touch_device_id()); 117 EXPECT_EQ(1u, displays_[1].touch_device_id());
111 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 118 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
112 EXPECT_EQ(2, displays_[3].touch_device_id()); 119 EXPECT_EQ(2u, displays_[3].touch_device_id());
113 } 120 }
114 121
115 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { 122 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) {
116 std::vector<ui::TouchscreenDevice> devices; 123 std::vector<ui::TouchscreenDevice> devices;
117 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(1022, 768), false)); 124 devices.push_back(ui::TouchscreenDevice(
118 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(802, 600), false)); 125 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(1022, 768)));
126 devices.push_back(ui::TouchscreenDevice(
127 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "", gfx::Size(802, 600)));
119 128
120 AssociateTouchscreens(&displays_, devices); 129 AssociateTouchscreens(&displays_, devices);
121 130
122 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 131 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
123 EXPECT_EQ(1, displays_[1].touch_device_id()); 132 EXPECT_EQ(1u, displays_[1].touch_device_id());
124 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 133 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
125 EXPECT_EQ(2, displays_[3].touch_device_id()); 134 EXPECT_EQ(2u, displays_[3].touch_device_id());
126 } 135 }
127 136
128 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { 137 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) {
129 std::vector<ui::TouchscreenDevice> devices; 138 std::vector<ui::TouchscreenDevice> devices;
130 devices.push_back(ui::TouchscreenDevice(1, gfx::Size(1920, 1080), false)); 139 devices.push_back(
131 devices.push_back(ui::TouchscreenDevice(2, gfx::Size(9999, 888), true)); 140 ui::TouchscreenDevice(1,
141 ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
142 "",
143 gfx::Size(1920, 1080)));
144 devices.push_back(ui::TouchscreenDevice(
145 2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "", gfx::Size(9999, 888)));
132 146
133 AssociateTouchscreens(&displays_, devices); 147 AssociateTouchscreens(&displays_, devices);
134 148
135 // Internal touchscreen is always mapped to internal display. 149 // Internal touchscreen is always mapped to internal display.
136 EXPECT_EQ(2, displays_[0].touch_device_id()); 150 EXPECT_EQ(2u, displays_[0].touch_device_id());
137 EXPECT_EQ(1, displays_[1].touch_device_id()); 151 EXPECT_EQ(1u, displays_[1].touch_device_id());
138 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 152 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
139 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); 153 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id());
140 } 154 }
141 155
142 } // namespace ash 156 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touchscreen_util.cc ('k') | ui/events/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698