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/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/launcher/launcher_button.h" | 9 #include "ash/launcher/launcher_button.h" |
10 #include "ash/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
11 #include "ash/launcher/launcher_view.h" | 11 #include "ash/launcher/launcher_view.h" |
12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
13 #include "ash/screen_ash.h" | 13 #include "ash/screen_ash.h" |
14 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
15 #include "ash/shelf/shelf_types.h" | 15 #include "ash/shelf/shelf_types.h" |
16 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
18 #include "ash/shell_window_ids.h" | 18 #include "ash/shell_window_ids.h" |
19 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
| 20 #include "ash/test/launcher_test_api.h" |
20 #include "ash/test/launcher_view_test_api.h" | 21 #include "ash/test/launcher_view_test_api.h" |
21 #include "ash/test/shell_test_api.h" | 22 #include "ash/test/shell_test_api.h" |
22 #include "ash/test/test_launcher_delegate.h" | 23 #include "ash/test/test_launcher_delegate.h" |
23 #include "ash/wm/window_util.h" | 24 #include "ash/wm/window_util.h" |
24 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
25 #include "base/command_line.h" | 26 #include "base/command_line.h" |
26 #include "base/compiler_specific.h" | 27 #include "base/compiler_specific.h" |
27 #include "base/i18n/rtl.h" | 28 #include "base/i18n/rtl.h" |
28 #include "base/run_loop.h" | 29 #include "base/run_loop.h" |
29 #include "ui/aura/client/aura_constants.h" | 30 #include "ui/aura/client/aura_constants.h" |
(...skipping 13 matching lines...) Expand all Loading... |
43 class PanelLayoutManagerTest : public test::AshTestBase { | 44 class PanelLayoutManagerTest : public test::AshTestBase { |
44 public: | 45 public: |
45 PanelLayoutManagerTest() {} | 46 PanelLayoutManagerTest() {} |
46 virtual ~PanelLayoutManagerTest() {} | 47 virtual ~PanelLayoutManagerTest() {} |
47 | 48 |
48 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
49 test::AshTestBase::SetUp(); | 50 test::AshTestBase::SetUp(); |
50 ASSERT_TRUE(test::TestLauncherDelegate::instance()); | 51 ASSERT_TRUE(test::TestLauncherDelegate::instance()); |
51 | 52 |
52 launcher_view_test_.reset(new test::LauncherViewTestAPI( | 53 launcher_view_test_.reset(new test::LauncherViewTestAPI( |
53 Launcher::ForPrimaryDisplay()->GetLauncherViewForTest())); | 54 GetLauncherView(Launcher::ForPrimaryDisplay()))); |
54 launcher_view_test_->SetAnimationDuration(1); | 55 launcher_view_test_->SetAnimationDuration(1); |
55 } | 56 } |
56 | 57 |
57 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { | 58 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { |
58 return CreateTestWindowInShellWithBounds(bounds); | 59 return CreateTestWindowInShellWithBounds(bounds); |
59 } | 60 } |
60 | 61 |
61 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { | 62 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { |
62 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 63 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
63 NULL, | 64 NULL, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 ash::Shell* shell = ash::Shell::GetInstance(); | 245 ash::Shell* shell = ash::Shell::GetInstance(); |
245 return shell->GetShelfAlignment(root_window); | 246 return shell->GetShelfAlignment(root_window); |
246 } | 247 } |
247 | 248 |
248 void SetShelfAutoHideBehavior(aura::Window* window, | 249 void SetShelfAutoHideBehavior(aura::Window* window, |
249 ShelfAutoHideBehavior behavior) { | 250 ShelfAutoHideBehavior behavior) { |
250 internal::ShelfLayoutManager* shelf = | 251 internal::ShelfLayoutManager* shelf = |
251 RootWindowController::ForWindow(window)->shelf()-> | 252 RootWindowController::ForWindow(window)->shelf()-> |
252 shelf_layout_manager(); | 253 shelf_layout_manager(); |
253 shelf->SetAutoHideBehavior(behavior); | 254 shelf->SetAutoHideBehavior(behavior); |
254 LauncherView* launcher_view = | 255 LauncherView* launcher_view = GetLauncherView(Launcher::ForWindow(window)); |
255 Launcher::ForWindow(window)->GetLauncherViewForTest(); | |
256 test::LauncherViewTestAPI test_api(launcher_view); | 256 test::LauncherViewTestAPI test_api(launcher_view); |
257 test_api.RunMessageLoopUntilAnimationsDone(); | 257 test_api.RunMessageLoopUntilAnimationsDone(); |
258 } | 258 } |
259 | 259 |
260 void SetShelfVisibilityState(aura::Window* window, | 260 void SetShelfVisibilityState(aura::Window* window, |
261 ShelfVisibilityState visibility_state) { | 261 ShelfVisibilityState visibility_state) { |
262 internal::ShelfLayoutManager* shelf = | 262 internal::ShelfLayoutManager* shelf = |
263 RootWindowController::ForWindow(window)->shelf()-> | 263 RootWindowController::ForWindow(window)->shelf()-> |
264 shelf_layout_manager(); | 264 shelf_layout_manager(); |
265 shelf->SetState(visibility_state); | 265 shelf->SetState(visibility_state); |
266 } | 266 } |
267 | 267 |
| 268 internal::LauncherView* GetLauncherView(Launcher* launcher) { |
| 269 return test::LauncherTestAPI(launcher).launcher_view(); |
| 270 } |
| 271 |
268 private: | 272 private: |
269 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; | 273 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; |
270 | 274 |
271 bool IsHorizontal(ShelfAlignment alignment) { | 275 bool IsHorizontal(ShelfAlignment alignment) { |
272 return alignment == SHELF_ALIGNMENT_BOTTOM || | 276 return alignment == SHELF_ALIGNMENT_BOTTOM || |
273 alignment == SHELF_ALIGNMENT_TOP; | 277 alignment == SHELF_ALIGNMENT_TOP; |
274 } | 278 } |
275 | 279 |
276 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); | 280 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); |
277 }; | 281 }; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 // space for launcher buttons. | 604 // space for launcher buttons. |
601 UpdateDisplay("600x400,600x400"); | 605 UpdateDisplay("600x400,600x400"); |
602 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 606 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
603 | 607 |
604 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 608 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
605 scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 609 scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
606 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 610 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
607 scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 611 scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
608 | 612 |
609 LauncherView* launcher_view_1st = | 613 LauncherView* launcher_view_1st = |
610 Launcher::ForPrimaryDisplay()->GetLauncherViewForTest(); | 614 GetLauncherView(Launcher::ForPrimaryDisplay()); |
611 LauncherView* launcher_view_2nd = | 615 LauncherView* launcher_view_2nd = |
612 Launcher::ForWindow(root_windows[1])->GetLauncherViewForTest(); | 616 GetLauncherView(Launcher::ForWindow(root_windows[1])); |
613 | 617 |
614 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 618 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
615 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); | 619 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); |
616 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 620 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
617 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); | 621 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); |
618 | 622 |
619 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d1->parent()->id()); | 623 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d1->parent()->id()); |
620 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d1->parent()->id()); | 624 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d1->parent()->id()); |
621 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d2->parent()->id()); | 625 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p1_d2->parent()->id()); |
622 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d2->parent()->id()); | 626 EXPECT_EQ(internal::kShellWindowId_PanelContainer, p2_d2->parent()->id()); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 EXPECT_TRUE(w1->IsVisible()); | 779 EXPECT_TRUE(w1->IsVisible()); |
776 EXPECT_FALSE(w2->IsVisible()); | 780 EXPECT_FALSE(w2->IsVisible()); |
777 EXPECT_TRUE(w3->IsVisible()); | 781 EXPECT_TRUE(w3->IsVisible()); |
778 } | 782 } |
779 | 783 |
780 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, | 784 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
781 testing::Bool()); | 785 testing::Bool()); |
782 | 786 |
783 } // namespace internal | 787 } // namespace internal |
784 } // namespace ash | 788 } // namespace ash |
OLD | NEW |