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" |
| 17 #include "ash/test/ash_md_test_base.h" |
16 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
17 #include "ash/test/display_manager_test_api.h" | 19 #include "ash/test/display_manager_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" |
(...skipping 64 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 : public AshMDTestBase { |
101 public: | 103 public: |
102 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | 104 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
103 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 105 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
104 NULL, CurrentContext(), bounds); | 106 NULL, CurrentContext(), bounds); |
105 widget->Show(); | 107 widget->Show(); |
106 return widget; | 108 return widget; |
107 } | 109 } |
108 | 110 |
109 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { | 111 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { |
110 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 112 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
(...skipping 11 matching lines...) Expand all Loading... |
122 widget->Show(); | 124 widget->Show(); |
123 return widget; | 125 return widget; |
124 } | 126 } |
125 | 127 |
126 aura::Window* GetModalContainer(aura::Window* root_window) { | 128 aura::Window* GetModalContainer(aura::Window* root_window) { |
127 return Shell::GetContainer(root_window, | 129 return Shell::GetContainer(root_window, |
128 ash::kShellWindowId_SystemModalContainer); | 130 ash::kShellWindowId_SystemModalContainer); |
129 } | 131 } |
130 }; | 132 }; |
131 | 133 |
132 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 134 // Note: First argument is optional and intentionally left blank. |
| 135 // (it's a prefix for the generated test cases) |
| 136 INSTANTIATE_TEST_CASE_P( |
| 137 , |
| 138 RootWindowControllerTest, |
| 139 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 140 MaterialDesignController::MATERIAL_NORMAL, |
| 141 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 142 |
| 143 TEST_P(RootWindowControllerTest, MoveWindows_Basic) { |
133 if (!SupportsMultipleDisplays()) | 144 if (!SupportsMultipleDisplays()) |
134 return; | 145 return; |
| 146 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
| 147 |
135 // Windows origin should be doubled when moved to the 1st display. | 148 // Windows origin should be doubled when moved to the 1st display. |
136 UpdateDisplay("600x600,300x300"); | 149 UpdateDisplay("600x600,300x300"); |
137 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 150 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
138 | 151 |
139 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 152 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
140 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 153 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
141 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 154 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
142 EXPECT_EQ("50,10 100x100", | 155 EXPECT_EQ("50,10 100x100", |
143 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 156 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
144 | 157 |
145 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 158 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
146 maximized->Maximize(); | 159 maximized->Maximize(); |
147 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 160 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
148 EXPECT_EQ("600,0 300x253", maximized->GetWindowBoundsInScreen().ToString()); | 161 EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(), |
149 EXPECT_EQ("0,0 300x253", | 162 maximized->GetWindowBoundsInScreen().ToString()); |
| 163 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), |
150 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 164 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
151 | 165 |
152 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 166 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
153 minimized->Minimize(); | 167 minimized->Minimize(); |
154 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 168 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
155 EXPECT_EQ("800,10 100x100", | 169 EXPECT_EQ("800,10 100x100", |
156 minimized->GetWindowBoundsInScreen().ToString()); | 170 minimized->GetWindowBoundsInScreen().ToString()); |
157 | 171 |
158 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); | 172 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); |
159 fullscreen->SetFullscreen(true); | 173 fullscreen->SetFullscreen(true); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_EQ("100,20 100x100", | 214 EXPECT_EQ("100,20 100x100", |
201 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 215 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
202 | 216 |
203 // Maximized area on primary display has 47px for non-md and 48px for md | 217 // Maximized area on primary display has 47px for non-md and 48px for md |
204 // (defined in ash::SHELF_SIZE) inset at the bottom. | 218 // (defined in ash::SHELF_SIZE) inset at the bottom. |
205 | 219 |
206 // First clear fullscreen status, since both fullscreen and maximized windows | 220 // First clear fullscreen status, since both fullscreen and maximized windows |
207 // share the same desktop workspace, which cancels the shelf status. | 221 // share the same desktop workspace, which cancels the shelf status. |
208 fullscreen->SetFullscreen(false); | 222 fullscreen->SetFullscreen(false); |
209 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 223 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
210 EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString()); | 224 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
211 EXPECT_EQ("0,0 600x553", | 225 maximized->GetWindowBoundsInScreen().ToString()); |
| 226 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
212 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 227 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
213 | 228 |
214 // Set fullscreen to true, but maximized window's size won't change because | 229 // Set fullscreen to true, but maximized window's size won't change because |
215 // it's not visible. see crbug.com/504299. | 230 // it's not visible. see crbug.com/504299. |
216 fullscreen->SetFullscreen(true); | 231 fullscreen->SetFullscreen(true); |
217 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 232 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
218 EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString()); | 233 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
219 EXPECT_EQ("0,0 600x553", | 234 maximized->GetWindowBoundsInScreen().ToString()); |
| 235 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
220 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 236 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
221 | 237 |
222 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 238 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
223 EXPECT_EQ("400,20 100x100", | 239 EXPECT_EQ("400,20 100x100", |
224 minimized->GetWindowBoundsInScreen().ToString()); | 240 minimized->GetWindowBoundsInScreen().ToString()); |
225 | 241 |
226 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 242 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
227 EXPECT_TRUE(fullscreen->IsFullscreen()); | 243 EXPECT_TRUE(fullscreen->IsFullscreen()); |
228 EXPECT_EQ("0,0 600x600", | 244 EXPECT_EQ("0,0 600x600", |
229 fullscreen->GetWindowBoundsInScreen().ToString()); | 245 fullscreen->GetWindowBoundsInScreen().ToString()); |
(...skipping 16 matching lines...) Expand all Loading... |
246 EXPECT_EQ(root_windows[0], | 262 EXPECT_EQ(root_windows[0], |
247 unparented_control->GetNativeView()->GetRootWindow()); | 263 unparented_control->GetNativeView()->GetRootWindow()); |
248 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 264 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
249 unparented_control->GetNativeView()->parent()->id()); | 265 unparented_control->GetNativeView()->parent()->id()); |
250 | 266 |
251 // Test if the panel has moved. | 267 // Test if the panel has moved. |
252 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); | 268 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); |
253 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); | 269 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); |
254 } | 270 } |
255 | 271 |
256 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { | 272 TEST_P(RootWindowControllerTest, MoveWindows_Modal) { |
257 if (!SupportsMultipleDisplays()) | 273 if (!SupportsMultipleDisplays()) |
258 return; | 274 return; |
259 | 275 |
260 UpdateDisplay("500x500,500x500"); | 276 UpdateDisplay("500x500,500x500"); |
261 | 277 |
262 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 278 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
263 // Emulate virtual screen coordinate system. | 279 // Emulate virtual screen coordinate system. |
264 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); | 280 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
265 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); | 281 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
266 | 282 |
(...skipping 12 matching lines...) Expand all Loading... |
279 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 295 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
280 | 296 |
281 UpdateDisplay("500x500"); | 297 UpdateDisplay("500x500"); |
282 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 298 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
283 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 299 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
284 generator_1st.ClickLeftButton(); | 300 generator_1st.ClickLeftButton(); |
285 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 301 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
286 } | 302 } |
287 | 303 |
288 // Make sure lock related windows moves. | 304 // Make sure lock related windows moves. |
289 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { | 305 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { |
290 if (!SupportsMultipleDisplays()) | 306 if (!SupportsMultipleDisplays()) |
291 return; | 307 return; |
292 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); | 308 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
293 | 309 |
294 UpdateDisplay("500x500"); | 310 UpdateDisplay("500x500"); |
295 const int kLockScreenWindowId = 1000; | 311 const int kLockScreenWindowId = 1000; |
296 const int kLockBackgroundWindowId = 1001; | 312 const int kLockBackgroundWindowId = 1001; |
297 | 313 |
298 RootWindowController* controller = | 314 RootWindowController* controller = |
299 Shell::GetInstance()->GetPrimaryRootWindowController(); | 315 Shell::GetInstance()->GetPrimaryRootWindowController(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 377 |
362 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); | 378 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); |
363 | 379 |
364 ASSERT_EQ(lock_screen->GetNativeWindow(), | 380 ASSERT_EQ(lock_screen->GetNativeWindow(), |
365 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); | 381 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); |
366 ASSERT_EQ(lock_background->GetNativeWindow(), | 382 ASSERT_EQ(lock_background->GetNativeWindow(), |
367 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); | 383 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); |
368 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); | 384 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); |
369 } | 385 } |
370 | 386 |
371 TEST_F(RootWindowControllerTest, ModalContainer) { | 387 TEST_P(RootWindowControllerTest, ModalContainer) { |
372 UpdateDisplay("600x600"); | 388 UpdateDisplay("600x600"); |
373 Shell* shell = Shell::GetInstance(); | 389 Shell* shell = Shell::GetInstance(); |
374 WmShell* wm_shell = WmShell::Get(); | 390 WmShell* wm_shell = WmShell::Get(); |
375 RootWindowController* controller = shell->GetPrimaryRootWindowController(); | 391 RootWindowController* controller = shell->GetPrimaryRootWindowController(); |
376 EXPECT_EQ(LoginStatus::USER, | 392 EXPECT_EQ(LoginStatus::USER, |
377 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 393 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
378 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 394 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
379 ->layout_manager(), | 395 ->layout_manager(), |
380 controller->GetSystemModalLayoutManager(NULL)); | 396 controller->GetSystemModalLayoutManager(NULL)); |
381 | 397 |
(...skipping 20 matching lines...) Expand all Loading... |
402 controller->GetSystemModalLayoutManager( | 418 controller->GetSystemModalLayoutManager( |
403 lock_modal_widget->GetNativeView())); | 419 lock_modal_widget->GetNativeView())); |
404 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 420 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
405 ->layout_manager(), | 421 ->layout_manager(), |
406 controller->GetSystemModalLayoutManager( | 422 controller->GetSystemModalLayoutManager( |
407 session_modal_widget->GetNativeView())); | 423 session_modal_widget->GetNativeView())); |
408 | 424 |
409 shell->session_state_delegate()->UnlockScreen(); | 425 shell->session_state_delegate()->UnlockScreen(); |
410 } | 426 } |
411 | 427 |
412 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { | 428 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { |
413 UpdateDisplay("600x600"); | 429 UpdateDisplay("600x600"); |
414 Shell* shell = Shell::GetInstance(); | 430 Shell* shell = Shell::GetInstance(); |
415 WmShell* wm_shell = WmShell::Get(); | 431 WmShell* wm_shell = WmShell::Get(); |
416 | 432 |
417 // Configure login screen environment. | 433 // Configure login screen environment. |
418 SetUserLoggedIn(false); | 434 SetUserLoggedIn(false); |
419 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, | 435 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, |
420 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 436 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
421 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); | 437 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); |
422 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); | 438 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); |
(...skipping 25 matching lines...) Expand all Loading... |
448 controller->GetSystemModalLayoutManager(NULL)); | 464 controller->GetSystemModalLayoutManager(NULL)); |
449 | 465 |
450 views::Widget* session_modal_widget = | 466 views::Widget* session_modal_widget = |
451 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 467 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
452 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 468 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
453 ->layout_manager(), | 469 ->layout_manager(), |
454 controller->GetSystemModalLayoutManager( | 470 controller->GetSystemModalLayoutManager( |
455 session_modal_widget->GetNativeView())); | 471 session_modal_widget->GetNativeView())); |
456 } | 472 } |
457 | 473 |
458 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { | 474 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { |
459 UpdateDisplay("600x600"); | 475 UpdateDisplay("600x600"); |
460 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 476 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
461 aura::Window* lock_container = | 477 aura::Window* lock_container = |
462 controller->GetContainer(kShellWindowId_LockScreenContainer); | 478 controller->GetContainer(kShellWindowId_LockScreenContainer); |
463 for (int block_reason = FIRST_BLOCK_REASON; | 479 for (int block_reason = FIRST_BLOCK_REASON; |
464 block_reason < NUMBER_OF_BLOCK_REASONS; | 480 block_reason < NUMBER_OF_BLOCK_REASONS; |
465 ++block_reason) { | 481 ++block_reason) { |
466 views::Widget* session_modal_widget = | 482 views::Widget* session_modal_widget = |
467 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 483 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
468 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 484 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
(...skipping 25 matching lines...) Expand all Loading... |
494 ->layout_manager(), | 510 ->layout_manager(), |
495 controller->GetSystemModalLayoutManager( | 511 controller->GetSystemModalLayoutManager( |
496 session_modal_widget->GetNativeView())); | 512 session_modal_widget->GetNativeView())); |
497 session_modal_widget->Close(); | 513 session_modal_widget->Close(); |
498 | 514 |
499 lock_modal_widget->Close(); | 515 lock_modal_widget->Close(); |
500 UnblockUserSession(); | 516 UnblockUserSession(); |
501 } | 517 } |
502 } | 518 } |
503 | 519 |
504 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { | 520 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { |
505 UpdateDisplay("600x600"); | 521 UpdateDisplay("600x600"); |
506 RootWindowController* controller = | 522 RootWindowController* controller = |
507 Shell::GetInstance()->GetPrimaryRootWindowController(); | 523 Shell::GetInstance()->GetPrimaryRootWindowController(); |
508 | 524 |
509 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 525 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
510 w1->Maximize(); | 526 w1->Maximize(); |
511 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 527 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
512 w2->SetFullscreen(true); | 528 w2->SetFullscreen(true); |
513 // |w3| is a transient child of |w2|. | 529 // |w3| is a transient child of |w2|. |
514 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, | 530 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, |
(...skipping 11 matching lines...) Expand all Loading... |
526 w3->Close(); | 542 w3->Close(); |
527 | 543 |
528 // Only w2 remains, if minimized GetWindowForFullscreenMode should return | 544 // Only w2 remains, if minimized GetWindowForFullscreenMode should return |
529 // NULL. | 545 // NULL. |
530 w2->Activate(); | 546 w2->Activate(); |
531 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); | 547 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); |
532 w2->Minimize(); | 548 w2->Minimize(); |
533 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); | 549 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); |
534 } | 550 } |
535 | 551 |
536 TEST_F(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { | 552 TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { |
537 if (!SupportsMultipleDisplays()) | 553 if (!SupportsMultipleDisplays()) |
538 return; | 554 return; |
539 | 555 |
540 UpdateDisplay("600x600,600x600"); | 556 UpdateDisplay("600x600,600x600"); |
541 Shell::RootWindowControllerList controllers = | 557 Shell::RootWindowControllerList controllers = |
542 Shell::GetInstance()->GetAllRootWindowControllers(); | 558 Shell::GetInstance()->GetAllRootWindowControllers(); |
543 | 559 |
544 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 560 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
545 w1->Maximize(); | 561 w1->Maximize(); |
546 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 562 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 | 582 // Verify that the first root window controller remains in fullscreen mode |
567 // when a window on the other display is activated. | 583 // when a window on the other display is activated. |
568 w3->Activate(); | 584 w3->Activate(); |
569 EXPECT_EQ(w2->GetNativeWindow(), | 585 EXPECT_EQ(w2->GetNativeWindow(), |
570 controllers[0]->GetWindowForFullscreenMode()); | 586 controllers[0]->GetWindowForFullscreenMode()); |
571 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); | 587 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); |
572 } | 588 } |
573 | 589 |
574 // Test that GetRootWindowController() works with multiple displays and | 590 // Test that GetRootWindowController() works with multiple displays and |
575 // child widgets. | 591 // child widgets. |
576 TEST_F(RootWindowControllerTest, GetRootWindowController) { | 592 TEST_P(RootWindowControllerTest, GetRootWindowController) { |
577 if (!SupportsMultipleDisplays()) | 593 if (!SupportsMultipleDisplays()) |
578 return; | 594 return; |
579 UpdateDisplay("600x600,600x600"); | 595 UpdateDisplay("600x600,600x600"); |
580 Shell::RootWindowControllerList controllers = | 596 Shell::RootWindowControllerList controllers = |
581 Shell::GetInstance()->GetAllRootWindowControllers(); | 597 Shell::GetInstance()->GetAllRootWindowControllers(); |
582 ASSERT_EQ(2u, controllers.size()); | 598 ASSERT_EQ(2u, controllers.size()); |
583 | 599 |
584 // Test null. | 600 // Test null. |
585 EXPECT_FALSE(GetRootWindowController(nullptr)); | 601 EXPECT_FALSE(GetRootWindowController(nullptr)); |
586 | 602 |
587 // Test a widget on the first display. | 603 // Test a widget on the first display. |
588 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 604 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
589 EXPECT_EQ(controllers[0], | 605 EXPECT_EQ(controllers[0], |
590 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); | 606 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); |
591 | 607 |
592 // Test a child widget. | 608 // Test a child widget. |
593 Widget* w2 = Widget::CreateWindowWithParentAndBounds( | 609 Widget* w2 = Widget::CreateWindowWithParentAndBounds( |
594 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 610 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
595 EXPECT_EQ(controllers[0], | 611 EXPECT_EQ(controllers[0], |
596 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); | 612 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); |
597 | 613 |
598 // Test a widget on the second display. | 614 // Test a widget on the second display. |
599 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); | 615 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); |
600 EXPECT_EQ(controllers[1], | 616 EXPECT_EQ(controllers[1], |
601 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); | 617 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); |
602 } | 618 } |
603 | 619 |
604 // Test that user session window can't be focused if user session blocked by | 620 // Test that user session window can't be focused if user session blocked by |
605 // some overlapping UI. | 621 // some overlapping UI. |
606 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { | 622 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { |
607 UpdateDisplay("600x600"); | 623 UpdateDisplay("600x600"); |
608 RootWindowController* controller = | 624 RootWindowController* controller = |
609 Shell::GetInstance()->GetPrimaryRootWindowController(); | 625 Shell::GetInstance()->GetPrimaryRootWindowController(); |
610 aura::Window* lock_container = | 626 aura::Window* lock_container = |
611 controller->GetContainer(kShellWindowId_LockScreenContainer); | 627 controller->GetContainer(kShellWindowId_LockScreenContainer); |
612 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, | 628 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, |
613 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 629 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
614 lock_window->Show(); | 630 lock_window->Show(); |
615 aura::Window* session_window = | 631 aura::Window* session_window = |
616 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 632 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 window_ = NULL; | 671 window_ = NULL; |
656 } | 672 } |
657 | 673 |
658 bool destroyed_; | 674 bool destroyed_; |
659 Window* window_; | 675 Window* window_; |
660 | 676 |
661 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); | 677 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); |
662 }; | 678 }; |
663 | 679 |
664 // Verifies shutdown doesn't delete windows that are not owned by the parent. | 680 // Verifies shutdown doesn't delete windows that are not owned by the parent. |
665 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { | 681 TEST_P(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { |
666 DestroyedWindowObserver observer1; | 682 DestroyedWindowObserver observer1; |
667 aura::test::TestWindowDelegate delegate1; | 683 aura::test::TestWindowDelegate delegate1; |
668 aura::Window* window1 = new aura::Window(&delegate1); | 684 aura::Window* window1 = new aura::Window(&delegate1); |
669 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 685 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
670 window1->set_owned_by_parent(false); | 686 window1->set_owned_by_parent(false); |
671 observer1.SetWindow(window1); | 687 observer1.SetWindow(window1); |
672 window1->Init(ui::LAYER_NOT_DRAWN); | 688 window1->Init(ui::LAYER_NOT_DRAWN); |
673 aura::client::ParentWindowWithContext( | 689 aura::client::ParentWindowWithContext( |
674 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); | 690 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); |
675 | 691 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1062 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
1047 gfx::Rect(0, 400, 800, 200)); | 1063 gfx::Rect(0, 400, 800, 200)); |
1048 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1064 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
1049 | 1065 |
1050 UpdateDisplay("600x800"); | 1066 UpdateDisplay("600x800"); |
1051 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1067 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
1052 } | 1068 } |
1053 | 1069 |
1054 } // namespace test | 1070 } // namespace test |
1055 } // namespace ash | 1071 } // namespace ash |
OLD | NEW |