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

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

Issue 13482010: Align panels over hidden launcher icons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test PanelLayoutManagerTest.PanelAlignsToHiddenLauncherIcon Created 7 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/panels/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/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_types.h" 15 #include "ash/shelf/shelf_types.h"
15 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/shell_window_ids.h" 18 #include "ash/shell_window_ids.h"
18 #include "ash/test/ash_test_base.h" 19 #include "ash/test/ash_test_base.h"
19 #include "ash/test/launcher_view_test_api.h" 20 #include "ash/test/launcher_view_test_api.h"
20 #include "ash/test/shell_test_api.h" 21 #include "ash/test/shell_test_api.h"
21 #include "ash/test/test_launcher_delegate.h" 22 #include "ash/test/test_launcher_delegate.h"
22 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
23 #include "base/basictypes.h" 24 #include "base/basictypes.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow 116 // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow
116 // takes a non-const Window. We can probably fix that. 117 // takes a non-const Window. We can probably fix that.
117 void IsPanelAboveLauncherIcon(aura::Window* panel) { 118 void IsPanelAboveLauncherIcon(aura::Window* panel) {
118 // Waits until all launcher view animations are done. 119 // Waits until all launcher view animations are done.
119 launcher_view_test()->RunMessageLoopUntilAnimationsDone(); 120 launcher_view_test()->RunMessageLoopUntilAnimationsDone();
120 121
121 Launcher* launcher = 122 Launcher* launcher =
122 RootWindowController::ForLauncher(panel)->shelf()->launcher(); 123 RootWindowController::ForLauncher(panel)->shelf()->launcher();
123 gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel); 124 gfx::Rect icon_bounds = launcher->GetScreenBoundsOfItemIconForWindow(panel);
124 ASSERT_FALSE(icon_bounds.IsEmpty()); 125 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0);
125 126
126 gfx::Rect window_bounds = panel->GetBoundsInScreen(); 127 gfx::Rect window_bounds = panel->GetBoundsInScreen();
127 gfx::Rect launcher_bounds = launcher->shelf_widget()-> 128 gfx::Rect launcher_bounds = launcher->shelf_widget()->
128 GetWindowBoundsInScreen(); 129 GetWindowBoundsInScreen();
129 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); 130 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow());
130 131
131 if (IsHorizontal(alignment)) { 132 if (IsHorizontal(alignment)) {
132 // The horizontal bounds of the panel window should contain the bounds of 133 // The horizontal bounds of the panel window should contain the bounds of
133 // the launcher icon. 134 // the launcher icon.
134 EXPECT_LE(window_bounds.x(), icon_bounds.x()); 135 EXPECT_LE(window_bounds.x(), icon_bounds.x());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void SetAlignment(aura::RootWindow* root_window, ShelfAlignment alignment) { 233 void SetAlignment(aura::RootWindow* root_window, ShelfAlignment alignment) {
233 ash::Shell* shell = ash::Shell::GetInstance(); 234 ash::Shell* shell = ash::Shell::GetInstance();
234 shell->SetShelfAlignment(alignment, root_window); 235 shell->SetShelfAlignment(alignment, root_window);
235 } 236 }
236 237
237 ShelfAlignment GetAlignment(aura::RootWindow* root_window) { 238 ShelfAlignment GetAlignment(aura::RootWindow* root_window) {
238 ash::Shell* shell = ash::Shell::GetInstance(); 239 ash::Shell* shell = ash::Shell::GetInstance();
239 return shell->GetShelfAlignment(root_window); 240 return shell->GetShelfAlignment(root_window);
240 } 241 }
241 242
243 void SetShelfAutoHideBehavior(aura::Window* window,
244 ShelfAutoHideBehavior behavior) {
245 internal::ShelfLayoutManager* shelf =
246 RootWindowController::ForWindow(window)->shelf()->
247 shelf_layout_manager();
248 shelf->SetAutoHideBehavior(behavior);
249 shelf->UpdateAutoHideState();
250 }
251
242 private: 252 private:
243 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; 253 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_;
244 254
245 bool IsHorizontal(ShelfAlignment alignment) { 255 bool IsHorizontal(ShelfAlignment alignment) {
246 return alignment == SHELF_ALIGNMENT_BOTTOM || 256 return alignment == SHELF_ALIGNMENT_BOTTOM ||
247 alignment == SHELF_ALIGNMENT_TOP; 257 alignment == SHELF_ALIGNMENT_TOP;
248 } 258 }
249 259
250 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); 260 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest);
251 }; 261 };
252 262
253 // Tests that a created panel window is successfully added to the panel 263 // Tests that a created panel window is successfully added to the panel
254 // layout manager. 264 // layout manager.
255 TEST_F(PanelLayoutManagerTest, AddOnePanel) { 265 TEST_F(PanelLayoutManagerTest, AddOnePanel) {
256 gfx::Rect bounds(0, 0, 201, 201); 266 gfx::Rect bounds(0, 0, 201, 201);
257 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); 267 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds));
258 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); 268 EXPECT_EQ(GetPanelContainer(window.get()), window->parent());
259 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); 269 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get()));
260 } 270 }
261 271
272 // Tests that a created panel window is successfully aligned over a hidden
273 // launcher icon.
274 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) {
275 gfx::Rect bounds(0, 0, 201, 201);
276 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(),
277 SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
278 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds));
279 EXPECT_EQ(GetPanelContainer(window.get()), window->parent());
280 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get()));
281 }
282
262 // Tests interactions between multiple panels 283 // Tests interactions between multiple panels
263 TEST_F(PanelLayoutManagerTest, MultiplePanelsAreAboveIcons) { 284 TEST_F(PanelLayoutManagerTest, MultiplePanelsAreAboveIcons) {
264 gfx::Rect odd_bounds(0, 0, 201, 201); 285 gfx::Rect odd_bounds(0, 0, 201, 201);
265 gfx::Rect even_bounds(0, 0, 200, 200); 286 gfx::Rect even_bounds(0, 0, 200, 200);
266 287
267 scoped_ptr<aura::Window> w1(CreatePanelWindow(odd_bounds)); 288 scoped_ptr<aura::Window> w1(CreatePanelWindow(odd_bounds));
268 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 289 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get()));
269 290
270 scoped_ptr<aura::Window> w2(CreatePanelWindow(even_bounds)); 291 scoped_ptr<aura::Window> w2(CreatePanelWindow(even_bounds));
271 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); 292 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get()));
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 TEST_F(PanelLayoutManagerTest, AlignmentTop) { 633 TEST_F(PanelLayoutManagerTest, AlignmentTop) {
613 gfx::Rect bounds(0, 0, 201, 201); 634 gfx::Rect bounds(0, 0, 201, 201);
614 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); 635 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
615 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP); 636 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP);
616 IsPanelAboveLauncherIcon(w.get()); 637 IsPanelAboveLauncherIcon(w.get());
617 IsCalloutAboveLauncherIcon(w.get()); 638 IsCalloutAboveLauncherIcon(w.get());
618 } 639 }
619 640
620 } // namespace internal 641 } // namespace internal
621 } // namespace ash 642 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698