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/device_data_manager.h" | 10 #include "ui/events/device_data_manager.h" |
| 11 #include "ui/events/test/events_test_utils_x11.h" |
11 #include "ui/gfx/display.h" | 12 #include "ui/gfx/display.h" |
12 | 13 |
13 namespace ash { | 14 namespace ash { |
14 | 15 |
15 namespace { | 16 namespace { |
16 DisplayInfo CreateDisplayInfo(int64 id, | 17 DisplayInfo CreateDisplayInfo(int64 id, |
17 int touch_device_id, | 18 int touch_device_id, |
18 const gfx::Rect& bounds) { | 19 const gfx::Rect& bounds) { |
19 DisplayInfo info(id, std::string(), false); | 20 DisplayInfo info(id, std::string(), false); |
20 info.SetBounds(bounds); | 21 info.SetBounds(bounds); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 EXPECT_EQ(0, static_cast<int>(x)); | 197 EXPECT_EQ(0, static_cast<int>(x)); |
197 EXPECT_EQ(0, static_cast<int>(y)); | 198 EXPECT_EQ(0, static_cast<int>(y)); |
198 | 199 |
199 x = 2559.0; | 200 x = 2559.0; |
200 y = 2427.0; | 201 y = 2427.0; |
201 device_manager->ApplyTouchTransformer(6, &x, &y); | 202 device_manager->ApplyTouchTransformer(6, &x, &y); |
202 EXPECT_EQ(2559, static_cast<int>(x)); | 203 EXPECT_EQ(2559, static_cast<int>(x)); |
203 EXPECT_EQ(1599, static_cast<int>(y)); | 204 EXPECT_EQ(1599, static_cast<int>(y)); |
204 } | 205 } |
205 | 206 |
| 207 TEST_F(TouchTransformerControllerTest, TouchRadiusScale) { |
| 208 DisplayInfo display = CreateDisplayInfo(1, 5, gfx::Rect(0, 0, 2560, 1600)); |
| 209 std::vector<unsigned int> devices; |
| 210 devices.push_back(5); |
| 211 ui::SetUpTouchDevicesForTest(devices); |
| 212 |
| 213 TouchTransformerController* tt_controller = |
| 214 Shell::GetInstance()->touch_transformer_controller(); |
| 215 // Default touchscreen position range is 1001x1001; |
| 216 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)), |
| 217 tt_controller->GetTouchResolutionScale(display)); |
| 218 } |
| 219 |
206 } // namespace ash | 220 } // namespace ash |
OLD | NEW |