| 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/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/run_loop.h" | 31 #include "base/run_loop.h" |
| 32 #include "ui/aura/client/aura_constants.h" | 32 #include "ui/aura/client/aura_constants.h" |
| 33 #include "ui/aura/test/event_generator.h" | 33 #include "ui/aura/test/event_generator.h" |
| 34 #include "ui/aura/test/test_windows.h" | 34 #include "ui/aura/test/test_windows.h" |
| 35 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
| 36 #include "ui/aura/window_event_dispatcher.h" | 36 #include "ui/aura/window_event_dispatcher.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 38 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
| 39 | 39 |
| 40 namespace ash { | 40 namespace ash { |
| 41 namespace internal { | |
| 42 | 41 |
| 43 using aura::test::WindowIsAbove; | 42 using aura::test::WindowIsAbove; |
| 44 | 43 |
| 45 class PanelLayoutManagerTest : public test::AshTestBase { | 44 class PanelLayoutManagerTest : public test::AshTestBase { |
| 46 public: | 45 public: |
| 47 PanelLayoutManagerTest() {} | 46 PanelLayoutManagerTest() {} |
| 48 virtual ~PanelLayoutManagerTest() {} | 47 virtual ~PanelLayoutManagerTest() {} |
| 49 | 48 |
| 50 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
| 51 test::AshTestBase::SetUp(); | 50 test::AshTestBase::SetUp(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 68 shelf_delegate->AddShelfItem(window); | 67 shelf_delegate->AddShelfItem(window); |
| 69 PanelLayoutManager* manager = static_cast<PanelLayoutManager*>( | 68 PanelLayoutManager* manager = static_cast<PanelLayoutManager*>( |
| 70 GetPanelContainer(window)->layout_manager()); | 69 GetPanelContainer(window)->layout_manager()); |
| 71 manager->Relayout(); | 70 manager->Relayout(); |
| 72 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 71 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 73 return window; | 72 return window; |
| 74 } | 73 } |
| 75 | 74 |
| 76 aura::Window* GetPanelContainer(aura::Window* panel) { | 75 aura::Window* GetPanelContainer(aura::Window* panel) { |
| 77 return Shell::GetContainer(panel->GetRootWindow(), | 76 return Shell::GetContainer(panel->GetRootWindow(), |
| 78 internal::kShellWindowId_PanelContainer); | 77 kShellWindowId_PanelContainer); |
| 79 } | 78 } |
| 80 | 79 |
| 81 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) { | 80 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) { |
| 82 PanelLayoutManager* manager = | 81 PanelLayoutManager* manager = |
| 83 static_cast<PanelLayoutManager*>(GetPanelContainer(panel)-> | 82 static_cast<PanelLayoutManager*>(GetPanelContainer(panel)-> |
| 84 layout_manager()); | 83 layout_manager()); |
| 85 DCHECK(manager); | 84 DCHECK(manager); |
| 86 PanelLayoutManager::PanelList::iterator found = std::find( | 85 PanelLayoutManager::PanelList::iterator found = std::find( |
| 87 manager->panel_windows_.begin(), manager->panel_windows_.end(), | 86 manager->panel_windows_.begin(), manager->panel_windows_.end(), |
| 88 panel); | 87 panel); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 shell->SetShelfAlignment(alignment, root_window); | 230 shell->SetShelfAlignment(alignment, root_window); |
| 232 } | 231 } |
| 233 | 232 |
| 234 ShelfAlignment GetAlignment(aura::Window* root_window) { | 233 ShelfAlignment GetAlignment(aura::Window* root_window) { |
| 235 ash::Shell* shell = ash::Shell::GetInstance(); | 234 ash::Shell* shell = ash::Shell::GetInstance(); |
| 236 return shell->GetShelfAlignment(root_window); | 235 return shell->GetShelfAlignment(root_window); |
| 237 } | 236 } |
| 238 | 237 |
| 239 void SetShelfAutoHideBehavior(aura::Window* window, | 238 void SetShelfAutoHideBehavior(aura::Window* window, |
| 240 ShelfAutoHideBehavior behavior) { | 239 ShelfAutoHideBehavior behavior) { |
| 241 internal::ShelfLayoutManager* shelf = | 240 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window) |
| 242 RootWindowController::ForWindow(window)->shelf()-> | 241 ->shelf() |
| 243 shelf_layout_manager(); | 242 ->shelf_layout_manager(); |
| 244 shelf->SetAutoHideBehavior(behavior); | 243 shelf->SetAutoHideBehavior(behavior); |
| 245 ShelfView* shelf_view = GetShelfView(Shelf::ForWindow(window)); | 244 ShelfView* shelf_view = GetShelfView(Shelf::ForWindow(window)); |
| 246 test::ShelfViewTestAPI test_api(shelf_view); | 245 test::ShelfViewTestAPI test_api(shelf_view); |
| 247 test_api.RunMessageLoopUntilAnimationsDone(); | 246 test_api.RunMessageLoopUntilAnimationsDone(); |
| 248 } | 247 } |
| 249 | 248 |
| 250 void SetShelfVisibilityState(aura::Window* window, | 249 void SetShelfVisibilityState(aura::Window* window, |
| 251 ShelfVisibilityState visibility_state) { | 250 ShelfVisibilityState visibility_state) { |
| 252 internal::ShelfLayoutManager* shelf = | 251 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window) |
| 253 RootWindowController::ForWindow(window)->shelf()-> | 252 ->shelf() |
| 254 shelf_layout_manager(); | 253 ->shelf_layout_manager(); |
| 255 shelf->SetState(visibility_state); | 254 shelf->SetState(visibility_state); |
| 256 } | 255 } |
| 257 | 256 |
| 258 internal::ShelfView* GetShelfView(Shelf* shelf) { | 257 ShelfView* GetShelfView(Shelf* shelf) { |
| 259 return test::ShelfTestAPI(shelf).shelf_view(); | 258 return test::ShelfTestAPI(shelf).shelf_view(); |
| 260 } | 259 } |
| 261 | 260 |
| 262 private: | 261 private: |
| 263 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 262 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 264 | 263 |
| 265 bool IsHorizontal(ShelfAlignment alignment) { | 264 bool IsHorizontal(ShelfAlignment alignment) { |
| 266 return alignment == SHELF_ALIGNMENT_BOTTOM || | 265 return alignment == SHELF_ALIGNMENT_BOTTOM || |
| 267 alignment == SHELF_ALIGNMENT_TOP; | 266 alignment == SHELF_ALIGNMENT_TOP; |
| 268 } | 267 } |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 601 |
| 603 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); | 602 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); |
| 604 ShelfView* shelf_view_2nd = | 603 ShelfView* shelf_view_2nd = |
| 605 GetShelfView(Shelf::ForWindow(root_windows[1])); | 604 GetShelfView(Shelf::ForWindow(root_windows[1])); |
| 606 | 605 |
| 607 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 606 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
| 608 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); | 607 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); |
| 609 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 608 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 610 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); | 609 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); |
| 611 | 610 |
| 612 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d1->parent()->id()); | 611 EXPECT_EQ(kShellWindowId_PanelContainer, p1_d1->parent()->id()); |
| 613 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d1->parent()->id()); | 612 EXPECT_EQ(kShellWindowId_PanelContainer, p2_d1->parent()->id()); |
| 614 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d2->parent()->id()); | 613 EXPECT_EQ(kShellWindowId_PanelContainer, p1_d2->parent()->id()); |
| 615 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d2->parent()->id()); | 614 EXPECT_EQ(kShellWindowId_PanelContainer, p2_d2->parent()->id()); |
| 616 | 615 |
| 617 // Test a panel on 1st display. | 616 // Test a panel on 1st display. |
| 618 // Clicking on the same display has no effect. | 617 // Clicking on the same display has no effect. |
| 619 ClickShelfItemForWindow(shelf_view_1st, p1_d1.get()); | 618 ClickShelfItemForWindow(shelf_view_1st, p1_d1.get()); |
| 620 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 619 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
| 621 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); | 620 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); |
| 622 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 621 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 623 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 622 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 624 EXPECT_FALSE(root_windows[1]->GetBoundsInScreen().Contains( | 623 EXPECT_FALSE(root_windows[1]->GetBoundsInScreen().Contains( |
| 625 p1_d1->GetBoundsInScreen())); | 624 p1_d1->GetBoundsInScreen())); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 780 |
| 782 // Windows should be restored to their prior state. | 781 // Windows should be restored to their prior state. |
| 783 EXPECT_TRUE(w1->IsVisible()); | 782 EXPECT_TRUE(w1->IsVisible()); |
| 784 EXPECT_FALSE(w2->IsVisible()); | 783 EXPECT_FALSE(w2->IsVisible()); |
| 785 EXPECT_TRUE(w3->IsVisible()); | 784 EXPECT_TRUE(w3->IsVisible()); |
| 786 } | 785 } |
| 787 | 786 |
| 788 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, | 787 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
| 789 testing::Bool()); | 788 testing::Bool()); |
| 790 | 789 |
| 791 } // namespace internal | |
| 792 } // namespace ash | 790 } // namespace ash |
| OLD | NEW |