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

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

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix new addition Created 8 years, 2 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_unittest.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/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/focus_cycler.h" 10 #include "ash/focus_cycler.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 SetState(shelf, ShelfLayoutManager::HIDDEN); 211 SetState(shelf, ShelfLayoutManager::HIDDEN);
212 // Run the animation to completion. 212 // Run the animation to completion.
213 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 213 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
214 StepWidgetLayerAnimatorToEnd(shelf->status()); 214 StepWidgetLayerAnimatorToEnd(shelf->status());
215 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 215 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
216 EXPECT_EQ(0, 216 EXPECT_EQ(0,
217 display.bounds().bottom() - display.work_area().bottom()); 217 display.bounds().bottom() - display.work_area().bottom());
218 218
219 // Make sure the bounds of the two widgets changed. 219 // Make sure the bounds of the two widgets changed.
220 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 220 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
221 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); 221 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom());
222 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 222 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
223 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); 223 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom());
224 224
225 // And show it again. 225 // And show it again.
226 SetState(shelf, ShelfLayoutManager::VISIBLE); 226 SetState(shelf, ShelfLayoutManager::VISIBLE);
227 // Run the animation to completion. 227 // Run the animation to completion.
228 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 228 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
229 StepWidgetLayerAnimatorToEnd(shelf->status()); 229 StepWidgetLayerAnimatorToEnd(shelf->status());
230 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 230 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
231 EXPECT_EQ(shelf_height, 231 EXPECT_EQ(shelf_height,
232 display.bounds().bottom() - display.work_area().bottom()); 232 display.bounds().bottom() - display.work_area().bottom());
233 233
234 // Make sure the bounds of the two widgets changed. 234 // Make sure the bounds of the two widgets changed.
235 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); 235 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds();
236 int bottom = gfx::Screen::GetPrimaryDisplay().bounds().bottom() - 236 int bottom =
237 shelf_height; 237 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom() - shelf_height;
238 EXPECT_EQ(launcher_bounds.y(), 238 EXPECT_EQ(launcher_bounds.y(),
239 bottom + (shelf->GetIdealBounds().height() - 239 bottom + (shelf->GetIdealBounds().height() -
240 launcher_bounds.height()) / 2); 240 launcher_bounds.height()) / 2);
241 status_bounds = shelf->status()->GetNativeView()->bounds(); 241 status_bounds = shelf->status()->GetNativeView()->bounds();
242 EXPECT_EQ(status_bounds.y(), 242 EXPECT_EQ(status_bounds.y(),
243 bottom + shelf_height - status_bounds.height()); 243 bottom + shelf_height - status_bounds.height());
244 } 244 }
245 245
246 // Makes sure LayoutShelf invoked while animating cleans things up. 246 // Makes sure LayoutShelf invoked while animating cleans things up.
247 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 247 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
248 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 248 ShelfLayoutManager* shelf = GetShelfLayoutManager();
249 // Force an initial layout. 249 // Force an initial layout.
250 shelf->LayoutShelf(); 250 shelf->LayoutShelf();
251 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 251 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
252 252
253 const aura::DisplayManager* manager = 253 const aura::DisplayManager* manager =
254 aura::Env::GetInstance()->display_manager(); 254 aura::Env::GetInstance()->display_manager();
255 const gfx::Display& display = 255 const gfx::Display& display =
256 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 256 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
257 257
258 // Hide the shelf. 258 // Hide the shelf.
259 SetState(shelf, ShelfLayoutManager::HIDDEN); 259 SetState(shelf, ShelfLayoutManager::HIDDEN);
260 shelf->LayoutShelf(); 260 shelf->LayoutShelf();
261 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 261 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
262 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); 262 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom());
263 263
264 // Make sure the bounds of the two widgets changed. 264 // Make sure the bounds of the two widgets changed.
265 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 265 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
266 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); 266 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom());
267 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 267 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
268 gfx::Screen::GetPrimaryDisplay().bounds().bottom()); 268 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom());
269 } 269 }
270 270
271 // Makes sure the launcher is initially sized correctly. 271 // Makes sure the launcher is initially sized correctly.
272 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { 272 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) {
273 Launcher* launcher = Shell::GetInstance()->launcher(); 273 Launcher* launcher = Shell::GetInstance()->launcher();
274 ASSERT_TRUE(launcher); 274 ASSERT_TRUE(launcher);
275 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); 275 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
276 ASSERT_TRUE(shelf_layout_manager); 276 ASSERT_TRUE(shelf_layout_manager);
277 ASSERT_TRUE(shelf_layout_manager->status()); 277 ASSERT_TRUE(shelf_layout_manager->status());
278 int status_width = 278 int status_width =
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 widget->Show(); 321 widget->Show();
322 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 322 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
323 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 323 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
324 324
325 // LayoutShelf() forces the animation to completion, at which point the 325 // LayoutShelf() forces the animation to completion, at which point the
326 // launcher should go off the screen. 326 // launcher should go off the screen.
327 shelf->LayoutShelf(); 327 shelf->LayoutShelf();
328 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 328 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
329 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); 329 shelf->launcher_widget()->GetWindowBoundsInScreen().y());
330 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 330 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
331 gfx::Screen::GetDisplayNearestWindow(root).work_area().bottom()); 331 Shell::GetScreen()->GetDisplayNearestWindow(
332 root).work_area().bottom());
332 333
333 // Move the mouse to the bottom of the screen. 334 // Move the mouse to the bottom of the screen.
334 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 335 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
335 336
336 // Shelf should be shown again (but it shouldn't have changed the work area). 337 // Shelf should be shown again (but it shouldn't have changed the work area).
337 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); 338 SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
338 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 339 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
339 shelf->LayoutShelf(); 340 shelf->LayoutShelf();
340 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), 341 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(),
341 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); 342 shelf->launcher_widget()->GetWindowBoundsInScreen().y());
342 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 343 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
343 gfx::Screen::GetDisplayNearestWindow(root).work_area().bottom()); 344 Shell::GetScreen()->GetDisplayNearestWindow(
345 root).work_area().bottom());
344 346
345 // Move mouse back up. 347 // Move mouse back up.
346 generator.MoveMouseTo(0, 0); 348 generator.MoveMouseTo(0, 0);
347 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); 349 SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
348 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 350 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
349 shelf->LayoutShelf(); 351 shelf->LayoutShelf();
350 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 352 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
351 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); 353 shelf->launcher_widget()->GetWindowBoundsInScreen().y());
352 354
353 // Drag mouse to bottom of screen. 355 // Drag mouse to bottom of screen.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 430
429 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 431 ShelfLayoutManager* shelf = GetShelfLayoutManager();
430 views::Widget* widget = new views::Widget; 432 views::Widget* widget = new views::Widget;
431 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 433 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
432 params.bounds = gfx::Rect(0, 0, 200, 200); 434 params.bounds = gfx::Rect(0, 0, 200, 200);
433 // Widget is now owned by the parent window. 435 // Widget is now owned by the parent window.
434 widget->Init(params); 436 widget->Init(params);
435 widget->Show(); 437 widget->Show();
436 aura::Window* window = widget->GetNativeWindow(); 438 aura::Window* window = widget->GetNativeWindow();
437 gfx::Rect display_bounds( 439 gfx::Rect display_bounds(
438 gfx::Screen::GetDisplayNearestWindow(window).bounds()); 440 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds());
439 441
440 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 442 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
441 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 443 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
442 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, 444 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
443 shelf->GetMaximizedWindowBounds(window).bottom()); 445 shelf->GetMaximizedWindowBounds(window).bottom());
444 446
445 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 447 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
446 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 448 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
447 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, 449 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
448 shelf->GetMaximizedWindowBounds(window).bottom()); 450 shelf->GetMaximizedWindowBounds(window).bottom());
449 451
450 widget->Maximize(); 452 widget->Maximize();
451 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 453 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
452 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), 454 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
455 window).work_area().bottom(),
453 widget->GetWorkAreaBoundsInScreen().bottom()); 456 widget->GetWorkAreaBoundsInScreen().bottom());
454 457
455 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 458 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
456 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 459 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
457 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), 460 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
461 window).work_area().bottom(),
458 widget->GetWorkAreaBoundsInScreen().bottom()); 462 widget->GetWorkAreaBoundsInScreen().bottom());
459 463
460 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 464 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
461 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 465 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
462 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), 466 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
467 window).work_area().bottom(),
463 widget->GetWorkAreaBoundsInScreen().bottom()); 468 widget->GetWorkAreaBoundsInScreen().bottom());
464 } 469 }
465 470
466 // Verifies the shelf is visible when status/launcher is focused. 471 // Verifies the shelf is visible when status/launcher is focused.
467 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { 472 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) {
468 // Since ShelfLayoutManager queries for mouse location, move the mouse so 473 // Since ShelfLayoutManager queries for mouse location, move the mouse so
469 // it isn't over the shelf. 474 // it isn't over the shelf.
470 aura::test::EventGenerator generator( 475 aura::test::EventGenerator generator(
471 Shell::GetPrimaryRootWindow(), gfx::Point()); 476 Shell::GetPrimaryRootWindow(), gfx::Point());
472 generator.MoveMouseTo(0, 0); 477 generator.MoveMouseTo(0, 0);
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 EXPECT_TRUE(status_area->IsMessageBubbleShown()); 954 EXPECT_TRUE(status_area->IsMessageBubbleShown());
950 } else { 955 } else {
951 EXPECT_FALSE(shelf->IsVisible()); 956 EXPECT_FALSE(shelf->IsVisible());
952 EXPECT_FALSE(status_area->IsMessageBubbleShown()); 957 EXPECT_FALSE(status_area->IsMessageBubbleShown());
953 } 958 }
954 } 959 }
955 } 960 }
956 961
957 } // namespace internal 962 } // namespace internal
958 } // namespace ash 963 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/shelf_layout_manager.cc ('k') | ash/wm/system_gesture_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698