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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 201573015: Introdcue AshWindowTreeHost and move ash/chrome specific code in WTH to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/session_state_delegate.h" 7 #include "ash/session_state_delegate.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 generator_1st.ClickLeftButton(); 285 generator_1st.ClickLeftButton();
286 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 286 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
287 } 287 }
288 288
289 TEST_F(RootWindowControllerTest, ModalContainer) { 289 TEST_F(RootWindowControllerTest, ModalContainer) {
290 UpdateDisplay("600x600"); 290 UpdateDisplay("600x600");
291 Shell* shell = Shell::GetInstance(); 291 Shell* shell = Shell::GetInstance();
292 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 292 RootWindowController* controller = shell->GetPrimaryRootWindowController();
293 EXPECT_EQ(user::LOGGED_IN_USER, 293 EXPECT_EQ(user::LOGGED_IN_USER,
294 shell->system_tray_delegate()->GetUserLoginStatus()); 294 shell->system_tray_delegate()->GetUserLoginStatus());
295 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 295 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
296 kShellWindowId_SystemModalContainer)
297 ->layout_manager(), 296 ->layout_manager(),
298 controller->GetSystemModalLayoutManager(NULL)); 297 controller->GetSystemModalLayoutManager(NULL));
299 298
300 views::Widget* session_modal_widget = 299 views::Widget* session_modal_widget =
301 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 300 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
302 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 301 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
303 kShellWindowId_SystemModalContainer)
304 ->layout_manager(), 302 ->layout_manager(),
305 controller->GetSystemModalLayoutManager( 303 controller->GetSystemModalLayoutManager(
306 session_modal_widget->GetNativeView())); 304 session_modal_widget->GetNativeView()));
307 305
308 shell->session_state_delegate()->LockScreen(); 306 shell->session_state_delegate()->LockScreen();
309 EXPECT_EQ(user::LOGGED_IN_LOCKED, 307 EXPECT_EQ(user::LOGGED_IN_LOCKED,
310 shell->system_tray_delegate()->GetUserLoginStatus()); 308 shell->system_tray_delegate()->GetUserLoginStatus());
311 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 309 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
312 kShellWindowId_LockSystemModalContainer)
313 ->layout_manager(), 310 ->layout_manager(),
314 controller->GetSystemModalLayoutManager(NULL)); 311 controller->GetSystemModalLayoutManager(NULL));
315 312
316 aura::Window* lock_container = Shell::GetContainer( 313 aura::Window* lock_container =
317 controller->root_window(), kShellWindowId_LockScreenContainer); 314 controller->GetContainer(kShellWindowId_LockScreenContainer);
318 views::Widget* lock_modal_widget = 315 views::Widget* lock_modal_widget =
319 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 316 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
320 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 317 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
321 kShellWindowId_LockSystemModalContainer)
322 ->layout_manager(), 318 ->layout_manager(),
323 controller->GetSystemModalLayoutManager( 319 controller->GetSystemModalLayoutManager(
324 lock_modal_widget->GetNativeView())); 320 lock_modal_widget->GetNativeView()));
325 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 321 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
326 kShellWindowId_SystemModalContainer)
327 ->layout_manager(), 322 ->layout_manager(),
328 controller->GetSystemModalLayoutManager( 323 controller->GetSystemModalLayoutManager(
329 session_modal_widget->GetNativeView())); 324 session_modal_widget->GetNativeView()));
330 325
331 shell->session_state_delegate()->UnlockScreen(); 326 shell->session_state_delegate()->UnlockScreen();
332 } 327 }
333 328
334 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 329 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
335 UpdateDisplay("600x600"); 330 UpdateDisplay("600x600");
336 Shell* shell = Shell::GetInstance(); 331 Shell* shell = Shell::GetInstance();
337 332
338 // Configure login screen environment. 333 // Configure login screen environment.
339 SetUserLoggedIn(false); 334 SetUserLoggedIn(false);
340 EXPECT_EQ(user::LOGGED_IN_NONE, 335 EXPECT_EQ(user::LOGGED_IN_NONE,
341 shell->system_tray_delegate()->GetUserLoginStatus()); 336 shell->system_tray_delegate()->GetUserLoginStatus());
342 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); 337 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers());
343 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); 338 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted());
344 339
345 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 340 RootWindowController* controller = shell->GetPrimaryRootWindowController();
346 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 341 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
347 kShellWindowId_LockSystemModalContainer)
348 ->layout_manager(), 342 ->layout_manager(),
349 controller->GetSystemModalLayoutManager(NULL)); 343 controller->GetSystemModalLayoutManager(NULL));
350 344
351 aura::Window* lock_container = Shell::GetContainer( 345 aura::Window* lock_container =
352 controller->root_window(), kShellWindowId_LockScreenContainer); 346 controller->GetContainer(kShellWindowId_LockScreenContainer);
353 views::Widget* login_modal_widget = 347 views::Widget* login_modal_widget =
354 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 348 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
355 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 349 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
356 kShellWindowId_LockSystemModalContainer)
357 ->layout_manager(), 350 ->layout_manager(),
358 controller->GetSystemModalLayoutManager( 351 controller->GetSystemModalLayoutManager(
359 login_modal_widget->GetNativeView())); 352 login_modal_widget->GetNativeView()));
360 login_modal_widget->Close(); 353 login_modal_widget->Close();
361 354
362 // Configure user session environment. 355 // Configure user session environment.
363 SetUserLoggedIn(true); 356 SetUserLoggedIn(true);
364 SetSessionStarted(true); 357 SetSessionStarted(true);
365 EXPECT_EQ(user::LOGGED_IN_USER, 358 EXPECT_EQ(user::LOGGED_IN_USER,
366 shell->system_tray_delegate()->GetUserLoginStatus()); 359 shell->system_tray_delegate()->GetUserLoginStatus());
367 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers()); 360 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers());
368 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted()); 361 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted());
369 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 362 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
370 kShellWindowId_SystemModalContainer)
371 ->layout_manager(), 363 ->layout_manager(),
372 controller->GetSystemModalLayoutManager(NULL)); 364 controller->GetSystemModalLayoutManager(NULL));
373 365
374 views::Widget* session_modal_widget = 366 views::Widget* session_modal_widget =
375 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 367 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
376 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 368 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
377 kShellWindowId_SystemModalContainer)
378 ->layout_manager(), 369 ->layout_manager(),
379 controller->GetSystemModalLayoutManager( 370 controller->GetSystemModalLayoutManager(
380 session_modal_widget->GetNativeView())); 371 session_modal_widget->GetNativeView()));
381 } 372 }
382 373
383 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { 374 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) {
384 UpdateDisplay("600x600"); 375 UpdateDisplay("600x600");
385 Shell* shell = Shell::GetInstance(); 376 Shell* shell = Shell::GetInstance();
386 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 377 RootWindowController* controller = shell->GetPrimaryRootWindowController();
387 aura::Window* lock_container = Shell::GetContainer( 378 aura::Window* lock_container =
388 controller->root_window(), kShellWindowId_LockScreenContainer); 379 controller->GetContainer(kShellWindowId_LockScreenContainer);
389 for (int block_reason = FIRST_BLOCK_REASON; 380 for (int block_reason = FIRST_BLOCK_REASON;
390 block_reason < NUMBER_OF_BLOCK_REASONS; 381 block_reason < NUMBER_OF_BLOCK_REASONS;
391 ++block_reason) { 382 ++block_reason) {
392 views::Widget* session_modal_widget = 383 views::Widget* session_modal_widget =
393 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 384 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
394 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 385 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
395 kShellWindowId_SystemModalContainer)
396 ->layout_manager(), 386 ->layout_manager(),
397 controller->GetSystemModalLayoutManager( 387 controller->GetSystemModalLayoutManager(
398 session_modal_widget->GetNativeView())); 388 session_modal_widget->GetNativeView()));
399 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 389 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
400 kShellWindowId_SystemModalContainer)
401 ->layout_manager(), 390 ->layout_manager(),
402 controller->GetSystemModalLayoutManager(NULL)); 391 controller->GetSystemModalLayoutManager(NULL));
403 session_modal_widget->Close(); 392 session_modal_widget->Close();
404 393
405 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 394 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
406 395
407 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 396 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
408 kShellWindowId_LockSystemModalContainer)
409 ->layout_manager(), 397 ->layout_manager(),
410 controller->GetSystemModalLayoutManager(NULL)); 398 controller->GetSystemModalLayoutManager(NULL));
411 399
412 views::Widget* lock_modal_widget = 400 views::Widget* lock_modal_widget =
413 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), 401 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100),
414 lock_container); 402 lock_container);
415 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 403 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
416 kShellWindowId_LockSystemModalContainer)
417 ->layout_manager(), 404 ->layout_manager(),
418 controller->GetSystemModalLayoutManager( 405 controller->GetSystemModalLayoutManager(
419 lock_modal_widget->GetNativeView())); 406 lock_modal_widget->GetNativeView()));
420 407
421 session_modal_widget = 408 session_modal_widget =
422 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 409 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
423 EXPECT_EQ(Shell::GetContainer(controller->root_window(), 410 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
424 kShellWindowId_SystemModalContainer)
425 ->layout_manager(), 411 ->layout_manager(),
426 controller->GetSystemModalLayoutManager( 412 controller->GetSystemModalLayoutManager(
427 session_modal_widget->GetNativeView())); 413 session_modal_widget->GetNativeView()));
428 session_modal_widget->Close(); 414 session_modal_widget->Close();
429 415
430 lock_modal_widget->Close(); 416 lock_modal_widget->Close();
431 UnblockUserSession(); 417 UnblockUserSession();
432 } 418 }
433 } 419 }
434 420
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 Shell::RootWindowControllerList controllers = 458 Shell::RootWindowControllerList controllers =
473 Shell::GetInstance()->GetAllRootWindowControllers(); 459 Shell::GetInstance()->GetAllRootWindowControllers();
474 460
475 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 461 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
476 w1->Maximize(); 462 w1->Maximize();
477 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 463 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
478 w2->SetFullscreen(true); 464 w2->SetFullscreen(true);
479 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); 465 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100));
480 466
481 EXPECT_EQ(w1->GetNativeWindow()->GetRootWindow(), 467 EXPECT_EQ(w1->GetNativeWindow()->GetRootWindow(),
482 controllers[0]->root_window()); 468 controllers[0]->GetRootWindow());
483 EXPECT_EQ(w2->GetNativeWindow()->GetRootWindow(), 469 EXPECT_EQ(w2->GetNativeWindow()->GetRootWindow(),
484 controllers[0]->root_window()); 470 controllers[0]->GetRootWindow());
485 EXPECT_EQ(w3->GetNativeWindow()->GetRootWindow(), 471 EXPECT_EQ(w3->GetNativeWindow()->GetRootWindow(),
486 controllers[1]->root_window()); 472 controllers[1]->GetRootWindow());
487 473
488 w1->Activate(); 474 w1->Activate();
489 EXPECT_EQ(NULL, controllers[0]->GetWindowForFullscreenMode()); 475 EXPECT_EQ(NULL, controllers[0]->GetWindowForFullscreenMode());
490 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); 476 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode());
491 477
492 w2->Activate(); 478 w2->Activate();
493 EXPECT_EQ(w2->GetNativeWindow(), 479 EXPECT_EQ(w2->GetNativeWindow(),
494 controllers[0]->GetWindowForFullscreenMode()); 480 controllers[0]->GetWindowForFullscreenMode());
495 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); 481 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode());
496 482
497 // Verify that the first root window controller remains in fullscreen mode 483 // Verify that the first root window controller remains in fullscreen mode
498 // when a window on the other display is activated. 484 // when a window on the other display is activated.
499 w3->Activate(); 485 w3->Activate();
500 EXPECT_EQ(w2->GetNativeWindow(), 486 EXPECT_EQ(w2->GetNativeWindow(),
501 controllers[0]->GetWindowForFullscreenMode()); 487 controllers[0]->GetWindowForFullscreenMode());
502 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); 488 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode());
503 } 489 }
504 490
505 // Test that user session window can't be focused if user session blocked by 491 // Test that user session window can't be focused if user session blocked by
506 // some overlapping UI. 492 // some overlapping UI.
507 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { 493 TEST_F(RootWindowControllerTest, FocusBlockedWindow) {
508 UpdateDisplay("600x600"); 494 UpdateDisplay("600x600");
509 RootWindowController* controller = 495 RootWindowController* controller =
510 Shell::GetInstance()->GetPrimaryRootWindowController(); 496 Shell::GetInstance()->GetPrimaryRootWindowController();
511 aura::Window* lock_container = Shell::GetContainer( 497 aura::Window* lock_container =
512 controller->root_window(), kShellWindowId_LockScreenContainer); 498 controller->GetContainer(kShellWindowId_LockScreenContainer);
513 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, 499 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL,
514 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); 500 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView();
515 lock_window->Show(); 501 lock_window->Show();
516 aura::Window* session_window = 502 aura::Window* session_window =
517 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); 503 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView();
518 session_window->Show(); 504 session_window->Show();
519 505
520 for (int block_reason = FIRST_BLOCK_REASON; 506 for (int block_reason = FIRST_BLOCK_REASON;
521 block_reason < NUMBER_OF_BLOCK_REASONS; 507 block_reason < NUMBER_OF_BLOCK_REASONS;
522 ++block_reason) { 508 ++block_reason) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 754
769 modal_widget->Close(); 755 modal_widget->Close();
770 756
771 // Verify that mouse events are now unblocked to the root window. 757 // Verify that mouse events are now unblocked to the root window.
772 root_window_event_generator.ClickLeftButton(); 758 root_window_event_generator.ClickLeftButton();
773 EXPECT_EQ(2, handler->num_mouse_events() / 2); 759 EXPECT_EQ(2, handler->num_mouse_events() / 2);
774 } 760 }
775 761
776 } // namespace test 762 } // namespace test
777 } // namespace ash 763 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698