OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/display/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/common/shelf/shelf_widget.h" | 9 #include "ash/common/shelf/shelf_widget.h" |
10 #include "ash/display/display_util.h" | 10 #include "ash/display/display_util.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 float scroll_x_offset_; | 106 float scroll_x_offset_; |
107 float scroll_y_offset_; | 107 float scroll_y_offset_; |
108 float scroll_x_offset_ordinal_; | 108 float scroll_x_offset_ordinal_; |
109 float scroll_y_offset_ordinal_; | 109 float scroll_y_offset_ordinal_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 111 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
112 }; | 112 }; |
113 | 113 |
114 class RootWindowTransformersTest : public test::AshTestBase { | 114 class RootWindowTransformersTest : public test::AshTestBase { |
115 public: | 115 public: |
116 RootWindowTransformersTest(){}; | 116 RootWindowTransformersTest() {} |
117 ~RootWindowTransformersTest() override{}; | 117 ~RootWindowTransformersTest() override {} |
118 | 118 |
119 float GetStoredUIScale(int64_t id) { | 119 float GetStoredUIScale(int64_t id) { |
120 return display_manager()->GetDisplayInfo(id).GetEffectiveUIScale(); | 120 return display_manager()->GetDisplayInfo(id).GetEffectiveUIScale(); |
121 }; | 121 } |
122 | 122 |
123 std::unique_ptr<RootWindowTransformer> | 123 std::unique_ptr<RootWindowTransformer> |
124 CreateCurrentRootWindowTransformerForMirroring() { | 124 CreateCurrentRootWindowTransformerForMirroring() { |
125 DCHECK(display_manager()->IsInMirrorMode()); | 125 DCHECK(display_manager()->IsInMirrorMode()); |
126 const display::ManagedDisplayInfo& mirror_display_info = | 126 const display::ManagedDisplayInfo& mirror_display_info = |
127 display_manager()->GetDisplayInfo( | 127 display_manager()->GetDisplayInfo( |
128 display_manager()->mirroring_display_id()); | 128 display_manager()->mirroring_display_id()); |
129 const display::ManagedDisplayInfo& source_display_info = | 129 const display::ManagedDisplayInfo& source_display_info = |
130 display_manager()->GetDisplayInfo( | 130 display_manager()->GetDisplayInfo( |
131 display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 131 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
132 return std::unique_ptr<RootWindowTransformer>( | 132 return std::unique_ptr<RootWindowTransformer>( |
133 CreateRootWindowTransformerForMirroredDisplay(source_display_info, | 133 CreateRootWindowTransformerForMirroredDisplay(source_display_info, |
134 mirror_display_info)); | 134 mirror_display_info)); |
135 }; | 135 } |
136 | 136 |
137 DISALLOW_COPY_AND_ASSIGN(RootWindowTransformersTest); | 137 DISALLOW_COPY_AND_ASSIGN(RootWindowTransformersTest); |
138 }; | 138 }; |
139 | 139 |
140 } // namespace | 140 } // namespace |
141 | 141 |
142 // using RootWindowTransformersTest = test::AshTestBase; | 142 // using RootWindowTransformersTest = test::AshTestBase; |
143 | 143 |
144 #if defined(OS_WIN) | 144 TEST_F(RootWindowTransformersTest, RotateAndMagnify) { |
145 // TODO(scottmg): RootWindow doesn't get resized on Windows | |
146 // Ash. http://crbug.com/247916. | |
147 #define MAYBE_RotateAndMagnify DISABLED_RotateAndMagniy | |
148 #define MAYBE_TouchScaleAndMagnify DISABLED_TouchScaleAndMagnify | |
149 #define MAYBE_ConvertHostToRootCoords DISABLED_ConvertHostToRootCoords | |
150 #else | |
151 #define MAYBE_RotateAndMagnify RotateAndMagniy | |
152 #define MAYBE_TouchScaleAndMagnify TouchScaleAndMagnify | |
153 #define MAYBE_ConvertHostToRootCoords ConvertHostToRootCoords | |
154 #endif | |
155 | |
156 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { | |
157 MagnificationController* magnifier = Shell::Get()->magnification_controller(); | 145 MagnificationController* magnifier = Shell::Get()->magnification_controller(); |
158 | 146 |
159 TestEventHandler event_handler; | 147 TestEventHandler event_handler; |
160 Shell::Get()->AddPreTargetHandler(&event_handler); | 148 Shell::Get()->AddPreTargetHandler(&event_handler); |
161 | 149 |
162 UpdateDisplay("120x200,300x400*2"); | 150 UpdateDisplay("120x200,300x400*2"); |
163 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 151 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
164 int64_t display2_id = display_manager()->GetSecondaryDisplay().id(); | 152 int64_t display2_id = display_manager()->GetSecondaryDisplay().id(); |
165 | 153 |
166 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 154 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 276 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
289 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 277 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
290 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 278 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
291 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 279 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
292 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 280 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
293 magnifier->SetEnabled(false); | 281 magnifier->SetEnabled(false); |
294 | 282 |
295 Shell::Get()->RemovePreTargetHandler(&event_handler); | 283 Shell::Get()->RemovePreTargetHandler(&event_handler); |
296 } | 284 } |
297 | 285 |
298 TEST_F(RootWindowTransformersTest, MAYBE_TouchScaleAndMagnify) { | 286 TEST_F(RootWindowTransformersTest, TouchScaleAndMagnify) { |
299 TestEventHandler event_handler; | 287 TestEventHandler event_handler; |
300 Shell::Get()->AddPreTargetHandler(&event_handler); | 288 Shell::Get()->AddPreTargetHandler(&event_handler); |
301 | 289 |
302 UpdateDisplay("200x200*2"); | 290 UpdateDisplay("200x200*2"); |
303 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 291 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
304 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 292 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
305 aura::Window* root_window = root_windows[0]; | 293 aura::Window* root_window = root_windows[0]; |
306 ui::test::EventGenerator generator(root_window); | 294 ui::test::EventGenerator generator(root_window); |
307 MagnificationController* magnifier = Shell::Get()->magnification_controller(); | 295 MagnificationController* magnifier = Shell::Get()->magnification_controller(); |
308 | 296 |
(...skipping 14 matching lines...) Expand all Loading... |
323 // ordinal_offset is invariant to the device scale factor. | 311 // ordinal_offset is invariant to the device scale factor. |
324 EXPECT_FLOAT_EQ(event_handler.scroll_x_offset(), | 312 EXPECT_FLOAT_EQ(event_handler.scroll_x_offset(), |
325 event_handler.scroll_x_offset_ordinal()); | 313 event_handler.scroll_x_offset_ordinal()); |
326 EXPECT_FLOAT_EQ(event_handler.scroll_y_offset(), | 314 EXPECT_FLOAT_EQ(event_handler.scroll_y_offset(), |
327 event_handler.scroll_y_offset_ordinal()); | 315 event_handler.scroll_y_offset_ordinal()); |
328 magnifier->SetEnabled(false); | 316 magnifier->SetEnabled(false); |
329 | 317 |
330 Shell::Get()->RemovePreTargetHandler(&event_handler); | 318 Shell::Get()->RemovePreTargetHandler(&event_handler); |
331 } | 319 } |
332 | 320 |
333 TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { | 321 TEST_F(RootWindowTransformersTest, ConvertHostToRootCoords) { |
334 TestEventHandler event_handler; | 322 TestEventHandler event_handler; |
335 Shell::Get()->AddPreTargetHandler(&event_handler); | 323 Shell::Get()->AddPreTargetHandler(&event_handler); |
336 MagnificationController* magnifier = Shell::Get()->magnification_controller(); | 324 MagnificationController* magnifier = Shell::Get()->magnification_controller(); |
337 | 325 |
338 // Test 1 | 326 // Test 1 |
339 UpdateDisplay("600x400*2/r@1.5"); | 327 UpdateDisplay("600x400*2/r@1.5"); |
340 | 328 |
341 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 329 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
342 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 330 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
343 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 331 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 412 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
425 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 413 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
426 | 414 |
427 UpdateDisplay("200x400,500x500"); | 415 UpdateDisplay("200x400,500x500"); |
428 // The aspect ratio is flipped, so X margin is now 125. | 416 // The aspect ratio is flipped, so X margin is now 125. |
429 transformer = CreateCurrentRootWindowTransformerForMirroring(); | 417 transformer = CreateCurrentRootWindowTransformerForMirroring(); |
430 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 418 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
431 } | 419 } |
432 | 420 |
433 } // namespace ash | 421 } // namespace ash |
OLD | NEW |