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

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

Issue 10540091: Rename gfx::Monitor to gfx::Display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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"
11 #include "ash/shell_delegate.h" 11 #include "ash/shell_delegate.h"
12 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
14 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
15 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
17 #include "ui/aura/monitor_manager.h" 17 #include "ui/aura/monitor_manager.h"
18 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
19 #include "ui/aura/test/event_generator.h" 19 #include "ui/aura/test/event_generator.h"
20 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/base/animation/animation_container_element.h" 21 #include "ui/base/animation/animation_container_element.h"
22 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
23 #include "ui/compositor/layer_animator.h" 23 #include "ui/compositor/layer_animator.h"
24 #include "ui/gfx/monitor.h" 24 #include "ui/gfx/display.h"
25 #include "ui/gfx/screen.h" 25 #include "ui/gfx/screen.h"
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
27 27
28 namespace ash { 28 namespace ash {
29 namespace internal { 29 namespace internal {
30 30
31 namespace { 31 namespace {
32 32
33 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { 33 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) {
34 ui::AnimationContainerElement* element = 34 ui::AnimationContainerElement* element =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Force an initial layout. 87 // Force an initial layout.
88 shelf->LayoutShelf(); 88 shelf->LayoutShelf();
89 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 89 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
90 90
91 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds()); 91 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds());
92 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); 92 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds());
93 int shelf_height = shelf->GetIdealBounds().height(); 93 int shelf_height = shelf->GetIdealBounds().height();
94 94
95 const aura::MonitorManager* manager = 95 const aura::MonitorManager* manager =
96 aura::Env::GetInstance()->monitor_manager(); 96 aura::Env::GetInstance()->monitor_manager();
97 const gfx::Monitor& monitor = 97 const gfx::Display& display =
98 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); 98 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
99 ASSERT_NE(-1, monitor.id()); 99 ASSERT_NE(-1, display.id());
100 // Bottom inset should be the max of widget heights. 100 // Bottom inset should be the max of widget heights.
101 EXPECT_EQ(shelf_height, 101 EXPECT_EQ(shelf_height,
102 monitor.bounds().bottom() - monitor.work_area().bottom()); 102 display.bounds().bottom() - display.work_area().bottom());
103 103
104 // Hide the shelf. 104 // Hide the shelf.
105 SetState(shelf, ShelfLayoutManager::HIDDEN); 105 SetState(shelf, ShelfLayoutManager::HIDDEN);
106 // Run the animation to completion. 106 // Run the animation to completion.
107 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 107 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
108 StepWidgetLayerAnimatorToEnd(shelf->status()); 108 StepWidgetLayerAnimatorToEnd(shelf->status());
109 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 109 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
110 EXPECT_EQ(0, 110 EXPECT_EQ(0,
111 monitor.bounds().bottom() - monitor.work_area().bottom()); 111 display.bounds().bottom() - display.work_area().bottom());
112 112
113 // Make sure the bounds of the two widgets changed. 113 // Make sure the bounds of the two widgets changed.
114 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 114 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
115 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 115 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
116 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 116 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
117 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 117 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
118 118
119 // And show it again. 119 // And show it again.
120 SetState(shelf, ShelfLayoutManager::VISIBLE); 120 SetState(shelf, ShelfLayoutManager::VISIBLE);
121 // Run the animation to completion. 121 // Run the animation to completion.
122 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 122 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
123 StepWidgetLayerAnimatorToEnd(shelf->status()); 123 StepWidgetLayerAnimatorToEnd(shelf->status());
124 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 124 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
125 EXPECT_EQ(shelf_height, 125 EXPECT_EQ(shelf_height,
126 monitor.bounds().bottom() - monitor.work_area().bottom()); 126 display.bounds().bottom() - display.work_area().bottom());
127 127
128 // Make sure the bounds of the two widgets changed. 128 // Make sure the bounds of the two widgets changed.
129 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); 129 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds();
130 int bottom = gfx::Screen::GetPrimaryMonitor().bounds().bottom() - 130 int bottom = gfx::Screen::GetPrimaryMonitor().bounds().bottom() -
131 shelf_height; 131 shelf_height;
132 EXPECT_EQ(launcher_bounds.y(), 132 EXPECT_EQ(launcher_bounds.y(),
133 bottom + (shelf->GetIdealBounds().height() - 133 bottom + (shelf->GetIdealBounds().height() -
134 launcher_bounds.height()) / 2); 134 launcher_bounds.height()) / 2);
135 status_bounds = shelf->status()->GetNativeView()->bounds(); 135 status_bounds = shelf->status()->GetNativeView()->bounds();
136 EXPECT_EQ(status_bounds.y(), 136 EXPECT_EQ(status_bounds.y(),
137 bottom + shelf_height - status_bounds.height()); 137 bottom + shelf_height - status_bounds.height());
138 } 138 }
139 139
140 // Makes sure LayoutShelf invoked while animating cleans things up. 140 // Makes sure LayoutShelf invoked while animating cleans things up.
141 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 141 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
142 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 142 ShelfLayoutManager* shelf = GetShelfLayoutManager();
143 // Force an initial layout. 143 // Force an initial layout.
144 shelf->LayoutShelf(); 144 shelf->LayoutShelf();
145 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 145 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
146 146
147 const aura::MonitorManager* manager = 147 const aura::MonitorManager* manager =
148 aura::Env::GetInstance()->monitor_manager(); 148 aura::Env::GetInstance()->monitor_manager();
149 const gfx::Monitor& monitor = 149 const gfx::Display& display =
150 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); 150 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
151 151
152 // Hide the shelf. 152 // Hide the shelf.
153 SetState(shelf, ShelfLayoutManager::HIDDEN); 153 SetState(shelf, ShelfLayoutManager::HIDDEN);
154 shelf->LayoutShelf(); 154 shelf->LayoutShelf();
155 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 155 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
156 EXPECT_EQ(0, monitor.bounds().bottom() - monitor.work_area().bottom()); 156 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom());
157 157
158 // Make sure the bounds of the two widgets changed. 158 // Make sure the bounds of the two widgets changed.
159 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 159 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
160 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 160 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
161 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 161 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
162 gfx::Screen::GetPrimaryMonitor().bounds().bottom()); 162 gfx::Screen::GetPrimaryMonitor().bounds().bottom());
163 } 163 }
164 164
165 // Makes sure the launcher is initially sized correctly. 165 // Makes sure the launcher is initially sized correctly.
166 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { 166 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 496 ShelfLayoutManager* shelf = GetShelfLayoutManager();
497 // Force an initial layout. 497 // Force an initial layout.
498 shelf->LayoutShelf(); 498 shelf->LayoutShelf();
499 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 499 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
500 500
501 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 501 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
502 502
503 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); 503 gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds());
504 const aura::MonitorManager* manager = 504 const aura::MonitorManager* manager =
505 aura::Env::GetInstance()->monitor_manager(); 505 aura::Env::GetInstance()->monitor_manager();
506 gfx::Monitor monitor = 506 gfx::Display display =
507 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); 507 manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
508 ASSERT_NE(-1, monitor.id()); 508 ASSERT_NE(-1, display.id());
509 EXPECT_EQ(shelf->GetIdealBounds().width(), 509 EXPECT_EQ(shelf->GetIdealBounds().width(),
510 monitor.GetWorkAreaInsets().left()); 510 display.GetWorkAreaInsets().left());
511 EXPECT_GE( 511 EXPECT_GE(
512 launcher_bounds.width(), 512 launcher_bounds.width(),
513 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); 513 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
514 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, 514 EXPECT_EQ(SHELF_ALIGNMENT_LEFT,
515 Shell::GetInstance()->system_tray()->shelf_alignment()); 515 Shell::GetInstance()->system_tray()->shelf_alignment());
516 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds()); 516 gfx::Rect status_bounds(shelf->status()->GetWindowScreenBounds());
517 EXPECT_GE(status_bounds.width(), 517 EXPECT_GE(status_bounds.width(),
518 shelf->status()->GetContentsView()->GetPreferredSize().width()); 518 shelf->status()->GetContentsView()->GetPreferredSize().width());
519 EXPECT_EQ(shelf->GetIdealBounds().width(), 519 EXPECT_EQ(shelf->GetIdealBounds().width(),
520 monitor.GetWorkAreaInsets().left()); 520 display.GetWorkAreaInsets().left());
521 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); 521 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
522 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom()); 522 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
523 EXPECT_EQ(0, monitor.GetWorkAreaInsets().right()); 523 EXPECT_EQ(0, display.GetWorkAreaInsets().right());
524 EXPECT_EQ(monitor.bounds().x(), launcher_bounds.x()); 524 EXPECT_EQ(display.bounds().x(), launcher_bounds.x());
525 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); 525 EXPECT_EQ(display.bounds().y(), launcher_bounds.y());
526 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); 526 EXPECT_EQ(display.bounds().height(), launcher_bounds.height());
527 527
528 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 528 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
529 launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds(); 529 launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds();
530 monitor = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); 530 display = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow());
531 ASSERT_NE(-1, monitor.id()); 531 ASSERT_NE(-1, display.id());
532 EXPECT_EQ(shelf->GetIdealBounds().width(), 532 EXPECT_EQ(shelf->GetIdealBounds().width(),
533 monitor.GetWorkAreaInsets().right()); 533 display.GetWorkAreaInsets().right());
534 EXPECT_GE( 534 EXPECT_GE(
535 launcher_bounds.width(), 535 launcher_bounds.width(),
536 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); 536 shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width());
537 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, 537 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT,
538 Shell::GetInstance()->system_tray()->shelf_alignment()); 538 Shell::GetInstance()->system_tray()->shelf_alignment());
539 status_bounds = gfx::Rect(shelf->status()->GetWindowScreenBounds()); 539 status_bounds = gfx::Rect(shelf->status()->GetWindowScreenBounds());
540 EXPECT_GE(status_bounds.width(), 540 EXPECT_GE(status_bounds.width(),
541 shelf->status()->GetContentsView()->GetPreferredSize().width()); 541 shelf->status()->GetContentsView()->GetPreferredSize().width());
542 EXPECT_EQ(shelf->GetIdealBounds().width(), 542 EXPECT_EQ(shelf->GetIdealBounds().width(),
543 monitor.GetWorkAreaInsets().right()); 543 display.GetWorkAreaInsets().right());
544 EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); 544 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
545 EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom()); 545 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
546 EXPECT_EQ(0, monitor.GetWorkAreaInsets().left()); 546 EXPECT_EQ(0, display.GetWorkAreaInsets().left());
547 EXPECT_EQ(monitor.work_area().right(), launcher_bounds.x()); 547 EXPECT_EQ(display.work_area().right(), launcher_bounds.x());
548 EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); 548 EXPECT_EQ(display.bounds().y(), launcher_bounds.y());
549 EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); 549 EXPECT_EQ(display.bounds().height(), launcher_bounds.height());
550 } 550 }
551 551
552 } // namespace internal 552 } // namespace internal
553 } // namespace ash 553 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_observer_hud.cc ('k') | ash/wm/window_util.cc » ('j') | ui/gfx/screen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698