| 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> |
| 8 |
| 7 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
| 8 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 9 #include "ash/display/display_util.h" | 11 #include "ash/display/display_util.h" |
| 10 #include "ash/host/root_window_transformer.h" | 12 #include "ash/host/root_window_transformer.h" |
| 11 #include "ash/magnifier/magnification_controller.h" | 13 #include "ash/magnifier/magnification_controller.h" |
| 12 #include "ash/screen_util.h" | 14 #include "ash/screen_util.h" |
| 13 #include "ash/shelf/shelf.h" | 15 #include "ash/shelf/shelf.h" |
| 14 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
| 15 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 16 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 float scroll_y_offset_ordinal_; | 110 float scroll_y_offset_ordinal_; |
| 109 | 111 |
| 110 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 112 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 float GetStoredUIScale(int64_t id) { | 115 float GetStoredUIScale(int64_t id) { |
| 114 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). | 116 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). |
| 115 GetEffectiveUIScale(); | 117 GetEffectiveUIScale(); |
| 116 } | 118 } |
| 117 | 119 |
| 118 scoped_ptr<RootWindowTransformer> | 120 std::unique_ptr<RootWindowTransformer> |
| 119 CreateCurrentRootWindowTransformerForMirroring() { | 121 CreateCurrentRootWindowTransformerForMirroring() { |
| 120 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 122 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 121 DCHECK(display_manager->IsInMirrorMode()); | 123 DCHECK(display_manager->IsInMirrorMode()); |
| 122 const DisplayInfo& mirror_display_info = | 124 const DisplayInfo& mirror_display_info = |
| 123 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); | 125 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); |
| 124 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 126 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
| 125 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); | 127 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 126 return scoped_ptr<RootWindowTransformer>( | 128 return std::unique_ptr<RootWindowTransformer>( |
| 127 CreateRootWindowTransformerForMirroredDisplay(source_display_info, | 129 CreateRootWindowTransformerForMirroredDisplay(source_display_info, |
| 128 mirror_display_info)); | 130 mirror_display_info)); |
| 129 } | 131 } |
| 130 | 132 |
| 131 } // namespace | 133 } // namespace |
| 132 | 134 |
| 133 typedef test::AshTestBase RootWindowTransformersTest; | 135 typedef test::AshTestBase RootWindowTransformersTest; |
| 134 | 136 |
| 135 #if defined(OS_WIN) | 137 #if defined(OS_WIN) |
| 136 // TODO(scottmg): RootWindow doesn't get resized on Windows | 138 // TODO(scottmg): RootWindow doesn't get resized on Windows |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 404 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 403 } | 405 } |
| 404 | 406 |
| 405 TEST_F(RootWindowTransformersTest, LetterBoxPillarBox) { | 407 TEST_F(RootWindowTransformersTest, LetterBoxPillarBox) { |
| 406 if (!SupportsMultipleDisplays()) | 408 if (!SupportsMultipleDisplays()) |
| 407 return; | 409 return; |
| 408 test::MirrorWindowTestApi test_api; | 410 test::MirrorWindowTestApi test_api; |
| 409 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 411 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 410 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); | 412 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
| 411 UpdateDisplay("400x200,500x500"); | 413 UpdateDisplay("400x200,500x500"); |
| 412 scoped_ptr<RootWindowTransformer> transformer( | 414 std::unique_ptr<RootWindowTransformer> transformer( |
| 413 CreateCurrentRootWindowTransformerForMirroring()); | 415 CreateCurrentRootWindowTransformerForMirroring()); |
| 414 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 416 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
| 415 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 417 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
| 416 | 418 |
| 417 UpdateDisplay("200x400,500x500"); | 419 UpdateDisplay("200x400,500x500"); |
| 418 // The aspect ratio is flipped, so X margin is now 125. | 420 // The aspect ratio is flipped, so X margin is now 125. |
| 419 transformer = CreateCurrentRootWindowTransformerForMirroring(); | 421 transformer = CreateCurrentRootWindowTransformerForMirroring(); |
| 420 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 422 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
| 421 } | 423 } |
| 422 | 424 |
| 423 } // namespace ash | 425 } // namespace ash |
| OLD | NEW |