| 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/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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { | 44 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { |
| 45 ui::AnimationContainerElement* element = | 45 ui::AnimationContainerElement* element = |
| 46 static_cast<ui::AnimationContainerElement*>( | 46 static_cast<ui::AnimationContainerElement*>( |
| 47 widget->GetNativeView()->layer()->GetAnimator()); | 47 widget->GetNativeView()->layer()->GetAnimator()); |
| 48 element->Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 48 element->Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 ShelfLayoutManager* GetShelfLayoutManager() { | 51 ShelfLayoutManager* GetShelfLayoutManager() { |
| 52 aura::Window* window = Shell::GetContainer( | 52 return Shell::GetPrimaryRootWindowController()->shelf(); |
| 53 Shell::GetPrimaryRootWindow(), | 53 } |
| 54 internal::kShellWindowId_LauncherContainer); | 54 |
| 55 return static_cast<ShelfLayoutManager*>(window->layout_manager()); | 55 SystemTray* GetSystemTray() { |
| 56 return Shell::GetPrimaryRootWindowController()->GetSystemTray(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 class ShelfLayoutObserverTest : public ShelfLayoutManager::Observer { | 59 class ShelfLayoutObserverTest : public ShelfLayoutManager::Observer { |
| 59 public: | 60 public: |
| 60 ShelfLayoutObserverTest() | 61 ShelfLayoutObserverTest() |
| 61 : changed_auto_hide_state_(false) { | 62 : changed_auto_hide_state_(false) { |
| 62 } | 63 } |
| 63 | 64 |
| 64 virtual ~ShelfLayoutObserverTest() {} | 65 virtual ~ShelfLayoutObserverTest() {} |
| 65 | 66 |
| 66 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } | 67 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 virtual void OnAutoHideStateChanged( | 70 virtual void OnAutoHideStateChanged( |
| 70 ShelfAutoHideState new_state) OVERRIDE { | 71 ShelfAutoHideState new_state) OVERRIDE { |
| 71 changed_auto_hide_state_ = true; | 72 changed_auto_hide_state_ = true; |
| 72 } | 73 } |
| 73 | 74 |
| 74 bool changed_auto_hide_state_; | 75 bool changed_auto_hide_state_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); | 77 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 // Trivial item implementation that tracks its views for testing. | 80 // Trivial item implementation that tracks its views for testing. |
| 80 class TestItem : public SystemTrayItem { | 81 class TestItem : public SystemTrayItem { |
| 81 public: | 82 public: |
| 82 TestItem() | 83 TestItem() |
| 83 : SystemTrayItem(Shell::GetInstance()->system_tray()), | 84 : SystemTrayItem(GetSystemTray()), |
| 84 tray_view_(NULL), | 85 tray_view_(NULL), |
| 85 default_view_(NULL), | 86 default_view_(NULL), |
| 86 detailed_view_(NULL), | 87 detailed_view_(NULL), |
| 87 notification_view_(NULL) {} | 88 notification_view_(NULL) {} |
| 88 | 89 |
| 89 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { | 90 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { |
| 90 tray_view_ = new views::View; | 91 tray_view_ = new views::View; |
| 91 // Add a label so it has non-zero width. | 92 // Add a label so it has non-zero width. |
| 92 tray_view_->SetLayoutManager(new views::FillLayout); | 93 tray_view_->SetLayoutManager(new views::FillLayout); |
| 93 tray_view_->AddChildView(new views::Label(UTF8ToUTF16("Tray"))); | 94 tray_view_->AddChildView(new views::Label(UTF8ToUTF16("Tray"))); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 147 |
| 147 DISALLOW_COPY_AND_ASSIGN(TestItem); | 148 DISALLOW_COPY_AND_ASSIGN(TestItem); |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 } // namespace | 151 } // namespace |
| 151 | 152 |
| 152 class ShelfLayoutManagerTest : public ash::test::AshTestBase { | 153 class ShelfLayoutManagerTest : public ash::test::AshTestBase { |
| 153 public: | 154 public: |
| 154 ShelfLayoutManagerTest() {} | 155 ShelfLayoutManagerTest() {} |
| 155 | 156 |
| 156 ShelfLayoutManager* shelf_layout_manager() { | |
| 157 return Shell::GetPrimaryRootWindowController()->shelf(); | |
| 158 } | |
| 159 | |
| 160 void SetState(ShelfLayoutManager* shelf, | 157 void SetState(ShelfLayoutManager* shelf, |
| 161 ShelfVisibilityState state) { | 158 ShelfVisibilityState state) { |
| 162 shelf->SetState(state); | 159 shelf->SetState(state); |
| 163 } | 160 } |
| 164 | 161 |
| 165 void UpdateAutoHideStateNow() { | 162 void UpdateAutoHideStateNow() { |
| 166 GetShelfLayoutManager()->UpdateAutoHideStateNow(); | 163 GetShelfLayoutManager()->UpdateAutoHideStateNow(); |
| 167 } | 164 } |
| 168 | 165 |
| 169 aura::Window* CreateTestWindow() { | 166 aura::Window* CreateTestWindow() { |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 500 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 504 } | 501 } |
| 505 | 502 |
| 506 // Makes sure shelf will be visible when app list opens as shelf is in | 503 // Makes sure shelf will be visible when app list opens as shelf is in |
| 507 // SHELF_VISIBLE state,and toggling app list won't change shelf | 504 // SHELF_VISIBLE state,and toggling app list won't change shelf |
| 508 // visibility state. | 505 // visibility state. |
| 509 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { | 506 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { |
| 510 Shell* shell = Shell::GetInstance(); | 507 Shell* shell = Shell::GetInstance(); |
| 511 internal::RootWindowController* controller = | 508 internal::RootWindowController* controller = |
| 512 Shell::GetPrimaryRootWindowController(); | 509 Shell::GetPrimaryRootWindowController(); |
| 513 ShelfLayoutManager* shelf = shelf_layout_manager(); | 510 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 514 shelf->LayoutShelf(); | 511 shelf->LayoutShelf(); |
| 515 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 512 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 516 | 513 |
| 517 // Create a normal unmaximized windowm shelf should be visible. | 514 // Create a normal unmaximized windowm shelf should be visible. |
| 518 aura::Window* window = CreateTestWindow(); | 515 aura::Window* window = CreateTestWindow(); |
| 519 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 516 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 520 window->Show(); | 517 window->Show(); |
| 521 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 518 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 522 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 519 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 523 | 520 |
| 524 // Toggle app list to show, and the shelf stays visible. | 521 // Toggle app list to show, and the shelf stays visible. |
| 525 shell->ToggleAppList(); | 522 shell->ToggleAppList(); |
| 526 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 523 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 527 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 524 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 528 | 525 |
| 529 // Toggle app list to hide, and the shelf stays visible. | 526 // Toggle app list to hide, and the shelf stays visible. |
| 530 shell->ToggleAppList(); | 527 shell->ToggleAppList(); |
| 531 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 528 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 532 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 529 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 533 } | 530 } |
| 534 | 531 |
| 535 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state | 532 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state |
| 536 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and | 533 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and |
| 537 // toggling app list won't change shelf visibility state. | 534 // toggling app list won't change shelf visibility state. |
| 538 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { | 535 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { |
| 539 Shell* shell = Shell::GetInstance(); | 536 Shell* shell = Shell::GetInstance(); |
| 540 ShelfLayoutManager* shelf = shelf_layout_manager(); | 537 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 541 internal::RootWindowController* controller = | 538 internal::RootWindowController* controller = |
| 542 Shell::GetPrimaryRootWindowController(); | 539 Shell::GetPrimaryRootWindowController(); |
| 543 shelf->LayoutShelf(); | 540 shelf->LayoutShelf(); |
| 544 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 541 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 545 | 542 |
| 546 // Create a window and show it in maximized state. | 543 // Create a window and show it in maximized state. |
| 547 aura::Window* window = CreateTestWindow(); | 544 aura::Window* window = CreateTestWindow(); |
| 548 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 545 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 549 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 546 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 550 window->Show(); | 547 window->Show(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 566 // Toggle app list to hide. | 563 // Toggle app list to hide. |
| 567 shell->ToggleAppList(); | 564 shell->ToggleAppList(); |
| 568 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 565 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 569 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 566 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 570 } | 567 } |
| 571 | 568 |
| 572 // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN | 569 // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN |
| 573 // state, and toggling app list won't change shelf visibility state. | 570 // state, and toggling app list won't change shelf visibility state. |
| 574 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { | 571 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { |
| 575 Shell* shell = Shell::GetInstance(); | 572 Shell* shell = Shell::GetInstance(); |
| 576 ShelfLayoutManager* shelf = shelf_layout_manager(); | 573 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 577 // For shelf to be visible, app list is not open in initial state. | 574 // For shelf to be visible, app list is not open in initial state. |
| 578 shelf->LayoutShelf(); | 575 shelf->LayoutShelf(); |
| 579 | 576 |
| 580 // Create a window and make it full screen. | 577 // Create a window and make it full screen. |
| 581 aura::Window* window = CreateTestWindow(); | 578 aura::Window* window = CreateTestWindow(); |
| 582 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 579 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 583 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 580 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 584 window->Show(); | 581 window->Show(); |
| 585 wm::ActivateWindow(window); | 582 wm::ActivateWindow(window); |
| 586 | 583 |
| 587 // App list and shelf is not shown. | 584 // App list and shelf is not shown. |
| 588 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 585 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 589 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 586 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 590 | 587 |
| 591 // Toggle app list to show. | 588 // Toggle app list to show. |
| 592 shell->ToggleAppList(); | 589 shell->ToggleAppList(); |
| 593 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 590 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 594 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 591 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 595 | 592 |
| 596 // Toggle app list to hide. | 593 // Toggle app list to hide. |
| 597 shell->ToggleAppList(); | 594 shell->ToggleAppList(); |
| 598 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 595 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 599 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 596 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 600 } | 597 } |
| 601 | 598 |
| 602 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT. | 599 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT. |
| 603 TEST_F(ShelfLayoutManagerTest, SetAlignment) { | 600 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
| 604 ShelfLayoutManager* shelf = shelf_layout_manager(); | 601 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 605 // Force an initial layout. | 602 // Force an initial layout. |
| 606 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 603 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 607 shelf->LayoutShelf(); | 604 shelf->LayoutShelf(); |
| 608 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 605 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 609 | 606 |
| 610 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 607 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 611 gfx::Rect launcher_bounds( | 608 gfx::Rect launcher_bounds( |
| 612 shelf->launcher_widget()->GetWindowBoundsInScreen()); | 609 shelf->launcher_widget()->GetWindowBoundsInScreen()); |
| 613 const internal::DisplayManager* manager = | 610 const internal::DisplayManager* manager = |
| 614 Shell::GetInstance()->display_manager(); | 611 Shell::GetInstance()->display_manager(); |
| 615 gfx::Display display = | 612 gfx::Display display = |
| 616 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 613 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 617 ASSERT_NE(-1, display.id()); | 614 ASSERT_NE(-1, display.id()); |
| 618 EXPECT_EQ(shelf->GetIdealBounds().width(), | 615 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 619 display.GetWorkAreaInsets().left()); | 616 display.GetWorkAreaInsets().left()); |
| 620 EXPECT_GE( | 617 EXPECT_GE( |
| 621 launcher_bounds.width(), | 618 launcher_bounds.width(), |
| 622 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); | 619 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); |
| 623 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, | 620 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
| 624 Shell::GetInstance()->system_tray()->shelf_alignment()); | |
| 625 StatusAreaWidget* status_area_widget = shelf->status_area_widget(); | 621 StatusAreaWidget* status_area_widget = shelf->status_area_widget(); |
| 626 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); | 622 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 627 EXPECT_GE(status_bounds.width(), | 623 EXPECT_GE(status_bounds.width(), |
| 628 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 624 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 629 EXPECT_EQ(shelf->GetIdealBounds().width(), | 625 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 630 display.GetWorkAreaInsets().left()); | 626 display.GetWorkAreaInsets().left()); |
| 631 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 627 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 632 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 628 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 633 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); | 629 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 634 EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); | 630 EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); |
| 635 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); | 631 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); |
| 636 EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); | 632 EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); |
| 637 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 633 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 638 display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 634 display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 639 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, | 635 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 640 display.GetWorkAreaInsets().left()); | 636 display.GetWorkAreaInsets().left()); |
| 641 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); | 637 EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); |
| 642 | 638 |
| 643 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 639 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 644 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 640 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 645 display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 641 display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 646 launcher_bounds = shelf->launcher_widget()->GetWindowBoundsInScreen(); | 642 launcher_bounds = shelf->launcher_widget()->GetWindowBoundsInScreen(); |
| 647 display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 643 display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
| 648 ASSERT_NE(-1, display.id()); | 644 ASSERT_NE(-1, display.id()); |
| 649 EXPECT_EQ(shelf->GetIdealBounds().width(), | 645 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 650 display.GetWorkAreaInsets().right()); | 646 display.GetWorkAreaInsets().right()); |
| 651 EXPECT_GE(launcher_bounds.width(), | 647 EXPECT_GE(launcher_bounds.width(), |
| 652 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); | 648 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); |
| 653 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, | 649 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); |
| 654 Shell::GetInstance()->system_tray()->shelf_alignment()); | |
| 655 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); | 650 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 656 EXPECT_GE(status_bounds.width(), | 651 EXPECT_GE(status_bounds.width(), |
| 657 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 652 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 658 EXPECT_EQ(shelf->GetIdealBounds().width(), | 653 EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 659 display.GetWorkAreaInsets().right()); | 654 display.GetWorkAreaInsets().right()); |
| 660 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 655 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 661 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 656 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 662 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); | 657 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 663 EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); | 658 EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); |
| 664 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); | 659 EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 765 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 771 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 766 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 772 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 767 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 773 } | 768 } |
| 774 | 769 |
| 775 TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { | 770 TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { |
| 776 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 771 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 777 shelf->LayoutShelf(); | 772 shelf->LayoutShelf(); |
| 778 | 773 |
| 779 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 774 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 780 SystemTray* tray = Shell::GetInstance()->system_tray(); | 775 SystemTray* tray = GetSystemTray(); |
| 781 | 776 |
| 782 // First, make sure the shelf is visible. | 777 // First, make sure the shelf is visible. |
| 783 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 778 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 784 EXPECT_FALSE(tray->HasSystemBubble()); | 779 EXPECT_FALSE(tray->HasSystemBubble()); |
| 785 | 780 |
| 786 // Now, drag up on the tray to show the bubble. | 781 // Now, drag up on the tray to show the bubble. |
| 787 gfx::Point start = | 782 gfx::Point start = |
| 788 shelf->status_area_widget()->GetWindowBoundsInScreen().CenterPoint(); | 783 shelf->status_area_widget()->GetWindowBoundsInScreen().CenterPoint(); |
| 789 gfx::Point end(start.x(), start.y() - 100); | 784 gfx::Point end(start.x(), start.y() - 100); |
| 790 generator.GestureScrollSequence(start, end, | 785 generator.GestureScrollSequence(start, end, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 820 // Turn on auto-hide for the shelf. | 815 // Turn on auto-hide for the shelf. |
| 821 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 816 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 822 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 817 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 823 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 818 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 824 | 819 |
| 825 // Show the status menu. That should make the shelf visible again. | 820 // Show the status menu. That should make the shelf visible again. |
| 826 Shell::GetInstance()->accelerator_controller()->PerformAction( | 821 Shell::GetInstance()->accelerator_controller()->PerformAction( |
| 827 SHOW_SYSTEM_TRAY_BUBBLE, ui::Accelerator()); | 822 SHOW_SYSTEM_TRAY_BUBBLE, ui::Accelerator()); |
| 828 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 823 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 829 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 824 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 830 EXPECT_TRUE(Shell::GetInstance()->system_tray()->HasSystemBubble()); | 825 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| 831 | 826 |
| 832 // Now activate the tray (using the keyboard, instead of using the mouse to | 827 // Now activate the tray (using the keyboard, instead of using the mouse to |
| 833 // make sure the mouse does not alter the auto-hide state in the shelf). | 828 // make sure the mouse does not alter the auto-hide state in the shelf). |
| 834 // This should not trigger any auto-hide state change in the shelf. | 829 // This should not trigger any auto-hide state change in the shelf. |
| 835 ShelfLayoutObserverTest observer; | 830 ShelfLayoutObserverTest observer; |
| 836 shelf->AddObserver(&observer); | 831 shelf->AddObserver(&observer); |
| 837 | 832 |
| 838 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 833 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 839 generator.PressKey(ui::VKEY_SPACE, 0); | 834 generator.PressKey(ui::VKEY_SPACE, 0); |
| 840 generator.ReleaseKey(ui::VKEY_SPACE, 0); | 835 generator.ReleaseKey(ui::VKEY_SPACE, 0); |
| 841 EXPECT_TRUE(Shell::GetInstance()->system_tray()->HasSystemBubble()); | 836 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| 842 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 837 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 843 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 838 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 844 EXPECT_FALSE(observer.changed_auto_hide_state()); | 839 EXPECT_FALSE(observer.changed_auto_hide_state()); |
| 845 | 840 |
| 846 shelf->RemoveObserver(&observer); | 841 shelf->RemoveObserver(&observer); |
| 847 } | 842 } |
| 848 | 843 |
| 849 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { | 844 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| 850 // Make sure the shelf is always visible. | 845 // Make sure the shelf is always visible. |
| 851 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 846 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 // Activate the first window. Now, both windows should be of the same size | 889 // Activate the first window. Now, both windows should be of the same size |
| 895 // again. | 890 // again. |
| 896 widget_two->Activate(); | 891 widget_two->Activate(); |
| 897 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 892 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 898 widget_two->GetNativeWindow()->bounds().ToString()); | 893 widget_two->GetNativeWindow()->bounds().ToString()); |
| 899 } | 894 } |
| 900 | 895 |
| 901 // Confirm that the shelf is dimmed only when content is maximized and | 896 // Confirm that the shelf is dimmed only when content is maximized and |
| 902 // shelf is not autohidden. | 897 // shelf is not autohidden. |
| 903 TEST_F(ShelfLayoutManagerTest, Dimming) { | 898 TEST_F(ShelfLayoutManagerTest, Dimming) { |
| 904 shelf_layout_manager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 899 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 905 scoped_ptr<aura::Window> w1(CreateTestWindow()); | 900 scoped_ptr<aura::Window> w1(CreateTestWindow()); |
| 906 w1->Show(); | 901 w1->Show(); |
| 907 wm::ActivateWindow(w1.get()); | 902 wm::ActivateWindow(w1.get()); |
| 908 | 903 |
| 909 // Normal window doesn't dim shelf. | 904 // Normal window doesn't dim shelf. |
| 910 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 905 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 911 Launcher* launcher = Launcher::ForPrimaryDisplay(); | 906 Launcher* launcher = Launcher::ForPrimaryDisplay(); |
| 912 EXPECT_FALSE(launcher->GetDimsShelf()); | 907 EXPECT_FALSE(launcher->GetDimsShelf()); |
| 913 | 908 |
| 914 // Maximized window does. | 909 // Maximized window does. |
| 915 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 910 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 916 EXPECT_TRUE(launcher->GetDimsShelf()); | 911 EXPECT_TRUE(launcher->GetDimsShelf()); |
| 917 | 912 |
| 918 // Change back to normal stops dimming. | 913 // Change back to normal stops dimming. |
| 919 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 914 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 920 EXPECT_FALSE(launcher->GetDimsShelf()); | 915 EXPECT_FALSE(launcher->GetDimsShelf()); |
| 921 | 916 |
| 922 // Changing back to maximized dims again. | 917 // Changing back to maximized dims again. |
| 923 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 918 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 924 EXPECT_TRUE(launcher->GetDimsShelf()); | 919 EXPECT_TRUE(launcher->GetDimsShelf()); |
| 925 | 920 |
| 926 // Changing shelf to autohide stops dimming. | 921 // Changing shelf to autohide stops dimming. |
| 927 shelf_layout_manager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 922 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 928 EXPECT_FALSE(launcher->GetDimsShelf()); | 923 EXPECT_FALSE(launcher->GetDimsShelf()); |
| 929 } | 924 } |
| 930 | 925 |
| 931 // Make sure that the shelf will not hide if the mouse is between a bubble and | 926 // Make sure that the shelf will not hide if the mouse is between a bubble and |
| 932 // the shelf. | 927 // the shelf. |
| 933 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { | 928 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { |
| 934 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 929 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 935 StatusAreaWidget* status_area_widget = | 930 StatusAreaWidget* status_area_widget = |
| 936 Shell::GetPrimaryRootWindowController()->status_area_widget(); | 931 Shell::GetPrimaryRootWindowController()->status_area_widget(); |
| 937 SystemTray* tray = Shell::GetInstance()->system_tray(); | 932 SystemTray* tray = GetSystemTray(); |
| 938 | 933 |
| 939 shelf->LayoutShelf(); | 934 shelf->LayoutShelf(); |
| 940 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 935 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 941 | 936 |
| 942 // Make two iterations - first without a message bubble which should make | 937 // Make two iterations - first without a message bubble which should make |
| 943 // the shelf disappear and then with a message bubble which should keep it | 938 // the shelf disappear and then with a message bubble which should keep it |
| 944 // visible. | 939 // visible. |
| 945 for (int i = 0; i < 2; i++) { | 940 for (int i = 0; i < 2; i++) { |
| 946 // Make sure the shelf is visible and position the mouse over it. Then | 941 // Make sure the shelf is visible and position the mouse over it. Then |
| 947 // allow auto hide. | 942 // allow auto hide. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 972 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 967 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 973 } else { | 968 } else { |
| 974 EXPECT_FALSE(shelf->IsVisible()); | 969 EXPECT_FALSE(shelf->IsVisible()); |
| 975 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 970 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 976 } | 971 } |
| 977 } | 972 } |
| 978 } | 973 } |
| 979 | 974 |
| 980 } // namespace internal | 975 } // namespace internal |
| 981 } // namespace ash | 976 } // namespace ash |
| OLD | NEW |