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

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

Issue 2196923002: Make ash::DisplayMode more like ui::DisplayMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 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 "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"
11 11
12 namespace ash { 12 namespace ash {
13 13
14 namespace { 14 namespace {
15 15
16 DisplayInfo CreateDisplayInfo(int64_t id, 16 DisplayInfo CreateDisplayInfo(int64_t id,
17 unsigned int touch_device_id, 17 unsigned int touch_device_id,
18 const gfx::Rect& bounds) { 18 const gfx::Rect& bounds) {
19 DisplayInfo info(id, std::string(), false); 19 DisplayInfo info(id, std::string(), false);
20 info.SetBounds(bounds); 20 info.SetBounds(bounds);
21 info.AddInputDevice(touch_device_id); 21 info.AddInputDevice(touch_device_id);
22 22
23 // Create a default mode. 23 // Create a default mode.
24 std::vector<DisplayMode> default_modes( 24 DisplayInfo::DisplayModeList default_modes(
25 1, DisplayMode(bounds.size(), 60, false, true)); 25 1, make_scoped_refptr(new DisplayMode(bounds.size(), 60, false, true)));
26 info.SetDisplayModes(default_modes); 26 info.SetDisplayModes(default_modes);
27 27
28 return info; 28 return info;
29 } 29 }
30 30
31 ui::TouchscreenDevice CreateTouchscreenDevice(unsigned int id, 31 ui::TouchscreenDevice CreateTouchscreenDevice(unsigned int id,
32 const gfx::Size& size) { 32 const gfx::Size& size) {
33 return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, 33 return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
34 std::string(), size, 0); 34 std::string(), size, 0);
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 typedef test::AshTestBase TouchTransformerControllerTest; 39 typedef test::AshTestBase TouchTransformerControllerTest;
40 40
41 TEST_F(TouchTransformerControllerTest, MirrorModeLetterboxing) { 41 TEST_F(TouchTransformerControllerTest, MirrorModeLetterboxing) {
42 // The internal display has native resolution of 2560x1700, and in 42 // The internal display has native resolution of 2560x1700, and in
43 // mirror mode it is configured as 1920x1200. This is in letterboxing 43 // mirror mode it is configured as 1920x1200. This is in letterboxing
44 // mode. 44 // mode.
45 DisplayInfo internal_display_info = 45 DisplayInfo internal_display_info =
46 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1920, 1200)); 46 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1920, 1200));
47 internal_display_info.set_is_aspect_preserving_scaling(true); 47 internal_display_info.set_is_aspect_preserving_scaling(true);
48 std::vector<DisplayMode> internal_modes; 48
49 internal_modes.push_back(DisplayMode(gfx::Size(2560, 1700), 60, false, true)); 49 DisplayInfo::DisplayModeList internal_modes;
50 internal_modes.push_back( 50
51 DisplayMode(gfx::Size(1920, 1200), 60, false, false)); 51 internal_modes.push_back(make_scoped_refptr(
52 new DisplayMode(gfx::Size(2560, 1700), 60, false, true)));
53 internal_modes.push_back(make_scoped_refptr(
54 new DisplayMode(gfx::Size(1920, 1200), 60, false, false)));
52 internal_display_info.SetDisplayModes(internal_modes); 55 internal_display_info.SetDisplayModes(internal_modes);
53 56
54 DisplayInfo external_display_info = 57 DisplayInfo external_display_info =
55 CreateDisplayInfo(2, 11u, gfx::Rect(0, 0, 1920, 1200)); 58 CreateDisplayInfo(2, 11u, gfx::Rect(0, 0, 1920, 1200));
56 59
57 gfx::Size fb_size(1920, 1200); 60 gfx::Size fb_size(1920, 1200);
58 61
59 // Create the touchscreens with the same size as the framebuffer so we can 62 // Create the touchscreens with the same size as the framebuffer so we can
60 // share the tests between Ozone & X11. 63 // share the tests between Ozone & X11.
61 ui::TouchscreenDevice internal_touchscreen = 64 ui::TouchscreenDevice internal_touchscreen =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 EXPECT_NEAR(1200, y, 0.5); 111 EXPECT_NEAR(1200, y, 0.5);
109 } 112 }
110 113
111 TEST_F(TouchTransformerControllerTest, MirrorModePillarboxing) { 114 TEST_F(TouchTransformerControllerTest, MirrorModePillarboxing) {
112 // The internal display has native resolution of 1366x768, and in 115 // The internal display has native resolution of 1366x768, and in
113 // mirror mode it is configured as 1024x768. This is in pillarboxing 116 // mirror mode it is configured as 1024x768. This is in pillarboxing
114 // mode. 117 // mode.
115 DisplayInfo internal_display_info = 118 DisplayInfo internal_display_info =
116 CreateDisplayInfo(1, 10, gfx::Rect(0, 0, 1024, 768)); 119 CreateDisplayInfo(1, 10, gfx::Rect(0, 0, 1024, 768));
117 internal_display_info.set_is_aspect_preserving_scaling(true); 120 internal_display_info.set_is_aspect_preserving_scaling(true);
118 std::vector<DisplayMode> internal_modes; 121 DisplayInfo::DisplayModeList internal_modes;
119 internal_modes.push_back(DisplayMode(gfx::Size(1366, 768), 60, false, true)); 122 internal_modes.push_back(make_scoped_refptr(
120 internal_modes.push_back(DisplayMode(gfx::Size(1024, 768), 60, false, false)); 123 new DisplayMode(gfx::Size(1366, 768), 60, false, true)));
124 internal_modes.push_back(make_scoped_refptr(
125 new DisplayMode(gfx::Size(1024, 768), 60, false, false)));
121 internal_display_info.SetDisplayModes(internal_modes); 126 internal_display_info.SetDisplayModes(internal_modes);
122 127
123 DisplayInfo external_display_info = 128 DisplayInfo external_display_info =
124 CreateDisplayInfo(2, 11, gfx::Rect(0, 0, 1024, 768)); 129 CreateDisplayInfo(2, 11, gfx::Rect(0, 0, 1024, 768));
125 130
126 gfx::Size fb_size(1024, 768); 131 gfx::Size fb_size(1024, 768);
127 132
128 // Create the touchscreens with the same size as the framebuffer so we can 133 // Create the touchscreens with the same size as the framebuffer so we can
129 // share the tests between Ozone & X11. 134 // share the tests between Ozone & X11.
130 ui::TouchscreenDevice internal_touchscreen = 135 ui::TouchscreenDevice internal_touchscreen =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 TEST_F(TouchTransformerControllerTest, SoftwareMirrorMode) { 185 TEST_F(TouchTransformerControllerTest, SoftwareMirrorMode) {
181 // External display 1 has size 1280x850. External display 2 has size 186 // External display 1 has size 1280x850. External display 2 has size
182 // 1920x1080. When using software mirroring to mirror display 1 onto 187 // 1920x1080. When using software mirroring to mirror display 1 onto
183 // display 2, the displays are in extended mode and we map touches from both 188 // display 2, the displays are in extended mode and we map touches from both
184 // displays to display 1. 189 // displays to display 1.
185 // The total frame buffer is 1920x1990, 190 // The total frame buffer is 1920x1990,
186 // where 1990 = 850 + 60 (hidden gap) + 1080 and the second monitor is 191 // where 1990 = 850 + 60 (hidden gap) + 1080 and the second monitor is
187 // translated to point (0, 950) in the framebuffer. 192 // translated to point (0, 950) in the framebuffer.
188 DisplayInfo display1_info = 193 DisplayInfo display1_info =
189 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1280, 850)); 194 CreateDisplayInfo(1, 10u, gfx::Rect(0, 0, 1280, 850));
190 std::vector<DisplayMode> display1_modes; 195 DisplayInfo::DisplayModeList display1_modes;
191 display1_modes.push_back(DisplayMode(gfx::Size(1280, 850), 60, false, true)); 196 display1_modes.push_back(make_scoped_refptr(
197 new DisplayMode(gfx::Size(1280, 850), 60, false, true)));
192 display1_info.SetDisplayModes(display1_modes); 198 display1_info.SetDisplayModes(display1_modes);
193 199
194 DisplayInfo display2_info = 200 DisplayInfo display2_info =
195 CreateDisplayInfo(2, 11u, gfx::Rect(0, 950, 1920, 1080)); 201 CreateDisplayInfo(2, 11u, gfx::Rect(0, 950, 1920, 1080));
196 std::vector<DisplayMode> display2_modes; 202 DisplayInfo::DisplayModeList display2_modes;
197 display2_modes.push_back(DisplayMode(gfx::Size(1920, 1080), 60, false, true)); 203 display2_modes.push_back(make_scoped_refptr(
204 new DisplayMode(gfx::Size(1920, 1080), 60, false, true)));
198 display2_info.SetDisplayModes(display2_modes); 205 display2_info.SetDisplayModes(display2_modes);
199 206
200 gfx::Size fb_size(1920, 1990); 207 gfx::Size fb_size(1920, 1990);
201 208
202 // Create the touchscreens with the same size as the framebuffer so we can 209 // Create the touchscreens with the same size as the framebuffer so we can
203 // share the tests between Ozone & X11. 210 // share the tests between Ozone & X11.
204 ui::TouchscreenDevice display1_touchscreen = 211 ui::TouchscreenDevice display1_touchscreen =
205 CreateTouchscreenDevice(10, fb_size); 212 CreateTouchscreenDevice(10, fb_size);
206 ui::TouchscreenDevice display2_touchscreen = 213 ui::TouchscreenDevice display2_touchscreen =
207 CreateTouchscreenDevice(11, fb_size); 214 CreateTouchscreenDevice(11, fb_size);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 CreateTouchscreenDevice(5, gfx::Size(1001, 1001)); 347 CreateTouchscreenDevice(5, gfx::Size(1001, 1001));
341 348
342 TouchTransformerController* tt_controller = 349 TouchTransformerController* tt_controller =
343 Shell::GetInstance()->touch_transformer_controller(); 350 Shell::GetInstance()->touch_transformer_controller();
344 // Default touchscreen position range is 1001x1001; 351 // Default touchscreen position range is 1001x1001;
345 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)), 352 EXPECT_EQ(sqrt((2560.0 * 1600.0) / (1001.0 * 1001.0)),
346 tt_controller->GetTouchResolutionScale(display, touch_device)); 353 tt_controller->GetTouchResolutionScale(display, touch_device));
347 } 354 }
348 355
349 } // namespace ash 356 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698