| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 gfx::Rect(0, 0, 200, 200)); | 292 gfx::Rect(0, 0, 200, 200)); |
| 293 EXPECT_EQ(200, launcher->status_size().width()); | 293 EXPECT_EQ(200, launcher->status_size().width()); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Verifies when the shell is deleted with a full screen window we don't | 296 // Verifies when the shell is deleted with a full screen window we don't |
| 297 // crash. This test is here as originally the crash was in ShelfLayoutManager. | 297 // crash. This test is here as originally the crash was in ShelfLayoutManager. |
| 298 TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) { | 298 TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) { |
| 299 views::Widget* widget = new views::Widget; | 299 views::Widget* widget = new views::Widget; |
| 300 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 300 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 301 params.bounds = gfx::Rect(0, 0, 200, 200); | 301 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 302 params.context = CurrentContext(); |
| 302 // Widget is now owned by the parent window. | 303 // Widget is now owned by the parent window. |
| 303 widget->Init(params); | 304 widget->Init(params); |
| 304 widget->SetFullscreen(true); | 305 widget->SetFullscreen(true); |
| 305 } | 306 } |
| 306 | 307 |
| 307 // Various assertions around auto-hide. | 308 // Various assertions around auto-hide. |
| 308 TEST_F(ShelfLayoutManagerTest, AutoHide) { | 309 TEST_F(ShelfLayoutManagerTest, AutoHide) { |
| 309 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 310 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 310 aura::test::EventGenerator generator(root, root); | 311 aura::test::EventGenerator generator(root, root); |
| 311 generator.MoveMouseTo(0, 0); | 312 generator.MoveMouseTo(0, 0); |
| 312 | 313 |
| 313 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 314 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 314 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 315 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 315 views::Widget* widget = new views::Widget; | 316 views::Widget* widget = new views::Widget; |
| 316 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 317 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 317 params.bounds = gfx::Rect(0, 0, 200, 200); | 318 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 319 params.context = CurrentContext(); |
| 318 // Widget is now owned by the parent window. | 320 // Widget is now owned by the parent window. |
| 319 widget->Init(params); | 321 widget->Init(params); |
| 320 widget->Maximize(); | 322 widget->Maximize(); |
| 321 widget->Show(); | 323 widget->Show(); |
| 322 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 324 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 323 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 325 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 324 | 326 |
| 325 // LayoutShelf() forces the animation to completion, at which point the | 327 // LayoutShelf() forces the animation to completion, at which point the |
| 326 // launcher should go off the screen. | 328 // launcher should go off the screen. |
| 327 shelf->LayoutShelf(); | 329 shelf->LayoutShelf(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 // it isn't over the shelf. | 376 // it isn't over the shelf. |
| 375 aura::test::EventGenerator generator( | 377 aura::test::EventGenerator generator( |
| 376 Shell::GetPrimaryRootWindow(), gfx::Point()); | 378 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 377 generator.MoveMouseTo(0, 0); | 379 generator.MoveMouseTo(0, 0); |
| 378 | 380 |
| 379 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 381 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 380 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 382 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 381 views::Widget* widget = new views::Widget; | 383 views::Widget* widget = new views::Widget; |
| 382 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 384 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 383 params.bounds = gfx::Rect(0, 0, 200, 200); | 385 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 386 params.context = CurrentContext(); |
| 384 // Widget is now owned by the parent window. | 387 // Widget is now owned by the parent window. |
| 385 widget->Init(params); | 388 widget->Init(params); |
| 386 widget->Maximize(); | 389 widget->Maximize(); |
| 387 widget->Show(); | 390 widget->Show(); |
| 388 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 391 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 389 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 392 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 390 | 393 |
| 391 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); | 394 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 392 // LayoutShelf() forces the animation to completion, at which point the | 395 // LayoutShelf() forces the animation to completion, at which point the |
| 393 // launcher should go off the screen. | 396 // launcher should go off the screen. |
| 394 shelf->LayoutShelf(); | 397 shelf->LayoutShelf(); |
| 395 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, | 398 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 396 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); | 399 shelf->launcher_widget()->GetWindowBoundsInScreen().y()); |
| 397 | 400 |
| 398 aura::Window* lock_container = Shell::GetContainer( | 401 aura::Window* lock_container = Shell::GetContainer( |
| 399 Shell::GetPrimaryRootWindow(), | 402 Shell::GetPrimaryRootWindow(), |
| 400 internal::kShellWindowId_LockScreenContainer); | 403 internal::kShellWindowId_LockScreenContainer); |
| 401 | 404 |
| 402 views::Widget* lock_widget = new views::Widget; | 405 views::Widget* lock_widget = new views::Widget; |
| 403 views::Widget::InitParams lock_params( | 406 views::Widget::InitParams lock_params( |
| 404 views::Widget::InitParams::TYPE_WINDOW); | 407 views::Widget::InitParams::TYPE_WINDOW); |
| 405 lock_params.bounds = gfx::Rect(0, 0, 200, 200); | 408 lock_params.bounds = gfx::Rect(0, 0, 200, 200); |
| 409 params.context = CurrentContext(); |
| 406 lock_params.parent = lock_container; | 410 lock_params.parent = lock_container; |
| 407 // Widget is now owned by the parent window. | 411 // Widget is now owned by the parent window. |
| 408 lock_widget->Init(lock_params); | 412 lock_widget->Init(lock_params); |
| 409 lock_widget->Maximize(); | 413 lock_widget->Maximize(); |
| 410 lock_widget->Show(); | 414 lock_widget->Show(); |
| 411 | 415 |
| 412 // Lock the screen. | 416 // Lock the screen. |
| 413 Shell::GetInstance()->delegate()->LockScreen(); | 417 Shell::GetInstance()->delegate()->LockScreen(); |
| 414 shelf->UpdateVisibilityState(); | 418 shelf->UpdateVisibilityState(); |
| 415 // Showing a widget in the lock screen should force the shelf to be visibile. | 419 // Showing a widget in the lock screen should force the shelf to be visibile. |
| 416 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 420 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 417 | 421 |
| 418 Shell::GetInstance()->delegate()->UnlockScreen(); | 422 Shell::GetInstance()->delegate()->UnlockScreen(); |
| 419 shelf->UpdateVisibilityState(); | 423 shelf->UpdateVisibilityState(); |
| 420 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 424 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 421 } | 425 } |
| 422 | 426 |
| 423 // Assertions around SetAutoHideBehavior. | 427 // Assertions around SetAutoHideBehavior. |
| 424 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { | 428 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| 425 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 429 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 426 // it isn't over the shelf. | 430 // it isn't over the shelf. |
| 427 aura::test::EventGenerator generator( | 431 aura::test::EventGenerator generator( |
| 428 Shell::GetPrimaryRootWindow(), gfx::Point()); | 432 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 429 generator.MoveMouseTo(0, 0); | 433 generator.MoveMouseTo(0, 0); |
| 430 | 434 |
| 431 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 435 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 432 views::Widget* widget = new views::Widget; | 436 views::Widget* widget = new views::Widget; |
| 433 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 437 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 434 params.bounds = gfx::Rect(0, 0, 200, 200); | 438 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 439 params.context = CurrentContext(); |
| 435 // Widget is now owned by the parent window. | 440 // Widget is now owned by the parent window. |
| 436 widget->Init(params); | 441 widget->Init(params); |
| 437 widget->Show(); | 442 widget->Show(); |
| 438 aura::Window* window = widget->GetNativeWindow(); | 443 aura::Window* window = widget->GetNativeWindow(); |
| 439 gfx::Rect display_bounds( | 444 gfx::Rect display_bounds( |
| 440 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 445 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 441 | 446 |
| 442 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 447 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 443 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 448 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 444 | 449 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 469 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 474 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 470 // it isn't over the shelf. | 475 // it isn't over the shelf. |
| 471 aura::test::EventGenerator generator( | 476 aura::test::EventGenerator generator( |
| 472 Shell::GetPrimaryRootWindow(), gfx::Point()); | 477 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 473 generator.MoveMouseTo(0, 0); | 478 generator.MoveMouseTo(0, 0); |
| 474 | 479 |
| 475 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 480 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 476 views::Widget* widget = new views::Widget; | 481 views::Widget* widget = new views::Widget; |
| 477 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 482 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 478 params.bounds = gfx::Rect(0, 0, 200, 200); | 483 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 484 params.context = CurrentContext(); |
| 479 // Widget is now owned by the parent window. | 485 // Widget is now owned by the parent window. |
| 480 widget->Init(params); | 486 widget->Init(params); |
| 481 widget->Show(); | 487 widget->Show(); |
| 482 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 488 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 483 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 489 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 484 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 490 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 485 | 491 |
| 486 // Focus the launcher. Have to go through the focus cycler as normal focus | 492 // Focus the launcher. Have to go through the focus cycler as normal focus |
| 487 // requests to it do nothing. | 493 // requests to it do nothing. |
| 488 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 494 shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 TEST_F(ShelfLayoutManagerTest, GestureDrag) { | 675 TEST_F(ShelfLayoutManagerTest, GestureDrag) { |
| 670 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 676 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 671 internal::RootWindowController* controller = | 677 internal::RootWindowController* controller = |
| 672 Shell::GetPrimaryRootWindowController(); | 678 Shell::GetPrimaryRootWindowController(); |
| 673 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 679 controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 674 shelf->LayoutShelf(); | 680 shelf->LayoutShelf(); |
| 675 | 681 |
| 676 views::Widget* widget = new views::Widget; | 682 views::Widget* widget = new views::Widget; |
| 677 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 683 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 678 params.bounds = gfx::Rect(0, 0, 200, 200); | 684 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 685 params.context = CurrentContext(); |
| 679 widget->Init(params); | 686 widget->Init(params); |
| 680 widget->Show(); | 687 widget->Show(); |
| 681 widget->Maximize(); | 688 widget->Maximize(); |
| 682 | 689 |
| 683 aura::Window* window = widget->GetNativeWindow(); | 690 aura::Window* window = widget->GetNativeWindow(); |
| 684 | 691 |
| 685 gfx::Rect shelf_shown = shelf->launcher_widget()->GetWindowBoundsInScreen(); | 692 gfx::Rect shelf_shown = shelf->launcher_widget()->GetWindowBoundsInScreen(); |
| 686 gfx::Rect bounds_shelf = window->bounds(); | 693 gfx::Rect bounds_shelf = window->bounds(); |
| 687 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 694 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 688 | 695 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 | 850 |
| 844 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { | 851 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| 845 // Make sure the shelf is always visible. | 852 // Make sure the shelf is always visible. |
| 846 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 853 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 847 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 854 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 848 shelf->LayoutShelf(); | 855 shelf->LayoutShelf(); |
| 849 | 856 |
| 850 views::Widget* widget_one = new views::Widget; | 857 views::Widget* widget_one = new views::Widget; |
| 851 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 858 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 852 params.bounds = gfx::Rect(0, 0, 200, 200); | 859 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 860 params.context = CurrentContext(); |
| 853 widget_one->Init(params); | 861 widget_one->Init(params); |
| 854 widget_one->Show(); | 862 widget_one->Show(); |
| 855 widget_one->Maximize(); | 863 widget_one->Maximize(); |
| 856 | 864 |
| 857 views::Widget* widget_two = new views::Widget; | 865 views::Widget* widget_two = new views::Widget; |
| 858 widget_two->Init(params); | 866 widget_two->Init(params); |
| 859 widget_two->Show(); | 867 widget_two->Show(); |
| 860 widget_two->Maximize(); | 868 widget_two->Maximize(); |
| 861 widget_two->Activate(); | 869 widget_two->Activate(); |
| 862 | 870 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 975 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 968 } else { | 976 } else { |
| 969 EXPECT_FALSE(shelf->IsVisible()); | 977 EXPECT_FALSE(shelf->IsVisible()); |
| 970 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 978 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 971 } | 979 } |
| 972 } | 980 } |
| 973 } | 981 } |
| 974 | 982 |
| 975 } // namespace internal | 983 } // namespace internal |
| 976 } // namespace ash | 984 } // namespace ash |
| OLD | NEW |