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

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

Issue 10388036: Adds the option of aligning the launcher to the left or right. There (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 years, 7 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/shelf_layout_manager.cc ('k') | ash/wm/workspace/workspace_manager.cc » ('j') | 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/shelf_layout_manager.h" 5 #include "ash/wm/shelf_layout_manager.h"
6 6
7 #include "ash/focus_cycler.h" 7 #include "ash/focus_cycler.h"
8 #include "ash/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #define MAYBE_SetVisible FAILS_SetVisible 77 #define MAYBE_SetVisible FAILS_SetVisible
78 #else 78 #else
79 #define MAYBE_SetVisible SetVisible 79 #define MAYBE_SetVisible SetVisible
80 #endif 80 #endif
81 // Makes sure SetVisible updates work area and widget appropriately. 81 // Makes sure SetVisible updates work area and widget appropriately.
82 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { 82 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
83 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 83 ShelfLayoutManager* shelf = GetShelfLayoutManager();
84 // Force an initial layout. 84 // Force an initial layout.
85 shelf->LayoutShelf(); 85 shelf->LayoutShelf();
86 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 86 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
87
88 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds());
89 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds());
90 int shelf_height = shelf->GetIdealBounds().height();
91
87 const aura::MonitorManager* manager = 92 const aura::MonitorManager* manager =
88 aura::Env::GetInstance()->monitor_manager(); 93 aura::Env::GetInstance()->monitor_manager();
89 const gfx::Monitor& monitor = 94 const gfx::Monitor& monitor =
90 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 95 manager->GetMonitorNearestWindow(Shell::GetRootWindow());
91 ASSERT_NE(-1, monitor.id()); 96 ASSERT_NE(-1, monitor.id());
92 // Bottom inset should be the max of widget heights. 97 // Bottom inset should be the max of widget heights.
93 EXPECT_EQ(shelf->shelf_height(), 98 EXPECT_EQ(shelf_height,
94 monitor.bounds().bottom() - monitor.work_area().bottom()); 99 monitor.bounds().bottom() - monitor.work_area().bottom());
95 100
96 // Hide the shelf. 101 // Hide the shelf.
97 SetState(shelf, ShelfLayoutManager::HIDDEN); 102 SetState(shelf, ShelfLayoutManager::HIDDEN);
98 // Run the animation to completion. 103 // Run the animation to completion.
99 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 104 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
100 StepWidgetLayerAnimatorToEnd(shelf->status()); 105 StepWidgetLayerAnimatorToEnd(shelf->status());
101 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 106 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
102 EXPECT_EQ(0, 107 EXPECT_EQ(0,
103 monitor.bounds().bottom() - monitor.work_area().bottom()); 108 monitor.bounds().bottom() - monitor.work_area().bottom());
104 109
105 // Make sure the bounds of the two widgets changed. 110 // Make sure the bounds of the two widgets changed.
106 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 111 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
107 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 112 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
108 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 113 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
109 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 114 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
110 115
111 // And show it again. 116 // And show it again.
112 SetState(shelf, ShelfLayoutManager::VISIBLE); 117 SetState(shelf, ShelfLayoutManager::VISIBLE);
113 // Run the animation to completion. 118 // Run the animation to completion.
114 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 119 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
115 StepWidgetLayerAnimatorToEnd(shelf->status()); 120 StepWidgetLayerAnimatorToEnd(shelf->status());
116 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 121 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
117 EXPECT_EQ(shelf->shelf_height(), 122 EXPECT_EQ(shelf_height,
118 monitor.bounds().bottom() - monitor.work_area().bottom()); 123 monitor.bounds().bottom() - monitor.work_area().bottom());
119 124
120 // Make sure the bounds of the two widgets changed. 125 // Make sure the bounds of the two widgets changed.
121 gfx::Rect launcher_bounds( 126 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds();
122 shelf->launcher_widget()->GetNativeView()->bounds());
123 int bottom = gfx::Screen::GetPrimaryMonitor().bounds().bottom() - 127 int bottom = gfx::Screen::GetPrimaryMonitor().bounds().bottom() -
124 shelf->shelf_height(); 128 shelf_height;
125 EXPECT_EQ(launcher_bounds.y(), 129 EXPECT_EQ(launcher_bounds.y(),
126 bottom + (shelf->shelf_height() - launcher_bounds.height()) / 2); 130 bottom + (shelf->GetIdealBounds().height() -
127 gfx::Rect status_bounds(shelf->status()->GetNativeView()->bounds()); 131 launcher_bounds.height()) / 2);
132 status_bounds = shelf->status()->GetNativeView()->bounds();
128 EXPECT_EQ(status_bounds.y(), 133 EXPECT_EQ(status_bounds.y(),
129 bottom + shelf->shelf_height() - status_bounds.height()); 134 bottom + shelf_height - status_bounds.height());
130 } 135 }
131 136
132 // Makes sure LayoutShelf invoked while animating cleans things up. 137 // Makes sure LayoutShelf invoked while animating cleans things up.
133 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 138 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
134 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 139 ShelfLayoutManager* shelf = GetShelfLayoutManager();
135 // Force an initial layout. 140 // Force an initial layout.
136 shelf->LayoutShelf(); 141 shelf->LayoutShelf();
137 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 142 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
138 143
139 const aura::MonitorManager* manager = 144 const aura::MonitorManager* manager =
(...skipping 18 matching lines...) Expand all
158 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { 163 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) {
159 Launcher* launcher = Shell::GetInstance()->launcher(); 164 Launcher* launcher = Shell::GetInstance()->launcher();
160 ASSERT_TRUE(launcher); 165 ASSERT_TRUE(launcher);
161 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); 166 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
162 ASSERT_TRUE(shelf_layout_manager); 167 ASSERT_TRUE(shelf_layout_manager);
163 ASSERT_TRUE(shelf_layout_manager->status()); 168 ASSERT_TRUE(shelf_layout_manager->status());
164 int status_width = 169 int status_width =
165 shelf_layout_manager->status()->GetWindowScreenBounds().width(); 170 shelf_layout_manager->status()->GetWindowScreenBounds().width();
166 // Test only makes sense if the status is > 0, which is better be. 171 // Test only makes sense if the status is > 0, which is better be.
167 EXPECT_GT(status_width, 0); 172 EXPECT_GT(status_width, 0);
168 EXPECT_EQ(status_width, launcher->GetStatusWidth()); 173 EXPECT_EQ(status_width, launcher->status_size().width());
169 } 174 }
170 175
171 // Makes sure the launcher is sized when the status area changes size. 176 // Makes sure the launcher is sized when the status area changes size.
172 TEST_F(ShelfLayoutManagerTest, LauncherUpdatedWhenStatusAreaChangesSize) { 177 TEST_F(ShelfLayoutManagerTest, LauncherUpdatedWhenStatusAreaChangesSize) {
173 Launcher* launcher = Shell::GetInstance()->launcher(); 178 Launcher* launcher = Shell::GetInstance()->launcher();
174 ASSERT_TRUE(launcher); 179 ASSERT_TRUE(launcher);
175 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); 180 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
176 ASSERT_TRUE(shelf_layout_manager); 181 ASSERT_TRUE(shelf_layout_manager);
177 ASSERT_TRUE(shelf_layout_manager->status()); 182 ASSERT_TRUE(shelf_layout_manager->status());
178 shelf_layout_manager->status()->SetBounds(gfx::Rect(0, 0, 200, 200)); 183 shelf_layout_manager->status()->SetBounds(gfx::Rect(0, 0, 200, 200));
179 EXPECT_EQ(200, launcher->GetStatusWidth()); 184 EXPECT_EQ(200, launcher->status_size().width());
180 } 185 }
181 186
182 // Verifies when the shell is deleted with a full screen window we don't 187 // Verifies when the shell is deleted with a full screen window we don't
183 // crash. This test is here as originally the crash was in ShelfLayoutManager. 188 // crash. This test is here as originally the crash was in ShelfLayoutManager.
184 TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) { 189 TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) {
185 views::Widget* widget = new views::Widget; 190 views::Widget* widget = new views::Widget;
186 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 191 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
187 params.bounds = gfx::Rect(0, 0, 200, 200); 192 params.bounds = gfx::Rect(0, 0, 200, 200);
188 // Widget is now owned by the parent window. 193 // Widget is now owned by the parent window.
189 widget->Init(params); 194 widget->Init(params);
(...skipping 13 matching lines...) Expand all
203 // Widget is now owned by the parent window. 208 // Widget is now owned by the parent window.
204 widget->Init(params); 209 widget->Init(params);
205 widget->Maximize(); 210 widget->Maximize();
206 widget->Show(); 211 widget->Show();
207 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 212 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
208 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 213 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
209 214
210 // LayoutShelf() forces the animation to completion, at which point the 215 // LayoutShelf() forces the animation to completion, at which point the
211 // launcher should go off the screen. 216 // launcher should go off the screen.
212 shelf->LayoutShelf(); 217 shelf->LayoutShelf();
213 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 218 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
214 shelf->launcher_widget()->GetWindowScreenBounds().y()); 219 shelf->launcher_widget()->GetWindowScreenBounds().y());
215 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 220 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
216 gfx::Screen::GetMonitorNearestWindow(root).work_area().bottom()); 221 gfx::Screen::GetMonitorNearestWindow(root).work_area().bottom());
217 222
218 // Move the mouse to the bottom of the screen. 223 // Move the mouse to the bottom of the screen.
219 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 224 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
220 225
221 // Shelf should be shown again (but it shouldn't have changed the work area). 226 // Shelf should be shown again (but it shouldn't have changed the work area).
222 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); 227 SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
223 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 228 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
224 shelf->LayoutShelf(); 229 shelf->LayoutShelf();
225 EXPECT_EQ(root->bounds().bottom() - shelf->shelf_height(), 230 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(),
226 shelf->launcher_widget()->GetWindowScreenBounds().y()); 231 shelf->launcher_widget()->GetWindowScreenBounds().y());
227 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 232 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
228 gfx::Screen::GetMonitorNearestWindow(root).work_area().bottom()); 233 gfx::Screen::GetMonitorNearestWindow(root).work_area().bottom());
229 234
230 // Move mouse back up. 235 // Move mouse back up.
231 generator.MoveMouseTo(0, 0); 236 generator.MoveMouseTo(0, 0);
232 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); 237 SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
233 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 238 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
234 shelf->LayoutShelf(); 239 shelf->LayoutShelf();
235 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 240 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
236 shelf->launcher_widget()->GetWindowScreenBounds().y()); 241 shelf->launcher_widget()->GetWindowScreenBounds().y());
237 242
238 // Drag mouse to bottom of screen. 243 // Drag mouse to bottom of screen.
239 generator.PressLeftButton(); 244 generator.PressLeftButton();
240 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 245 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
241 UpdateAutoHideStateNow(); 246 UpdateAutoHideStateNow();
242 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 247 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
243 248
244 generator.ReleaseLeftButton(); 249 generator.ReleaseLeftButton();
245 generator.MoveMouseTo(1, root->bounds().bottom() - 1); 250 generator.MoveMouseTo(1, root->bounds().bottom() - 1);
(...skipping 21 matching lines...) Expand all
267 widget->Init(params); 272 widget->Init(params);
268 widget->Maximize(); 273 widget->Maximize();
269 widget->Show(); 274 widget->Show();
270 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 275 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
271 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 276 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
272 277
273 aura::RootWindow* root = Shell::GetRootWindow(); 278 aura::RootWindow* root = Shell::GetRootWindow();
274 // LayoutShelf() forces the animation to completion, at which point the 279 // LayoutShelf() forces the animation to completion, at which point the
275 // launcher should go off the screen. 280 // launcher should go off the screen.
276 shelf->LayoutShelf(); 281 shelf->LayoutShelf();
277 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 282 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
278 shelf->launcher_widget()->GetWindowScreenBounds().y()); 283 shelf->launcher_widget()->GetWindowScreenBounds().y());
279 284
280 aura::Window* lock_container = Shell::GetInstance()->GetContainer( 285 aura::Window* lock_container = Shell::GetInstance()->GetContainer(
281 internal::kShellWindowId_LockScreenContainer); 286 internal::kShellWindowId_LockScreenContainer);
282 287
283 views::Widget* lock_widget = new views::Widget; 288 views::Widget* lock_widget = new views::Widget;
284 views::Widget::InitParams lock_params( 289 views::Widget::InitParams lock_params(
285 views::Widget::InitParams::TYPE_WINDOW); 290 views::Widget::InitParams::TYPE_WINDOW);
286 lock_params.bounds = gfx::Rect(0, 0, 200, 200); 291 lock_params.bounds = gfx::Rect(0, 0, 200, 200);
287 lock_params.parent = lock_container; 292 lock_params.parent = lock_container;
(...skipping 24 matching lines...) Expand all
312 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 317 ShelfLayoutManager* shelf = GetShelfLayoutManager();
313 views::Widget* widget = new views::Widget; 318 views::Widget* widget = new views::Widget;
314 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 319 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
315 params.bounds = gfx::Rect(0, 0, 200, 200); 320 params.bounds = gfx::Rect(0, 0, 200, 200);
316 // Widget is now owned by the parent window. 321 // Widget is now owned by the parent window.
317 widget->Init(params); 322 widget->Init(params);
318 widget->Show(); 323 widget->Show();
319 aura::Window* window = widget->GetNativeWindow(); 324 aura::Window* window = widget->GetNativeWindow();
320 gfx::Rect monitor_bounds( 325 gfx::Rect monitor_bounds(
321 gfx::Screen::GetMonitorNearestWindow(window).bounds()); 326 gfx::Screen::GetMonitorNearestWindow(window).bounds());
322 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 327 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
323 shelf->GetMaximizedWindowBounds(window).bottom()); 328 shelf->GetMaximizedWindowBounds(window).bottom());
324 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 329 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
325 330
326 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 331 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
327 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 332 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
328 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 333 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
329 shelf->GetMaximizedWindowBounds(window).bottom()); 334 shelf->GetMaximizedWindowBounds(window).bottom());
330 335
331 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); 336 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
332 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 337 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
333 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 338 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
334 shelf->GetMaximizedWindowBounds(window).bottom()); 339 shelf->GetMaximizedWindowBounds(window).bottom());
335 340
336 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 341 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
337 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 342 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
338 EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 343 EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
339 shelf->GetMaximizedWindowBounds(window).bottom()); 344 shelf->GetMaximizedWindowBounds(window).bottom());
340 345
341 widget->Maximize(); 346 widget->Maximize();
342 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 347 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
343 EXPECT_EQ(gfx::Screen::GetMonitorNearestWindow(window).work_area().bottom(), 348 EXPECT_EQ(gfx::Screen::GetMonitorNearestWindow(window).work_area().bottom(),
344 widget->GetWorkAreaBoundsInScreen().bottom()); 349 widget->GetWorkAreaBoundsInScreen().bottom());
345 350
346 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 351 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
347 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 352 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
348 EXPECT_EQ(gfx::Screen::GetMonitorNearestWindow(window).work_area().bottom(), 353 EXPECT_EQ(gfx::Screen::GetMonitorNearestWindow(window).work_area().bottom(),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 shell->ToggleAppList(); 477 shell->ToggleAppList();
473 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 478 EXPECT_TRUE(shell->GetAppListTargetVisibility());
474 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 479 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
475 480
476 // Toggle app list to hide. 481 // Toggle app list to hide.
477 shell->ToggleAppList(); 482 shell->ToggleAppList();
478 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 483 EXPECT_FALSE(shell->GetAppListTargetVisibility());
479 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 484 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
480 } 485 }
481 486
487 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT.
488 TEST_F(ShelfLayoutManagerTest, SetAlignment) {
489 ShelfLayoutManager* shelf = GetShelfLayoutManager();
490 // Force an initial layout.
491 shelf->LayoutShelf();
492 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
493
494 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
495
496 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds());
497 const aura::MonitorManager* manager =
498 aura::Env::GetInstance()->monitor_manager();
499 gfx::Monitor monitor =
500 manager->GetMonitorNearestWindow(Shell::GetRootWindow());
501 ASSERT_NE(-1, monitor.id());
502 EXPECT_EQ(shelf->GetIdealBounds().width(),
503 monitor.GetWorkAreaInsets().left());
504 EXPECT_GE(
505 launcher_bounds.width(),
506 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
507 EXPECT_EQ(shelf->GetIdealBounds().width(),
508 monitor.GetWorkAreaInsets().left());
509 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
510 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom());
511 EXPECT_EQ(0, monitor.GetWorkAreaInsets().right());
512 EXPECT_EQ(monitor.bounds().x(), launcher_bounds.x());
513 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y());
514 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height());
515
516
517 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
518 launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds();
519 monitor = manager->GetMonitorNearestWindow(Shell::GetRootWindow());
520 ASSERT_NE(-1, monitor.id());
521 EXPECT_EQ(shelf->GetIdealBounds().width(),
522 monitor.GetWorkAreaInsets().right());
523 EXPECT_GE(
524 launcher_bounds.width(),
525 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
526 EXPECT_EQ(shelf->GetIdealBounds().width(),
527 monitor.GetWorkAreaInsets().right());
528 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
529 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom());
530 EXPECT_EQ(0, monitor.GetWorkAreaInsets().left());
531 EXPECT_EQ(monitor.work_area().right(), launcher_bounds.x());
532 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y());
533 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height());
534 }
535
482 } // namespace internal 536 } // namespace internal
483 } // namespace ash 537 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/shelf_layout_manager.cc ('k') | ash/wm/workspace/workspace_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698