OLD | NEW |
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 "ash/touch/touch_transformer_controller.h" | 5 #include "ui/display/manager/chromeos/touch_transform_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include <memory> |
8 #include "ash/test/ash_test_base.h" | 8 #include <string> |
9 #include "base/rand_util.h" | 9 #include <utility> |
| 10 |
| 11 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
11 #include "ui/aura/window_tree_host.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/display/manager/display_manager.h" |
| 15 #include "ui/display/screen_base.h" |
12 #include "ui/events/devices/device_data_manager.h" | 16 #include "ui/events/devices/device_data_manager.h" |
13 | 17 |
14 namespace ash { | 18 namespace display { |
15 | 19 namespace test { |
16 namespace { | 20 namespace { |
17 | 21 |
18 constexpr int kDisplayId1 = 1; | 22 constexpr int kDisplayId1 = 1; |
19 constexpr int kTouchId1 = 5; | 23 constexpr int kTouchId1 = 5; |
20 | 24 |
21 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, | 25 ManagedDisplayInfo CreateDisplayInfo(int64_t id, |
22 unsigned int touch_device_id, | 26 unsigned int touch_device_id, |
23 const gfx::Rect& bounds) { | 27 const gfx::Rect& bounds) { |
24 display::ManagedDisplayInfo info(id, std::string(), false); | 28 ManagedDisplayInfo info(id, std::string(), false); |
25 info.SetBounds(bounds); | 29 info.SetBounds(bounds); |
26 info.AddInputDevice(touch_device_id); | 30 info.AddInputDevice(touch_device_id); |
27 | 31 |
28 // Create a default mode. | 32 // Create a default mode. |
29 display::ManagedDisplayInfo::ManagedDisplayModeList default_modes( | 33 ManagedDisplayInfo::ManagedDisplayModeList default_modes( |
30 1, make_scoped_refptr( | 34 1, make_scoped_refptr( |
31 new display::ManagedDisplayMode(bounds.size(), 60, false, true))); | 35 new ManagedDisplayMode(bounds.size(), 60, false, true))); |
32 info.SetManagedDisplayModes(default_modes); | 36 info.SetManagedDisplayModes(default_modes); |
33 | 37 |
34 return info; | 38 return info; |
35 } | 39 } |
36 | 40 |
37 ui::TouchscreenDevice CreateTouchscreenDevice(unsigned int id, | 41 ui::TouchscreenDevice CreateTouchscreenDevice(unsigned int id, |
38 const gfx::Size& size) { | 42 const gfx::Size& size) { |
39 return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, | 43 return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, |
40 std::string(), size, 0); | 44 std::string(), size, 0); |
41 } | 45 } |
42 | 46 |
43 std::string GetTouchPointString( | 47 std::string GetTouchPointString( |
44 const display::TouchCalibrationData::CalibrationPointPairQuad& pts) { | 48 const TouchCalibrationData::CalibrationPointPairQuad& pts) { |
45 std::string str = "Failed for point pairs: "; | 49 std::string str = "Failed for point pairs: "; |
46 for (std::size_t row = 0; row < pts.size(); row++) { | 50 for (std::size_t row = 0; row < pts.size(); row++) { |
47 str += "{(" + base::IntToString(pts[row].first.x()) + "," + | 51 str += "{(" + base::IntToString(pts[row].first.x()) + "," + |
48 base::IntToString(pts[row].first.y()) + "), (" + | 52 base::IntToString(pts[row].first.y()) + "), (" + |
49 base::IntToString(pts[row].second.x()) + "," + | 53 base::IntToString(pts[row].second.x()) + "," + |
50 base::IntToString(pts[row].second.y()) + ")} "; | 54 base::IntToString(pts[row].second.y()) + ")} "; |
51 } | 55 } |
52 return str; | 56 return str; |
53 } | 57 } |
54 | 58 |
(...skipping 29 matching lines...) Expand all Loading... |
84 // corner of display device. | 88 // corner of display device. |
85 x = touch_size.width(); | 89 x = touch_size.width(); |
86 y = touch_size.height(); | 90 y = touch_size.height(); |
87 device_manager->ApplyTouchTransformer(touch_id, &x, &y); | 91 device_manager->ApplyTouchTransformer(touch_id, &x, &y); |
88 EXPECT_NEAR(display_size.width(), x, max_error_delta.width()) << error_msg; | 92 EXPECT_NEAR(display_size.width(), x, max_error_delta.width()) << error_msg; |
89 EXPECT_NEAR(display_size.height(), y, max_error_delta.height()) << error_msg; | 93 EXPECT_NEAR(display_size.height(), y, max_error_delta.height()) << error_msg; |
90 } | 94 } |
91 | 95 |
92 } // namespace | 96 } // namespace |
93 | 97 |
94 class TouchTransformerControllerTest : public test::AshTestBase { | 98 class TouchTransformControllerTest : public testing::Test { |
95 public: | 99 public: |
96 TouchTransformerControllerTest() {} | 100 TouchTransformControllerTest() {} |
97 ~TouchTransformerControllerTest() override {} | 101 ~TouchTransformControllerTest() override {} |
98 | 102 |
99 gfx::Transform GetTouchTransform( | 103 gfx::Transform GetTouchTransform(const ManagedDisplayInfo& display, |
100 const display::ManagedDisplayInfo& display, | 104 const ManagedDisplayInfo& touch_display, |
101 const display::ManagedDisplayInfo& touch_display, | 105 const ui::TouchscreenDevice& touchscreen, |
102 const ui::TouchscreenDevice& touchscreen, | 106 const gfx::Size& framebuffer_size) const { |
103 const gfx::Size& framebuffer_size) const { | 107 return touch_transform_controller_->GetTouchTransform( |
104 return Shell::GetInstance() | 108 display, touch_display, touchscreen, framebuffer_size); |
105 ->touch_transformer_controller() | |
106 ->GetTouchTransform(display, touch_display, touchscreen, | |
107 framebuffer_size); | |
108 } | 109 } |
109 | 110 |
110 double GetTouchResolutionScale( | 111 double GetTouchResolutionScale( |
111 const display::ManagedDisplayInfo& touch_display, | 112 const ManagedDisplayInfo& touch_display, |
112 const ui::TouchscreenDevice& touch_device) const { | 113 const ui::TouchscreenDevice& touch_device) const { |
113 return Shell::GetInstance() | 114 return touch_transform_controller_->GetTouchResolutionScale(touch_display, |
114 ->touch_transformer_controller() | 115 touch_device); |
115 ->GetTouchResolutionScale(touch_display, touch_device); | 116 } |
| 117 |
| 118 // testing::Test: |
| 119 void SetUp() override { |
| 120 ui::DeviceDataManager::CreateInstance(); |
| 121 std::unique_ptr<ScreenBase> screen = base::MakeUnique<ScreenBase>(); |
| 122 Screen::SetScreenInstance(screen.get()); |
| 123 display_manager_ = base::MakeUnique<DisplayManager>(std::move(screen)); |
| 124 touch_transform_controller_ = base::MakeUnique<TouchTransformController>( |
| 125 nullptr, display_manager_.get()); |
| 126 } |
| 127 |
| 128 void TearDown() override { |
| 129 Screen::SetScreenInstance(nullptr); |
| 130 ui::DeviceDataManager::DeleteInstance(); |
116 } | 131 } |
117 | 132 |
118 private: | 133 private: |
119 DISALLOW_COPY_AND_ASSIGN(TouchTransformerControllerTest); | 134 std::unique_ptr<DisplayManager> display_manager_; |
| 135 std::unique_ptr<TouchTransformController> touch_transform_controller_; |
| 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(TouchTransformControllerTest); |
120 }; | 138 }; |
121 | 139 |
122 TEST_F(TouchTransformerControllerTest, MirrorModeLetterboxing) { | 140 TEST_F(TouchTransformControllerTest, MirrorModeLetterboxing) { |
123 // The internal display has native resolution of 2560x1700, and in | 141 // The internal display has native resolution of 2560x1700, and in |
124 // mirror mode it is configured as 1920x1200. This is in letterboxing | 142 // mirror mode it is configured as 1920x1200. This is in letterboxing |
125 // mode. | 143 // mode. |
126 display::ManagedDisplayInfo internal_display_info = | 144 ManagedDisplayInfo internal_display_info = |
127 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1920, 1200)); | 145 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1920, 1200)); |
128 internal_display_info.set_is_aspect_preserving_scaling(true); | 146 internal_display_info.set_is_aspect_preserving_scaling(true); |
129 | 147 |
130 display::ManagedDisplayInfo::ManagedDisplayModeList internal_modes; | 148 ManagedDisplayInfo::ManagedDisplayModeList internal_modes; |
131 | 149 |
132 internal_modes.push_back(make_scoped_refptr( | 150 internal_modes.push_back(make_scoped_refptr( |
133 new display::ManagedDisplayMode(gfx::Size(2560, 1700), 60, false, true))); | 151 new ManagedDisplayMode(gfx::Size(2560, 1700), 60, false, true))); |
134 internal_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( | 152 internal_modes.push_back(make_scoped_refptr( |
135 gfx::Size(1920, 1200), 60, false, false))); | 153 new ManagedDisplayMode(gfx::Size(1920, 1200), 60, false, false))); |
136 internal_display_info.SetManagedDisplayModes(internal_modes); | 154 internal_display_info.SetManagedDisplayModes(internal_modes); |
137 | 155 |
138 display::ManagedDisplayInfo external_display_info = | 156 ManagedDisplayInfo external_display_info = |
139 CreateDisplayInfo(2, 11u, gfx::Rect(0, 0, 1920, 1200)); | 157 CreateDisplayInfo(2, 11u, gfx::Rect(0, 0, 1920, 1200)); |
140 | 158 |
141 gfx::Size fb_size(1920, 1200); | 159 gfx::Size fb_size(1920, 1200); |
142 | 160 |
143 // Create the touchscreens with the same size as the framebuffer so we can | 161 // Create the touchscreens with the same size as the framebuffer so we can |
144 // share the tests between Ozone & X11. | 162 // share the tests between Ozone & X11. |
145 ui::TouchscreenDevice internal_touchscreen = | 163 ui::TouchscreenDevice internal_touchscreen = |
146 CreateTouchscreenDevice(10, fb_size); | 164 CreateTouchscreenDevice(10, fb_size); |
147 ui::TouchscreenDevice external_touchscreen = | 165 ui::TouchscreenDevice external_touchscreen = |
148 CreateTouchscreenDevice(11, fb_size); | 166 CreateTouchscreenDevice(11, fb_size); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 EXPECT_NEAR(100, x, 0.5); | 199 EXPECT_NEAR(100, x, 0.5); |
182 EXPECT_NEAR(0, y, 0.5); | 200 EXPECT_NEAR(0, y, 0.5); |
183 | 201 |
184 x = 100.0; | 202 x = 100.0; |
185 y = 1165.0; | 203 y = 1165.0; |
186 device_manager->ApplyTouchTransformer(10, &x, &y); | 204 device_manager->ApplyTouchTransformer(10, &x, &y); |
187 EXPECT_NEAR(100, x, 0.5); | 205 EXPECT_NEAR(100, x, 0.5); |
188 EXPECT_NEAR(1200, y, 0.5); | 206 EXPECT_NEAR(1200, y, 0.5); |
189 } | 207 } |
190 | 208 |
191 TEST_F(TouchTransformerControllerTest, MirrorModePillarboxing) { | 209 TEST_F(TouchTransformControllerTest, MirrorModePillarboxing) { |
192 // The internal display has native resolution of 1366x768, and in | 210 // The internal display has native resolution of 1366x768, and in |
193 // mirror mode it is configured as 1024x768. This is in pillarboxing | 211 // mirror mode it is configured as 1024x768. This is in pillarboxing |
194 // mode. | 212 // mode. |
195 display::ManagedDisplayInfo internal_display_info = | 213 ManagedDisplayInfo internal_display_info = |
196 CreateDisplayInfo(1, 10, gfx::Rect(0, 0, 1024, 768)); | 214 CreateDisplayInfo(1, 10, gfx::Rect(0, 0, 1024, 768)); |
197 internal_display_info.set_is_aspect_preserving_scaling(true); | 215 internal_display_info.set_is_aspect_preserving_scaling(true); |
198 display::ManagedDisplayInfo::ManagedDisplayModeList internal_modes; | 216 ManagedDisplayInfo::ManagedDisplayModeList internal_modes; |
199 internal_modes.push_back(make_scoped_refptr( | 217 internal_modes.push_back(make_scoped_refptr( |
200 new display::ManagedDisplayMode(gfx::Size(1366, 768), 60, false, true))); | 218 new ManagedDisplayMode(gfx::Size(1366, 768), 60, false, true))); |
201 internal_modes.push_back(make_scoped_refptr( | 219 internal_modes.push_back(make_scoped_refptr( |
202 new display::ManagedDisplayMode(gfx::Size(1024, 768), 60, false, false))); | 220 new ManagedDisplayMode(gfx::Size(1024, 768), 60, false, false))); |
203 internal_display_info.SetManagedDisplayModes(internal_modes); | 221 internal_display_info.SetManagedDisplayModes(internal_modes); |
204 | 222 |
205 display::ManagedDisplayInfo external_display_info = | 223 ManagedDisplayInfo external_display_info = |
206 CreateDisplayInfo(2, 11, gfx::Rect(0, 0, 1024, 768)); | 224 CreateDisplayInfo(2, 11, gfx::Rect(0, 0, 1024, 768)); |
207 | 225 |
208 gfx::Size fb_size(1024, 768); | 226 gfx::Size fb_size(1024, 768); |
209 | 227 |
210 // Create the touchscreens with the same size as the framebuffer so we can | 228 // Create the touchscreens with the same size as the framebuffer so we can |
211 // share the tests between Ozone & X11. | 229 // share the tests between Ozone & X11. |
212 ui::TouchscreenDevice internal_touchscreen = | 230 ui::TouchscreenDevice internal_touchscreen = |
213 CreateTouchscreenDevice(10, fb_size); | 231 CreateTouchscreenDevice(10, fb_size); |
214 ui::TouchscreenDevice external_touchscreen = | 232 ui::TouchscreenDevice external_touchscreen = |
215 CreateTouchscreenDevice(11, fb_size); | 233 CreateTouchscreenDevice(11, fb_size); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 EXPECT_NEAR(0, x, 0.5); | 266 EXPECT_NEAR(0, x, 0.5); |
249 EXPECT_NEAR(100, y, 0.5); | 267 EXPECT_NEAR(100, y, 0.5); |
250 | 268 |
251 x = 896.0; | 269 x = 896.0; |
252 y = 100.0; | 270 y = 100.0; |
253 device_manager->ApplyTouchTransformer(10, &x, &y); | 271 device_manager->ApplyTouchTransformer(10, &x, &y); |
254 EXPECT_NEAR(1024, x, 0.5); | 272 EXPECT_NEAR(1024, x, 0.5); |
255 EXPECT_NEAR(100, y, 0.5); | 273 EXPECT_NEAR(100, y, 0.5); |
256 } | 274 } |
257 | 275 |
258 TEST_F(TouchTransformerControllerTest, SoftwareMirrorMode) { | 276 TEST_F(TouchTransformControllerTest, SoftwareMirrorMode) { |
259 // External display 1 has size 1280x850. External display 2 has size | 277 // External display 1 has size 1280x850. External display 2 has size |
260 // 1920x1080. When using software mirroring to mirror display 1 onto | 278 // 1920x1080. When using software mirroring to mirror display 1 onto |
261 // display 2, the displays are in extended mode and we map touches from both | 279 // display 2, the displays are in extended mode and we map touches from both |
262 // displays to display 1. | 280 // displays to display 1. |
263 // The total frame buffer is 1920x1990, | 281 // The total frame buffer is 1920x1990, |
264 // where 1990 = 850 + 60 (hidden gap) + 1080 and the second monitor is | 282 // where 1990 = 850 + 60 (hidden gap) + 1080 and the second monitor is |
265 // translated to point (0, 950) in the framebuffer. | 283 // translated to point (0, 950) in the framebuffer. |
266 display::ManagedDisplayInfo display1_info = | 284 ManagedDisplayInfo display1_info = |
267 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1280, 850)); | 285 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1280, 850)); |
268 display::ManagedDisplayInfo::ManagedDisplayModeList display1_modes; | 286 ManagedDisplayInfo::ManagedDisplayModeList display1_modes; |
269 display1_modes.push_back(make_scoped_refptr( | 287 display1_modes.push_back(make_scoped_refptr( |
270 new display::ManagedDisplayMode(gfx::Size(1280, 850), 60, false, true))); | 288 new ManagedDisplayMode(gfx::Size(1280, 850), 60, false, true))); |
271 display1_info.SetManagedDisplayModes(display1_modes); | 289 display1_info.SetManagedDisplayModes(display1_modes); |
272 | 290 |
273 display::ManagedDisplayInfo display2_info = | 291 ManagedDisplayInfo display2_info = |
274 CreateDisplayInfo(2, 11u, gfx::Rect(0, 950, 1920, 1080)); | 292 CreateDisplayInfo(2, 11u, gfx::Rect(0, 950, 1920, 1080)); |
275 display::ManagedDisplayInfo::ManagedDisplayModeList display2_modes; | 293 ManagedDisplayInfo::ManagedDisplayModeList display2_modes; |
276 display2_modes.push_back(make_scoped_refptr( | 294 display2_modes.push_back(make_scoped_refptr( |
277 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60, false, true))); | 295 new ManagedDisplayMode(gfx::Size(1920, 1080), 60, false, true))); |
278 display2_info.SetManagedDisplayModes(display2_modes); | 296 display2_info.SetManagedDisplayModes(display2_modes); |
279 | 297 |
280 gfx::Size fb_size(1920, 1990); | 298 gfx::Size fb_size(1920, 1990); |
281 | 299 |
282 // Create the touchscreens with the same size as the framebuffer so we can | 300 // Create the touchscreens with the same size as the framebuffer so we can |
283 // share the tests between Ozone & X11. | 301 // share the tests between Ozone & X11. |
284 ui::TouchscreenDevice display1_touchscreen = | 302 ui::TouchscreenDevice display1_touchscreen = |
285 CreateTouchscreenDevice(10, fb_size); | 303 CreateTouchscreenDevice(10, fb_size); |
286 ui::TouchscreenDevice display2_touchscreen = | 304 ui::TouchscreenDevice display2_touchscreen = |
287 CreateTouchscreenDevice(11, fb_size); | 305 CreateTouchscreenDevice(11, fb_size); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 EXPECT_NEAR(0, x, 0.5); | 349 EXPECT_NEAR(0, x, 0.5); |
332 EXPECT_NEAR(0, y, 0.5); | 350 EXPECT_NEAR(0, y, 0.5); |
333 | 351 |
334 x = 1773.0; | 352 x = 1773.0; |
335 y = 1990.0; | 353 y = 1990.0; |
336 device_manager->ApplyTouchTransformer(11, &x, &y); | 354 device_manager->ApplyTouchTransformer(11, &x, &y); |
337 EXPECT_NEAR(1280, x, 0.5); | 355 EXPECT_NEAR(1280, x, 0.5); |
338 EXPECT_NEAR(850, y, 0.5); | 356 EXPECT_NEAR(850, y, 0.5); |
339 } | 357 } |
340 | 358 |
341 TEST_F(TouchTransformerControllerTest, ExtendedMode) { | 359 TEST_F(TouchTransformControllerTest, ExtendedMode) { |
342 // The internal display has size 1366 x 768. The external display has | 360 // The internal display has size 1366 x 768. The external display has |
343 // size 2560x1600. The total frame buffer is 2560x2428, | 361 // size 2560x1600. The total frame buffer is 2560x2428, |
344 // where 2428 = 768 + 60 (hidden gap) + 1600 | 362 // where 2428 = 768 + 60 (hidden gap) + 1600 |
345 // and the second monitor is translated to Point (0, 828) in the | 363 // and the second monitor is translated to Point (0, 828) in the |
346 // framebuffer. | 364 // framebuffer. |
347 display::ManagedDisplayInfo display1 = | 365 ManagedDisplayInfo display1 = |
348 CreateDisplayInfo(1, 5u, gfx::Rect(0, 0, 1366, 768)); | 366 CreateDisplayInfo(1, 5u, gfx::Rect(0, 0, 1366, 768)); |
349 display::ManagedDisplayInfo display2 = | 367 ManagedDisplayInfo display2 = |
350 CreateDisplayInfo(2, 6u, gfx::Rect(0, 828, 2560, 1600)); | 368 CreateDisplayInfo(2, 6u, gfx::Rect(0, 828, 2560, 1600)); |
351 gfx::Size fb_size(2560, 2428); | 369 gfx::Size fb_size(2560, 2428); |
352 | 370 |
353 // Create the touchscreens with the same size as the framebuffer so we can | 371 // Create the touchscreens with the same size as the framebuffer so we can |
354 // share the tests between Ozone & X11. | 372 // share the tests between Ozone & X11. |
355 ui::TouchscreenDevice touchscreen1 = CreateTouchscreenDevice(5, fb_size); | 373 ui::TouchscreenDevice touchscreen1 = CreateTouchscreenDevice(5, fb_size); |
356 ui::TouchscreenDevice touchscreen2 = CreateTouchscreenDevice(6, fb_size); | 374 ui::TouchscreenDevice touchscreen2 = CreateTouchscreenDevice(6, fb_size); |
357 | 375 |
358 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 376 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
359 | 377 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 #if defined(USE_OZONE) | 420 #if defined(USE_OZONE) |
403 // On ozone we expect screen coordinates so add display origin. | 421 // On ozone we expect screen coordinates so add display origin. |
404 EXPECT_NEAR(2559 + 0, x, 0.5); | 422 EXPECT_NEAR(2559 + 0, x, 0.5); |
405 EXPECT_NEAR(1599 + 828, y, 0.5); | 423 EXPECT_NEAR(1599 + 828, y, 0.5); |
406 #else | 424 #else |
407 EXPECT_NEAR(2559, x, 0.5); | 425 EXPECT_NEAR(2559, x, 0.5); |
408 EXPECT_NEAR(1599, y, 0.5); | 426 EXPECT_NEAR(1599, y, 0.5); |
409 #endif | 427 #endif |
410 } | 428 } |
411 | 429 |
412 TEST_F(TouchTransformerControllerTest, TouchRadiusScale) { | 430 TEST_F(TouchTransformControllerTest, TouchRadiusScale) { |
413 display::ManagedDisplayInfo display = | 431 ManagedDisplayInfo display = |
414 CreateDisplayInfo(1, 5u, gfx::Rect(0, 0, 2560, 1600)); | 432 CreateDisplayInfo(1, 5u, gfx::Rect(0, 0, 2560, 1600)); |
415 ui::TouchscreenDevice touch_device = | 433 ui::TouchscreenDevice touch_device = |
416 CreateTouchscreenDevice(5, gfx::Size(1001, 1001)); | 434 CreateTouchscreenDevice(5, gfx::Size(1001, 1001)); |
417 | 435 |
418 // Default touchscreen position range is 1001x1001; | 436 // Default touchscreen position range is 1001x1001; |
419 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)), | 437 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)), |
420 GetTouchResolutionScale(display, touch_device)); | 438 GetTouchResolutionScale(display, touch_device)); |
421 } | 439 } |
422 | 440 |
423 TEST_F(TouchTransformerControllerTest, OzoneTranslation) { | 441 TEST_F(TouchTransformControllerTest, OzoneTranslation) { |
424 #if defined(USE_OZONE) | 442 #if defined(USE_OZONE) |
425 // The internal display has size 1920 x 1200. The external display has | 443 // The internal display has size 1920 x 1200. The external display has |
426 // size 1920x1200. The total frame buffer is 1920x2450, | 444 // size 1920x1200. The total frame buffer is 1920x2450, |
427 // where 2458 = 1200 + 50 (hidden gap) + 1200 | 445 // where 2458 = 1200 + 50 (hidden gap) + 1200 |
428 // and the second monitor is translated to Point (0, 1250) in the | 446 // and the second monitor is translated to Point (0, 1250) in the |
429 // framebuffer. | 447 // framebuffer. |
430 const int kDisplayId2 = 2; | 448 const int kDisplayId2 = 2; |
431 const int kTouchId2 = 6; | 449 const int kTouchId2 = 6; |
432 const gfx::Size kDisplaySize(1920, 1200); | 450 const gfx::Size kDisplaySize(1920, 1200); |
433 const gfx::Size kTouchSize(1920, 1200); | 451 const gfx::Size kTouchSize(1920, 1200); |
434 const int kHiddenGap = 50; | 452 const int kHiddenGap = 50; |
435 | 453 |
436 display::ManagedDisplayInfo display1 = CreateDisplayInfo( | 454 ManagedDisplayInfo display1 = CreateDisplayInfo( |
437 kDisplayId1, kTouchId1, | 455 kDisplayId1, kTouchId1, |
438 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 456 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
439 display::ManagedDisplayInfo display2 = | 457 ManagedDisplayInfo display2 = |
440 CreateDisplayInfo(kDisplayId2, kTouchId2, | 458 CreateDisplayInfo(kDisplayId2, kTouchId2, |
441 gfx::Rect(0, kDisplaySize.height() + kHiddenGap, | 459 gfx::Rect(0, kDisplaySize.height() + kHiddenGap, |
442 kDisplaySize.width(), kDisplaySize.height())); | 460 kDisplaySize.width(), kDisplaySize.height())); |
443 | 461 |
444 gfx::Size fb_size(1920, 2450); | 462 gfx::Size fb_size(1920, 2450); |
445 | 463 |
446 ui::TouchscreenDevice touchscreen1 = | 464 ui::TouchscreenDevice touchscreen1 = |
447 CreateTouchscreenDevice(kTouchId1, kDisplaySize); | 465 CreateTouchscreenDevice(kTouchId1, kDisplaySize); |
448 ui::TouchscreenDevice touchscreen2 = | 466 ui::TouchscreenDevice touchscreen2 = |
449 CreateTouchscreenDevice(kTouchId2, kDisplaySize); | 467 CreateTouchscreenDevice(kTouchId2, kDisplaySize); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 EXPECT_NEAR(1200, y, 0.5); | 518 EXPECT_NEAR(1200, y, 0.5); |
501 | 519 |
502 x = 1920.0; | 520 x = 1920.0; |
503 y = 1200.0; | 521 y = 1200.0; |
504 device_manager->ApplyTouchTransformer(kTouchId2, &x, &y); | 522 device_manager->ApplyTouchTransformer(kTouchId2, &x, &y); |
505 EXPECT_NEAR(1920, x, 0.5); | 523 EXPECT_NEAR(1920, x, 0.5); |
506 EXPECT_NEAR(1200 + kDisplaySize.height() + kHiddenGap, y, 0.5); | 524 EXPECT_NEAR(1200 + kDisplaySize.height() + kHiddenGap, y, 0.5); |
507 #endif // USE_OZONE | 525 #endif // USE_OZONE |
508 } | 526 } |
509 | 527 |
510 TEST_F(TouchTransformerControllerTest, AccurateUserTouchCalibration) { | 528 TEST_F(TouchTransformControllerTest, AccurateUserTouchCalibration) { |
511 const gfx::Size kDisplaySize(1920, 1200); | 529 const gfx::Size kDisplaySize(1920, 1200); |
512 const gfx::Size kTouchSize(1920, 1200); | 530 const gfx::Size kTouchSize(1920, 1200); |
513 | 531 |
514 display::ManagedDisplayInfo display = CreateDisplayInfo( | 532 ManagedDisplayInfo display = CreateDisplayInfo( |
515 kDisplayId1, kTouchId1, | 533 kDisplayId1, kTouchId1, |
516 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 534 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
517 | 535 |
518 // Assuming the user provided accurate inputs during calibration. ie the user | 536 // Assuming the user provided accurate inputs during calibration. ie the user |
519 // actually tapped (100,100) when asked to tap (100,100) with no human error. | 537 // actually tapped (100,100) when asked to tap (100,100) with no human error. |
520 display::TouchCalibrationData::CalibrationPointPairQuad user_input = {{ | 538 TouchCalibrationData::CalibrationPointPairQuad user_input = {{ |
521 std::make_pair(gfx::Point(100, 100), gfx::Point(100, 100)), | 539 std::make_pair(gfx::Point(100, 100), gfx::Point(100, 100)), |
522 std::make_pair(gfx::Point(1820, 100), gfx::Point(1820, 100)), | 540 std::make_pair(gfx::Point(1820, 100), gfx::Point(1820, 100)), |
523 std::make_pair(gfx::Point(100, 1100), gfx::Point(100, 1100)), | 541 std::make_pair(gfx::Point(100, 1100), gfx::Point(100, 1100)), |
524 std::make_pair(gfx::Point(1820, 1100), gfx::Point(1820, 1100)), | 542 std::make_pair(gfx::Point(1820, 1100), gfx::Point(1820, 1100)), |
525 }}; | 543 }}; |
526 display::TouchCalibrationData touch_data(user_input, kDisplaySize); | 544 TouchCalibrationData touch_data(user_input, kDisplaySize); |
527 display.SetTouchCalibrationData(touch_data); | 545 display.SetTouchCalibrationData(touch_data); |
528 EXPECT_TRUE(display.has_touch_calibration_data()); | 546 EXPECT_TRUE(display.has_touch_calibration_data()); |
529 | 547 |
530 const std::string msg = GetTouchPointString(user_input); | 548 const std::string msg = GetTouchPointString(user_input); |
531 | 549 |
532 gfx::Size fb_size(1920, 1200); | 550 gfx::Size fb_size(1920, 1200); |
533 | 551 |
534 ui::TouchscreenDevice touchscreen = | 552 ui::TouchscreenDevice touchscreen = |
535 CreateTouchscreenDevice(kTouchId1, kTouchSize); | 553 CreateTouchscreenDevice(kTouchId1, kTouchSize); |
536 | 554 |
537 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 555 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
538 | 556 |
539 device_manager->UpdateTouchInfoForDisplay( | 557 device_manager->UpdateTouchInfoForDisplay( |
540 display.id(), touchscreen.id, | 558 display.id(), touchscreen.id, |
541 GetTouchTransform(display, display, touchscreen, kTouchSize)); | 559 GetTouchTransform(display, display, touchscreen, kTouchSize)); |
542 | 560 |
543 EXPECT_EQ(kDisplayId1, | 561 EXPECT_EQ(kDisplayId1, |
544 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); | 562 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); |
545 | 563 |
546 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, gfx::Size(1, 1), | 564 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, gfx::Size(1, 1), |
547 msg); | 565 msg); |
548 } | 566 } |
549 | 567 |
550 TEST_F(TouchTransformerControllerTest, ErrorProneUserTouchCalibration) { | 568 TEST_F(TouchTransformControllerTest, ErrorProneUserTouchCalibration) { |
551 const gfx::Size kDisplaySize(1920, 1200); | 569 const gfx::Size kDisplaySize(1920, 1200); |
552 const gfx::Size kTouchSize(1920, 1200); | 570 const gfx::Size kTouchSize(1920, 1200); |
553 // User touch inputs have a max error of 5%. | 571 // User touch inputs have a max error of 5%. |
554 const float kError = 0.05; | 572 const float kError = 0.05; |
555 // The maximum user error rate is |kError|%. Since the calibration is | 573 // The maximum user error rate is |kError|%. Since the calibration is |
556 // performed with a best fit algorithm, the error rate observed should be less | 574 // performed with a best fit algorithm, the error rate observed should be less |
557 // than |kError|. | 575 // than |kError|. |
558 const gfx::Size kMaxErrorDelta = gfx::ScaleToCeiledSize(kTouchSize, kError); | 576 const gfx::Size kMaxErrorDelta = gfx::ScaleToCeiledSize(kTouchSize, kError); |
559 | 577 |
560 display::ManagedDisplayInfo display = CreateDisplayInfo( | 578 ManagedDisplayInfo display = CreateDisplayInfo( |
561 kDisplayId1, kTouchId1, | 579 kDisplayId1, kTouchId1, |
562 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 580 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
563 | 581 |
564 // Assuming the user provided inaccurate inputs during calibration. ie the | 582 // Assuming the user provided inaccurate inputs during calibration. ie the |
565 // user did not tap (100,100) when asked to tap (100,100) due to human error. | 583 // user did not tap (100,100) when asked to tap (100,100) due to human error. |
566 display::TouchCalibrationData::CalibrationPointPairQuad user_input = { | 584 TouchCalibrationData::CalibrationPointPairQuad user_input = { |
567 {std::make_pair(gfx::Point(100, 100), gfx::Point(130, 60)), | 585 {std::make_pair(gfx::Point(100, 100), gfx::Point(130, 60)), |
568 std::make_pair(gfx::Point(1820, 100), gfx::Point(1878, 130)), | 586 std::make_pair(gfx::Point(1820, 100), gfx::Point(1878, 130)), |
569 std::make_pair(gfx::Point(100, 1100), gfx::Point(158, 1060)), | 587 std::make_pair(gfx::Point(100, 1100), gfx::Point(158, 1060)), |
570 std::make_pair(gfx::Point(1820, 1100), gfx::Point(1790, 1140))}}; | 588 std::make_pair(gfx::Point(1820, 1100), gfx::Point(1790, 1140))}}; |
571 display::TouchCalibrationData touch_data(user_input, kDisplaySize); | 589 TouchCalibrationData touch_data(user_input, kDisplaySize); |
572 display.SetTouchCalibrationData(touch_data); | 590 display.SetTouchCalibrationData(touch_data); |
573 EXPECT_TRUE(display.has_touch_calibration_data()); | 591 EXPECT_TRUE(display.has_touch_calibration_data()); |
574 | 592 |
575 const std::string msg = GetTouchPointString(user_input); | 593 const std::string msg = GetTouchPointString(user_input); |
576 | 594 |
577 ui::TouchscreenDevice touchscreen = | 595 ui::TouchscreenDevice touchscreen = |
578 CreateTouchscreenDevice(kTouchId1, kTouchSize); | 596 CreateTouchscreenDevice(kTouchId1, kTouchSize); |
579 | 597 |
580 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 598 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
581 | 599 |
582 device_manager->UpdateTouchInfoForDisplay( | 600 device_manager->UpdateTouchInfoForDisplay( |
583 display.id(), touchscreen.id, | 601 display.id(), touchscreen.id, |
584 GetTouchTransform(display, display, touchscreen, kTouchSize)); | 602 GetTouchTransform(display, display, touchscreen, kTouchSize)); |
585 | 603 |
586 EXPECT_EQ(kDisplayId1, | 604 EXPECT_EQ(kDisplayId1, |
587 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); | 605 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); |
588 | 606 |
589 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, kMaxErrorDelta, | 607 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, kMaxErrorDelta, |
590 msg); | 608 msg); |
591 } | 609 } |
592 | 610 |
593 TEST_F(TouchTransformerControllerTest, ResolutionChangeUserTouchCalibration) { | 611 TEST_F(TouchTransformControllerTest, ResolutionChangeUserTouchCalibration) { |
594 const gfx::Size kDisplaySize(2560, 1600); | 612 const gfx::Size kDisplaySize(2560, 1600); |
595 const gfx::Size kTouchSize(1920, 1200); | 613 const gfx::Size kTouchSize(1920, 1200); |
596 // User touch inputs have a max error of 5%. | 614 // User touch inputs have a max error of 5%. |
597 const float kError = 0.05; | 615 const float kError = 0.05; |
598 // The maximum user error rate is |kError|%. Since the calibration is | 616 // The maximum user error rate is |kError|%. Since the calibration is |
599 // performed with a best fit algorithm, the error rate observed should be less | 617 // performed with a best fit algorithm, the error rate observed should be less |
600 // tha |kError|. | 618 // tha |kError|. |
601 gfx::Size kMaxErrorDelta = gfx::ScaleToCeiledSize(kDisplaySize, kError); | 619 gfx::Size kMaxErrorDelta = gfx::ScaleToCeiledSize(kDisplaySize, kError); |
602 | 620 |
603 display::ManagedDisplayInfo display = CreateDisplayInfo( | 621 ManagedDisplayInfo display = CreateDisplayInfo( |
604 kDisplayId1, kTouchId1, | 622 kDisplayId1, kTouchId1, |
605 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 623 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
606 | 624 |
607 // The calibration was performed at a resolution different from the curent | 625 // The calibration was performed at a resolution different from the curent |
608 // resolution of the display. | 626 // resolution of the display. |
609 const gfx::Size CALIBRATION_SIZE(1920, 1200); | 627 const gfx::Size CALIBRATION_SIZE(1920, 1200); |
610 display::TouchCalibrationData::CalibrationPointPairQuad user_input = { | 628 TouchCalibrationData::CalibrationPointPairQuad user_input = { |
611 {std::make_pair(gfx::Point(100, 100), gfx::Point(50, 70)), | 629 {std::make_pair(gfx::Point(100, 100), gfx::Point(50, 70)), |
612 std::make_pair(gfx::Point(1820, 100), gfx::Point(1780, 70)), | 630 std::make_pair(gfx::Point(1820, 100), gfx::Point(1780, 70)), |
613 std::make_pair(gfx::Point(100, 1100), gfx::Point(70, 1060)), | 631 std::make_pair(gfx::Point(100, 1100), gfx::Point(70, 1060)), |
614 std::make_pair(gfx::Point(1820, 1100), gfx::Point(1770, 1140))}}; | 632 std::make_pair(gfx::Point(1820, 1100), gfx::Point(1770, 1140))}}; |
615 | 633 |
616 display::TouchCalibrationData touch_data(user_input, CALIBRATION_SIZE); | 634 TouchCalibrationData touch_data(user_input, CALIBRATION_SIZE); |
617 display.SetTouchCalibrationData(touch_data); | 635 display.SetTouchCalibrationData(touch_data); |
618 EXPECT_TRUE(display.has_touch_calibration_data()); | 636 EXPECT_TRUE(display.has_touch_calibration_data()); |
619 | 637 |
620 const std::string msg = GetTouchPointString(user_input); | 638 const std::string msg = GetTouchPointString(user_input); |
621 | 639 |
622 ui::TouchscreenDevice touchscreen = | 640 ui::TouchscreenDevice touchscreen = |
623 CreateTouchscreenDevice(kTouchId1, kTouchSize); | 641 CreateTouchscreenDevice(kTouchId1, kTouchSize); |
624 | 642 |
625 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 643 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
626 | 644 |
627 device_manager->UpdateTouchInfoForDisplay( | 645 device_manager->UpdateTouchInfoForDisplay( |
628 display.id(), touchscreen.id, | 646 display.id(), touchscreen.id, |
629 GetTouchTransform(display, display, touchscreen, kTouchSize)); | 647 GetTouchTransform(display, display, touchscreen, kTouchSize)); |
630 | 648 |
631 EXPECT_EQ(kDisplayId1, | 649 EXPECT_EQ(kDisplayId1, |
632 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); | 650 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); |
633 | 651 |
634 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, kMaxErrorDelta, | 652 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, kMaxErrorDelta, |
635 msg); | 653 msg); |
636 } | 654 } |
637 | 655 |
638 TEST_F(TouchTransformerControllerTest, DifferentBoundsUserTouchCalibration) { | 656 TEST_F(TouchTransformControllerTest, DifferentBoundsUserTouchCalibration) { |
639 // The display bounds is different from the touch device bounds in this test. | 657 // The display bounds is different from the touch device bounds in this test. |
640 const gfx::Size kDisplaySize(1024, 600); | 658 const gfx::Size kDisplaySize(1024, 600); |
641 const gfx::Size kTouchSize(4096, 4096); | 659 const gfx::Size kTouchSize(4096, 4096); |
642 const float kAcceptableError = 0.04; | 660 const float kAcceptableError = 0.04; |
643 gfx::Size kMaxErrorDelta = | 661 gfx::Size kMaxErrorDelta = |
644 gfx::ScaleToCeiledSize(kDisplaySize, kAcceptableError); | 662 gfx::ScaleToCeiledSize(kDisplaySize, kAcceptableError); |
645 | 663 |
646 display::ManagedDisplayInfo display = CreateDisplayInfo( | 664 ManagedDisplayInfo display = CreateDisplayInfo( |
647 kDisplayId1, kTouchId1, | 665 kDisplayId1, kTouchId1, |
648 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 666 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
649 | 667 |
650 // Real world data. | 668 // Real world data. |
651 display::TouchCalibrationData::CalibrationPointPairQuad user_input = { | 669 TouchCalibrationData::CalibrationPointPairQuad user_input = { |
652 {std::make_pair(gfx::Point(136, 136), gfx::Point(538, 931)), | 670 {std::make_pair(gfx::Point(136, 136), gfx::Point(538, 931)), |
653 std::make_pair(gfx::Point(873, 136), gfx::Point(3475, 922)), | 671 std::make_pair(gfx::Point(873, 136), gfx::Point(3475, 922)), |
654 std::make_pair(gfx::Point(136, 411), gfx::Point(611, 2800)), | 672 std::make_pair(gfx::Point(136, 411), gfx::Point(611, 2800)), |
655 std::make_pair(gfx::Point(873, 411), gfx::Point(3535, 2949))}}; | 673 std::make_pair(gfx::Point(873, 411), gfx::Point(3535, 2949))}}; |
656 display::TouchCalibrationData touch_data(user_input, kDisplaySize); | 674 TouchCalibrationData touch_data(user_input, kDisplaySize); |
657 display.SetTouchCalibrationData(touch_data); | 675 display.SetTouchCalibrationData(touch_data); |
658 EXPECT_TRUE(display.has_touch_calibration_data()); | 676 EXPECT_TRUE(display.has_touch_calibration_data()); |
659 | 677 |
660 const std::string msg = GetTouchPointString(user_input); | 678 const std::string msg = GetTouchPointString(user_input); |
661 | 679 |
662 ui::TouchscreenDevice touchscreen = | 680 ui::TouchscreenDevice touchscreen = |
663 CreateTouchscreenDevice(kTouchId1, kTouchSize); | 681 CreateTouchscreenDevice(kTouchId1, kTouchSize); |
664 | 682 |
665 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 683 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
666 | 684 |
667 device_manager->UpdateTouchInfoForDisplay( | 685 device_manager->UpdateTouchInfoForDisplay( |
668 display.id(), touchscreen.id, | 686 display.id(), touchscreen.id, |
669 GetTouchTransform(display, display, touchscreen, kTouchSize)); | 687 GetTouchTransform(display, display, touchscreen, kTouchSize)); |
670 | 688 |
671 EXPECT_EQ(kDisplayId1, | 689 EXPECT_EQ(kDisplayId1, |
672 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); | 690 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); |
673 | 691 |
674 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, kMaxErrorDelta, | 692 CheckPointsOfInterests(kTouchId1, kTouchSize, kDisplaySize, kMaxErrorDelta, |
675 msg); | 693 msg); |
676 } | 694 } |
677 | 695 |
678 TEST_F(TouchTransformerControllerTest, LetterboxingUserTouchCalibration) { | 696 TEST_F(TouchTransformControllerTest, LetterboxingUserTouchCalibration) { |
679 // The internal display has native resolution of 2560x1700, and in | 697 // The internal display has native resolution of 2560x1700, and in |
680 // mirror mode it is configured as 1920x1200. This is in letterboxing | 698 // mirror mode it is configured as 1920x1200. This is in letterboxing |
681 // mode. | 699 // mode. |
682 const gfx::Size kNativeDisplaySize(2560, 1700); | 700 const gfx::Size kNativeDisplaySize(2560, 1700); |
683 const gfx::Size kDisplaySize(1920, 1200); | 701 const gfx::Size kDisplaySize(1920, 1200); |
684 const gfx::Size kTouchSize(1920, 1200); | 702 const gfx::Size kTouchSize(1920, 1200); |
685 | 703 |
686 display::ManagedDisplayInfo internal_display_info = CreateDisplayInfo( | 704 ManagedDisplayInfo internal_display_info = CreateDisplayInfo( |
687 kDisplayId1, kTouchId1, | 705 kDisplayId1, kTouchId1, |
688 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 706 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
689 internal_display_info.set_is_aspect_preserving_scaling(true); | 707 internal_display_info.set_is_aspect_preserving_scaling(true); |
690 | 708 |
691 display::ManagedDisplayInfo::ManagedDisplayModeList internal_modes; | 709 ManagedDisplayInfo::ManagedDisplayModeList internal_modes; |
692 | 710 |
693 internal_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( | 711 internal_modes.push_back(make_scoped_refptr(new ManagedDisplayMode( |
694 gfx::Size(kNativeDisplaySize.width(), kNativeDisplaySize.height()), 60, | 712 gfx::Size(kNativeDisplaySize.width(), kNativeDisplaySize.height()), 60, |
695 false, true))); | 713 false, true))); |
696 internal_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( | 714 internal_modes.push_back(make_scoped_refptr(new ManagedDisplayMode( |
697 gfx::Size(kDisplaySize.width(), kDisplaySize.height()), 60, false, | 715 gfx::Size(kDisplaySize.width(), kDisplaySize.height()), 60, false, |
698 false))); | 716 false))); |
699 internal_display_info.SetManagedDisplayModes(internal_modes); | 717 internal_display_info.SetManagedDisplayModes(internal_modes); |
700 | 718 |
701 gfx::Size fb_size(kDisplaySize); | 719 gfx::Size fb_size(kDisplaySize); |
702 | 720 |
703 // Create the touchscreens with the same size as the framebuffer so we can | 721 // Create the touchscreens with the same size as the framebuffer so we can |
704 // share the tests between Ozone & X11. | 722 // share the tests between Ozone & X11. |
705 ui::TouchscreenDevice internal_touchscreen = | 723 ui::TouchscreenDevice internal_touchscreen = |
706 CreateTouchscreenDevice(kTouchId1, fb_size); | 724 CreateTouchscreenDevice(kTouchId1, fb_size); |
707 | 725 |
708 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 726 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
709 | 727 |
710 // Assuming the user provided inaccurate inputs during calibration. ie the | 728 // Assuming the user provided inaccurate inputs during calibration. ie the |
711 // user did not tap (100,100) when asked to tap (100,100) due to human error. | 729 // user did not tap (100,100) when asked to tap (100,100) due to human error. |
712 // Since the display is of size 2560x1700 and the touch device is of size | 730 // Since the display is of size 2560x1700 and the touch device is of size |
713 // 1920x1200, the corresponding points have to be scaled. | 731 // 1920x1200, the corresponding points have to be scaled. |
714 display::TouchCalibrationData::CalibrationPointPairQuad user_input = {{ | 732 TouchCalibrationData::CalibrationPointPairQuad user_input = {{ |
715 std::make_pair(gfx::Point(100, 100), gfx::Point(75, 71)), | 733 std::make_pair(gfx::Point(100, 100), gfx::Point(75, 71)), |
716 std::make_pair(gfx::Point(2460, 100), gfx::Point(1845, 71)), | 734 std::make_pair(gfx::Point(2460, 100), gfx::Point(1845, 71)), |
717 std::make_pair(gfx::Point(100, 1600), gfx::Point(75, 1130)), | 735 std::make_pair(gfx::Point(100, 1600), gfx::Point(75, 1130)), |
718 std::make_pair(gfx::Point(2460, 1600), gfx::Point(1845, 1130)), | 736 std::make_pair(gfx::Point(2460, 1600), gfx::Point(1845, 1130)), |
719 }}; | 737 }}; |
720 // The calibration was performed at the native display resolution. | 738 // The calibration was performed at the native display resolution. |
721 display::TouchCalibrationData touch_data(user_input, kNativeDisplaySize); | 739 TouchCalibrationData touch_data(user_input, kNativeDisplaySize); |
722 internal_display_info.SetTouchCalibrationData(touch_data); | 740 internal_display_info.SetTouchCalibrationData(touch_data); |
723 EXPECT_TRUE(internal_display_info.has_touch_calibration_data()); | 741 EXPECT_TRUE(internal_display_info.has_touch_calibration_data()); |
724 | 742 |
725 device_manager->UpdateTouchInfoForDisplay( | 743 device_manager->UpdateTouchInfoForDisplay( |
726 internal_display_info.id(), internal_touchscreen.id, | 744 internal_display_info.id(), internal_touchscreen.id, |
727 GetTouchTransform(internal_display_info, internal_display_info, | 745 GetTouchTransform(internal_display_info, internal_display_info, |
728 internal_touchscreen, fb_size)); | 746 internal_touchscreen, fb_size)); |
729 | 747 |
730 EXPECT_EQ(kDisplayId1, | 748 EXPECT_EQ(kDisplayId1, |
731 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); | 749 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); |
(...skipping 11 matching lines...) Expand all Loading... |
743 EXPECT_NEAR(100, x, 0.5); | 761 EXPECT_NEAR(100, x, 0.5); |
744 EXPECT_NEAR(0, y, 0.5); | 762 EXPECT_NEAR(0, y, 0.5); |
745 | 763 |
746 x = 100.0; | 764 x = 100.0; |
747 y = 1165.0; | 765 y = 1165.0; |
748 device_manager->ApplyTouchTransformer(kTouchId1, &x, &y); | 766 device_manager->ApplyTouchTransformer(kTouchId1, &x, &y); |
749 EXPECT_NEAR(100, x, 0.5); | 767 EXPECT_NEAR(100, x, 0.5); |
750 EXPECT_NEAR(1200, y, 0.5); | 768 EXPECT_NEAR(1200, y, 0.5); |
751 } | 769 } |
752 | 770 |
753 TEST_F(TouchTransformerControllerTest, PillarBoxingUserTouchCalibration) { | 771 TEST_F(TouchTransformControllerTest, PillarBoxingUserTouchCalibration) { |
754 // The internal display has native resolution of 2560x1700, and in | 772 // The internal display has native resolution of 2560x1700, and in |
755 // mirror mode it is configured as 1920x1200. This is in letterboxing | 773 // mirror mode it is configured as 1920x1200. This is in letterboxing |
756 // mode. | 774 // mode. |
757 const gfx::Size kNativeDisplaySize(2560, 1600); | 775 const gfx::Size kNativeDisplaySize(2560, 1600); |
758 const gfx::Size kDisplaySize(1920, 1400); | 776 const gfx::Size kDisplaySize(1920, 1400); |
759 const gfx::Size kTouchSize(1920, 1400); | 777 const gfx::Size kTouchSize(1920, 1400); |
760 | 778 |
761 display::ManagedDisplayInfo internal_display_info = CreateDisplayInfo( | 779 ManagedDisplayInfo internal_display_info = CreateDisplayInfo( |
762 kDisplayId1, kTouchId1, | 780 kDisplayId1, kTouchId1, |
763 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); | 781 gfx::Rect(0, 0, kDisplaySize.width(), kDisplaySize.height())); |
764 internal_display_info.set_is_aspect_preserving_scaling(true); | 782 internal_display_info.set_is_aspect_preserving_scaling(true); |
765 | 783 |
766 display::ManagedDisplayInfo::ManagedDisplayModeList internal_modes; | 784 ManagedDisplayInfo::ManagedDisplayModeList internal_modes; |
767 | 785 |
768 internal_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( | 786 internal_modes.push_back(make_scoped_refptr(new ManagedDisplayMode( |
769 gfx::Size(kNativeDisplaySize.width(), kNativeDisplaySize.height()), 60, | 787 gfx::Size(kNativeDisplaySize.width(), kNativeDisplaySize.height()), 60, |
770 false, true))); | 788 false, true))); |
771 internal_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( | 789 internal_modes.push_back(make_scoped_refptr(new ManagedDisplayMode( |
772 gfx::Size(kDisplaySize.width(), kDisplaySize.height()), 60, false, | 790 gfx::Size(kDisplaySize.width(), kDisplaySize.height()), 60, false, |
773 false))); | 791 false))); |
774 internal_display_info.SetManagedDisplayModes(internal_modes); | 792 internal_display_info.SetManagedDisplayModes(internal_modes); |
775 | 793 |
776 gfx::Size fb_size(kDisplaySize); | 794 gfx::Size fb_size(kDisplaySize); |
777 | 795 |
778 // Create the touchscreens with the same size as the framebuffer so we can | 796 // Create the touchscreens with the same size as the framebuffer so we can |
779 // share the tests between Ozone & X11. | 797 // share the tests between Ozone & X11. |
780 ui::TouchscreenDevice internal_touchscreen = | 798 ui::TouchscreenDevice internal_touchscreen = |
781 CreateTouchscreenDevice(kTouchId1, fb_size); | 799 CreateTouchscreenDevice(kTouchId1, fb_size); |
782 | 800 |
783 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 801 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
784 | 802 |
785 // Assuming the user provided accurate inputs during calibration. ie the user | 803 // Assuming the user provided accurate inputs during calibration. ie the user |
786 // actually tapped (100,100) when asked to tap (100,100) with no human error. | 804 // actually tapped (100,100) when asked to tap (100,100) with no human error. |
787 // Since the display is of size 2560x1600 and the touch device is of size | 805 // Since the display is of size 2560x1600 and the touch device is of size |
788 // 1920x1400, the corresponding points have to be scaled. | 806 // 1920x1400, the corresponding points have to be scaled. |
789 display::TouchCalibrationData::CalibrationPointPairQuad user_input = {{ | 807 TouchCalibrationData::CalibrationPointPairQuad user_input = {{ |
790 std::make_pair(gfx::Point(100, 100), gfx::Point(75, 88)), | 808 std::make_pair(gfx::Point(100, 100), gfx::Point(75, 88)), |
791 std::make_pair(gfx::Point(2460, 100), gfx::Point(1845, 88)), | 809 std::make_pair(gfx::Point(2460, 100), gfx::Point(1845, 88)), |
792 std::make_pair(gfx::Point(100, 1500), gfx::Point(75, 1313)), | 810 std::make_pair(gfx::Point(100, 1500), gfx::Point(75, 1313)), |
793 std::make_pair(gfx::Point(2460, 1500), gfx::Point(1845, 1313)), | 811 std::make_pair(gfx::Point(2460, 1500), gfx::Point(1845, 1313)), |
794 }}; | 812 }}; |
795 // The calibration was performed at the native display resolution. | 813 // The calibration was performed at the native display resolution. |
796 display::TouchCalibrationData touch_data(user_input, kNativeDisplaySize); | 814 TouchCalibrationData touch_data(user_input, kNativeDisplaySize); |
797 internal_display_info.SetTouchCalibrationData(touch_data); | 815 internal_display_info.SetTouchCalibrationData(touch_data); |
798 EXPECT_TRUE(internal_display_info.has_touch_calibration_data()); | 816 EXPECT_TRUE(internal_display_info.has_touch_calibration_data()); |
799 | 817 |
800 device_manager->UpdateTouchInfoForDisplay( | 818 device_manager->UpdateTouchInfoForDisplay( |
801 internal_display_info.id(), internal_touchscreen.id, | 819 internal_display_info.id(), internal_touchscreen.id, |
802 GetTouchTransform(internal_display_info, internal_display_info, | 820 GetTouchTransform(internal_display_info, internal_display_info, |
803 internal_touchscreen, fb_size)); | 821 internal_touchscreen, fb_size)); |
804 | 822 |
805 EXPECT_EQ(kDisplayId1, | 823 EXPECT_EQ(kDisplayId1, |
806 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); | 824 device_manager->GetTargetDisplayForTouchDevice(kTouchId1)); |
(...skipping 11 matching lines...) Expand all Loading... |
818 EXPECT_NEAR(0, x, 0.5); | 836 EXPECT_NEAR(0, x, 0.5); |
819 EXPECT_NEAR(0, y, 0.5); | 837 EXPECT_NEAR(0, y, 0.5); |
820 | 838 |
821 x = 1782.0; | 839 x = 1782.0; |
822 y = 0.0; | 840 y = 0.0; |
823 device_manager->ApplyTouchTransformer(kTouchId1, &x, &y); | 841 device_manager->ApplyTouchTransformer(kTouchId1, &x, &y); |
824 EXPECT_NEAR(1920, x, 0.5); | 842 EXPECT_NEAR(1920, x, 0.5); |
825 EXPECT_NEAR(0, y, 0.5); | 843 EXPECT_NEAR(0, y, 0.5); |
826 } | 844 } |
827 | 845 |
828 } // namespace ash | 846 } // namespace test |
| 847 } // namespace display |
OLD | NEW |