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 #include "ash/display/multi_display_manager.h" | 6 #include "ash/display/multi_display_manager.h" |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } // namespace | 61 } // namespace |
62 | 62 |
63 namespace test { | 63 namespace test { |
64 class RootWindowControllerTest : public test::AshTestBase { | 64 class RootWindowControllerTest : public test::AshTestBase { |
65 public: | 65 public: |
66 RootWindowControllerTest() {} | 66 RootWindowControllerTest() {} |
67 virtual ~RootWindowControllerTest() {} | 67 virtual ~RootWindowControllerTest() {} |
68 | 68 |
69 virtual void SetUp() OVERRIDE { | 69 virtual void SetUp() OVERRIDE { |
70 internal::DisplayController::SetExtendedDesktopEnabled(true); | 70 internal::DisplayController::SetExtendedDesktopEnabled(true); |
71 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | |
72 AshTestBase::SetUp(); | 71 AshTestBase::SetUp(); |
73 } | 72 } |
74 | 73 |
75 virtual void TearDown() OVERRIDE { | 74 virtual void TearDown() OVERRIDE { |
76 AshTestBase::TearDown(); | 75 AshTestBase::TearDown(); |
77 internal::DisplayController::SetExtendedDesktopEnabled(false); | 76 internal::DisplayController::SetExtendedDesktopEnabled(false); |
78 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
79 } | 77 } |
80 | 78 |
81 private: | 79 private: |
82 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerTest); | 80 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerTest); |
83 }; | 81 }; |
84 | 82 |
85 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 83 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
86 UpdateDisplay("0+0-600x600,600+0-500x500"); | 84 UpdateDisplay("600x600,500x500"); |
87 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 85 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
88 | 86 |
89 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 87 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
90 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 88 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
91 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 89 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
92 EXPECT_EQ("50,10 100x100", | 90 EXPECT_EQ("50,10 100x100", |
93 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 91 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
94 | 92 |
95 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 93 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
96 maximized->Maximize(); | 94 maximized->Maximize(); |
(...skipping 15 matching lines...) Expand all Loading... |
112 fullscreen->SetFullscreen(true); | 110 fullscreen->SetFullscreen(true); |
113 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); | 111 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); |
114 #if !defined(OS_WIN) | 112 #if !defined(OS_WIN) |
115 // TODO(oshima): Window reports smaller screen size. Investigate why. | 113 // TODO(oshima): Window reports smaller screen size. Investigate why. |
116 EXPECT_EQ("600,0 500x500", | 114 EXPECT_EQ("600,0 500x500", |
117 fullscreen->GetWindowBoundsInScreen().ToString()); | 115 fullscreen->GetWindowBoundsInScreen().ToString()); |
118 EXPECT_EQ("0,0 500x500", | 116 EXPECT_EQ("0,0 500x500", |
119 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 117 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
120 #endif | 118 #endif |
121 | 119 |
122 UpdateDisplay("0+0-600x600"); | 120 UpdateDisplay("600x600"); |
123 | 121 |
124 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 122 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
125 EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 123 EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
126 EXPECT_EQ("50,10 100x100", | 124 EXPECT_EQ("50,10 100x100", |
127 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 125 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
128 | 126 |
129 // Maximized area on primary display has 2px (given as | 127 // Maximized area on primary display has 2px (given as |
130 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. | 128 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. |
131 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 129 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
132 EXPECT_EQ("0,0 600x598", | 130 EXPECT_EQ("0,0 600x598", |
(...skipping 19 matching lines...) Expand all Loading... |
152 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 150 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
153 | 151 |
154 fullscreen->SetFullscreen(false); | 152 fullscreen->SetFullscreen(false); |
155 EXPECT_EQ("300,10 100x100", | 153 EXPECT_EQ("300,10 100x100", |
156 fullscreen->GetWindowBoundsInScreen().ToString()); | 154 fullscreen->GetWindowBoundsInScreen().ToString()); |
157 EXPECT_EQ("300,10 100x100", | 155 EXPECT_EQ("300,10 100x100", |
158 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 156 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
159 } | 157 } |
160 | 158 |
161 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { | 159 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { |
162 UpdateDisplay("0+0-500x500,500+0-500x500"); | 160 UpdateDisplay("500x500,500x500"); |
163 | 161 |
164 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 162 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
165 // Emulate virtual screen coordinate system. | 163 // Emulate virtual screen coordinate system. |
166 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); | 164 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
167 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); | 165 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
168 | 166 |
169 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); | 167 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); |
170 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 168 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
171 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); | 169 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); |
172 | 170 |
173 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); | 171 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); |
174 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); | 172 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); |
175 EXPECT_TRUE(GetModalContainer(root_windows[1])->Contains( | 173 EXPECT_TRUE(GetModalContainer(root_windows[1])->Contains( |
176 modal->GetNativeView())); | 174 modal->GetNativeView())); |
177 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 175 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
178 | 176 |
179 aura::test::EventGenerator generator_1st(root_windows[0]); | 177 aura::test::EventGenerator generator_1st(root_windows[0]); |
180 generator_1st.ClickLeftButton(); | 178 generator_1st.ClickLeftButton(); |
181 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 179 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
182 | 180 |
183 UpdateDisplay("0+0-500x500"); | 181 UpdateDisplay("500x500"); |
184 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 182 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
185 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 183 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
186 generator_1st.ClickLeftButton(); | 184 generator_1st.ClickLeftButton(); |
187 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 185 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
188 } | 186 } |
189 | 187 |
190 } // namespace test | 188 } // namespace test |
191 } // namespace ash | 189 } // namespace ash |
OLD | NEW |