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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" |
9 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
11 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
12 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
13 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
14 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
16 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
17 #include "ash/test/display_manager_test_api.h" | 18 #include "ash/test/display_manager_test_api.h" |
| 19 #include "ash/test/material_design_controller_test_api.h" |
18 #include "ash/wm/system_modal_container_layout_manager.h" | 20 #include "ash/wm/system_modal_container_layout_manager.h" |
19 #include "ash/wm/window_properties.h" | 21 #include "ash/wm/window_properties.h" |
20 #include "ash/wm/window_state_aura.h" | 22 #include "ash/wm/window_state_aura.h" |
21 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
22 #include "base/command_line.h" | 24 #include "base/command_line.h" |
23 #include "ui/aura/client/focus_change_observer.h" | 25 #include "ui/aura/client/focus_change_observer.h" |
24 #include "ui/aura/client/focus_client.h" | 26 #include "ui/aura/client/focus_client.h" |
25 #include "ui/aura/client/window_tree_client.h" | 27 #include "ui/aura/client/window_tree_client.h" |
26 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
27 #include "ui/aura/test/test_window_delegate.h" | 29 #include "ui/aura/test/test_window_delegate.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 92 |
91 aura::Window* window_; | 93 aura::Window* window_; |
92 | 94 |
93 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
94 }; | 96 }; |
95 | 97 |
96 } // namespace | 98 } // namespace |
97 | 99 |
98 namespace test { | 100 namespace test { |
99 | 101 |
100 class RootWindowControllerTest : public test::AshTestBase { | 102 class RootWindowControllerTest |
| 103 : public test::AshTestBase, |
| 104 public testing::WithParamInterface<ash::MaterialDesignController::Mode> { |
101 public: | 105 public: |
| 106 RootWindowControllerTest() : md_maximized_window_height_offset_(0) {} |
| 107 |
| 108 void SetUp() override { |
| 109 test::AshTestBase::SetUp(); |
| 110 material_design_state_.reset( |
| 111 new test::MaterialDesignControllerTestAPI(GetParam())); |
| 112 md_maximized_window_height_offset_ = |
| 113 ash::MaterialDesignController::IsMaterial() ? -1 : 0; |
| 114 } |
| 115 |
| 116 void TearDown() override { |
| 117 material_design_state_.reset(); |
| 118 test::AshTestBase::TearDown(); |
| 119 } |
| 120 |
102 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | 121 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
103 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 122 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
104 NULL, CurrentContext(), bounds); | 123 NULL, CurrentContext(), bounds); |
105 widget->Show(); | 124 widget->Show(); |
106 return widget; | 125 return widget; |
107 } | 126 } |
108 | 127 |
109 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { | 128 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { |
110 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 129 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
111 new TestDelegate(true), CurrentContext(), bounds); | 130 new TestDelegate(true), CurrentContext(), bounds); |
112 widget->Show(); | 131 widget->Show(); |
113 return widget; | 132 return widget; |
114 } | 133 } |
115 | 134 |
116 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, | 135 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, |
117 gfx::NativeWindow parent) { | 136 gfx::NativeWindow parent) { |
118 views::Widget* widget = | 137 views::Widget* widget = |
119 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), | 138 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), |
120 parent, | 139 parent, |
121 bounds); | 140 bounds); |
122 widget->Show(); | 141 widget->Show(); |
123 return widget; | 142 return widget; |
124 } | 143 } |
125 | 144 |
126 aura::Window* GetModalContainer(aura::Window* root_window) { | 145 aura::Window* GetModalContainer(aura::Window* root_window) { |
127 return Shell::GetContainer(root_window, | 146 return Shell::GetContainer(root_window, |
128 ash::kShellWindowId_SystemModalContainer); | 147 ash::kShellWindowId_SystemModalContainer); |
129 } | 148 } |
| 149 |
| 150 int GetMdMaximizedWindowHeightOffset() { |
| 151 return md_maximized_window_height_offset_; |
| 152 } |
| 153 |
| 154 private: |
| 155 std::unique_ptr<test::MaterialDesignControllerTestAPI> |
| 156 material_design_state_; |
| 157 |
| 158 // The material design shelf is taller (by 1px) so use this offset to |
| 159 // adjust the expected height of a maximized window. |
| 160 int md_maximized_window_height_offset_; |
130 }; | 161 }; |
131 | 162 |
132 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 163 // Note: First argument is optional and intentionally left blank. |
| 164 // (it's a prefix for the generated test cases) |
| 165 INSTANTIATE_TEST_CASE_P( |
| 166 , |
| 167 RootWindowControllerTest, |
| 168 testing::Values(ash::MaterialDesignController::NON_MATERIAL, |
| 169 ash::MaterialDesignController::MATERIAL_NORMAL, |
| 170 ash::MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 171 |
| 172 TEST_P(RootWindowControllerTest, MoveWindows_Basic) { |
133 if (!SupportsMultipleDisplays()) | 173 if (!SupportsMultipleDisplays()) |
134 return; | 174 return; |
| 175 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
| 176 |
135 // Windows origin should be doubled when moved to the 1st display. | 177 // Windows origin should be doubled when moved to the 1st display. |
136 UpdateDisplay("600x600,300x300"); | 178 UpdateDisplay("600x600,300x300"); |
137 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 179 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
138 | 180 |
139 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 181 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
140 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 182 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
141 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 183 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
142 EXPECT_EQ("50,10 100x100", | 184 EXPECT_EQ("50,10 100x100", |
143 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 185 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
144 | 186 |
145 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 187 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
146 maximized->Maximize(); | 188 maximized->Maximize(); |
147 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 189 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
148 EXPECT_EQ("600,0 300x253", maximized->GetWindowBoundsInScreen().ToString()); | 190 EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(), |
149 EXPECT_EQ("0,0 300x253", | 191 maximized->GetWindowBoundsInScreen().ToString()); |
| 192 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), |
150 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 193 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
151 | 194 |
152 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 195 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
153 minimized->Minimize(); | 196 minimized->Minimize(); |
154 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 197 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
155 EXPECT_EQ("800,10 100x100", | 198 EXPECT_EQ("800,10 100x100", |
156 minimized->GetWindowBoundsInScreen().ToString()); | 199 minimized->GetWindowBoundsInScreen().ToString()); |
157 | 200 |
158 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); | 201 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); |
159 fullscreen->SetFullscreen(true); | 202 fullscreen->SetFullscreen(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_EQ("100,20 100x100", | 243 EXPECT_EQ("100,20 100x100", |
201 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 244 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
202 | 245 |
203 // Maximized area on primary display has 47px for non-md and 48px for md | 246 // Maximized area on primary display has 47px for non-md and 48px for md |
204 // (defined in ash::SHELF_SIZE) inset at the bottom. | 247 // (defined in ash::SHELF_SIZE) inset at the bottom. |
205 | 248 |
206 // First clear fullscreen status, since both fullscreen and maximized windows | 249 // First clear fullscreen status, since both fullscreen and maximized windows |
207 // share the same desktop workspace, which cancels the shelf status. | 250 // share the same desktop workspace, which cancels the shelf status. |
208 fullscreen->SetFullscreen(false); | 251 fullscreen->SetFullscreen(false); |
209 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 252 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
210 EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString()); | 253 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
211 EXPECT_EQ("0,0 600x553", | 254 maximized->GetWindowBoundsInScreen().ToString()); |
| 255 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
212 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 256 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
213 | 257 |
214 // Set fullscreen to true, but maximized window's size won't change because | 258 // Set fullscreen to true, but maximized window's size won't change because |
215 // it's not visible. see crbug.com/504299. | 259 // it's not visible. see crbug.com/504299. |
216 fullscreen->SetFullscreen(true); | 260 fullscreen->SetFullscreen(true); |
217 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 261 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
218 EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString()); | 262 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
219 EXPECT_EQ("0,0 600x553", | 263 maximized->GetWindowBoundsInScreen().ToString()); |
| 264 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
220 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 265 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
221 | 266 |
222 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 267 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
223 EXPECT_EQ("400,20 100x100", | 268 EXPECT_EQ("400,20 100x100", |
224 minimized->GetWindowBoundsInScreen().ToString()); | 269 minimized->GetWindowBoundsInScreen().ToString()); |
225 | 270 |
226 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 271 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
227 EXPECT_TRUE(fullscreen->IsFullscreen()); | 272 EXPECT_TRUE(fullscreen->IsFullscreen()); |
228 EXPECT_EQ("0,0 600x600", | 273 EXPECT_EQ("0,0 600x600", |
229 fullscreen->GetWindowBoundsInScreen().ToString()); | 274 fullscreen->GetWindowBoundsInScreen().ToString()); |
(...skipping 16 matching lines...) Expand all Loading... |
246 EXPECT_EQ(root_windows[0], | 291 EXPECT_EQ(root_windows[0], |
247 unparented_control->GetNativeView()->GetRootWindow()); | 292 unparented_control->GetNativeView()->GetRootWindow()); |
248 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 293 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
249 unparented_control->GetNativeView()->parent()->id()); | 294 unparented_control->GetNativeView()->parent()->id()); |
250 | 295 |
251 // Test if the panel has moved. | 296 // Test if the panel has moved. |
252 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); | 297 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); |
253 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); | 298 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); |
254 } | 299 } |
255 | 300 |
256 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { | 301 TEST_P(RootWindowControllerTest, MoveWindows_Modal) { |
257 if (!SupportsMultipleDisplays()) | 302 if (!SupportsMultipleDisplays()) |
258 return; | 303 return; |
259 | 304 |
260 UpdateDisplay("500x500,500x500"); | 305 UpdateDisplay("500x500,500x500"); |
261 | 306 |
262 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 307 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
263 // Emulate virtual screen coordinate system. | 308 // Emulate virtual screen coordinate system. |
264 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); | 309 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
265 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); | 310 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
266 | 311 |
(...skipping 12 matching lines...) Expand all Loading... |
279 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 324 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
280 | 325 |
281 UpdateDisplay("500x500"); | 326 UpdateDisplay("500x500"); |
282 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 327 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
283 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 328 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
284 generator_1st.ClickLeftButton(); | 329 generator_1st.ClickLeftButton(); |
285 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 330 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
286 } | 331 } |
287 | 332 |
288 // Make sure lock related windows moves. | 333 // Make sure lock related windows moves. |
289 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { | 334 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { |
290 if (!SupportsMultipleDisplays()) | 335 if (!SupportsMultipleDisplays()) |
291 return; | 336 return; |
292 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); | 337 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
293 | 338 |
294 UpdateDisplay("500x500"); | 339 UpdateDisplay("500x500"); |
295 const int kLockScreenWindowId = 1000; | 340 const int kLockScreenWindowId = 1000; |
296 const int kLockBackgroundWindowId = 1001; | 341 const int kLockBackgroundWindowId = 1001; |
297 | 342 |
298 RootWindowController* controller = | 343 RootWindowController* controller = |
299 Shell::GetInstance()->GetPrimaryRootWindowController(); | 344 Shell::GetInstance()->GetPrimaryRootWindowController(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 406 |
362 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); | 407 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); |
363 | 408 |
364 ASSERT_EQ(lock_screen->GetNativeWindow(), | 409 ASSERT_EQ(lock_screen->GetNativeWindow(), |
365 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); | 410 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); |
366 ASSERT_EQ(lock_background->GetNativeWindow(), | 411 ASSERT_EQ(lock_background->GetNativeWindow(), |
367 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); | 412 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); |
368 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); | 413 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); |
369 } | 414 } |
370 | 415 |
371 TEST_F(RootWindowControllerTest, ModalContainer) { | 416 TEST_P(RootWindowControllerTest, ModalContainer) { |
372 UpdateDisplay("600x600"); | 417 UpdateDisplay("600x600"); |
373 Shell* shell = Shell::GetInstance(); | 418 Shell* shell = Shell::GetInstance(); |
374 WmShell* wm_shell = WmShell::Get(); | 419 WmShell* wm_shell = WmShell::Get(); |
375 RootWindowController* controller = shell->GetPrimaryRootWindowController(); | 420 RootWindowController* controller = shell->GetPrimaryRootWindowController(); |
376 EXPECT_EQ(LoginStatus::USER, | 421 EXPECT_EQ(LoginStatus::USER, |
377 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 422 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
378 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 423 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
379 ->layout_manager(), | 424 ->layout_manager(), |
380 controller->GetSystemModalLayoutManager(NULL)); | 425 controller->GetSystemModalLayoutManager(NULL)); |
381 | 426 |
(...skipping 20 matching lines...) Expand all Loading... |
402 controller->GetSystemModalLayoutManager( | 447 controller->GetSystemModalLayoutManager( |
403 lock_modal_widget->GetNativeView())); | 448 lock_modal_widget->GetNativeView())); |
404 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 449 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
405 ->layout_manager(), | 450 ->layout_manager(), |
406 controller->GetSystemModalLayoutManager( | 451 controller->GetSystemModalLayoutManager( |
407 session_modal_widget->GetNativeView())); | 452 session_modal_widget->GetNativeView())); |
408 | 453 |
409 shell->session_state_delegate()->UnlockScreen(); | 454 shell->session_state_delegate()->UnlockScreen(); |
410 } | 455 } |
411 | 456 |
412 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { | 457 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { |
413 UpdateDisplay("600x600"); | 458 UpdateDisplay("600x600"); |
414 Shell* shell = Shell::GetInstance(); | 459 Shell* shell = Shell::GetInstance(); |
415 WmShell* wm_shell = WmShell::Get(); | 460 WmShell* wm_shell = WmShell::Get(); |
416 | 461 |
417 // Configure login screen environment. | 462 // Configure login screen environment. |
418 SetUserLoggedIn(false); | 463 SetUserLoggedIn(false); |
419 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, | 464 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, |
420 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 465 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
421 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); | 466 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); |
422 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); | 467 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); |
(...skipping 25 matching lines...) Expand all Loading... |
448 controller->GetSystemModalLayoutManager(NULL)); | 493 controller->GetSystemModalLayoutManager(NULL)); |
449 | 494 |
450 views::Widget* session_modal_widget = | 495 views::Widget* session_modal_widget = |
451 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 496 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
452 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 497 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
453 ->layout_manager(), | 498 ->layout_manager(), |
454 controller->GetSystemModalLayoutManager( | 499 controller->GetSystemModalLayoutManager( |
455 session_modal_widget->GetNativeView())); | 500 session_modal_widget->GetNativeView())); |
456 } | 501 } |
457 | 502 |
458 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { | 503 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { |
459 UpdateDisplay("600x600"); | 504 UpdateDisplay("600x600"); |
460 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 505 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
461 aura::Window* lock_container = | 506 aura::Window* lock_container = |
462 controller->GetContainer(kShellWindowId_LockScreenContainer); | 507 controller->GetContainer(kShellWindowId_LockScreenContainer); |
463 for (int block_reason = FIRST_BLOCK_REASON; | 508 for (int block_reason = FIRST_BLOCK_REASON; |
464 block_reason < NUMBER_OF_BLOCK_REASONS; | 509 block_reason < NUMBER_OF_BLOCK_REASONS; |
465 ++block_reason) { | 510 ++block_reason) { |
466 views::Widget* session_modal_widget = | 511 views::Widget* session_modal_widget = |
467 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 512 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
468 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 513 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
(...skipping 25 matching lines...) Expand all Loading... |
494 ->layout_manager(), | 539 ->layout_manager(), |
495 controller->GetSystemModalLayoutManager( | 540 controller->GetSystemModalLayoutManager( |
496 session_modal_widget->GetNativeView())); | 541 session_modal_widget->GetNativeView())); |
497 session_modal_widget->Close(); | 542 session_modal_widget->Close(); |
498 | 543 |
499 lock_modal_widget->Close(); | 544 lock_modal_widget->Close(); |
500 UnblockUserSession(); | 545 UnblockUserSession(); |
501 } | 546 } |
502 } | 547 } |
503 | 548 |
504 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { | 549 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { |
505 UpdateDisplay("600x600"); | 550 UpdateDisplay("600x600"); |
506 RootWindowController* controller = | 551 RootWindowController* controller = |
507 Shell::GetInstance()->GetPrimaryRootWindowController(); | 552 Shell::GetInstance()->GetPrimaryRootWindowController(); |
508 | 553 |
509 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 554 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
510 w1->Maximize(); | 555 w1->Maximize(); |
511 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 556 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
512 w2->SetFullscreen(true); | 557 w2->SetFullscreen(true); |
513 // |w3| is a transient child of |w2|. | 558 // |w3| is a transient child of |w2|. |
514 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, | 559 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, |
(...skipping 11 matching lines...) Expand all Loading... |
526 w3->Close(); | 571 w3->Close(); |
527 | 572 |
528 // Only w2 remains, if minimized GetWindowForFullscreenMode should return | 573 // Only w2 remains, if minimized GetWindowForFullscreenMode should return |
529 // NULL. | 574 // NULL. |
530 w2->Activate(); | 575 w2->Activate(); |
531 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); | 576 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); |
532 w2->Minimize(); | 577 w2->Minimize(); |
533 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); | 578 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); |
534 } | 579 } |
535 | 580 |
536 TEST_F(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { | 581 TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { |
537 if (!SupportsMultipleDisplays()) | 582 if (!SupportsMultipleDisplays()) |
538 return; | 583 return; |
539 | 584 |
540 UpdateDisplay("600x600,600x600"); | 585 UpdateDisplay("600x600,600x600"); |
541 Shell::RootWindowControllerList controllers = | 586 Shell::RootWindowControllerList controllers = |
542 Shell::GetInstance()->GetAllRootWindowControllers(); | 587 Shell::GetInstance()->GetAllRootWindowControllers(); |
543 | 588 |
544 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 589 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
545 w1->Maximize(); | 590 w1->Maximize(); |
546 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 591 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
(...skipping 19 matching lines...) Expand all Loading... |
566 // Verify that the first root window controller remains in fullscreen mode | 611 // Verify that the first root window controller remains in fullscreen mode |
567 // when a window on the other display is activated. | 612 // when a window on the other display is activated. |
568 w3->Activate(); | 613 w3->Activate(); |
569 EXPECT_EQ(w2->GetNativeWindow(), | 614 EXPECT_EQ(w2->GetNativeWindow(), |
570 controllers[0]->GetWindowForFullscreenMode()); | 615 controllers[0]->GetWindowForFullscreenMode()); |
571 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); | 616 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); |
572 } | 617 } |
573 | 618 |
574 // Test that GetRootWindowController() works with multiple displays and | 619 // Test that GetRootWindowController() works with multiple displays and |
575 // child widgets. | 620 // child widgets. |
576 TEST_F(RootWindowControllerTest, GetRootWindowController) { | 621 TEST_P(RootWindowControllerTest, GetRootWindowController) { |
577 if (!SupportsMultipleDisplays()) | 622 if (!SupportsMultipleDisplays()) |
578 return; | 623 return; |
579 UpdateDisplay("600x600,600x600"); | 624 UpdateDisplay("600x600,600x600"); |
580 Shell::RootWindowControllerList controllers = | 625 Shell::RootWindowControllerList controllers = |
581 Shell::GetInstance()->GetAllRootWindowControllers(); | 626 Shell::GetInstance()->GetAllRootWindowControllers(); |
582 ASSERT_EQ(2u, controllers.size()); | 627 ASSERT_EQ(2u, controllers.size()); |
583 | 628 |
584 // Test null. | 629 // Test null. |
585 EXPECT_FALSE(GetRootWindowController(nullptr)); | 630 EXPECT_FALSE(GetRootWindowController(nullptr)); |
586 | 631 |
587 // Test a widget on the first display. | 632 // Test a widget on the first display. |
588 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 633 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
589 EXPECT_EQ(controllers[0], | 634 EXPECT_EQ(controllers[0], |
590 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); | 635 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); |
591 | 636 |
592 // Test a child widget. | 637 // Test a child widget. |
593 Widget* w2 = Widget::CreateWindowWithParentAndBounds( | 638 Widget* w2 = Widget::CreateWindowWithParentAndBounds( |
594 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 639 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
595 EXPECT_EQ(controllers[0], | 640 EXPECT_EQ(controllers[0], |
596 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); | 641 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); |
597 | 642 |
598 // Test a widget on the second display. | 643 // Test a widget on the second display. |
599 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); | 644 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); |
600 EXPECT_EQ(controllers[1], | 645 EXPECT_EQ(controllers[1], |
601 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); | 646 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); |
602 } | 647 } |
603 | 648 |
604 // Test that user session window can't be focused if user session blocked by | 649 // Test that user session window can't be focused if user session blocked by |
605 // some overlapping UI. | 650 // some overlapping UI. |
606 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { | 651 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { |
607 UpdateDisplay("600x600"); | 652 UpdateDisplay("600x600"); |
608 RootWindowController* controller = | 653 RootWindowController* controller = |
609 Shell::GetInstance()->GetPrimaryRootWindowController(); | 654 Shell::GetInstance()->GetPrimaryRootWindowController(); |
610 aura::Window* lock_container = | 655 aura::Window* lock_container = |
611 controller->GetContainer(kShellWindowId_LockScreenContainer); | 656 controller->GetContainer(kShellWindowId_LockScreenContainer); |
612 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, | 657 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, |
613 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 658 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
614 lock_window->Show(); | 659 lock_window->Show(); |
615 aura::Window* session_window = | 660 aura::Window* session_window = |
616 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 661 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 window_ = NULL; | 700 window_ = NULL; |
656 } | 701 } |
657 | 702 |
658 bool destroyed_; | 703 bool destroyed_; |
659 Window* window_; | 704 Window* window_; |
660 | 705 |
661 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); | 706 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); |
662 }; | 707 }; |
663 | 708 |
664 // Verifies shutdown doesn't delete windows that are not owned by the parent. | 709 // Verifies shutdown doesn't delete windows that are not owned by the parent. |
665 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { | 710 TEST_P(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { |
666 DestroyedWindowObserver observer1; | 711 DestroyedWindowObserver observer1; |
667 aura::test::TestWindowDelegate delegate1; | 712 aura::test::TestWindowDelegate delegate1; |
668 aura::Window* window1 = new aura::Window(&delegate1); | 713 aura::Window* window1 = new aura::Window(&delegate1); |
669 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 714 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
670 window1->set_owned_by_parent(false); | 715 window1->set_owned_by_parent(false); |
671 observer1.SetWindow(window1); | 716 observer1.SetWindow(window1); |
672 window1->Init(ui::LAYER_NOT_DRAWN); | 717 window1->Init(ui::LAYER_NOT_DRAWN); |
673 aura::client::ParentWindowWithContext( | 718 aura::client::ParentWindowWithContext( |
674 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); | 719 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); |
675 | 720 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1091 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
1047 gfx::Rect(0, 400, 800, 200)); | 1092 gfx::Rect(0, 400, 800, 200)); |
1048 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1093 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
1049 | 1094 |
1050 UpdateDisplay("600x800"); | 1095 UpdateDisplay("600x800"); |
1051 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1096 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
1052 } | 1097 } |
1053 | 1098 |
1054 } // namespace test | 1099 } // namespace test |
1055 } // namespace ash | 1100 } // namespace ash |
OLD | NEW |