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

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

Issue 1073573002: Ozone support for device special cases in keyboard event rewriting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: white space Created 5 years, 8 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
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 <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
9 #include "ash/touch/touchscreen_util.h" 9 #include "ash/touch/touchscreen_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 std::vector<ui::TouchscreenDevice> devices; 69 std::vector<ui::TouchscreenDevice> devices;
70 AssociateTouchscreens(&displays_, devices); 70 AssociateTouchscreens(&displays_, devices);
71 71
72 for (size_t i = 0; i < displays_.size(); ++i) 72 for (size_t i = 0; i < displays_.size(); ++i)
73 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, 73 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId,
74 displays_[i].touch_device_id()); 74 displays_[i].touch_device_id());
75 } 75 }
76 76
77 TEST_F(TouchscreenUtilTest, OneToOneMapping) { 77 TEST_F(TouchscreenUtilTest, OneToOneMapping) {
78 std::vector<ui::TouchscreenDevice> devices; 78 std::vector<ui::TouchscreenDevice> devices;
79 devices.push_back(ui::TouchscreenDevice( 79 devices.push_back(
80 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(800, 600), 0)); 80 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
81 devices.push_back(ui::TouchscreenDevice( 81 gfx::Size(800, 600), 0));
82 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); 82 devices.push_back(
83 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
84 gfx::Size(1024, 768), 0));
83 85
84 AssociateTouchscreens(&displays_, devices); 86 AssociateTouchscreens(&displays_, devices);
85 87
86 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
87 EXPECT_EQ(1u, displays_[1].touch_device_id()); 89 EXPECT_EQ(1u, displays_[1].touch_device_id());
88 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 90 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
89 EXPECT_EQ(2u, displays_[3].touch_device_id()); 91 EXPECT_EQ(2u, displays_[3].touch_device_id());
90 } 92 }
91 93
92 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) { 94 TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) {
93 std::vector<ui::TouchscreenDevice> devices; 95 std::vector<ui::TouchscreenDevice> devices;
94 devices.push_back(ui::TouchscreenDevice( 96 devices.push_back(
95 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768), 0)); 97 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
98 gfx::Size(1024, 768), 0));
96 99
97 AssociateTouchscreens(&displays_, devices); 100 AssociateTouchscreens(&displays_, devices);
98 101
99 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 102 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
100 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id()); 103 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id());
101 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 104 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
102 EXPECT_EQ(2u, displays_[3].touch_device_id()); 105 EXPECT_EQ(2u, displays_[3].touch_device_id());
103 } 106 }
104 107
105 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) { 108 TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) {
106 std::vector<ui::TouchscreenDevice> devices; 109 std::vector<ui::TouchscreenDevice> devices;
107 devices.push_back(ui::TouchscreenDevice( 110 devices.push_back(
108 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(801, 600), 0)); 111 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
109 devices.push_back(ui::TouchscreenDevice( 112 gfx::Size(801, 600), 0));
110 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1023, 768), 0)); 113 devices.push_back(
114 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
115 gfx::Size(1023, 768), 0));
111 116
112 AssociateTouchscreens(&displays_, devices); 117 AssociateTouchscreens(&displays_, devices);
113 118
114 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 119 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
115 EXPECT_EQ(1u, displays_[1].touch_device_id()); 120 EXPECT_EQ(1u, displays_[1].touch_device_id());
116 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 121 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
117 EXPECT_EQ(2u, displays_[3].touch_device_id()); 122 EXPECT_EQ(2u, displays_[3].touch_device_id());
118 } 123 }
119 124
120 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) { 125 TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) {
121 std::vector<ui::TouchscreenDevice> devices; 126 std::vector<ui::TouchscreenDevice> devices;
122 devices.push_back(ui::TouchscreenDevice( 127 devices.push_back(
123 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1022, 768), 0)); 128 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
124 devices.push_back(ui::TouchscreenDevice( 129 gfx::Size(1022, 768), 0));
125 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(802, 600), 0)); 130 devices.push_back(
131 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
132 gfx::Size(802, 600), 0));
126 133
127 AssociateTouchscreens(&displays_, devices); 134 AssociateTouchscreens(&displays_, devices);
128 135
129 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id()); 136 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
130 EXPECT_EQ(1u, displays_[1].touch_device_id()); 137 EXPECT_EQ(1u, displays_[1].touch_device_id());
131 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 138 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
132 EXPECT_EQ(2u, displays_[3].touch_device_id()); 139 EXPECT_EQ(2u, displays_[3].touch_device_id());
133 } 140 }
134 141
135 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) { 142 TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) {
136 std::vector<ui::TouchscreenDevice> devices; 143 std::vector<ui::TouchscreenDevice> devices;
137 devices.push_back(ui::TouchscreenDevice( 144 devices.push_back(
138 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080), 0)); 145 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "",
139 devices.push_back(ui::TouchscreenDevice( 146 gfx::Size(1920, 1080), 0));
140 2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(9999, 888), 0)); 147 devices.push_back(
148 ui::TouchscreenDevice(2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "",
149 gfx::Size(9999, 888), 0));
141 150
142 AssociateTouchscreens(&displays_, devices); 151 AssociateTouchscreens(&displays_, devices);
143 152
144 // Internal touchscreen is always mapped to internal display. 153 // Internal touchscreen is always mapped to internal display.
145 EXPECT_EQ(2u, displays_[0].touch_device_id()); 154 EXPECT_EQ(2u, displays_[0].touch_device_id());
146 EXPECT_EQ(1u, displays_[1].touch_device_id()); 155 EXPECT_EQ(1u, displays_[1].touch_device_id());
147 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); 156 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
148 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); 157 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id());
149 } 158 }
150 159
151 } // namespace ash 160 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698