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

Side by Side Diff: ash/wm/shelf_layout_manager_unittest.cc

Issue 10987005: Autohide behavior simplified to always/never (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/wm/shelf_layout_manager.cc ('k') | ash/wm/shelf_types.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/wm/shelf_layout_manager.h" 5 #include "ash/wm/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/focus_cycler.h" 9 #include "ash/focus_cycler.h"
10 #include "ash/launcher/launcher.h" 10 #include "ash/launcher/launcher.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 widget->SetFullscreen(true); 296 widget->SetFullscreen(true);
297 } 297 }
298 298
299 // Various assertions around auto-hide. 299 // Various assertions around auto-hide.
300 TEST_F(ShelfLayoutManagerTest, AutoHide) { 300 TEST_F(ShelfLayoutManagerTest, AutoHide) {
301 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); 301 aura::RootWindow* root = Shell::GetPrimaryRootWindow();
302 aura::test::EventGenerator generator(root, root); 302 aura::test::EventGenerator generator(root, root);
303 generator.MoveMouseTo(0, 0); 303 generator.MoveMouseTo(0, 0);
304 304
305 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 305 ShelfLayoutManager* shelf = GetShelfLayoutManager();
306 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
306 views::Widget* widget = new views::Widget; 307 views::Widget* widget = new views::Widget;
307 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 308 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
308 params.bounds = gfx::Rect(0, 0, 200, 200); 309 params.bounds = gfx::Rect(0, 0, 200, 200);
309 // Widget is now owned by the parent window. 310 // Widget is now owned by the parent window.
310 widget->Init(params); 311 widget->Init(params);
311 widget->Maximize(); 312 widget->Maximize();
312 widget->Show(); 313 widget->Show();
313 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 314 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
314 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 315 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
315 316
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 // Assertions around the lock screen showing. 361 // Assertions around the lock screen showing.
361 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { 362 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
362 // Since ShelfLayoutManager queries for mouse location, move the mouse so 363 // Since ShelfLayoutManager queries for mouse location, move the mouse so
363 // it isn't over the shelf. 364 // it isn't over the shelf.
364 aura::test::EventGenerator generator( 365 aura::test::EventGenerator generator(
365 Shell::GetPrimaryRootWindow(), gfx::Point()); 366 Shell::GetPrimaryRootWindow(), gfx::Point());
366 generator.MoveMouseTo(0, 0); 367 generator.MoveMouseTo(0, 0);
367 368
368 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 369 ShelfLayoutManager* shelf = GetShelfLayoutManager();
370 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
369 views::Widget* widget = new views::Widget; 371 views::Widget* widget = new views::Widget;
370 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 372 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
371 params.bounds = gfx::Rect(0, 0, 200, 200); 373 params.bounds = gfx::Rect(0, 0, 200, 200);
372 // Widget is now owned by the parent window. 374 // Widget is now owned by the parent window.
373 widget->Init(params); 375 widget->Init(params);
374 widget->Maximize(); 376 widget->Maximize();
375 widget->Show(); 377 widget->Show();
376 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 378 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
377 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 379 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
378 380
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 421 ShelfLayoutManager* shelf = GetShelfLayoutManager();
420 views::Widget* widget = new views::Widget; 422 views::Widget* widget = new views::Widget;
421 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 423 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
422 params.bounds = gfx::Rect(0, 0, 200, 200); 424 params.bounds = gfx::Rect(0, 0, 200, 200);
423 // Widget is now owned by the parent window. 425 // Widget is now owned by the parent window.
424 widget->Init(params); 426 widget->Init(params);
425 widget->Show(); 427 widget->Show();
426 aura::Window* window = widget->GetNativeWindow(); 428 aura::Window* window = widget->GetNativeWindow();
427 gfx::Rect display_bounds( 429 gfx::Rect display_bounds(
428 gfx::Screen::GetDisplayNearestWindow(window).bounds()); 430 gfx::Screen::GetDisplayNearestWindow(window).bounds());
429 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
430 shelf->GetMaximizedWindowBounds(window).bottom());
431 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
432 431
433 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 432 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
434 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 433 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
435 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, 434 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
436 shelf->GetMaximizedWindowBounds(window).bottom()); 435 shelf->GetMaximizedWindowBounds(window).bottom());
437 436
438 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
439 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
440 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
441 shelf->GetMaximizedWindowBounds(window).bottom());
442
443 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 437 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
444 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 438 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
445 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, 439 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
446 shelf->GetMaximizedWindowBounds(window).bottom()); 440 shelf->GetMaximizedWindowBounds(window).bottom());
447 441
448 widget->Maximize(); 442 widget->Maximize();
449 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 443 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
450 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), 444 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(),
451 widget->GetWorkAreaBoundsInScreen().bottom()); 445 widget->GetWorkAreaBoundsInScreen().bottom());
452 446
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 490 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
497 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 491 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
498 } 492 }
499 493
500 // Makes sure shelf will be visible when app list opens as shelf is in VISIBLE 494 // Makes sure shelf will be visible when app list opens as shelf is in VISIBLE
501 // state,and toggling app list won't change shelf visibility state. 495 // state,and toggling app list won't change shelf visibility state.
502 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { 496 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
503 Shell* shell = Shell::GetInstance(); 497 Shell* shell = Shell::GetInstance();
504 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); 498 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
505 shelf->LayoutShelf(); 499 shelf->LayoutShelf();
506 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); 500 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
507 501
508 // Create a normal unmaximized windowm shelf should be visible. 502 // Create a normal unmaximized windowm shelf should be visible.
509 aura::Window* window = CreateTestWindow(); 503 aura::Window* window = CreateTestWindow();
510 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 504 window->SetBounds(gfx::Rect(0, 0, 100, 100));
511 window->Show(); 505 window->Show();
512 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 506 EXPECT_FALSE(shell->GetAppListTargetVisibility());
513 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 507 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
514 508
515 // Toggle app list to show, and the shelf stays visible. 509 // Toggle app list to show, and the shelf stays visible.
516 shell->ToggleAppList(); 510 shell->ToggleAppList();
517 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 511 EXPECT_TRUE(shell->GetAppListTargetVisibility());
518 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 512 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
519 513
520 // Toggle app list to hide, and the shelf stays visible. 514 // Toggle app list to hide, and the shelf stays visible.
521 shell->ToggleAppList(); 515 shell->ToggleAppList();
522 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 516 EXPECT_FALSE(shell->GetAppListTargetVisibility());
523 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 517 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
524 } 518 }
525 519
526 // Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens 520 // Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens
527 // as shelf is in AUTO_HIDE state, and toggling app list won't change shelf 521 // as shelf is in AUTO_HIDE state, and toggling app list won't change shelf
528 // visibility state. 522 // visibility state.
529 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 523 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
530 Shell* shell = Shell::GetInstance(); 524 Shell* shell = Shell::GetInstance();
531 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); 525 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
532 shelf->LayoutShelf(); 526 shelf->LayoutShelf();
533 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); 527 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
534 528
535 // Create a window and show it in maximized state. 529 // Create a window and show it in maximized state.
536 aura::Window* window = CreateTestWindow(); 530 aura::Window* window = CreateTestWindow();
537 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 531 window->SetBounds(gfx::Rect(0, 0, 100, 100));
538 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 532 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
539 window->Show(); 533 window->Show();
540 wm::ActivateWindow(window); 534 wm::ActivateWindow(window);
541 535
542 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 536 EXPECT_FALSE(shell->GetAppListTargetVisibility());
543 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 537 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 EXPECT_TRUE(status_area->IsMessageBubbleShown()); 941 EXPECT_TRUE(status_area->IsMessageBubbleShown());
948 } else { 942 } else {
949 EXPECT_FALSE(shelf->IsVisible()); 943 EXPECT_FALSE(shelf->IsVisible());
950 EXPECT_FALSE(status_area->IsMessageBubbleShown()); 944 EXPECT_FALSE(status_area->IsMessageBubbleShown());
951 } 945 }
952 } 946 }
953 } 947 }
954 948
955 } // namespace internal 949 } // namespace internal
956 } // namespace ash 950 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/shelf_layout_manager.cc ('k') | ash/wm/shelf_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698