OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/display_controller.h" | 5 #include "ash/display/display_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/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/gfx/display.h" | 10 #include "ui/gfx/display.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 class DisplayControllerTest : public test::AshTestBase { | 32 class DisplayControllerTest : public test::AshTestBase { |
33 public: | 33 public: |
34 DisplayControllerTest() {} | 34 DisplayControllerTest() {} |
35 virtual ~DisplayControllerTest() {} | 35 virtual ~DisplayControllerTest() {} |
36 | 36 |
37 virtual void SetUp() OVERRIDE { | 37 virtual void SetUp() OVERRIDE { |
38 internal::DisplayController::SetExtendedDesktopEnabled(true); | 38 internal::DisplayController::SetExtendedDesktopEnabled(true); |
39 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | |
40 AshTestBase::SetUp(); | 39 AshTestBase::SetUp(); |
41 } | 40 } |
42 | 41 |
43 virtual void TearDown() OVERRIDE { | 42 virtual void TearDown() OVERRIDE { |
44 AshTestBase::TearDown(); | 43 AshTestBase::TearDown(); |
45 internal::DisplayController::SetExtendedDesktopEnabled(false); | 44 internal::DisplayController::SetExtendedDesktopEnabled(false); |
46 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
47 } | 45 } |
48 | 46 |
49 private: | 47 private: |
50 DISALLOW_COPY_AND_ASSIGN(DisplayControllerTest); | 48 DISALLOW_COPY_AND_ASSIGN(DisplayControllerTest); |
51 }; | 49 }; |
52 | 50 |
53 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
54 // TOD(oshima): Windows creates a window with smaller client area. | 52 // TOD(oshima): Windows creates a window with smaller client area. |
55 // Fix this and enable tests. | 53 // Fix this and enable tests. |
56 #define MAYBE_SecondaryDisplayLayout DISABLED_SecondaryDisplayLayout | 54 #define MAYBE_SecondaryDisplayLayout DISABLED_SecondaryDisplayLayout |
57 #define MAYBE_BoundsUpdated DISABLED_BoundsUpdated | 55 #define MAYBE_BoundsUpdated DISABLED_BoundsUpdated |
58 #else | 56 #else |
59 #define MAYBE_SecondaryDisplayLayout SecondaryDisplayLayout | 57 #define MAYBE_SecondaryDisplayLayout SecondaryDisplayLayout |
60 #define MAYBE_BoundsUpdated BoundsUpdated | 58 #define MAYBE_BoundsUpdated BoundsUpdated |
61 #endif | 59 #endif |
62 | 60 |
63 TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) { | 61 TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) { |
64 UpdateDisplay("0+0-500x500,0+0-400x400"); | 62 UpdateDisplay("500x500,400x400"); |
65 gfx::Display* secondary_display = | 63 gfx::Display* secondary_display = |
66 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); | 64 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); |
67 gfx::Insets insets(5, 5, 5, 5); | 65 gfx::Insets insets(5, 5, 5, 5); |
68 secondary_display->UpdateWorkAreaFromInsets(insets); | 66 secondary_display->UpdateWorkAreaFromInsets(insets); |
69 | 67 |
70 // Default layout is LEFT. | 68 // Default layout is LEFT. |
71 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 69 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
72 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString()); | 70 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString()); |
73 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString()); | 71 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString()); |
74 | 72 |
(...skipping 15 matching lines...) Expand all Loading... |
90 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 88 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
91 internal::DisplayController::TOP); | 89 internal::DisplayController::TOP); |
92 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 90 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
93 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString()); | 91 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString()); |
94 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString()); | 92 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString()); |
95 } | 93 } |
96 | 94 |
97 TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) { | 95 TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) { |
98 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 96 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
99 internal::DisplayController::BOTTOM); | 97 internal::DisplayController::BOTTOM); |
100 UpdateDisplay("0+0-500x500,0+0-400x400"); | 98 UpdateDisplay("500x500,400x400"); |
101 gfx::Display* secondary_display = | 99 gfx::Display* secondary_display = |
102 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); | 100 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); |
103 gfx::Insets insets(5, 5, 5, 5); | 101 gfx::Insets insets(5, 5, 5, 5); |
104 secondary_display->UpdateWorkAreaFromInsets(insets); | 102 secondary_display->UpdateWorkAreaFromInsets(insets); |
105 | 103 |
106 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 104 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
107 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); | 105 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); |
108 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); | 106 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); |
109 | 107 |
110 UpdateDisplay("0+0-600x600,0+0-400x400"); | 108 UpdateDisplay("600x600,400x400"); |
111 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString()); | 109 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString()); |
112 EXPECT_EQ("0,600 400x400", GetSecondaryDisplay().bounds().ToString()); | 110 EXPECT_EQ("0,600 400x400", GetSecondaryDisplay().bounds().ToString()); |
113 EXPECT_EQ("5,605 390x390", GetSecondaryDisplay().work_area().ToString()); | 111 EXPECT_EQ("5,605 390x390", GetSecondaryDisplay().work_area().ToString()); |
114 | 112 |
115 UpdateDisplay("0+0-600x600,0+0-500x500"); | 113 UpdateDisplay("600x600,500x500"); |
116 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString()); | 114 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString()); |
117 EXPECT_EQ("0,600 500x500", GetSecondaryDisplay().bounds().ToString()); | 115 EXPECT_EQ("0,600 500x500", GetSecondaryDisplay().bounds().ToString()); |
118 EXPECT_EQ("5,605 490x490", GetSecondaryDisplay().work_area().ToString()); | 116 EXPECT_EQ("5,605 490x490", GetSecondaryDisplay().work_area().ToString()); |
119 | 117 |
120 UpdateDisplay("0+0-600x600"); | 118 UpdateDisplay("600x600"); |
121 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString()); | 119 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString()); |
122 EXPECT_EQ(1, gfx::Screen::GetNumDisplays()); | 120 EXPECT_EQ(1, gfx::Screen::GetNumDisplays()); |
123 | 121 |
124 UpdateDisplay("0+0-700x700,0+0-1000x1000"); | 122 UpdateDisplay("700x700,1000x1000"); |
125 ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); | 123 ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); |
126 EXPECT_EQ("0,0 700x700", GetPrimaryDisplay().bounds().ToString()); | 124 EXPECT_EQ("0,0 700x700", GetPrimaryDisplay().bounds().ToString()); |
127 EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString()); | 125 EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString()); |
128 } | 126 } |
129 | 127 |
130 } // namespace test | 128 } // namespace test |
131 } // namespace ash | 129 } // namespace ash |
OLD | NEW |