| 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/panel_layout_manager.h" | 5 #include "ash/wm/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/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 class PanelLayoutManagerTest : public ash::test::AshTestBase { | 27 class PanelLayoutManagerTest : public ash::test::AshTestBase { |
| 28 public: | 28 public: |
| 29 PanelLayoutManagerTest() {} | 29 PanelLayoutManagerTest() {} |
| 30 virtual ~PanelLayoutManagerTest() {} | 30 virtual ~PanelLayoutManagerTest() {} |
| 31 | 31 |
| 32 virtual void SetUp() OVERRIDE { | 32 virtual void SetUp() OVERRIDE { |
| 33 ash::test::AshTestBase::SetUp(); | 33 ash::test::AshTestBase::SetUp(); |
| 34 ASSERT_TRUE(ash::test::TestLauncherDelegate::instance()); | 34 ASSERT_TRUE(ash::test::TestLauncherDelegate::instance()); |
| 35 | 35 |
| 36 Launcher* launcher = Shell::GetInstance()->launcher(); | |
| 37 launcher_view_test_.reset(new test::LauncherViewTestAPI( | 36 launcher_view_test_.reset(new test::LauncherViewTestAPI( |
| 38 launcher->GetLauncherViewForTest())); | 37 Launcher::ForPrimaryDisplay()->GetLauncherViewForTest())); |
| 39 launcher_view_test_->SetAnimationDuration(1); | 38 launcher_view_test_->SetAnimationDuration(1); |
| 40 } | 39 } |
| 41 | 40 |
| 42 aura::Window* CreateNormalWindow() { | 41 aura::Window* CreateNormalWindow() { |
| 43 return aura::test::CreateTestWindowWithBounds(gfx::Rect(), NULL); | 42 return aura::test::CreateTestWindowWithBounds(gfx::Rect(), NULL); |
| 44 } | 43 } |
| 45 | 44 |
| 46 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { | 45 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { |
| 47 aura::Window* window = aura::test::CreateTestWindowWithDelegateAndType( | 46 aura::Window* window = aura::test::CreateTestWindowWithDelegateAndType( |
| 48 NULL, | 47 NULL, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 72 ASSERT_TRUE(manager->callout_widget()); | 71 ASSERT_TRUE(manager->callout_widget()); |
| 73 *widget = manager->callout_widget(); | 72 *widget = manager->callout_widget(); |
| 74 } | 73 } |
| 75 | 74 |
| 76 // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow | 75 // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow |
| 77 // takes a non-const Window. We can probably fix that. | 76 // takes a non-const Window. We can probably fix that. |
| 78 void IsPanelAboveLauncherIcon(aura::Window* panel) { | 77 void IsPanelAboveLauncherIcon(aura::Window* panel) { |
| 79 // Waits until all launcher view animations are done. | 78 // Waits until all launcher view animations are done. |
| 80 launcher_view_test()->RunMessageLoopUntilAnimationsDone(); | 79 launcher_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 81 | 80 |
| 82 Launcher* launcher = Shell::GetInstance()->launcher(); | 81 Launcher* launcher = Launcher::ForPrimaryDisplay(); |
| 83 gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel); | 82 gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel); |
| 84 ASSERT_FALSE(icon_bounds.IsEmpty()); | 83 ASSERT_FALSE(icon_bounds.IsEmpty()); |
| 85 | 84 |
| 86 gfx::Rect window_bounds = panel->GetBoundsInRootWindow(); | 85 gfx::Rect window_bounds = panel->GetBoundsInRootWindow(); |
| 87 | 86 |
| 88 // 1-pixel tolerance--since we center panels over their icons, panels with | 87 // 1-pixel tolerance--since we center panels over their icons, panels with |
| 89 // odd pixel widths won't be perfectly lined up with even pixel width | 88 // odd pixel widths won't be perfectly lined up with even pixel width |
| 90 // launcher icons. | 89 // launcher icons. |
| 91 EXPECT_NEAR(icon_bounds.CenterPoint().x(), | 90 EXPECT_NEAR(icon_bounds.CenterPoint().x(), |
| 92 window_bounds.CenterPoint().x(), | 91 window_bounds.CenterPoint().x(), |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 wm::ActivateWindow(w2.get()); | 255 wm::ActivateWindow(w2.get()); |
| 257 // Windows should be stacked 1 < 2 > 3 | 256 // Windows should be stacked 1 < 2 > 3 |
| 258 w1.reset(); | 257 w1.reset(); |
| 259 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 258 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
| 260 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 259 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
| 261 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 260 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 262 } | 261 } |
| 263 | 262 |
| 264 } // namespace internal | 263 } // namespace internal |
| 265 } // namespace ash | 264 } // namespace ash |
| OLD | NEW |