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 "ash/touch/touch_transformer_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ui/aura/window_tree_host.h" | 9 #include "ui/aura/window_tree_host.h" |
10 #include "ui/events/devices/device_data_manager.h" | 10 #include "ui/events/devices/device_data_manager.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 Shell::GetInstance()->touch_transformer_controller(); | 70 Shell::GetInstance()->touch_transformer_controller(); |
71 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 71 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
72 | 72 |
73 device_manager->UpdateTouchInfoForDisplay( | 73 device_manager->UpdateTouchInfoForDisplay( |
74 internal_display_info.id(), internal_display_info.touch_device_id(), | 74 internal_display_info.id(), internal_display_info.touch_device_id(), |
75 tt_controller->GetTouchTransform(internal_display_info, | 75 tt_controller->GetTouchTransform(internal_display_info, |
76 internal_display_info, | 76 internal_display_info, |
77 internal_touchscreen, fb_size)); | 77 internal_touchscreen, fb_size)); |
78 | 78 |
79 device_manager->UpdateTouchInfoForDisplay( | 79 device_manager->UpdateTouchInfoForDisplay( |
80 external_display_info.id(), external_display_info.touch_device_id(), | 80 internal_display_info.id(), external_display_info.touch_device_id(), |
81 tt_controller->GetTouchTransform(external_display_info, | 81 tt_controller->GetTouchTransform(external_display_info, |
82 external_display_info, | 82 external_display_info, |
83 external_touchscreen, fb_size)); | 83 external_touchscreen, fb_size)); |
84 | 84 |
85 EXPECT_EQ(1, device_manager->GetDisplayForTouchDevice(10)); | 85 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(10)); |
86 EXPECT_EQ(2, device_manager->GetDisplayForTouchDevice(11)); | 86 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(11)); |
87 | 87 |
88 // External touch display has the default TouchTransformer. | 88 // External touch display has the default TouchTransformer. |
89 float x = 100.0; | 89 float x = 100.0; |
90 float y = 100.0; | 90 float y = 100.0; |
91 device_manager->ApplyTouchTransformer(11, &x, &y); | 91 device_manager->ApplyTouchTransformer(11, &x, &y); |
92 EXPECT_EQ(100, x); | 92 EXPECT_EQ(100, x); |
93 EXPECT_EQ(100, y); | 93 EXPECT_EQ(100, y); |
94 | 94 |
95 // In letterboxing, there is (1-2560*(1200/1920)/1700)/2 = 2.95% of the | 95 // In letterboxing, there is (1-2560*(1200/1920)/1700)/2 = 2.95% of the |
96 // height on both the top & bottom region of the screen is blank. | 96 // height on both the top & bottom region of the screen is blank. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 Shell::GetInstance()->touch_transformer_controller(); | 141 Shell::GetInstance()->touch_transformer_controller(); |
142 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 142 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
143 | 143 |
144 device_manager->UpdateTouchInfoForDisplay( | 144 device_manager->UpdateTouchInfoForDisplay( |
145 internal_display_info.id(), internal_display_info.touch_device_id(), | 145 internal_display_info.id(), internal_display_info.touch_device_id(), |
146 tt_controller->GetTouchTransform(internal_display_info, | 146 tt_controller->GetTouchTransform(internal_display_info, |
147 internal_display_info, | 147 internal_display_info, |
148 internal_touchscreen, fb_size)); | 148 internal_touchscreen, fb_size)); |
149 | 149 |
150 device_manager->UpdateTouchInfoForDisplay( | 150 device_manager->UpdateTouchInfoForDisplay( |
151 external_display_info.id(), external_display_info.touch_device_id(), | 151 internal_display_info.id(), external_display_info.touch_device_id(), |
152 tt_controller->GetTouchTransform(external_display_info, | 152 tt_controller->GetTouchTransform(external_display_info, |
153 external_display_info, | 153 external_display_info, |
154 external_touchscreen, fb_size)); | 154 external_touchscreen, fb_size)); |
155 | 155 |
156 EXPECT_EQ(1, device_manager->GetDisplayForTouchDevice(10)); | 156 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(10)); |
157 EXPECT_EQ(2, device_manager->GetDisplayForTouchDevice(11)); | 157 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(11)); |
158 | 158 |
159 // External touch display has the default TouchTransformer. | 159 // External touch display has the default TouchTransformer. |
160 float x = 100.0; | 160 float x = 100.0; |
161 float y = 100.0; | 161 float y = 100.0; |
162 device_manager->ApplyTouchTransformer(11, &x, &y); | 162 device_manager->ApplyTouchTransformer(11, &x, &y); |
163 EXPECT_EQ(100, x); | 163 EXPECT_EQ(100, x); |
164 EXPECT_EQ(100, y); | 164 EXPECT_EQ(100, y); |
165 | 165 |
166 // In pillarboxing, there is (1-768*(1024/768)/1366)/2 = 12.5% of the | 166 // In pillarboxing, there is (1-768*(1024/768)/1366)/2 = 12.5% of the |
167 // width on both the left & rigth region of the screen is blank. | 167 // width on both the left & rigth region of the screen is blank. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 TouchTransformerController* tt_controller = | 214 TouchTransformerController* tt_controller = |
215 Shell::GetInstance()->touch_transformer_controller(); | 215 Shell::GetInstance()->touch_transformer_controller(); |
216 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); | 216 ui::DeviceDataManager* device_manager = ui::DeviceDataManager::GetInstance(); |
217 | 217 |
218 device_manager->UpdateTouchInfoForDisplay( | 218 device_manager->UpdateTouchInfoForDisplay( |
219 display1_info.id(), display1_info.touch_device_id(), | 219 display1_info.id(), display1_info.touch_device_id(), |
220 tt_controller->GetTouchTransform(display1_info, display1_info, | 220 tt_controller->GetTouchTransform(display1_info, display1_info, |
221 display1_touchscreen, fb_size)); | 221 display1_touchscreen, fb_size)); |
222 | 222 |
223 device_manager->UpdateTouchInfoForDisplay( | 223 device_manager->UpdateTouchInfoForDisplay( |
224 display2_info.id(), display2_info.touch_device_id(), | 224 display1_info.id(), display2_info.touch_device_id(), |
225 tt_controller->GetTouchTransform(display1_info, display2_info, | 225 tt_controller->GetTouchTransform(display1_info, display2_info, |
226 display2_touchscreen, fb_size)); | 226 display2_touchscreen, fb_size)); |
227 | 227 |
228 EXPECT_EQ(1, device_manager->GetDisplayForTouchDevice(10)); | 228 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(10)); |
229 EXPECT_EQ(2, device_manager->GetDisplayForTouchDevice(11)); | 229 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(11)); |
230 | 230 |
231 // Mapping for touch events from display 1's touchscreen: | 231 // Mapping for touch events from display 1's touchscreen: |
232 // [0, 1920) x [0, 1990) -> [0, 1280) x [0, 850) | 232 // [0, 1920) x [0, 1990) -> [0, 1280) x [0, 850) |
233 float x = 0.0; | 233 float x = 0.0; |
234 float y = 0.0; | 234 float y = 0.0; |
235 device_manager->ApplyTouchTransformer(10, &x, &y); | 235 device_manager->ApplyTouchTransformer(10, &x, &y); |
236 EXPECT_NEAR(0, x, 0.5); | 236 EXPECT_NEAR(0, x, 0.5); |
237 EXPECT_NEAR(0, y, 0.5); | 237 EXPECT_NEAR(0, y, 0.5); |
238 | 238 |
239 x = 1920.0; | 239 x = 1920.0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 device_manager->UpdateTouchInfoForDisplay( | 288 device_manager->UpdateTouchInfoForDisplay( |
289 display1.id(), display1.touch_device_id(), | 289 display1.id(), display1.touch_device_id(), |
290 tt_controller->GetTouchTransform(display1, display1, touchscreen1, | 290 tt_controller->GetTouchTransform(display1, display1, touchscreen1, |
291 fb_size)); | 291 fb_size)); |
292 | 292 |
293 device_manager->UpdateTouchInfoForDisplay( | 293 device_manager->UpdateTouchInfoForDisplay( |
294 display2.id(), display2.touch_device_id(), | 294 display2.id(), display2.touch_device_id(), |
295 tt_controller->GetTouchTransform(display2, display2, touchscreen2, | 295 tt_controller->GetTouchTransform(display2, display2, touchscreen2, |
296 fb_size)); | 296 fb_size)); |
297 | 297 |
298 EXPECT_EQ(1, device_manager->GetDisplayForTouchDevice(5)); | 298 EXPECT_EQ(1, device_manager->GetTargetDisplayForTouchDevice(5)); |
299 EXPECT_EQ(2, device_manager->GetDisplayForTouchDevice(6)); | 299 EXPECT_EQ(2, device_manager->GetTargetDisplayForTouchDevice(6)); |
300 | 300 |
301 // Mapping for touch events from internal touch display: | 301 // Mapping for touch events from internal touch display: |
302 // [0, 2560) x [0, 2428) -> [0, 1366) x [0, 768) | 302 // [0, 2560) x [0, 2428) -> [0, 1366) x [0, 768) |
303 float x = 0.0; | 303 float x = 0.0; |
304 float y = 0.0; | 304 float y = 0.0; |
305 device_manager->ApplyTouchTransformer(5, &x, &y); | 305 device_manager->ApplyTouchTransformer(5, &x, &y); |
306 EXPECT_NEAR(0, x, 0.5); | 306 EXPECT_NEAR(0, x, 0.5); |
307 EXPECT_NEAR(0, y, 0.5); | 307 EXPECT_NEAR(0, y, 0.5); |
308 | 308 |
309 x = 2559.0; | 309 x = 2559.0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 CreateTouchscreenDevice(5, gfx::Size(1001, 1001)); | 345 CreateTouchscreenDevice(5, gfx::Size(1001, 1001)); |
346 | 346 |
347 TouchTransformerController* tt_controller = | 347 TouchTransformerController* tt_controller = |
348 Shell::GetInstance()->touch_transformer_controller(); | 348 Shell::GetInstance()->touch_transformer_controller(); |
349 // Default touchscreen position range is 1001x1001; | 349 // Default touchscreen position range is 1001x1001; |
350 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)), | 350 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)), |
351 tt_controller->GetTouchResolutionScale(display, touch_device)); | 351 tt_controller->GetTouchResolutionScale(display, touch_device)); |
352 } | 352 } |
353 | 353 |
354 } // namespace ash | 354 } // namespace ash |
OLD | NEW |