| 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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/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/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 ShelfDragCallback(const gfx::Rect& not_visible, const gfx::Rect& visible) | 141 ShelfDragCallback(const gfx::Rect& not_visible, const gfx::Rect& visible) |
| 142 : not_visible_bounds_(not_visible), | 142 : not_visible_bounds_(not_visible), |
| 143 visible_bounds_(visible), | 143 visible_bounds_(visible), |
| 144 was_visible_on_drag_start_(false) { | 144 was_visible_on_drag_start_(false) { |
| 145 EXPECT_EQ(not_visible_bounds_.bottom(), visible_bounds_.bottom()); | 145 EXPECT_EQ(not_visible_bounds_.bottom(), visible_bounds_.bottom()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual ~ShelfDragCallback() {} | 148 virtual ~ShelfDragCallback() {} |
| 149 | 149 |
| 150 void ProcessScroll(ui::EventType type, const gfx::Vector2dF& delta) { | 150 void ProcessScroll(ui::EventType type, const gfx::Vector2dF& delta) { |
| 151 if (GetShelfLayoutManager()->visibility_state() == ash::SHELF_HIDDEN) | 151 if (GetShelfLayoutManager()->visibility_state() == SHELF_HIDDEN) |
| 152 return; | 152 return; |
| 153 | 153 |
| 154 if (type == ui::ET_GESTURE_SCROLL_BEGIN) { | 154 if (type == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 155 scroll_ = gfx::Vector2dF(); | 155 scroll_ = gfx::Vector2dF(); |
| 156 was_visible_on_drag_start_ = GetShelfLayoutManager()->IsVisible(); | 156 was_visible_on_drag_start_ = GetShelfLayoutManager()->IsVisible(); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 // The state of the shelf at the end of the gesture is tested separately. | 160 // The state of the shelf at the end of the gesture is tested separately. |
| 161 if (type == ui::ET_GESTURE_SCROLL_END) | 161 if (type == ui::ET_GESTURE_SCROLL_END) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 views::View* tray_view_; | 311 views::View* tray_view_; |
| 312 views::View* default_view_; | 312 views::View* default_view_; |
| 313 views::View* detailed_view_; | 313 views::View* detailed_view_; |
| 314 views::View* notification_view_; | 314 views::View* notification_view_; |
| 315 | 315 |
| 316 DISALLOW_COPY_AND_ASSIGN(TestItem); | 316 DISALLOW_COPY_AND_ASSIGN(TestItem); |
| 317 }; | 317 }; |
| 318 | 318 |
| 319 } // namespace | 319 } // namespace |
| 320 | 320 |
| 321 class ShelfLayoutManagerTest : public ash::test::AshTestBase { | 321 class ShelfLayoutManagerTest : public test::AshTestBase { |
| 322 public: | 322 public: |
| 323 ShelfLayoutManagerTest() {} | 323 ShelfLayoutManagerTest() {} |
| 324 | 324 |
| 325 // Calls the private SetState() function. | 325 // Calls the private SetState() function. |
| 326 void SetState(ShelfLayoutManager* layout_manager, | 326 void SetState(ShelfLayoutManager* layout_manager, |
| 327 ShelfVisibilityState state) { | 327 ShelfVisibilityState state) { |
| 328 layout_manager->SetState(state); | 328 layout_manager->SetState(state); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void UpdateAutoHideStateNow() { | 331 void UpdateAutoHideStateNow() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 364 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 365 params.bounds = gfx::Rect(0, 0, 200, 200); | 365 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 366 params.context = CurrentContext(); | 366 params.context = CurrentContext(); |
| 367 return CreateTestWidgetWithParams(params); | 367 return CreateTestWidgetWithParams(params); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void RunGestureDragTests(gfx::Vector2d); | 370 void RunGestureDragTests(gfx::Vector2d); |
| 371 | 371 |
| 372 // Turn on the lock screen. | 372 // Turn on the lock screen. |
| 373 void LockScreen() { | 373 void LockScreen() { |
| 374 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 374 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| 375 // The test session state delegate does not fire the lock state change. | 375 // The test session state delegate does not fire the lock state change. |
| 376 Shell::GetInstance()->OnLockStateChanged(true); | 376 Shell::GetInstance()->OnLockStateChanged(true); |
| 377 } | 377 } |
| 378 | 378 |
| 379 // Turn off the lock screen. | 379 // Turn off the lock screen. |
| 380 void UnlockScreen() { | 380 void UnlockScreen() { |
| 381 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 381 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); |
| 382 // The test session state delegate does not fire the lock state change. | 382 // The test session state delegate does not fire the lock state change. |
| 383 Shell::GetInstance()->OnLockStateChanged(false); | 383 Shell::GetInstance()->OnLockStateChanged(false); |
| 384 } | 384 } |
| 385 | 385 |
| 386 private: | 386 private: |
| 387 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); | 387 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
| 388 }; | 388 }; |
| 389 | 389 |
| 390 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { | 390 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| 391 Shelf* shelf = GetShelf(); | 391 Shelf* shelf = GetShelf(); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 #endif | 790 #endif |
| 791 | 791 |
| 792 // Various assertions around auto-hide. | 792 // Various assertions around auto-hide. |
| 793 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { | 793 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { |
| 794 aura::Window* root = Shell::GetPrimaryRootWindow(); | 794 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 795 ui::test::EventGenerator generator(root, root); | 795 ui::test::EventGenerator generator(root, root); |
| 796 generator.MoveMouseTo(0, 0); | 796 generator.MoveMouseTo(0, 0); |
| 797 | 797 |
| 798 Shelf* shelf = GetShelf(); | 798 Shelf* shelf = GetShelf(); |
| 799 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 799 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 800 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 800 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 801 views::Widget* widget = new views::Widget; | 801 views::Widget* widget = new views::Widget; |
| 802 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 802 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 803 params.bounds = gfx::Rect(0, 0, 200, 200); | 803 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 804 params.context = CurrentContext(); | 804 params.context = CurrentContext(); |
| 805 // Widget is now owned by the parent window. | 805 // Widget is now owned by the parent window. |
| 806 widget->Init(params); | 806 widget->Init(params); |
| 807 widget->Maximize(); | 807 widget->Maximize(); |
| 808 widget->Show(); | 808 widget->Show(); |
| 809 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 809 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 810 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 810 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 874 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 875 | 875 |
| 876 // Create a window because the shelf is always shown when no windows are | 876 // Create a window because the shelf is always shown when no windows are |
| 877 // visible. | 877 // visible. |
| 878 CreateTestWidget(); | 878 CreateTestWidget(); |
| 879 | 879 |
| 880 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 880 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 881 ASSERT_EQ(root_windows[0], | 881 ASSERT_EQ(root_windows[0], |
| 882 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); | 882 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); |
| 883 | 883 |
| 884 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 884 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 885 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 885 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 886 | 886 |
| 887 int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; | 887 int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; |
| 888 int y = root_windows[0]->GetBoundsInScreen().y(); | 888 int y = root_windows[0]->GetBoundsInScreen().y(); |
| 889 | 889 |
| 890 // Start off the mouse nowhere near the shelf; the shelf should be hidden. | 890 // Start off the mouse nowhere near the shelf; the shelf should be hidden. |
| 891 ui::test::EventGenerator& generator(GetEventGenerator()); | 891 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 892 generator.MoveMouseTo(right_edge - 50, y); | 892 generator.MoveMouseTo(right_edge - 50, y); |
| 893 UpdateAutoHideStateNow(); | 893 UpdateAutoHideStateNow(); |
| 894 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 894 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 return; | 960 return; |
| 961 | 961 |
| 962 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 962 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 963 // it isn't over the shelf. | 963 // it isn't over the shelf. |
| 964 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 964 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 965 gfx::Point()); | 965 gfx::Point()); |
| 966 generator.MoveMouseTo(0, 0); | 966 generator.MoveMouseTo(0, 0); |
| 967 | 967 |
| 968 Shelf* shelf = GetShelf(); | 968 Shelf* shelf = GetShelf(); |
| 969 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 969 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 970 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 970 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 971 views::Widget* widget = new views::Widget; | 971 views::Widget* widget = new views::Widget; |
| 972 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 972 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 973 params.bounds = gfx::Rect(0, 0, 200, 200); | 973 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 974 params.context = CurrentContext(); | 974 params.context = CurrentContext(); |
| 975 // Widget is now owned by the parent window. | 975 // Widget is now owned by the parent window. |
| 976 widget->Init(params); | 976 widget->Init(params); |
| 977 widget->Maximize(); | 977 widget->Maximize(); |
| 978 widget->Show(); | 978 widget->Show(); |
| 979 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 979 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 980 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 980 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 ->shelf_widget() | 2265 ->shelf_widget() |
| 2266 ->status_area_widget(); | 2266 ->status_area_widget(); |
| 2267 EXPECT_TRUE(status_area_widget->IsVisible()); | 2267 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 2268 // Shelf should be in the first display's area. | 2268 // Shelf should be in the first display's area. |
| 2269 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2269 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 2270 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2270 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 2271 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2271 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 2272 } | 2272 } |
| 2273 | 2273 |
| 2274 } // namespace ash | 2274 } // namespace ash |
| OLD | NEW |