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

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

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix command line Created 8 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
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/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
16 #include "ui/aura/monitor.h" 16 #include "ui/aura/monitor_aura.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/gfx/compositor/layer_animator.h" 22 #include "ui/gfx/compositor/layer_animator.h"
23 #include "ui/gfx/compositor/layer.h" 23 #include "ui/gfx/compositor/layer.h"
24 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
25 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
26 26
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #define MAYBE_SetVisible SetVisible 75 #define MAYBE_SetVisible SetVisible
76 #endif 76 #endif
77 // Makes sure SetVisible updates work area and widget appropriately. 77 // Makes sure SetVisible updates work area and widget appropriately.
78 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { 78 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
79 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 79 ShelfLayoutManager* shelf = GetShelfLayoutManager();
80 // Force an initial layout. 80 // Force an initial layout.
81 shelf->LayoutShelf(); 81 shelf->LayoutShelf();
82 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 82 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
83 const aura::MonitorManager* manager = 83 const aura::MonitorManager* manager =
84 aura::Env::GetInstance()->monitor_manager(); 84 aura::Env::GetInstance()->monitor_manager();
85 const aura::Monitor* monitor = 85 const aura::MonitorAura* monitor =
86 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 86 manager->GetMonitorNearestWindow(Shell::GetRootWindow());
87 ASSERT_TRUE(monitor); 87 ASSERT_TRUE(monitor);
88 // Bottom inset should be the max of widget heights. 88 // Bottom inset should be the max of widget heights.
89 EXPECT_EQ(shelf->shelf_height(), 89 EXPECT_EQ(shelf->shelf_height(),
90 monitor->work_area_insets().bottom()); 90 monitor->work_area_insets().bottom());
91 91
92 // Hide the shelf. 92 // Hide the shelf.
93 SetState(shelf, ShelfLayoutManager::HIDDEN); 93 SetState(shelf, ShelfLayoutManager::HIDDEN);
94 // Run the animation to completion. 94 // Run the animation to completion.
95 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 95 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
96 StepWidgetLayerAnimatorToEnd(shelf->status()); 96 StepWidgetLayerAnimatorToEnd(shelf->status());
97 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 97 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
98 EXPECT_EQ(0, monitor->work_area_insets().bottom()); 98 EXPECT_EQ(0, monitor->work_area_insets().bottom());
99 99
100 // Make sure the bounds of the two widgets changed. 100 // Make sure the bounds of the two widgets changed.
101 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 101 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
102 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 102 gfx::Screen::GetPrimaryMonitor()->GetBounds().bottom());
103 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 103 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
104 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 104 gfx::Screen::GetPrimaryMonitor()->GetBounds().bottom());
105 105
106 // And show it again. 106 // And show it again.
107 SetState(shelf, ShelfLayoutManager::VISIBLE); 107 SetState(shelf, ShelfLayoutManager::VISIBLE);
108 // Run the animation to completion. 108 // Run the animation to completion.
109 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); 109 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
110 StepWidgetLayerAnimatorToEnd(shelf->status()); 110 StepWidgetLayerAnimatorToEnd(shelf->status());
111 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 111 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
112 EXPECT_EQ(shelf->shelf_height(), 112 EXPECT_EQ(shelf->shelf_height(),
113 monitor->work_area_insets().bottom()); 113 monitor->work_area_insets().bottom());
114 114
115 // Make sure the bounds of the two widgets changed. 115 // Make sure the bounds of the two widgets changed.
116 gfx::Rect launcher_bounds( 116 gfx::Rect launcher_bounds(
117 shelf->launcher_widget()->GetNativeView()->bounds()); 117 shelf->launcher_widget()->GetNativeView()->bounds());
118 int bottom = gfx::Screen::GetPrimaryMonitorBounds().bottom() - 118 int bottom = gfx::Screen::GetPrimaryMonitor()->GetBounds().bottom() -
119 shelf->shelf_height(); 119 shelf->shelf_height();
120 EXPECT_EQ(launcher_bounds.y(), 120 EXPECT_EQ(launcher_bounds.y(),
121 bottom + (shelf->shelf_height() - launcher_bounds.height()) / 2); 121 bottom + (shelf->shelf_height() - launcher_bounds.height()) / 2);
122 gfx::Rect status_bounds(shelf->status()->GetNativeView()->bounds()); 122 gfx::Rect status_bounds(shelf->status()->GetNativeView()->bounds());
123 EXPECT_EQ(status_bounds.y(), 123 EXPECT_EQ(status_bounds.y(),
124 bottom + shelf->shelf_height() - status_bounds.height()); 124 bottom + shelf->shelf_height() - status_bounds.height());
125 } 125 }
126 126
127 // Makes sure LayoutShelf invoked while animating cleans things up. 127 // Makes sure LayoutShelf invoked while animating cleans things up.
128 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 128 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
129 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 129 ShelfLayoutManager* shelf = GetShelfLayoutManager();
130 // Force an initial layout. 130 // Force an initial layout.
131 shelf->LayoutShelf(); 131 shelf->LayoutShelf();
132 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 132 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
133 133
134 const aura::MonitorManager* manager = 134 const aura::MonitorManager* manager =
135 aura::Env::GetInstance()->monitor_manager(); 135 aura::Env::GetInstance()->monitor_manager();
136 const aura::Monitor* monitor = 136 const aura::MonitorAura* monitor =
137 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 137 manager->GetMonitorNearestWindow(Shell::GetRootWindow());
138 138
139 // Hide the shelf. 139 // Hide the shelf.
140 SetState(shelf, ShelfLayoutManager::HIDDEN); 140 SetState(shelf, ShelfLayoutManager::HIDDEN);
141 shelf->LayoutShelf(); 141 shelf->LayoutShelf();
142 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 142 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
143 EXPECT_EQ(0, monitor->work_area_insets().bottom()); 143 EXPECT_EQ(0, monitor->work_area_insets().bottom());
144 // Make sure the bounds of the two widgets changed. 144 // Make sure the bounds of the two widgets changed.
145 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), 145 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(),
146 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 146 gfx::Screen::GetPrimaryMonitor()->GetBounds().bottom());
147 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 147 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
148 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 148 gfx::Screen::GetPrimaryMonitor()->GetBounds().bottom());
149 } 149 }
150 150
151 // Makes sure the launcher is initially sized correctly. 151 // Makes sure the launcher is initially sized correctly.
152 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { 152 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) {
153 Launcher* launcher = Shell::GetInstance()->launcher(); 153 Launcher* launcher = Shell::GetInstance()->launcher();
154 ASSERT_TRUE(launcher); 154 ASSERT_TRUE(launcher);
155 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); 155 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
156 ASSERT_TRUE(shelf_layout_manager); 156 ASSERT_TRUE(shelf_layout_manager);
157 ASSERT_TRUE(shelf_layout_manager->status()); 157 ASSERT_TRUE(shelf_layout_manager->status());
158 int status_width = 158 int status_width =
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 447 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
448 448
449 // Toggle app list to hide. 449 // Toggle app list to hide.
450 shell->ToggleAppList(); 450 shell->ToggleAppList();
451 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 451 EXPECT_FALSE(shell->GetAppListTargetVisibility());
452 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); 452 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
453 } 453 }
454 454
455 } // namespace internal 455 } // namespace internal
456 } // namespace ash 456 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698