Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2111443002: mash: Migrate SessionStateDelegate access to WmShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, 118 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds,
119 gfx::NativeWindow parent) { 119 gfx::NativeWindow parent) {
120 views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds( 120 views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds(
121 new TestDelegate(true), parent, bounds); 121 new TestDelegate(true), parent, bounds);
122 widget->Show(); 122 widget->Show();
123 return widget; 123 return widget;
124 } 124 }
125 125
126 aura::Window* GetModalContainer(aura::Window* root_window) { 126 aura::Window* GetModalContainer(aura::Window* root_window) {
127 return Shell::GetContainer(root_window, 127 return Shell::GetContainer(root_window,
128 ash::kShellWindowId_SystemModalContainer); 128 kShellWindowId_SystemModalContainer);
129 } 129 }
130 }; 130 };
131 131
132 INSTANTIATE_TEST_CASE_P( 132 INSTANTIATE_TEST_CASE_P(
133 /* prefix intentionally left blank due to only one parameterization */, 133 /* prefix intentionally left blank due to only one parameterization */,
134 RootWindowControllerTest, 134 RootWindowControllerTest,
135 testing::Values(MaterialDesignController::NON_MATERIAL, 135 testing::Values(MaterialDesignController::NON_MATERIAL,
136 MaterialDesignController::MATERIAL_NORMAL, 136 MaterialDesignController::MATERIAL_NORMAL,
137 MaterialDesignController::MATERIAL_EXPERIMENTAL)); 137 MaterialDesignController::MATERIAL_EXPERIMENTAL));
138 138
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 // d2 must have been deleted. 203 // d2 must have been deleted.
204 EXPECT_FALSE(tracker.Contains(d2)); 204 EXPECT_FALSE(tracker.Contains(d2));
205 205
206 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); 206 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow());
207 EXPECT_EQ("100,20 100x100", normal->GetWindowBoundsInScreen().ToString()); 207 EXPECT_EQ("100,20 100x100", normal->GetWindowBoundsInScreen().ToString());
208 EXPECT_EQ("100,20 100x100", 208 EXPECT_EQ("100,20 100x100",
209 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); 209 normal->GetNativeView()->GetBoundsInRootWindow().ToString());
210 210
211 // Maximized area on primary display has 47px for non-md and 48px for md 211 // Maximized area on primary display has 47px for non-md and 48px for md
212 // (defined in ash::SHELF_SIZE) inset at the bottom. 212 // (defined in SHELF_SIZE) inset at the bottom.
213 213
214 // First clear fullscreen status, since both fullscreen and maximized windows 214 // First clear fullscreen status, since both fullscreen and maximized windows
215 // share the same desktop workspace, which cancels the shelf status. 215 // share the same desktop workspace, which cancels the shelf status.
216 fullscreen->SetFullscreen(false); 216 fullscreen->SetFullscreen(false);
217 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); 217 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
218 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 218 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
219 maximized->GetWindowBoundsInScreen().ToString()); 219 maximized->GetWindowBoundsInScreen().ToString());
220 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 220 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
221 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 221 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
222 222
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Make sure lock related windows moves. 295 // Make sure lock related windows moves.
296 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { 296 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) {
297 if (!SupportsMultipleDisplays()) 297 if (!SupportsMultipleDisplays())
298 return; 298 return;
299 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); 299 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true);
300 300
301 UpdateDisplay("500x500"); 301 UpdateDisplay("500x500");
302 const int kLockScreenWindowId = 1000; 302 const int kLockScreenWindowId = 1000;
303 const int kLockBackgroundWindowId = 1001; 303 const int kLockBackgroundWindowId = 1001;
304 304
305 RootWindowController* controller = 305 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
306 Shell::GetInstance()->GetPrimaryRootWindowController();
307 306
308 aura::Window* lock_container = 307 aura::Window* lock_container =
309 controller->GetContainer(kShellWindowId_LockScreenContainer); 308 controller->GetContainer(kShellWindowId_LockScreenContainer);
310 aura::Window* lock_background_container = 309 aura::Window* lock_background_container =
311 controller->GetContainer(kShellWindowId_LockScreenBackgroundContainer); 310 controller->GetContainer(kShellWindowId_LockScreenBackgroundContainer);
312 311
313 views::Widget* lock_screen = 312 views::Widget* lock_screen =
314 CreateModalWidgetWithParent(gfx::Rect(10, 10, 100, 100), lock_container); 313 CreateModalWidgetWithParent(gfx::Rect(10, 10, 100, 100), lock_container);
315 lock_screen->GetNativeWindow()->set_id(kLockScreenWindowId); 314 lock_screen->GetNativeWindow()->set_id(kLockScreenWindowId);
316 lock_screen->SetFullscreen(true); 315 lock_screen->SetFullscreen(true);
317 316
318 views::Widget* lock_background = CreateModalWidgetWithParent( 317 views::Widget* lock_background = CreateModalWidgetWithParent(
319 gfx::Rect(10, 10, 100, 100), lock_background_container); 318 gfx::Rect(10, 10, 100, 100), lock_background_container);
320 lock_background->GetNativeWindow()->set_id(kLockBackgroundWindowId); 319 lock_background->GetNativeWindow()->set_id(kLockBackgroundWindowId);
321 320
322 ASSERT_EQ(lock_screen->GetNativeWindow(), 321 ASSERT_EQ(lock_screen->GetNativeWindow(),
323 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 322 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
324 ASSERT_EQ(lock_background->GetNativeWindow(), 323 ASSERT_EQ(lock_background->GetNativeWindow(),
325 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); 324 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId));
326 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString()); 325 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString());
327 326
328 // Switch to unified. 327 // Switch to unified.
329 UpdateDisplay("500x500,500x500"); 328 UpdateDisplay("500x500,500x500");
330 329
331 // In unified mode, RWC is created 330 // In unified mode, RWC is created
332 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); 331 controller = Shell::GetPrimaryRootWindowController();
333 332
334 ASSERT_EQ(lock_screen->GetNativeWindow(), 333 ASSERT_EQ(lock_screen->GetNativeWindow(),
335 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 334 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
336 ASSERT_EQ(lock_background->GetNativeWindow(), 335 ASSERT_EQ(lock_background->GetNativeWindow(),
337 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); 336 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId));
338 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString()); 337 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString());
339 338
340 // Switch to mirror. 339 // Switch to mirror.
341 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 340 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
342 display_manager->SetMirrorMode(true); 341 display_manager->SetMirrorMode(true);
343 EXPECT_TRUE(display_manager->IsInMirrorMode()); 342 EXPECT_TRUE(display_manager->IsInMirrorMode());
344 343
345 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); 344 controller = Shell::GetPrimaryRootWindowController();
346 ASSERT_EQ(lock_screen->GetNativeWindow(), 345 ASSERT_EQ(lock_screen->GetNativeWindow(),
347 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 346 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
348 ASSERT_EQ(lock_background->GetNativeWindow(), 347 ASSERT_EQ(lock_background->GetNativeWindow(),
349 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); 348 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId));
350 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString()); 349 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString());
351 350
352 // Switch to unified. 351 // Switch to unified.
353 display_manager->SetMirrorMode(false); 352 display_manager->SetMirrorMode(false);
354 EXPECT_TRUE(display_manager->IsInUnifiedMode()); 353 EXPECT_TRUE(display_manager->IsInUnifiedMode());
355 354
356 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); 355 controller = Shell::GetPrimaryRootWindowController();
357 356
358 ASSERT_EQ(lock_screen->GetNativeWindow(), 357 ASSERT_EQ(lock_screen->GetNativeWindow(),
359 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 358 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
360 ASSERT_EQ(lock_background->GetNativeWindow(), 359 ASSERT_EQ(lock_background->GetNativeWindow(),
361 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); 360 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId));
362 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString()); 361 EXPECT_EQ("0,0 500x500", lock_screen->GetNativeWindow()->bounds().ToString());
363 362
364 // Switch to single display. 363 // Switch to single display.
365 UpdateDisplay("600x500"); 364 UpdateDisplay("600x500");
366 EXPECT_FALSE(display_manager->IsInUnifiedMode()); 365 EXPECT_FALSE(display_manager->IsInUnifiedMode());
367 EXPECT_FALSE(display_manager->IsInMirrorMode()); 366 EXPECT_FALSE(display_manager->IsInMirrorMode());
368 367
369 controller = Shell::GetInstance()->GetPrimaryRootWindowController(); 368 controller = Shell::GetPrimaryRootWindowController();
370 369
371 ASSERT_EQ(lock_screen->GetNativeWindow(), 370 ASSERT_EQ(lock_screen->GetNativeWindow(),
372 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 371 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
373 ASSERT_EQ(lock_background->GetNativeWindow(), 372 ASSERT_EQ(lock_background->GetNativeWindow(),
374 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); 373 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId));
375 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); 374 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString());
376 } 375 }
377 376
378 TEST_P(RootWindowControllerTest, ModalContainer) { 377 TEST_P(RootWindowControllerTest, ModalContainer) {
379 UpdateDisplay("600x600"); 378 UpdateDisplay("600x600");
380 Shell* shell = Shell::GetInstance();
381 WmShell* wm_shell = WmShell::Get(); 379 WmShell* wm_shell = WmShell::Get();
382 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 380 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
383 EXPECT_EQ(LoginStatus::USER, 381 EXPECT_EQ(LoginStatus::USER,
384 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 382 wm_shell->system_tray_delegate()->GetUserLoginStatus());
385 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 383 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
386 ->layout_manager(), 384 ->layout_manager(),
387 controller->GetSystemModalLayoutManager(NULL)); 385 controller->GetSystemModalLayoutManager(NULL));
388 386
389 views::Widget* session_modal_widget = 387 views::Widget* session_modal_widget =
390 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 388 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
391 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 389 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
392 ->layout_manager(), 390 ->layout_manager(),
393 controller->GetSystemModalLayoutManager( 391 controller->GetSystemModalLayoutManager(
394 session_modal_widget->GetNativeView())); 392 session_modal_widget->GetNativeView()));
395 393
396 shell->session_state_delegate()->LockScreen(); 394 wm_shell->GetSessionStateDelegate()->LockScreen();
397 EXPECT_EQ(LoginStatus::LOCKED, 395 EXPECT_EQ(LoginStatus::LOCKED,
398 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 396 wm_shell->system_tray_delegate()->GetUserLoginStatus());
399 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 397 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
400 ->layout_manager(), 398 ->layout_manager(),
401 controller->GetSystemModalLayoutManager(NULL)); 399 controller->GetSystemModalLayoutManager(NULL));
402 400
403 aura::Window* lock_container = 401 aura::Window* lock_container =
404 controller->GetContainer(kShellWindowId_LockScreenContainer); 402 controller->GetContainer(kShellWindowId_LockScreenContainer);
405 views::Widget* lock_modal_widget = 403 views::Widget* lock_modal_widget =
406 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 404 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
407 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 405 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
408 ->layout_manager(), 406 ->layout_manager(),
409 controller->GetSystemModalLayoutManager( 407 controller->GetSystemModalLayoutManager(
410 lock_modal_widget->GetNativeView())); 408 lock_modal_widget->GetNativeView()));
411 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 409 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
412 ->layout_manager(), 410 ->layout_manager(),
413 controller->GetSystemModalLayoutManager( 411 controller->GetSystemModalLayoutManager(
414 session_modal_widget->GetNativeView())); 412 session_modal_widget->GetNativeView()));
415 413
416 shell->session_state_delegate()->UnlockScreen(); 414 wm_shell->GetSessionStateDelegate()->UnlockScreen();
417 } 415 }
418 416
419 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 417 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
420 UpdateDisplay("600x600"); 418 UpdateDisplay("600x600");
421 Shell* shell = Shell::GetInstance();
422 WmShell* wm_shell = WmShell::Get();
423 419
424 // Configure login screen environment. 420 // Configure login screen environment.
421 SessionStateDelegate* session_state_delegate =
422 WmShell::Get()->GetSessionStateDelegate();
425 SetUserLoggedIn(false); 423 SetUserLoggedIn(false);
426 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 424 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
427 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 425 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
428 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); 426 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers());
429 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); 427 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted());
430 428
431 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 429 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
432 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 430 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
433 ->layout_manager(), 431 ->layout_manager(),
434 controller->GetSystemModalLayoutManager(NULL)); 432 controller->GetSystemModalLayoutManager(NULL));
435 433
436 aura::Window* lock_container = 434 aura::Window* lock_container =
437 controller->GetContainer(kShellWindowId_LockScreenContainer); 435 controller->GetContainer(kShellWindowId_LockScreenContainer);
438 views::Widget* login_modal_widget = 436 views::Widget* login_modal_widget =
439 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 437 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
440 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 438 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
441 ->layout_manager(), 439 ->layout_manager(),
442 controller->GetSystemModalLayoutManager( 440 controller->GetSystemModalLayoutManager(
443 login_modal_widget->GetNativeView())); 441 login_modal_widget->GetNativeView()));
444 login_modal_widget->Close(); 442 login_modal_widget->Close();
445 443
446 // Configure user session environment. 444 // Configure user session environment.
447 SetUserLoggedIn(true); 445 SetUserLoggedIn(true);
448 SetSessionStarted(true); 446 SetSessionStarted(true);
449 EXPECT_EQ(LoginStatus::USER, 447 EXPECT_EQ(LoginStatus::USER,
450 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 448 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
451 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers()); 449 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers());
452 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted()); 450 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted());
453 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 451 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
454 ->layout_manager(), 452 ->layout_manager(),
455 controller->GetSystemModalLayoutManager(NULL)); 453 controller->GetSystemModalLayoutManager(NULL));
456 454
457 views::Widget* session_modal_widget = 455 views::Widget* session_modal_widget =
458 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 456 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
459 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 457 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
460 ->layout_manager(), 458 ->layout_manager(),
461 controller->GetSystemModalLayoutManager( 459 controller->GetSystemModalLayoutManager(
462 session_modal_widget->GetNativeView())); 460 session_modal_widget->GetNativeView()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 session_modal_widget->GetNativeView())); 498 session_modal_widget->GetNativeView()));
501 session_modal_widget->Close(); 499 session_modal_widget->Close();
502 500
503 lock_modal_widget->Close(); 501 lock_modal_widget->Close();
504 UnblockUserSession(); 502 UnblockUserSession();
505 } 503 }
506 } 504 }
507 505
508 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { 506 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) {
509 UpdateDisplay("600x600"); 507 UpdateDisplay("600x600");
510 RootWindowController* controller = 508 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
511 Shell::GetInstance()->GetPrimaryRootWindowController();
512 509
513 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 510 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
514 w1->Maximize(); 511 w1->Maximize();
515 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 512 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
516 w2->SetFullscreen(true); 513 w2->SetFullscreen(true);
517 // |w3| is a transient child of |w2|. 514 // |w3| is a transient child of |w2|.
518 Widget* w3 = Widget::CreateWindowWithParentAndBounds( 515 Widget* w3 = Widget::CreateWindowWithParentAndBounds(
519 NULL, w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); 516 NULL, w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100));
520 517
521 // Test that GetWindowForFullscreenMode() finds the fullscreen window when one 518 // Test that GetWindowForFullscreenMode() finds the fullscreen window when one
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 // Test a widget on the second display. 599 // Test a widget on the second display.
603 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); 600 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100));
604 EXPECT_EQ(controllers[1], 601 EXPECT_EQ(controllers[1],
605 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); 602 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow()));
606 } 603 }
607 604
608 // Test that user session window can't be focused if user session blocked by 605 // Test that user session window can't be focused if user session blocked by
609 // some overlapping UI. 606 // some overlapping UI.
610 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { 607 TEST_P(RootWindowControllerTest, FocusBlockedWindow) {
611 UpdateDisplay("600x600"); 608 UpdateDisplay("600x600");
612 RootWindowController* controller = 609 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
613 Shell::GetInstance()->GetPrimaryRootWindowController();
614 aura::Window* lock_container = 610 aura::Window* lock_container =
615 controller->GetContainer(kShellWindowId_LockScreenContainer); 611 controller->GetContainer(kShellWindowId_LockScreenContainer);
616 aura::Window* lock_window = 612 aura::Window* lock_window =
617 Widget::CreateWindowWithParentAndBounds(NULL, lock_container, 613 Widget::CreateWindowWithParentAndBounds(NULL, lock_container,
618 gfx::Rect(0, 0, 100, 100)) 614 gfx::Rect(0, 0, 100, 100))
619 ->GetNativeView(); 615 ->GetNativeView();
620 lock_window->Show(); 616 lock_window->Show();
621 aura::Window* session_window = 617 aura::Window* session_window =
622 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); 618 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView();
623 session_window->Show(); 619 session_window->Show();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 aura::client::ParentWindowWithContext( 674 aura::client::ParentWindowWithContext(
679 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); 675 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect());
680 676
681 DestroyedWindowObserver observer2; 677 DestroyedWindowObserver observer2;
682 aura::Window* window2 = new aura::Window(NULL); 678 aura::Window* window2 = new aura::Window(NULL);
683 window2->set_owned_by_parent(false); 679 window2->set_owned_by_parent(false);
684 observer2.SetWindow(window2); 680 observer2.SetWindow(window2);
685 window2->Init(ui::LAYER_NOT_DRAWN); 681 window2->Init(ui::LAYER_NOT_DRAWN);
686 Shell::GetInstance()->GetPrimaryRootWindow()->AddChild(window2); 682 Shell::GetInstance()->GetPrimaryRootWindow()->AddChild(window2);
687 683
688 Shell::GetInstance()->GetPrimaryRootWindowController()->CloseChildWindows(); 684 Shell::GetPrimaryRootWindowController()->CloseChildWindows();
689 685
690 ASSERT_FALSE(observer1.destroyed()); 686 ASSERT_FALSE(observer1.destroyed());
691 delete window1; 687 delete window1;
692 688
693 ASSERT_FALSE(observer2.destroyed()); 689 ASSERT_FALSE(observer2.destroyed());
694 delete window2; 690 delete window2;
695 } 691 }
696 692
697 typedef test::NoSessionAshTestBase NoSessionRootWindowControllerTest; 693 typedef test::NoSessionAshTestBase NoSessionRootWindowControllerTest;
698 694
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 TEST_F(VirtualKeyboardRootWindowControllerTest, 816 TEST_F(VirtualKeyboardRootWindowControllerTest,
821 DeleteOldContainerOnVirtualKeyboardInit) { 817 DeleteOldContainerOnVirtualKeyboardInit) {
822 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 818 aura::Window* root_window = Shell::GetPrimaryRootWindow();
823 aura::Window* keyboard_container = 819 aura::Window* keyboard_container =
824 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); 820 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer);
825 ASSERT_TRUE(keyboard_container); 821 ASSERT_TRUE(keyboard_container);
826 // Track the keyboard container window. 822 // Track the keyboard container window.
827 aura::WindowTracker tracker; 823 aura::WindowTracker tracker;
828 tracker.Add(keyboard_container); 824 tracker.Add(keyboard_container);
829 // Mock a login user profile change to reinitialize the keyboard. 825 // Mock a login user profile change to reinitialize the keyboard.
830 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); 826 Shell::GetInstance()->OnLoginUserProfilePrepared();
831 // keyboard_container should no longer be present. 827 // keyboard_container should no longer be present.
832 EXPECT_FALSE(tracker.Contains(keyboard_container)); 828 EXPECT_FALSE(tracker.Contains(keyboard_container));
833 } 829 }
834 830
835 // Test for crbug.com/342524. After user login, the work space should restore to 831 // Test for crbug.com/342524. After user login, the work space should restore to
836 // full screen. 832 // full screen.
837 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { 833 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) {
838 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 834 aura::Window* root_window = Shell::GetPrimaryRootWindow();
839 aura::Window* keyboard_container = 835 aura::Window* keyboard_container =
840 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); 836 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer);
(...skipping 13 matching lines...) Expand all
854 // Notify keyboard bounds changing. 850 // Notify keyboard bounds changing.
855 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); 851 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds());
856 852
857 if (!keyboard::IsKeyboardOverscrollEnabled()) { 853 if (!keyboard::IsKeyboardOverscrollEnabled()) {
858 gfx::Rect after = 854 gfx::Rect after =
859 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 855 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
860 EXPECT_LT(after, before); 856 EXPECT_LT(after, before);
861 } 857 }
862 858
863 // Mock a login user profile change to reinitialize the keyboard. 859 // Mock a login user profile change to reinitialize the keyboard.
864 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); 860 Shell::GetInstance()->OnLoginUserProfilePrepared();
865 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().work_area(), 861 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().work_area(),
866 before); 862 before);
867 } 863 }
868 864
869 // Ensure that system modal dialogs do not block events targeted at the virtual 865 // Ensure that system modal dialogs do not block events targeted at the virtual
870 // keyboard. 866 // keyboard.
871 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { 867 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) {
872 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 868 aura::Window* root_window = Shell::GetPrimaryRootWindow();
873 aura::Window* keyboard_container = 869 aura::Window* keyboard_container =
874 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); 870 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1042 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1047 gfx::Rect(0, 400, 800, 200)); 1043 gfx::Rect(0, 400, 800, 200));
1048 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1044 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1049 1045
1050 UpdateDisplay("600x800"); 1046 UpdateDisplay("600x800");
1051 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1047 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1052 } 1048 }
1053 1049
1054 } // namespace test 1050 } // namespace test
1055 } // namespace ash 1051 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698