Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: ash/wm/panel_layout_manager_unittest.cc

Issue 9808026: Layout panels on top of their launcher icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pre-patch with tests Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/panel_layout_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/shell.h" 9 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/test_launcher_delegate.h"
11 #include "base/basictypes.h" 13 #include "base/basictypes.h"
12 #include "base/command_line.h" 14 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
14 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
15 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
16 #include "ui/views/widget/widget_delegate.h" 18 #include "ui/views/widget/widget_delegate.h"
17 19
18 namespace ash { 20 namespace ash {
19 21
20 namespace { 22 namespace {
21 23
22 views::Widget* CreatePanelWindow(const gfx::Rect& rect) { 24 views::Widget* CreatePanelWindow(const gfx::Rect& rect) {
23 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL); 25 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
24 params.bounds = rect; 26 params.bounds = rect;
25 views::Widget* widget = new views::Widget(); 27 views::Widget* widget = new views::Widget();
26 widget->Init(params); 28 widget->Init(params);
29 ash::test::TestLauncherDelegate* launcher_delegate = static_cast<ash::test::Te stLauncherDelegate*>(
30 Shell::GetInstance()->launcher()->delegate());
31 launcher_delegate->AddLauncherItem(widget->GetNativeWindow());
27 widget->Show(); 32 widget->Show();
28 return widget; 33 return widget;
29 } 34 }
30 35
31 class PanelLayoutManagerTest : public ash::test::AshTestBase { 36 class PanelLayoutManagerTest : public ash::test::AshTestBase {
32 public: 37 public:
33 PanelLayoutManagerTest() {} 38 PanelLayoutManagerTest() {}
34 virtual ~PanelLayoutManagerTest() {} 39 virtual ~PanelLayoutManagerTest() {}
35 40
36 aura::Window* GetPanelContainer() { 41 aura::Window* GetPanelContainer() {
37 return Shell::GetInstance()->GetContainer( 42 return Shell::GetInstance()->GetContainer(
38 ash::internal::kShellWindowId_PanelContainer); 43 ash::internal::kShellWindowId_PanelContainer);
39 } 44 }
40 45
41 private: 46 private:
42 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); 47 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest);
43 }; 48 };
44 49
50 void AssertPanelAboveLauncherIcon(views::Widget* panel) {
51 Launcher* launcher = Shell::GetInstance()->launcher();
52 aura::Window* window = panel->GetNativeWindow();
53 gfx::Rect icon_rect = launcher->GetScreenBoundsOfItemIconForWindow(window);
54 EXPECT_FALSE(icon_rect.IsEmpty());
Dmitry Lomov (no reviews) 2012/04/10 19:13:22 This test fails. The reason for the failure is tha
55 }
56
45 } // namespace 57 } // namespace
46 58
47 // Tests that a created panel window is successfully added to the panel 59 // Tests that a created panel window is successfully added to the panel
48 // layout manager. 60 // layout manager.
49 TEST_F(PanelLayoutManagerTest, AddOnePanel) { 61 TEST_F(PanelLayoutManagerTest, AddOnePanel) {
50 gfx::Rect bounds(1, 1, 200, 200); 62 gfx::Rect bounds(1, 1, 200, 200);
51 views::Widget* w1 = CreatePanelWindow(bounds); 63 views::Widget* w1 = CreatePanelWindow(bounds);
52 EXPECT_EQ(GetPanelContainer(), w1->GetNativeWindow()->parent()); 64 EXPECT_EQ(GetPanelContainer(), w1->GetNativeWindow()->parent());
53 } 65 }
54 66
55 // Tests that panels are ordered right-to-left. 67 // Tests that panels are ordered right-to-left.
56 TEST_F(PanelLayoutManagerTest, PanelOrderRightToLeft) { 68 TEST_F(PanelLayoutManagerTest, PanelAboveLauncherIcons) {
57 if (!CommandLine::ForCurrentProcess()->HasSwitch( 69 if (!CommandLine::ForCurrentProcess()->HasSwitch(
58 switches::kAuraPanelManager)) 70 switches::kAuraPanelManager))
59 return; 71 return;
60 gfx::Rect bounds(1, 1, 200, 200); 72 gfx::Rect bounds(1, 1, 200, 200);
61 views::Widget* w1 = CreatePanelWindow(bounds); 73 views::Widget* w1 = CreatePanelWindow(bounds);
74 AssertPanelAboveLauncherIcon(w1);
62 views::Widget* w2 = CreatePanelWindow(bounds); 75 views::Widget* w2 = CreatePanelWindow(bounds);
63 EXPECT_LT(w2->GetWindowScreenBounds().x(), w1->GetWindowScreenBounds().x()); 76 AssertPanelAboveLauncherIcon(w2);
64
65 views::Widget* w3 = CreatePanelWindow(bounds); 77 views::Widget* w3 = CreatePanelWindow(bounds);
66 EXPECT_LT(w3->GetWindowScreenBounds().x(), w2->GetWindowScreenBounds().x()); 78 AssertPanelAboveLauncherIcon(w3);
67 EXPECT_LT(w2->GetWindowScreenBounds().x(), w1->GetWindowScreenBounds().x()); 79 AssertPanelAboveLauncherIcon(w1);
80 AssertPanelAboveLauncherIcon(w2);
68 } 81 }
69 82
70 // Tests removing a panel. 83 // Tests removing a panel.
71 TEST_F(PanelLayoutManagerTest, RemovePanel) { 84 TEST_F(PanelLayoutManagerTest, RemovePanel) {
72 if (!CommandLine::ForCurrentProcess()->HasSwitch( 85 if (!CommandLine::ForCurrentProcess()->HasSwitch(
73 switches::kAuraPanelManager)) 86 switches::kAuraPanelManager))
74 return; 87 return;
75 88
76 gfx::Rect bounds(1, 1, 200, 200); 89 gfx::Rect bounds(1, 1, 200, 200);
77 views::Widget* w1 = CreatePanelWindow(bounds); 90 views::Widget* w1 = CreatePanelWindow(bounds);
78 views::Widget* w2 = CreatePanelWindow(bounds); 91 views::Widget* w2 = CreatePanelWindow(bounds);
79 views::Widget* w3 = CreatePanelWindow(bounds); 92 views::Widget* w3 = CreatePanelWindow(bounds);
80 93
81 gfx::Rect w3bounds = w3->GetWindowScreenBounds(); 94 gfx::Rect w3bounds = w3->GetWindowScreenBounds();
82 95
83 GetPanelContainer()->RemoveChild(w2->GetNativeWindow()); 96 GetPanelContainer()->RemoveChild(w2->GetNativeWindow());
84 97
85 // Verify that w3 has moved. 98 // Verify that w3 has moved.
86 EXPECT_NE(w3->GetWindowScreenBounds(), w3bounds); 99 EXPECT_NE(w3->GetWindowScreenBounds(), w3bounds);
87 // Verify that w3 is still left of w1. 100 // Verify that w3 is still left of w1.
88 EXPECT_LT(w3->GetWindowScreenBounds().x(), w1->GetWindowScreenBounds().x()); 101 EXPECT_LT(w3->GetWindowScreenBounds().x(), w1->GetWindowScreenBounds().x());
89 } 102 }
90 103
91 } // namespace ash 104 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panel_layout_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698