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

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

Issue 10969076: Revert of AutoHide Behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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);
307 views::Widget* widget = new views::Widget; 306 views::Widget* widget = new views::Widget;
308 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 307 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
309 params.bounds = gfx::Rect(0, 0, 200, 200); 308 params.bounds = gfx::Rect(0, 0, 200, 200);
310 // Widget is now owned by the parent window. 309 // Widget is now owned by the parent window.
311 widget->Init(params); 310 widget->Init(params);
312 widget->Maximize(); 311 widget->Maximize();
313 widget->Show(); 312 widget->Show();
314 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 313 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
315 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 314 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
316 315
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 359
361 // Assertions around the lock screen showing. 360 // Assertions around the lock screen showing.
362 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { 361 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
363 // Since ShelfLayoutManager queries for mouse location, move the mouse so 362 // Since ShelfLayoutManager queries for mouse location, move the mouse so
364 // it isn't over the shelf. 363 // it isn't over the shelf.
365 aura::test::EventGenerator generator( 364 aura::test::EventGenerator generator(
366 Shell::GetPrimaryRootWindow(), gfx::Point()); 365 Shell::GetPrimaryRootWindow(), gfx::Point());
367 generator.MoveMouseTo(0, 0); 366 generator.MoveMouseTo(0, 0);
368 367
369 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 368 ShelfLayoutManager* shelf = GetShelfLayoutManager();
370 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
371 views::Widget* widget = new views::Widget; 369 views::Widget* widget = new views::Widget;
372 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 370 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
373 params.bounds = gfx::Rect(0, 0, 200, 200); 371 params.bounds = gfx::Rect(0, 0, 200, 200);
374 // Widget is now owned by the parent window. 372 // Widget is now owned by the parent window.
375 widget->Init(params); 373 widget->Init(params);
376 widget->Maximize(); 374 widget->Maximize();
377 widget->Show(); 375 widget->Show();
378 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 376 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
379 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 377 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
380 378
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 419 ShelfLayoutManager* shelf = GetShelfLayoutManager();
422 views::Widget* widget = new views::Widget; 420 views::Widget* widget = new views::Widget;
423 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 421 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
424 params.bounds = gfx::Rect(0, 0, 200, 200); 422 params.bounds = gfx::Rect(0, 0, 200, 200);
425 // Widget is now owned by the parent window. 423 // Widget is now owned by the parent window.
426 widget->Init(params); 424 widget->Init(params);
427 widget->Show(); 425 widget->Show();
428 aura::Window* window = widget->GetNativeWindow(); 426 aura::Window* window = widget->GetNativeWindow();
429 gfx::Rect display_bounds( 427 gfx::Rect display_bounds(
430 gfx::Screen::GetDisplayNearestWindow(window).bounds()); 428 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());
431 432
432 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 433 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
433 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 434 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
434 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, 435 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
435 shelf->GetMaximizedWindowBounds(window).bottom()); 436 shelf->GetMaximizedWindowBounds(window).bottom());
436 437
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
437 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 443 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
438 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 444 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
439 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, 445 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
440 shelf->GetMaximizedWindowBounds(window).bottom()); 446 shelf->GetMaximizedWindowBounds(window).bottom());
441 447
442 widget->Maximize(); 448 widget->Maximize();
443 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 449 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
444 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), 450 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(),
445 widget->GetWorkAreaBoundsInScreen().bottom()); 451 widget->GetWorkAreaBoundsInScreen().bottom());
446 452
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 496 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
491 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 497 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
492 } 498 }
493 499
494 // Makes sure shelf will be visible when app list opens as shelf is in VISIBLE 500 // Makes sure shelf will be visible when app list opens as shelf is in VISIBLE
495 // state,and toggling app list won't change shelf visibility state. 501 // state,and toggling app list won't change shelf visibility state.
496 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { 502 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
497 Shell* shell = Shell::GetInstance(); 503 Shell* shell = Shell::GetInstance();
498 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); 504 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
499 shelf->LayoutShelf(); 505 shelf->LayoutShelf();
500 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 506 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
501 507
502 // Create a normal unmaximized windowm shelf should be visible. 508 // Create a normal unmaximized windowm shelf should be visible.
503 aura::Window* window = CreateTestWindow(); 509 aura::Window* window = CreateTestWindow();
504 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 510 window->SetBounds(gfx::Rect(0, 0, 100, 100));
505 window->Show(); 511 window->Show();
506 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 512 EXPECT_FALSE(shell->GetAppListTargetVisibility());
507 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 513 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
508 514
509 // Toggle app list to show, and the shelf stays visible. 515 // Toggle app list to show, and the shelf stays visible.
510 shell->ToggleAppList(); 516 shell->ToggleAppList();
511 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 517 EXPECT_TRUE(shell->GetAppListTargetVisibility());
512 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 518 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
513 519
514 // Toggle app list to hide, and the shelf stays visible. 520 // Toggle app list to hide, and the shelf stays visible.
515 shell->ToggleAppList(); 521 shell->ToggleAppList();
516 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 522 EXPECT_FALSE(shell->GetAppListTargetVisibility());
517 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 523 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
518 } 524 }
519 525
520 // Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens 526 // Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens
521 // as shelf is in AUTO_HIDE state, and toggling app list won't change shelf 527 // as shelf is in AUTO_HIDE state, and toggling app list won't change shelf
522 // visibility state. 528 // visibility state.
523 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 529 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
524 Shell* shell = Shell::GetInstance(); 530 Shell* shell = Shell::GetInstance();
525 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); 531 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
526 shelf->LayoutShelf(); 532 shelf->LayoutShelf();
527 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 533 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
528 534
529 // Create a window and show it in maximized state. 535 // Create a window and show it in maximized state.
530 aura::Window* window = CreateTestWindow(); 536 aura::Window* window = CreateTestWindow();
531 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 537 window->SetBounds(gfx::Rect(0, 0, 100, 100));
532 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 538 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
533 window->Show(); 539 window->Show();
534 wm::ActivateWindow(window); 540 wm::ActivateWindow(window);
535 541
536 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 542 EXPECT_FALSE(shell->GetAppListTargetVisibility());
537 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 543 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 EXPECT_TRUE(status_area->IsMessageBubbleShown()); 933 EXPECT_TRUE(status_area->IsMessageBubbleShown());
928 } else { 934 } else {
929 EXPECT_FALSE(shelf->IsVisible()); 935 EXPECT_FALSE(shelf->IsVisible());
930 EXPECT_FALSE(status_area->IsMessageBubbleShown()); 936 EXPECT_FALSE(status_area->IsMessageBubbleShown());
931 } 937 }
932 } 938 }
933 } 939 }
934 940
935 } // namespace internal 941 } // namespace internal
936 } // namespace ash 942 } // 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