OLD | NEW |
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/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 ShelfLayoutObserverTest() | 60 ShelfLayoutObserverTest() |
61 : changed_auto_hide_state_(false) { | 61 : changed_auto_hide_state_(false) { |
62 } | 62 } |
63 | 63 |
64 virtual ~ShelfLayoutObserverTest() {} | 64 virtual ~ShelfLayoutObserverTest() {} |
65 | 65 |
66 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } | 66 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } |
67 | 67 |
68 private: | 68 private: |
69 virtual void OnAutoHideStateChanged( | 69 virtual void OnAutoHideStateChanged( |
70 ShelfLayoutManager::AutoHideState new_state) OVERRIDE { | 70 ShelfAutoHideState new_state) OVERRIDE { |
71 changed_auto_hide_state_ = true; | 71 changed_auto_hide_state_ = true; |
72 } | 72 } |
73 | 73 |
74 bool changed_auto_hide_state_; | 74 bool changed_auto_hide_state_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); | 76 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); |
77 }; | 77 }; |
78 | 78 |
79 // Trivial item implementation that tracks its views for testing. | 79 // Trivial item implementation that tracks its views for testing. |
80 class TestItem : public SystemTrayItem { | 80 class TestItem : public SystemTrayItem { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 class ShelfLayoutManagerTest : public ash::test::AshTestBase { | 152 class ShelfLayoutManagerTest : public ash::test::AshTestBase { |
153 public: | 153 public: |
154 ShelfLayoutManagerTest() {} | 154 ShelfLayoutManagerTest() {} |
155 | 155 |
156 ShelfLayoutManager* shelf_layout_manager() { | 156 ShelfLayoutManager* shelf_layout_manager() { |
157 return Shell::GetPrimaryRootWindowController()->shelf(); | 157 return Shell::GetPrimaryRootWindowController()->shelf(); |
158 } | 158 } |
159 | 159 |
160 void SetState(ShelfLayoutManager* shelf, | 160 void SetState(ShelfLayoutManager* shelf, |
161 ShelfLayoutManager::VisibilityState state) { | 161 ShelfVisibilityState state) { |
162 shelf->SetState(state); | 162 shelf->SetState(state); |
163 } | 163 } |
164 | 164 |
165 void UpdateAutoHideStateNow() { | 165 void UpdateAutoHideStateNow() { |
166 GetShelfLayoutManager()->UpdateAutoHideStateNow(); | 166 GetShelfLayoutManager()->UpdateAutoHideStateNow(); |
167 } | 167 } |
168 | 168 |
169 aura::Window* CreateTestWindow() { | 169 aura::Window* CreateTestWindow() { |
170 aura::Window* window = new aura::Window(NULL); | 170 aura::Window* window = new aura::Window(NULL); |
171 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 171 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
(...skipping 17 matching lines...) Expand all Loading... |
189 #if defined(OS_MACOSX) | 189 #if defined(OS_MACOSX) |
190 #define MAYBE_SetVisible DISABLED_SetVisible | 190 #define MAYBE_SetVisible DISABLED_SetVisible |
191 #else | 191 #else |
192 #define MAYBE_SetVisible SetVisible | 192 #define MAYBE_SetVisible SetVisible |
193 #endif | 193 #endif |
194 // Makes sure SetVisible updates work area and widget appropriately. | 194 // Makes sure SetVisible updates work area and widget appropriately. |
195 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { | 195 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
196 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 196 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
197 // Force an initial layout. | 197 // Force an initial layout. |
198 shelf->LayoutShelf(); | 198 shelf->LayoutShelf(); |
199 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 199 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
200 | 200 |
201 gfx::Rect status_bounds( | 201 gfx::Rect status_bounds( |
202 shelf->status_area_widget()->GetWindowBoundsInScreen()); | 202 shelf->status_area_widget()->GetWindowBoundsInScreen()); |
203 gfx::Rect launcher_bounds( | 203 gfx::Rect launcher_bounds( |
204 shelf->launcher_widget()->GetWindowBoundsInScreen()); | 204 shelf->launcher_widget()->GetWindowBoundsInScreen()); |
205 int shelf_height = shelf->GetIdealBounds().height(); | 205 int shelf_height = shelf->GetIdealBounds().height(); |
206 | 206 |
207 const gfx::Display& display = Shell::GetInstance()->display_manager()-> | 207 const gfx::Display& display = Shell::GetInstance()->display_manager()-> |
208 GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 208 GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
209 ASSERT_NE(-1, display.id()); | 209 ASSERT_NE(-1, display.id()); |
210 // Bottom inset should be the max of widget heights. | 210 // Bottom inset should be the max of widget heights. |
211 EXPECT_EQ(shelf_height, | 211 EXPECT_EQ(shelf_height, |
212 display.bounds().bottom() - display.work_area().bottom()); | 212 display.bounds().bottom() - display.work_area().bottom()); |
213 | 213 |
214 // Hide the shelf. | 214 // Hide the shelf. |
215 SetState(shelf, ShelfLayoutManager::HIDDEN); | 215 SetState(shelf, SHELF_HIDDEN); |
216 // Run the animation to completion. | 216 // Run the animation to completion. |
217 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); | 217 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); |
218 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); | 218 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); |
219 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 219 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
220 EXPECT_EQ(0, | 220 EXPECT_EQ(0, |
221 display.bounds().bottom() - display.work_area().bottom()); | 221 display.bounds().bottom() - display.work_area().bottom()); |
222 | 222 |
223 // Make sure the bounds of the two widgets changed. | 223 // Make sure the bounds of the two widgets changed. |
224 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), | 224 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), |
225 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 225 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
226 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), | 226 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), |
227 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 227 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
228 | 228 |
229 // And show it again. | 229 // And show it again. |
230 SetState(shelf, ShelfLayoutManager::VISIBLE); | 230 SetState(shelf, SHELF_VISIBLE); |
231 // Run the animation to completion. | 231 // Run the animation to completion. |
232 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); | 232 StepWidgetLayerAnimatorToEnd(shelf->launcher_widget()); |
233 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); | 233 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); |
234 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 234 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
235 EXPECT_EQ(shelf_height, | 235 EXPECT_EQ(shelf_height, |
236 display.bounds().bottom() - display.work_area().bottom()); | 236 display.bounds().bottom() - display.work_area().bottom()); |
237 | 237 |
238 // Make sure the bounds of the two widgets changed. | 238 // Make sure the bounds of the two widgets changed. |
239 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); | 239 launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); |
240 int bottom = | 240 int bottom = |
241 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom() - shelf_height; | 241 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom() - shelf_height; |
242 EXPECT_EQ(launcher_bounds.y(), | 242 EXPECT_EQ(launcher_bounds.y(), |
243 bottom + (shelf->GetIdealBounds().height() - | 243 bottom + (shelf->GetIdealBounds().height() - |
244 launcher_bounds.height()) / 2); | 244 launcher_bounds.height()) / 2); |
245 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); | 245 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); |
246 EXPECT_EQ(status_bounds.y(), | 246 EXPECT_EQ(status_bounds.y(), |
247 bottom + shelf_height - status_bounds.height()); | 247 bottom + shelf_height - status_bounds.height()); |
248 } | 248 } |
249 | 249 |
250 // Makes sure LayoutShelf invoked while animating cleans things up. | 250 // Makes sure LayoutShelf invoked while animating cleans things up. |
251 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 251 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
252 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 252 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
253 // Force an initial layout. | 253 // Force an initial layout. |
254 shelf->LayoutShelf(); | 254 shelf->LayoutShelf(); |
255 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 255 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
256 | 256 |
257 const gfx::Display& display = Shell::GetInstance()->display_manager()-> | 257 const gfx::Display& display = Shell::GetInstance()->display_manager()-> |
258 GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 258 GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
259 | 259 |
260 // Hide the shelf. | 260 // Hide the shelf. |
261 SetState(shelf, ShelfLayoutManager::HIDDEN); | 261 SetState(shelf, SHELF_HIDDEN); |
262 shelf->LayoutShelf(); | 262 shelf->LayoutShelf(); |
263 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 263 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
264 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); | 264 EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); |
265 | 265 |
266 // Make sure the bounds of the two widgets changed. | 266 // Make sure the bounds of the two widgets changed. |
267 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), | 267 EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), |
268 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 268 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
269 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), | 269 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), |
270 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 270 Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
271 } | 271 } |
272 | 272 |
273 // Makes sure the launcher is initially sized correctly. | 273 // Makes sure the launcher is initially sized correctly. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 316 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
317 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 317 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
318 views::Widget* widget = new views::Widget; | 318 views::Widget* widget = new views::Widget; |
319 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 319 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
320 params.bounds = gfx::Rect(0, 0, 200, 200); | 320 params.bounds = gfx::Rect(0, 0, 200, 200); |
321 // Widget is now owned by the parent window. | 321 // Widget is now owned by the parent window. |
322 widget->Init(params); | 322 widget->Init(params); |
323 widget->Maximize(); | 323 widget->Maximize(); |
324 widget->Show(); | 324 widget->Show(); |
325 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 325 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
326 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 326 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
327 | 327 |
328 // LayoutShelf() forces the animation to completion, at which point the | 328 // LayoutShelf() forces the animation to completion, at which point the |
329 // launcher should go off the screen. | 329 // launcher should go off the screen. |
330 shelf->LayoutShelf(); | 330 shelf->LayoutShelf(); |
331 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 331 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
332 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); | 332 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); |
333 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 333 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
334 Shell::GetScreen()->GetDisplayNearestWindow( | 334 Shell::GetScreen()->GetDisplayNearestWindow( |
335 root).work_area().bottom()); | 335 root).work_area().bottom()); |
336 | 336 |
337 // Move the mouse to the bottom of the screen. | 337 // Move the mouse to the bottom of the screen. |
338 generator.MoveMouseTo(0, root->bounds().bottom() - 1); | 338 generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
339 | 339 |
340 // Shelf should be shown again (but it shouldn't have changed the work area). | 340 // Shelf should be shown again (but it shouldn't have changed the work area). |
341 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); | 341 SetState(shelf, SHELF_AUTO_HIDE); |
342 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 342 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
343 shelf->LayoutShelf(); | 343 shelf->LayoutShelf(); |
344 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), | 344 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), |
345 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); | 345 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); |
346 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 346 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
347 Shell::GetScreen()->GetDisplayNearestWindow( | 347 Shell::GetScreen()->GetDisplayNearestWindow( |
348 root).work_area().bottom()); | 348 root).work_area().bottom()); |
349 | 349 |
350 // Move mouse back up. | 350 // Move mouse back up. |
351 generator.MoveMouseTo(0, 0); | 351 generator.MoveMouseTo(0, 0); |
352 SetState(shelf, ShelfLayoutManager::AUTO_HIDE); | 352 SetState(shelf, SHELF_AUTO_HIDE); |
353 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 353 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
354 shelf->LayoutShelf(); | 354 shelf->LayoutShelf(); |
355 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 355 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
356 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); | 356 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); |
357 | 357 |
358 // Drag mouse to bottom of screen. | 358 // Drag mouse to bottom of screen. |
359 generator.PressLeftButton(); | 359 generator.PressLeftButton(); |
360 generator.MoveMouseTo(0, root->bounds().bottom() - 1); | 360 generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
361 UpdateAutoHideStateNow(); | 361 UpdateAutoHideStateNow(); |
362 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 362 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
363 | 363 |
364 generator.ReleaseLeftButton(); | 364 generator.ReleaseLeftButton(); |
365 generator.MoveMouseTo(1, root->bounds().bottom() - 1); | 365 generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
366 UpdateAutoHideStateNow(); | 366 UpdateAutoHideStateNow(); |
367 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 367 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
368 generator.PressLeftButton(); | 368 generator.PressLeftButton(); |
369 generator.MoveMouseTo(1, root->bounds().bottom() - 1); | 369 generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
370 UpdateAutoHideStateNow(); | 370 UpdateAutoHideStateNow(); |
371 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 371 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
372 } | 372 } |
373 | 373 |
374 // Assertions around the lock screen showing. | 374 // Assertions around the lock screen showing. |
375 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { | 375 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
376 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 376 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
377 // it isn't over the shelf. | 377 // it isn't over the shelf. |
378 aura::test::EventGenerator generator( | 378 aura::test::EventGenerator generator( |
379 Shell::GetPrimaryRootWindow(), gfx::Point()); | 379 Shell::GetPrimaryRootWindow(), gfx::Point()); |
380 generator.MoveMouseTo(0, 0); | 380 generator.MoveMouseTo(0, 0); |
381 | 381 |
382 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 382 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
383 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 383 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
384 views::Widget* widget = new views::Widget; | 384 views::Widget* widget = new views::Widget; |
385 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 385 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
386 params.bounds = gfx::Rect(0, 0, 200, 200); | 386 params.bounds = gfx::Rect(0, 0, 200, 200); |
387 // Widget is now owned by the parent window. | 387 // Widget is now owned by the parent window. |
388 widget->Init(params); | 388 widget->Init(params); |
389 widget->Maximize(); | 389 widget->Maximize(); |
390 widget->Show(); | 390 widget->Show(); |
391 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 391 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
392 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 392 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
393 | 393 |
394 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 394 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
395 // LayoutShelf() forces the animation to completion, at which point the | 395 // LayoutShelf() forces the animation to completion, at which point the |
396 // launcher should go off the screen. | 396 // launcher should go off the screen. |
397 shelf->LayoutShelf(); | 397 shelf->LayoutShelf(); |
398 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 398 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
399 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); | 399 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); |
400 | 400 |
401 aura::Window* lock_container = Shell::GetContainer( | 401 aura::Window* lock_container = Shell::GetContainer( |
402 Shell::GetPrimaryRootWindow(), | 402 Shell::GetPrimaryRootWindow(), |
403 internal::kShellWindowId_LockScreenContainer); | 403 internal::kShellWindowId_LockScreenContainer); |
404 | 404 |
405 views::Widget* lock_widget = new views::Widget; | 405 views::Widget* lock_widget = new views::Widget; |
406 views::Widget::InitParams lock_params( | 406 views::Widget::InitParams lock_params( |
407 views::Widget::InitParams::TYPE_WINDOW); | 407 views::Widget::InitParams::TYPE_WINDOW); |
408 lock_params.bounds = gfx::Rect(0, 0, 200, 200); | 408 lock_params.bounds = gfx::Rect(0, 0, 200, 200); |
409 lock_params.parent = lock_container; | 409 lock_params.parent = lock_container; |
410 // Widget is now owned by the parent window. | 410 // Widget is now owned by the parent window. |
411 lock_widget->Init(lock_params); | 411 lock_widget->Init(lock_params); |
412 lock_widget->Maximize(); | 412 lock_widget->Maximize(); |
413 lock_widget->Show(); | 413 lock_widget->Show(); |
414 | 414 |
415 // Lock the screen. | 415 // Lock the screen. |
416 Shell::GetInstance()->delegate()->LockScreen(); | 416 Shell::GetInstance()->delegate()->LockScreen(); |
417 shelf->UpdateVisibilityState(); | 417 shelf->UpdateVisibilityState(); |
418 // Showing a widget in the lock screen should force the shelf to be visibile. | 418 // Showing a widget in the lock screen should force the shelf to be visibile. |
419 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 419 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
420 | 420 |
421 Shell::GetInstance()->delegate()->UnlockScreen(); | 421 Shell::GetInstance()->delegate()->UnlockScreen(); |
422 shelf->UpdateVisibilityState(); | 422 shelf->UpdateVisibilityState(); |
423 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 423 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
424 } | 424 } |
425 | 425 |
426 // Assertions around SetAutoHideBehavior. | 426 // Assertions around SetAutoHideBehavior. |
427 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { | 427 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
428 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 428 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
429 // it isn't over the shelf. | 429 // it isn't over the shelf. |
430 aura::test::EventGenerator generator( | 430 aura::test::EventGenerator generator( |
431 Shell::GetPrimaryRootWindow(), gfx::Point()); | 431 Shell::GetPrimaryRootWindow(), gfx::Point()); |
432 generator.MoveMouseTo(0, 0); | 432 generator.MoveMouseTo(0, 0); |
433 | 433 |
434 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 434 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
435 views::Widget* widget = new views::Widget; | 435 views::Widget* widget = new views::Widget; |
436 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 436 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
437 params.bounds = gfx::Rect(0, 0, 200, 200); | 437 params.bounds = gfx::Rect(0, 0, 200, 200); |
438 // Widget is now owned by the parent window. | 438 // Widget is now owned by the parent window. |
439 widget->Init(params); | 439 widget->Init(params); |
440 widget->Show(); | 440 widget->Show(); |
441 aura::Window* window = widget->GetNativeWindow(); | 441 aura::Window* window = widget->GetNativeWindow(); |
442 gfx::Rect display_bounds( | 442 gfx::Rect display_bounds( |
443 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 443 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
444 | 444 |
445 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 445 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
446 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 446 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
447 | 447 |
448 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 448 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
449 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 449 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
450 | 450 |
451 widget->Maximize(); | 451 widget->Maximize(); |
452 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 452 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
453 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( | 453 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
454 window).work_area().bottom(), | 454 window).work_area().bottom(), |
455 widget->GetWorkAreaBoundsInScreen().bottom()); | 455 widget->GetWorkAreaBoundsInScreen().bottom()); |
456 | 456 |
457 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 457 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
458 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 458 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
459 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( | 459 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
460 window).work_area().bottom(), | 460 window).work_area().bottom(), |
461 widget->GetWorkAreaBoundsInScreen().bottom()); | 461 widget->GetWorkAreaBoundsInScreen().bottom()); |
462 | 462 |
463 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 463 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
464 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 464 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
465 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( | 465 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
466 window).work_area().bottom(), | 466 window).work_area().bottom(), |
467 widget->GetWorkAreaBoundsInScreen().bottom()); | 467 widget->GetWorkAreaBoundsInScreen().bottom()); |
468 } | 468 } |
469 | 469 |
470 // Verifies the shelf is visible when status/launcher is focused. | 470 // Verifies the shelf is visible when status/launcher is focused. |
471 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { | 471 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { |
472 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 472 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
473 // it isn't over the shelf. | 473 // it isn't over the shelf. |
474 aura::test::EventGenerator generator( | 474 aura::test::EventGenerator generator( |
475 Shell::GetPrimaryRootWindow(), gfx::Point()); | 475 Shell::GetPrimaryRootWindow(), gfx::Point()); |
476 generator.MoveMouseTo(0, 0); | 476 generator.MoveMouseTo(0, 0); |
477 | 477 |
478 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 478 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
479 views::Widget* widget = new views::Widget; | 479 views::Widget* widget = new views::Widget; |
480 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 480 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
481 params.bounds = gfx::Rect(0, 0, 200, 200); | 481 params.bounds = gfx::Rect(0, 0, 200, 200); |
482 // Widget is now owned by the parent window. | 482 // Widget is now owned by the parent window. |
483 widget->Init(params); | 483 widget->Init(params); |
484 widget->Show(); | 484 widget->Show(); |
485 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 485 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
486 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 486 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
487 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 487 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
488 | 488 |
489 // Focus the launcher. Have to go through the focus cycler as normal focus | 489 // Focus the launcher. Have to go through the focus cycler as normal focus |
490 // requests to it do nothing. | 490 // requests to it do nothing. |
491 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 491 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
492 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 492 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
493 | 493 |
494 widget->Activate(); | 494 widget->Activate(); |
495 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 495 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
496 | 496 |
497 // Trying to activate the status should fail, since we only allow activating | 497 // Trying to activate the status should fail, since we only allow activating |
498 // it when the user is using the keyboard (i.e. through FocusCycler). | 498 // it when the user is using the keyboard (i.e. through FocusCycler). |
499 shelf->status_area_widget()->Activate(); | 499 shelf->status_area_widget()->Activate(); |
500 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 500 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
501 | 501 |
502 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 502 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
503 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 503 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
504 } | 504 } |
505 | 505 |
506 // Makes sure shelf will be visible when app list opens as shelf is in VISIBLE | 506 // Makes sure shelf will be visible when app list opens as shelf is in |
507 // state,and toggling app list won't change shelf visibility state. | 507 // SHELF_VISIBLE state,and toggling app list won't change shelf |
| 508 // visibility state. |
508 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { | 509 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { |
509 Shell* shell = Shell::GetInstance(); | 510 Shell* shell = Shell::GetInstance(); |
510 internal::RootWindowController* controller = | 511 internal::RootWindowController* controller = |
511 Shell::GetPrimaryRootWindowController(); | 512 Shell::GetPrimaryRootWindowController(); |
512 ShelfLayoutManager* shelf = shelf_layout_manager(); | 513 ShelfLayoutManager* shelf = shelf_layout_manager(); |
513 shelf->LayoutShelf(); | 514 shelf->LayoutShelf(); |
514 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 515 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
515 | 516 |
516 // Create a normal unmaximized windowm shelf should be visible. | 517 // Create a normal unmaximized windowm shelf should be visible. |
517 aura::Window* window = CreateTestWindow(); | 518 aura::Window* window = CreateTestWindow(); |
518 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 519 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
519 window->Show(); | 520 window->Show(); |
520 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 521 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
521 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 522 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
522 | 523 |
523 // Toggle app list to show, and the shelf stays visible. | 524 // Toggle app list to show, and the shelf stays visible. |
524 shell->ToggleAppList(); | 525 shell->ToggleAppList(); |
525 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 526 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
526 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 527 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
527 | 528 |
528 // Toggle app list to hide, and the shelf stays visible. | 529 // Toggle app list to hide, and the shelf stays visible. |
529 shell->ToggleAppList(); | 530 shell->ToggleAppList(); |
530 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 531 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
531 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 532 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
532 } | 533 } |
533 | 534 |
534 // Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens | 535 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state |
535 // as shelf is in AUTO_HIDE state, and toggling app list won't change shelf | 536 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and |
536 // visibility state. | 537 // toggling app list won't change shelf visibility state. |
537 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { | 538 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { |
538 Shell* shell = Shell::GetInstance(); | 539 Shell* shell = Shell::GetInstance(); |
539 ShelfLayoutManager* shelf = shelf_layout_manager(); | 540 ShelfLayoutManager* shelf = shelf_layout_manager(); |
540 internal::RootWindowController* controller = | 541 internal::RootWindowController* controller = |
541 Shell::GetPrimaryRootWindowController(); | 542 Shell::GetPrimaryRootWindowController(); |
542 shelf->LayoutShelf(); | 543 shelf->LayoutShelf(); |
543 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 544 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
544 | 545 |
545 // Create a window and show it in maximized state. | 546 // Create a window and show it in maximized state. |
546 aura::Window* window = CreateTestWindow(); | 547 aura::Window* window = CreateTestWindow(); |
547 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 548 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
548 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 549 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
549 window->Show(); | 550 window->Show(); |
550 wm::ActivateWindow(window); | 551 wm::ActivateWindow(window); |
551 | 552 |
552 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 553 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
553 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 554 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
554 | 555 |
555 // Toggle app list to show. | 556 // Toggle app list to show. |
556 shell->ToggleAppList(); | 557 shell->ToggleAppList(); |
557 // The shelf's auto hide state won't be changed until the timer fires, so | 558 // The shelf's auto hide state won't be changed until the timer fires, so |
558 // calling shell->UpdateShelfVisibility() is kind of manually helping it to | 559 // calling shell->UpdateShelfVisibility() is kind of manually helping it to |
559 // update the state. | 560 // update the state. |
560 shell->UpdateShelfVisibility(); | 561 shell->UpdateShelfVisibility(); |
561 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 562 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
562 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 563 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
563 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 564 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
564 | 565 |
565 // Toggle app list to hide. | 566 // Toggle app list to hide. |
566 shell->ToggleAppList(); | 567 shell->ToggleAppList(); |
567 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 568 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
568 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 569 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
569 } | 570 } |
570 | 571 |
571 // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN | 572 // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN |
572 // state, and toggling app list won't change shelf visibility state. | 573 // state, and toggling app list won't change shelf visibility state. |
573 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { | 574 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { |
574 Shell* shell = Shell::GetInstance(); | 575 Shell* shell = Shell::GetInstance(); |
575 ShelfLayoutManager* shelf = shelf_layout_manager(); | 576 ShelfLayoutManager* shelf = shelf_layout_manager(); |
576 // For shelf to be visible, app list is not open in initial state. | 577 // For shelf to be visible, app list is not open in initial state. |
577 shelf->LayoutShelf(); | 578 shelf->LayoutShelf(); |
578 | 579 |
579 // Create a window and make it full screen. | 580 // Create a window and make it full screen. |
580 aura::Window* window = CreateTestWindow(); | 581 aura::Window* window = CreateTestWindow(); |
581 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 582 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
582 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 583 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
583 window->Show(); | 584 window->Show(); |
584 wm::ActivateWindow(window); | 585 wm::ActivateWindow(window); |
585 | 586 |
586 // App list and shelf is not shown. | 587 // App list and shelf is not shown. |
587 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 588 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
588 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 589 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
589 | 590 |
590 // Toggle app list to show. | 591 // Toggle app list to show. |
591 shell->ToggleAppList(); | 592 shell->ToggleAppList(); |
592 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 593 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
593 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 594 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
594 | 595 |
595 // Toggle app list to hide. | 596 // Toggle app list to hide. |
596 shell->ToggleAppList(); | 597 shell->ToggleAppList(); |
597 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 598 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
598 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 599 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
599 } | 600 } |
600 | 601 |
601 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT. | 602 // Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT. |
602 TEST_F(ShelfLayoutManagerTest, SetAlignment) { | 603 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
603 ShelfLayoutManager* shelf = shelf_layout_manager(); | 604 ShelfLayoutManager* shelf = shelf_layout_manager(); |
604 // Force an initial layout. | 605 // Force an initial layout. |
605 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 606 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
606 shelf->LayoutShelf(); | 607 shelf->LayoutShelf(); |
607 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 608 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
608 | 609 |
609 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 610 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
610 gfx::Rect launcher_bounds( | 611 gfx::Rect launcher_bounds( |
611 shelf->launcher_widget()->GetWindowBoundsInScreen()); | 612 shelf->launcher_widget()->GetWindowBoundsInScreen()); |
612 const internal::DisplayManager* manager = | 613 const internal::DisplayManager* manager = |
613 Shell::GetInstance()->display_manager(); | 614 Shell::GetInstance()->display_manager(); |
614 gfx::Display display = | 615 gfx::Display display = |
615 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 616 manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
616 ASSERT_NE(-1, display.id()); | 617 ASSERT_NE(-1, display.id()); |
617 EXPECT_EQ(shelf->GetIdealBounds().width(), | 618 EXPECT_EQ(shelf->GetIdealBounds().width(), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 682 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
682 params.bounds = gfx::Rect(0, 0, 200, 200); | 683 params.bounds = gfx::Rect(0, 0, 200, 200); |
683 widget->Init(params); | 684 widget->Init(params); |
684 widget->Show(); | 685 widget->Show(); |
685 widget->Maximize(); | 686 widget->Maximize(); |
686 | 687 |
687 aura::Window* window = widget->GetNativeWindow(); | 688 aura::Window* window = widget->GetNativeWindow(); |
688 | 689 |
689 gfx::Rect shelf_shown = shelf->launcher_widget()->GetWindowBoundsInScreen(); | 690 gfx::Rect shelf_shown = shelf->launcher_widget()->GetWindowBoundsInScreen(); |
690 gfx::Rect bounds_shelf = window->bounds(); | 691 gfx::Rect bounds_shelf = window->bounds(); |
691 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 692 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
692 | 693 |
693 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 694 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
694 | 695 |
695 // Swipe up on the shelf. This should not change any state. | 696 // Swipe up on the shelf. This should not change any state. |
696 gfx::Point start = | 697 gfx::Point start = |
697 shelf->launcher_widget()->GetWindowBoundsInScreen().CenterPoint(); | 698 shelf->launcher_widget()->GetWindowBoundsInScreen().CenterPoint(); |
698 gfx::Point end(start.x(), start.y() + 100); | 699 gfx::Point end(start.x(), start.y() + 100); |
699 | 700 |
700 // Swipe down on the shelf to hide it. | 701 // Swipe down on the shelf to hide it. |
701 end.set_y(start.y() + 100); | 702 end.set_y(start.y() + 100); |
702 generator.GestureScrollSequence(start, end, | 703 generator.GestureScrollSequence(start, end, |
703 base::TimeDelta::FromMilliseconds(10), 1); | 704 base::TimeDelta::FromMilliseconds(10), 1); |
704 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 705 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
705 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 706 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
706 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 707 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
707 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); | 708 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); |
708 EXPECT_NE(shelf_shown.ToString(), | 709 EXPECT_NE(shelf_shown.ToString(), |
709 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); | 710 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); |
710 | 711 |
711 gfx::Rect bounds_noshelf = window->bounds(); | 712 gfx::Rect bounds_noshelf = window->bounds(); |
712 gfx::Rect shelf_hidden = shelf->launcher_widget()->GetWindowBoundsInScreen(); | 713 gfx::Rect shelf_hidden = shelf->launcher_widget()->GetWindowBoundsInScreen(); |
713 | 714 |
714 // Swipe up to show the shelf. | 715 // Swipe up to show the shelf. |
715 generator.GestureScrollSequence(end, start, | 716 generator.GestureScrollSequence(end, start, |
716 base::TimeDelta::FromMilliseconds(10), 1); | 717 base::TimeDelta::FromMilliseconds(10), 1); |
717 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 718 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
718 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 719 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
719 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 720 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
720 EXPECT_EQ(shelf_shown.ToString(), | 721 EXPECT_EQ(shelf_shown.ToString(), |
721 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); | 722 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); |
722 | 723 |
723 // Swipe up again. The shelf should hide. | 724 // Swipe up again. The shelf should hide. |
724 end.set_y(start.y() - 100); | 725 end.set_y(start.y() - 100); |
725 generator.GestureScrollSequence(start, end, | 726 generator.GestureScrollSequence(start, end, |
726 base::TimeDelta::FromMilliseconds(10), 1); | 727 base::TimeDelta::FromMilliseconds(10), 1); |
727 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 728 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
728 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 729 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
729 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 730 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
730 EXPECT_EQ(shelf_hidden.ToString(), | 731 EXPECT_EQ(shelf_hidden.ToString(), |
731 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); | 732 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); |
732 | 733 |
733 // Swipe up yet again to show it. | 734 // Swipe up yet again to show it. |
734 end.set_y(start.y() + 100); | 735 end.set_y(start.y() + 100); |
735 generator.GestureScrollSequence(end, start, | 736 generator.GestureScrollSequence(end, start, |
736 base::TimeDelta::FromMilliseconds(10), 1); | 737 base::TimeDelta::FromMilliseconds(10), 1); |
737 | 738 |
738 // Swipe down very little. It shouldn't change any state. | 739 // Swipe down very little. It shouldn't change any state. |
739 end.set_y(start.y() + shelf_shown.height() * 3 / 10); | 740 end.set_y(start.y() + shelf_shown.height() * 3 / 10); |
740 generator.GestureScrollSequence(start, end, | 741 generator.GestureScrollSequence(start, end, |
741 base::TimeDelta::FromMilliseconds(100), 1); | 742 base::TimeDelta::FromMilliseconds(100), 1); |
742 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 743 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
743 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 744 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
744 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 745 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
745 EXPECT_EQ(shelf_shown.ToString(), | 746 EXPECT_EQ(shelf_shown.ToString(), |
746 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); | 747 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); |
747 | 748 |
748 // Swipe down again to hide. | 749 // Swipe down again to hide. |
749 end.set_y(start.y() + 100); | 750 end.set_y(start.y() + 100); |
750 generator.GestureScrollSequence(start, end, | 751 generator.GestureScrollSequence(start, end, |
751 base::TimeDelta::FromMilliseconds(10), 1); | 752 base::TimeDelta::FromMilliseconds(10), 1); |
752 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 753 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
753 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 754 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
754 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 755 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
755 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 756 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
756 EXPECT_EQ(shelf_hidden.ToString(), | 757 EXPECT_EQ(shelf_hidden.ToString(), |
757 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); | 758 shelf->launcher_widget()->GetWindowBoundsInScreen().ToString()); |
758 | 759 |
759 // Make the window fullscreen. | 760 // Make the window fullscreen. |
760 widget->SetFullscreen(true); | 761 widget->SetFullscreen(true); |
761 gfx::Rect bounds_fullscreen = window->bounds(); | 762 gfx::Rect bounds_fullscreen = window->bounds(); |
762 EXPECT_TRUE(widget->IsFullscreen()); | 763 EXPECT_TRUE(widget->IsFullscreen()); |
763 EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); | 764 EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); |
764 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 765 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
765 | 766 |
766 // Swipe-up. This should not change anything. | 767 // Swipe-up. This should not change anything. |
767 generator.GestureScrollSequence(end, start, | 768 generator.GestureScrollSequence(end, start, |
768 base::TimeDelta::FromMilliseconds(10), 1); | 769 base::TimeDelta::FromMilliseconds(10), 1); |
769 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 770 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
770 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 771 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
771 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 772 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
772 } | 773 } |
773 | 774 |
774 TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { | 775 TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { |
775 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 776 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
776 shelf->LayoutShelf(); | 777 shelf->LayoutShelf(); |
777 | 778 |
778 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 779 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
779 SystemTray* tray = Shell::GetInstance()->system_tray(); | 780 SystemTray* tray = Shell::GetInstance()->system_tray(); |
(...skipping 22 matching lines...) Expand all Loading... |
802 | 803 |
803 // Now, hide the shelf. | 804 // Now, hide the shelf. |
804 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 805 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
805 | 806 |
806 // Start a drag from the bezel, and drag up to show both the shelf and the | 807 // Start a drag from the bezel, and drag up to show both the shelf and the |
807 // tray bubble. | 808 // tray bubble. |
808 start.set_y(start.y() + 100); | 809 start.set_y(start.y() + 100); |
809 end.set_y(start.y() - 400); | 810 end.set_y(start.y() - 400); |
810 generator.GestureScrollSequence(start, end, | 811 generator.GestureScrollSequence(start, end, |
811 base::TimeDelta::FromMilliseconds(10), 1); | 812 base::TimeDelta::FromMilliseconds(10), 1); |
812 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 813 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
813 EXPECT_TRUE(tray->HasSystemBubble()); | 814 EXPECT_TRUE(tray->HasSystemBubble()); |
814 } | 815 } |
815 | 816 |
816 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { | 817 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { |
817 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 818 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
818 | 819 |
819 // Turn on auto-hide for the shelf. | 820 // Turn on auto-hide for the shelf. |
820 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 821 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
821 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 822 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
822 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 823 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
823 | 824 |
824 // Focus the system tray. That should make the shelf visible again. | 825 // Focus the system tray. That should make the shelf visible again. |
825 Shell::GetInstance()->accelerator_controller()->PerformAction( | 826 Shell::GetInstance()->accelerator_controller()->PerformAction( |
826 FOCUS_SYSTEM_TRAY, ui::Accelerator()); | 827 FOCUS_SYSTEM_TRAY, ui::Accelerator()); |
827 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 828 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
828 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 829 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
829 EXPECT_FALSE(Shell::GetInstance()->system_tray()->HasSystemBubble()); | 830 EXPECT_FALSE(Shell::GetInstance()->system_tray()->HasSystemBubble()); |
830 | 831 |
831 // Now activate the tray (using the keyboard, instead of using the mouse to | 832 // Now activate the tray (using the keyboard, instead of using the mouse to |
832 // make sure the mouse does not alter the auto-hide state in the shelf). | 833 // make sure the mouse does not alter the auto-hide state in the shelf). |
833 // This should not trigger any auto-hide state change in the shelf. | 834 // This should not trigger any auto-hide state change in the shelf. |
834 ShelfLayoutObserverTest observer; | 835 ShelfLayoutObserverTest observer; |
835 shelf->AddObserver(&observer); | 836 shelf->AddObserver(&observer); |
836 | 837 |
837 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 838 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
838 generator.PressKey(ui::VKEY_SPACE, 0); | 839 generator.PressKey(ui::VKEY_SPACE, 0); |
839 generator.ReleaseKey(ui::VKEY_SPACE, 0); | 840 generator.ReleaseKey(ui::VKEY_SPACE, 0); |
840 EXPECT_TRUE(Shell::GetInstance()->system_tray()->HasSystemBubble()); | 841 EXPECT_TRUE(Shell::GetInstance()->system_tray()->HasSystemBubble()); |
841 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 842 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
842 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 843 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
843 EXPECT_FALSE(observer.changed_auto_hide_state()); | 844 EXPECT_FALSE(observer.changed_auto_hide_state()); |
844 | 845 |
845 shelf->RemoveObserver(&observer); | 846 shelf->RemoveObserver(&observer); |
846 } | 847 } |
847 | 848 |
848 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { | 849 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
849 // Make sure the shelf is always visible. | 850 // Make sure the shelf is always visible. |
850 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 851 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
851 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 852 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
852 shelf->LayoutShelf(); | 853 shelf->LayoutShelf(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 972 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
972 } else { | 973 } else { |
973 EXPECT_FALSE(shelf->IsVisible()); | 974 EXPECT_FALSE(shelf->IsVisible()); |
974 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 975 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
975 } | 976 } |
976 } | 977 } |
977 } | 978 } |
978 | 979 |
979 } // namespace internal | 980 } // namespace internal |
980 } // namespace ash | 981 } // namespace ash |
OLD | NEW |