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

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

Issue 9784010: Fixes bug where maximized window wasn't getting resized when toggling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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_layout_manager.h » ('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/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) { 165 TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) {
166 views::Widget* widget = new views::Widget; 166 views::Widget* widget = new views::Widget;
167 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 167 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
168 params.bounds = gfx::Rect(0, 0, 200, 200); 168 params.bounds = gfx::Rect(0, 0, 200, 200);
169 // Widget is now owned by the parent window. 169 // Widget is now owned by the parent window.
170 widget->Init(params); 170 widget->Init(params);
171 widget->SetFullscreen(true); 171 widget->SetFullscreen(true);
172 } 172 }
173 173
174 // Various assertions around auto-hide. 174 // Various assertions around auto-hide.
175 TEST_F(ShelfLayoutManagerTest, DISABLED_AutoHide) { 175 TEST_F(ShelfLayoutManagerTest, AutoHide) {
176 aura::RootWindow* root = Shell::GetRootWindow();
177 aura::test::EventGenerator generator(root, root);
178 generator.MoveMouseTo(0, 0);
179
176 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 180 ShelfLayoutManager* shelf = GetShelfLayoutManager();
177 views::Widget* widget = new views::Widget; 181 views::Widget* widget = new views::Widget;
178 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 182 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
179 params.bounds = gfx::Rect(0, 0, 200, 200); 183 params.bounds = gfx::Rect(0, 0, 200, 200);
180 // Widget is now owned by the parent window. 184 // Widget is now owned by the parent window.
181 widget->Init(params); 185 widget->Init(params);
182 widget->Maximize(); 186 widget->Maximize();
183 widget->Show(); 187 widget->Show();
184 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 188 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
185 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 189 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
186 190
187 aura::RootWindow* root = Shell::GetRootWindow();
188 // LayoutShelf() forces the animation to completion, at which point the 191 // LayoutShelf() forces the animation to completion, at which point the
189 // launcher should go off the screen. 192 // launcher should go off the screen.
190 shelf->LayoutShelf(); 193 shelf->LayoutShelf();
191 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 194 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
192 shelf->launcher_widget()->GetWindowScreenBounds().y()); 195 shelf->launcher_widget()->GetWindowScreenBounds().y());
196 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
197 gfx::Screen::GetMonitorWorkAreaNearestWindow(root).bottom());
193 198
194 // Move the mouse to the bottom of the screen. 199 // Move the mouse to the bottom of the screen.
195 aura::test::EventGenerator generator(root, root); 200 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
196 generator.MoveMouseTo(gfx::Point(0, root->bounds().bottom() - 1));
197 201
198 // Shelf should be shown again. 202 // Shelf should be shown again (but it shouldn't have changed the work area).
199 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); 203 SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
200 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 204 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
201 shelf->LayoutShelf(); 205 shelf->LayoutShelf();
202 EXPECT_EQ(root->bounds().bottom() - shelf->shelf_height(), 206 EXPECT_EQ(root->bounds().bottom() - shelf->shelf_height(),
203 shelf->launcher_widget()->GetWindowScreenBounds().y()); 207 shelf->launcher_widget()->GetWindowScreenBounds().y());
208 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
209 gfx::Screen::GetMonitorWorkAreaNearestWindow(root).bottom());
204 210
205 // Move mouse back up. 211 // Move mouse back up.
206 generator.MoveMouseTo(gfx::Point(0, 0)); 212 generator.MoveMouseTo(0, 0);
207 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); 213 SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
208 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 214 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
209 shelf->LayoutShelf(); 215 shelf->LayoutShelf();
210 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, 216 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
211 shelf->launcher_widget()->GetWindowScreenBounds().y()); 217 shelf->launcher_widget()->GetWindowScreenBounds().y());
212 } 218 }
213 219
214 // Assertions around the lock screen showing. 220 // Assertions around the lock screen showing.
215 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { 221 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
216 // Since ShelfLayoutManager queries for mouse location, move the mouse so 222 // Since ShelfLayoutManager queries for mouse location, move the mouse so
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Showing a widget in the lock screen should force the shelf to be visibile. 262 // Showing a widget in the lock screen should force the shelf to be visibile.
257 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 263 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
258 264
259 Shell::GetInstance()->delegate()->UnlockScreen(); 265 Shell::GetInstance()->delegate()->UnlockScreen();
260 shelf->UpdateVisibilityState(); 266 shelf->UpdateVisibilityState();
261 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 267 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
262 } 268 }
263 269
264 // Assertions around SetAutoHideBehavior. 270 // Assertions around SetAutoHideBehavior.
265 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { 271 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
272 // Since ShelfLayoutManager queries for mouse location, move the mouse so
273 // it isn't over the shelf.
274 aura::test::EventGenerator generator(
275 Shell::GetInstance()->GetRootWindow(), gfx::Point());
276 generator.MoveMouseTo(0, 0);
277
266 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 278 ShelfLayoutManager* shelf = GetShelfLayoutManager();
267 views::Widget* widget = new views::Widget; 279 views::Widget* widget = new views::Widget;
268 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 280 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
269 params.bounds = gfx::Rect(0, 0, 200, 200); 281 params.bounds = gfx::Rect(0, 0, 200, 200);
270 // Widget is now owned by the parent window. 282 // Widget is now owned by the parent window.
271 widget->Init(params); 283 widget->Init(params);
272 widget->Show(); 284 widget->Show();
273 aura::Window* window = widget->GetNativeWindow(); 285 aura::Window* window = widget->GetNativeWindow();
274 gfx::Rect monitor_bounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); 286 gfx::Rect monitor_bounds(gfx::Screen::GetMonitorAreaNearestWindow(window));
275 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 287 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
(...skipping 10 matching lines...) Expand all
286 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 298 EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
287 shelf->GetMaximizedWindowBounds(window).bottom()); 299 shelf->GetMaximizedWindowBounds(window).bottom());
288 300
289 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 301 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
290 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 302 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
291 EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight, 303 EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
292 shelf->GetMaximizedWindowBounds(window).bottom()); 304 shelf->GetMaximizedWindowBounds(window).bottom());
293 305
294 widget->Maximize(); 306 widget->Maximize();
295 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 307 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
308 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window).bottom(),
309 widget->GetWorkAreaBoundsInScreen().bottom());
310
311 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
312 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
313 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window).bottom(),
314 widget->GetWorkAreaBoundsInScreen().bottom());
315
316 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
317 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
318 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window).bottom(),
319 widget->GetWorkAreaBoundsInScreen().bottom());
296 } 320 }
297 321
298 } // namespace internal 322 } // namespace internal
299 } // namespace ash 323 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/shelf_layout_manager.cc ('k') | ash/wm/workspace/workspace_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698