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

Side by Side Diff: ash/display/root_window_transformers_unittest.cc

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: Created 4 years, 2 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 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_manager.h"
11 #include "ash/display/display_util.h" 10 #include "ash/display/display_util.h"
12 #include "ash/host/root_window_transformer.h" 11 #include "ash/host/root_window_transformer.h"
13 #include "ash/magnifier/magnification_controller.h" 12 #include "ash/magnifier/magnification_controller.h"
14 #include "ash/screen_util.h" 13 #include "ash/screen_util.h"
15 #include "ash/shell.h" 14 #include "ash/shell.h"
16 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
17 #include "ash/test/cursor_manager_test_api.h" 16 #include "ash/test/cursor_manager_test_api.h"
18 #include "ash/test/display_manager_test_api.h"
19 #include "ash/test/mirror_window_test_api.h" 17 #include "ash/test/mirror_window_test_api.h"
20 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
21 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
22 #include "ui/aura/window_event_dispatcher.h" 20 #include "ui/aura/window_event_dispatcher.h"
23 #include "ui/aura/window_tracker.h" 21 #include "ui/aura/window_tracker.h"
24 #include "ui/display/display.h" 22 #include "ui/display/display.h"
25 #include "ui/display/manager/display_layout.h" 23 #include "ui/display/manager/display_layout.h"
24 #include "ui/display/manager/display_manager.h"
26 #include "ui/display/manager/managed_display_info.h" 25 #include "ui/display/manager/managed_display_info.h"
27 #include "ui/display/screen.h" 26 #include "ui/display/screen.h"
27 #include "ui/display/test/display_manager_test_api.h"
28 #include "ui/events/event_handler.h" 28 #include "ui/events/event_handler.h"
29 #include "ui/events/test/event_generator.h" 29 #include "ui/events/test/event_generator.h"
30 #include "ui/gfx/geometry/rect_conversions.h" 30 #include "ui/gfx/geometry/rect_conversions.h"
31 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
32 32
33 namespace ash { 33 namespace ash {
34 namespace { 34 namespace {
35 35
36 const char kWallpaperView[] = "WallpaperView"; 36 const char kWallpaperView[] = "WallpaperView";
37 37
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 display_manager()->GetSecondaryDisplay().bounds().ToString()); 197 display_manager()->GetSecondaryDisplay().bounds().ToString());
198 generator1.MoveMouseToInHost(39, 120); 198 generator1.MoveMouseToInHost(39, 120);
199 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); 199 EXPECT_EQ("110,70", event_handler.GetLocationAndReset());
200 EXPECT_EQ("110,70", 200 EXPECT_EQ("110,70",
201 aura::Env::GetInstance()->last_mouse_location().ToString()); 201 aura::Env::GetInstance()->last_mouse_location().ToString());
202 EXPECT_EQ(display::Display::ROTATE_90, 202 EXPECT_EQ(display::Display::ROTATE_90,
203 GetActiveDisplayRotation(display1.id())); 203 GetActiveDisplayRotation(display1.id()));
204 EXPECT_EQ(display::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 204 EXPECT_EQ(display::Display::ROTATE_0, GetActiveDisplayRotation(display2_id));
205 magnifier->SetEnabled(false); 205 magnifier->SetEnabled(false);
206 206
207 display_manager()->SetLayoutForCurrentDisplays(test::CreateDisplayLayout( 207 display_manager()->SetLayoutForCurrentDisplays(
208 display_manager(), display::DisplayPlacement::BOTTOM, 50)); 208 display::test::CreateDisplayLayout(
209 display_manager(), display::DisplayPlacement::BOTTOM, 50));
209 EXPECT_EQ("50,120 150x200", 210 EXPECT_EQ("50,120 150x200",
210 display_manager()->GetSecondaryDisplay().bounds().ToString()); 211 display_manager()->GetSecondaryDisplay().bounds().ToString());
211 212
212 display_manager()->SetDisplayRotation( 213 display_manager()->SetDisplayRotation(
213 display2_id, display::Display::ROTATE_270, 214 display2_id, display::Display::ROTATE_270,
214 display::Display::ROTATION_SOURCE_ACTIVE); 215 display::Display::ROTATION_SOURCE_ACTIVE);
215 // Move the cursor to the center of the second root window. 216 // Move the cursor to the center of the second root window.
216 generator2.MoveMouseToInHost(151, 199); 217 generator2.MoveMouseToInHost(151, 199);
217 218
218 magnifier->SetEnabled(true); 219 magnifier->SetEnabled(true);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { 257 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) {
257 if (!SupportsMultipleDisplays()) 258 if (!SupportsMultipleDisplays())
258 return; 259 return;
259 260
260 TestEventHandler event_handler; 261 TestEventHandler event_handler;
261 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 262 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
262 263
263 UpdateDisplay("600x400*2@1.5,500x300"); 264 UpdateDisplay("600x400*2@1.5,500x300");
264 265
265 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); 266 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
266 test::ScopedSetInternalDisplayId set_internal(display_manager(), 267 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
267 display1.id()); 268 display1.id());
268 display::Display display2 = display_manager()->GetSecondaryDisplay(); 269 display::Display display2 = display_manager()->GetSecondaryDisplay();
269 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 270 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
270 MagnificationController* magnifier = 271 MagnificationController* magnifier =
271 Shell::GetInstance()->magnification_controller(); 272 Shell::GetInstance()->magnification_controller();
272 273
273 magnifier->SetEnabled(true); 274 magnifier->SetEnabled(true);
274 EXPECT_EQ(2.0f, magnifier->GetScale()); 275 EXPECT_EQ(2.0f, magnifier->GetScale());
275 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 276 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
276 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 277 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
277 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); 278 EXPECT_EQ("450,0 500x300", display2.bounds().ToString());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 magnifier->SetEnabled(false); 418 magnifier->SetEnabled(false);
418 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); 419 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale());
419 420
420 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 421 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
421 } 422 }
422 423
423 TEST_F(RootWindowTransformersTest, LetterBoxPillarBox) { 424 TEST_F(RootWindowTransformersTest, LetterBoxPillarBox) {
424 if (!SupportsMultipleDisplays()) 425 if (!SupportsMultipleDisplays())
425 return; 426 return;
426 test::MirrorWindowTestApi test_api; 427 test::MirrorWindowTestApi test_api;
427 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING); 428 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
428 UpdateDisplay("400x200,500x500"); 429 UpdateDisplay("400x200,500x500");
429 std::unique_ptr<RootWindowTransformer> transformer( 430 std::unique_ptr<RootWindowTransformer> transformer(
430 CreateCurrentRootWindowTransformerForMirroring()); 431 CreateCurrentRootWindowTransformerForMirroring());
431 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. 432 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125.
432 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); 433 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString());
433 434
434 UpdateDisplay("200x400,500x500"); 435 UpdateDisplay("200x400,500x500");
435 // The aspect ratio is flipped, so X margin is now 125. 436 // The aspect ratio is flipped, so X margin is now 125.
436 transformer = CreateCurrentRootWindowTransformerForMirroring(); 437 transformer = CreateCurrentRootWindowTransformerForMirroring();
437 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); 438 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString());
438 } 439 }
439 440
440 } // namespace ash 441 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698