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

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

Issue 10442017: Rename GetRootWindow() -> GetPrimaryRootWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-try -b linux_chromeos,win_aura 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/system_gesture_event_filter.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 shelf->LayoutShelf(); 86 shelf->LayoutShelf();
87 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 87 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
88 88
89 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds()); 89 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds());
90 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); 90 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds());
91 int shelf_height = shelf->GetIdealBounds().height(); 91 int shelf_height = shelf->GetIdealBounds().height();
92 92
93 const aura::MonitorManager* manager = 93 const aura::MonitorManager* manager =
94 aura::Env::GetInstance()->monitor_manager(); 94 aura::Env::GetInstance()->monitor_manager();
95 const gfx::Monitor& monitor = 95 const gfx::Monitor& monitor =
96 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 96 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
97 ASSERT_NE(-1, monitor.id()); 97 ASSERT_NE(-1, monitor.id());
98 // Bottom inset should be the max of widget heights. 98 // Bottom inset should be the max of widget heights.
99 EXPECT_EQ(shelf_height, 99 EXPECT_EQ(shelf_height,
100 monitor.bounds().bottom() - monitor.work_area().bottom()); 100 monitor.bounds().bottom() - monitor.work_area().bottom());
101 101
102 // Hide the shelf. 102 // Hide the shelf.
103 SetState(shelf, ShelfLayoutManager::HIDDEN); 103 SetState(shelf, ShelfLayoutManager::HIDDEN);
104 // Run the animation to completion. 104 // Run the animation to completion.
105 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 105 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
106 StepWidgetLayerAnimatorToEnd(shelf->status()); 106 StepWidgetLayerAnimatorToEnd(shelf->status());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Makes sure LayoutShelf invoked while animating cleans things up. 138 // Makes sure LayoutShelf invoked while animating cleans things up.
139 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 139 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
140 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 140 ShelfLayoutManager* shelf = GetShelfLayoutManager();
141 // Force an initial layout. 141 // Force an initial layout.
142 shelf->LayoutShelf(); 142 shelf->LayoutShelf();
143 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 143 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
144 144
145 const aura::MonitorManager* manager = 145 const aura::MonitorManager* manager =
146 aura::Env::GetInstance()->monitor_manager(); 146 aura::Env::GetInstance()->monitor_manager();
147 const gfx::Monitor& monitor = 147 const gfx::Monitor& monitor =
148 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 148 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
149 149
150 // Hide the shelf. 150 // Hide the shelf.
151 SetState(shelf, ShelfLayoutManager::HIDDEN); 151 SetState(shelf, ShelfLayoutManager::HIDDEN);
152 shelf->LayoutShelf(); 152 shelf->LayoutShelf();
153 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 153 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
154 EXPECT_EQ(0, monitor.bounds().bottom() - monitor.work_area().bottom()); 154 EXPECT_EQ(0, monitor.bounds().bottom() - monitor.work_area().bottom());
155 155
156 // Make sure the bounds of the two widgets changed. 156 // Make sure the bounds of the two widgets changed.
157 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 157 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
158 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 158 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 views::Widget* widget = new views::Widget; 191 views::Widget* widget = new views::Widget;
192 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 192 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
193 params.bounds = gfx::Rect(0, 0, 200, 200); 193 params.bounds = gfx::Rect(0, 0, 200, 200);
194 // Widget is now owned by the parent window. 194 // Widget is now owned by the parent window.
195 widget->Init(params); 195 widget->Init(params);
196 widget->SetFullscreen(true); 196 widget->SetFullscreen(true);
197 } 197 }
198 198
199 // Various assertions around auto-hide. 199 // Various assertions around auto-hide.
200 TEST_F(ShelfLayoutManagerTest, AutoHide) { 200 TEST_F(ShelfLayoutManagerTest, AutoHide) {
201 aura::RootWindow* root = Shell::GetRootWindow(); 201 aura::RootWindow* root = Shell::GetPrimaryRootWindow();
202 aura::test::EventGenerator generator(root, root); 202 aura::test::EventGenerator generator(root, root);
203 generator.MoveMouseTo(0, 0); 203 generator.MoveMouseTo(0, 0);
204 204
205 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 205 ShelfLayoutManager* shelf = GetShelfLayoutManager();
206 views::Widget* widget = new views::Widget; 206 views::Widget* widget = new views::Widget;
207 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 207 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
208 params.bounds = gfx::Rect(0, 0, 200, 200); 208 params.bounds = gfx::Rect(0, 0, 200, 200);
209 // Widget is now owned by the parent window. 209 // Widget is now owned by the parent window.
210 widget->Init(params); 210 widget->Init(params);
211 widget->Maximize(); 211 widget->Maximize();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 generator.MoveMouseTo(1, root->bounds().bottom() - 1); 255 generator.MoveMouseTo(1, root->bounds().bottom() - 1);
256 UpdateAutoHideStateNow(); 256 UpdateAutoHideStateNow();
257 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 257 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
258 } 258 }
259 259
260 // Assertions around the lock screen showing. 260 // Assertions around the lock screen showing.
261 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { 261 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
262 // Since ShelfLayoutManager queries for mouse location, move the mouse so 262 // Since ShelfLayoutManager queries for mouse location, move the mouse so
263 // it isn't over the shelf. 263 // it isn't over the shelf.
264 aura::test::EventGenerator generator( 264 aura::test::EventGenerator generator(
265 Shell::GetInstance()->GetRootWindow(), gfx::Point()); 265 Shell::GetPrimaryRootWindow(), gfx::Point());
266 generator.MoveMouseTo(0, 0); 266 generator.MoveMouseTo(0, 0);
267 267
268 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 268 ShelfLayoutManager* shelf = GetShelfLayoutManager();
269 views::Widget* widget = new views::Widget; 269 views::Widget* widget = new views::Widget;
270 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 270 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
271 params.bounds = gfx::Rect(0, 0, 200, 200); 271 params.bounds = gfx::Rect(0, 0, 200, 200);
272 // Widget is now owned by the parent window. 272 // Widget is now owned by the parent window.
273 widget->Init(params); 273 widget->Init(params);
274 widget->Maximize(); 274 widget->Maximize();
275 widget->Show(); 275 widget->Show();
276 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 276 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
277 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 277 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
278 278
279 aura::RootWindow* root = Shell::GetRootWindow(); 279 aura::RootWindow* root = Shell::GetPrimaryRootWindow();
280 // LayoutShelf() forces the animation to completion, at which point the 280 // LayoutShelf() forces the animation to completion, at which point the
281 // launcher should go off the screen. 281 // launcher should go off the screen.
282 shelf->LayoutShelf(); 282 shelf->LayoutShelf();
283 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 283 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
284 shelf->launcher_widget()->GetWindowScreenBounds().y()); 284 shelf->launcher_widget()->GetWindowScreenBounds().y());
285 285
286 aura::Window* lock_container = Shell::GetInstance()->GetContainer( 286 aura::Window* lock_container = Shell::GetInstance()->GetContainer(
287 internal::kShellWindowId_LockScreenContainer); 287 internal::kShellWindowId_LockScreenContainer);
288 288
289 views::Widget* lock_widget = new views::Widget; 289 views::Widget* lock_widget = new views::Widget;
(...skipping 15 matching lines...) Expand all
305 Shell::GetInstance()->delegate()->UnlockScreen(); 305 Shell::GetInstance()->delegate()->UnlockScreen();
306 shelf->UpdateVisibilityState(); 306 shelf->UpdateVisibilityState();
307 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 307 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
308 } 308 }
309 309
310 // Assertions around SetAutoHideBehavior. 310 // Assertions around SetAutoHideBehavior.
311 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { 311 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
312 // Since ShelfLayoutManager queries for mouse location, move the mouse so 312 // Since ShelfLayoutManager queries for mouse location, move the mouse so
313 // it isn't over the shelf. 313 // it isn't over the shelf.
314 aura::test::EventGenerator generator( 314 aura::test::EventGenerator generator(
315 Shell::GetInstance()->GetRootWindow(), gfx::Point()); 315 Shell::GetPrimaryRootWindow(), gfx::Point());
316 generator.MoveMouseTo(0, 0); 316 generator.MoveMouseTo(0, 0);
317 317
318 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 318 ShelfLayoutManager* shelf = GetShelfLayoutManager();
319 views::Widget* widget = new views::Widget; 319 views::Widget* widget = new views::Widget;
320 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 320 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
321 params.bounds = gfx::Rect(0, 0, 200, 200); 321 params.bounds = gfx::Rect(0, 0, 200, 200);
322 // Widget is now owned by the parent window. 322 // Widget is now owned by the parent window.
323 widget->Init(params); 323 widget->Init(params);
324 widget->Show(); 324 widget->Show();
325 aura::Window* window = widget->GetNativeWindow(); 325 aura::Window* window = widget->GetNativeWindow();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 358 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
359 EXPECT_EQ(gfx::Screen::GetMonitorNearestWindow(window).work_area().bottom(), 359 EXPECT_EQ(gfx::Screen::GetMonitorNearestWindow(window).work_area().bottom(),
360 widget->GetWorkAreaBoundsInScreen().bottom()); 360 widget->GetWorkAreaBoundsInScreen().bottom());
361 } 361 }
362 362
363 // Verifies the shelf is visible when status/launcher is focused. 363 // Verifies the shelf is visible when status/launcher is focused.
364 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { 364 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) {
365 // Since ShelfLayoutManager queries for mouse location, move the mouse so 365 // Since ShelfLayoutManager queries for mouse location, move the mouse so
366 // it isn't over the shelf. 366 // it isn't over the shelf.
367 aura::test::EventGenerator generator( 367 aura::test::EventGenerator generator(
368 Shell::GetInstance()->GetRootWindow(), gfx::Point()); 368 Shell::GetPrimaryRootWindow(), gfx::Point());
369 generator.MoveMouseTo(0, 0); 369 generator.MoveMouseTo(0, 0);
370 370
371 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 371 ShelfLayoutManager* shelf = GetShelfLayoutManager();
372 views::Widget* widget = new views::Widget; 372 views::Widget* widget = new views::Widget;
373 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 373 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
374 params.bounds = gfx::Rect(0, 0, 200, 200); 374 params.bounds = gfx::Rect(0, 0, 200, 200);
375 // Widget is now owned by the parent window. 375 // Widget is now owned by the parent window.
376 widget->Init(params); 376 widget->Init(params);
377 widget->Show(); 377 widget->Show();
378 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 378 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // Force an initial layout. 494 // Force an initial layout.
495 shelf->LayoutShelf(); 495 shelf->LayoutShelf();
496 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 496 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
497 497
498 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 498 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
499 499
500 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); 500 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds());
501 const aura::MonitorManager* manager = 501 const aura::MonitorManager* manager =
502 aura::Env::GetInstance()->monitor_manager(); 502 aura::Env::GetInstance()->monitor_manager();
503 gfx::Monitor monitor = 503 gfx::Monitor monitor =
504 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 504 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
505 ASSERT_NE(-1, monitor.id()); 505 ASSERT_NE(-1, monitor.id());
506 EXPECT_EQ(shelf->GetIdealBounds().width(), 506 EXPECT_EQ(shelf->GetIdealBounds().width(),
507 monitor.GetWorkAreaInsets().left()); 507 monitor.GetWorkAreaInsets().left());
508 EXPECT_GE( 508 EXPECT_GE(
509 launcher_bounds.width(), 509 launcher_bounds.width(),
510 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); 510 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
511 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, 511 EXPECT_EQ(SHELF_ALIGNMENT_LEFT,
512 Shell::GetInstance()->tray()->shelf_alignment()); 512 Shell::GetInstance()->tray()->shelf_alignment());
513 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds()); 513 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds());
514 EXPECT_GE(status_bounds.width(), 514 EXPECT_GE(status_bounds.width(),
515 shelf->status()->GetContentsView()->GetPreferredSize().width()); 515 shelf->status()->GetContentsView()->GetPreferredSize().width());
516 EXPECT_EQ(shelf->GetIdealBounds().width(), 516 EXPECT_EQ(shelf->GetIdealBounds().width(),
517 monitor.GetWorkAreaInsets().left()); 517 monitor.GetWorkAreaInsets().left());
518 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); 518 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
519 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom()); 519 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom());
520 EXPECT_EQ(0, monitor.GetWorkAreaInsets().right()); 520 EXPECT_EQ(0, monitor.GetWorkAreaInsets().right());
521 EXPECT_EQ(monitor.bounds().x(), launcher_bounds.x()); 521 EXPECT_EQ(monitor.bounds().x(), launcher_bounds.x());
522 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); 522 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y());
523 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); 523 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height());
524 524
525 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 525 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
526 launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds(); 526 launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds();
527 monitor = manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 527 monitor = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
528 ASSERT_NE(-1, monitor.id()); 528 ASSERT_NE(-1, monitor.id());
529 EXPECT_EQ(shelf->GetIdealBounds().width(), 529 EXPECT_EQ(shelf->GetIdealBounds().width(),
530 monitor.GetWorkAreaInsets().right()); 530 monitor.GetWorkAreaInsets().right());
531 EXPECT_GE( 531 EXPECT_GE(
532 launcher_bounds.width(), 532 launcher_bounds.width(),
533 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); 533 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
534 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, 534 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT,
535 Shell::GetInstance()->tray()->shelf_alignment()); 535 Shell::GetInstance()->tray()->shelf_alignment());
536 status_bounds = gfx::Rect(shelf->status()->GetWindowScreenBounds()); 536 status_bounds = gfx::Rect(shelf->status()->GetWindowScreenBounds());
537 EXPECT_GE(status_bounds.width(), 537 EXPECT_GE(status_bounds.width(),
538 shelf->status()->GetContentsView()->GetPreferredSize().width()); 538 shelf->status()->GetContentsView()->GetPreferredSize().width());
539 EXPECT_EQ(shelf->GetIdealBounds().width(), 539 EXPECT_EQ(shelf->GetIdealBounds().width(),
540 monitor.GetWorkAreaInsets().right()); 540 monitor.GetWorkAreaInsets().right());
541 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); 541 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top());
542 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom()); 542 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom());
543 EXPECT_EQ(0, monitor.GetWorkAreaInsets().left()); 543 EXPECT_EQ(0, monitor.GetWorkAreaInsets().left());
544 EXPECT_EQ(monitor.work_area().right(), launcher_bounds.x()); 544 EXPECT_EQ(monitor.work_area().right(), launcher_bounds.x());
545 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); 545 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y());
546 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); 546 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height());
547 } 547 }
548 548
549 } // namespace internal 549 } // namespace internal
550 } // namespace ash 550 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/shelf_layout_manager.cc ('k') | ash/wm/system_gesture_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698