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/focus_cycler.h" | 10 #include "ash/focus_cycler.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 Shell::GetInstance()->delegate()->LockScreen(); | 411 Shell::GetInstance()->delegate()->LockScreen(); |
412 shelf->UpdateVisibilityState(); | 412 shelf->UpdateVisibilityState(); |
413 // Showing a widget in the lock screen should force the shelf to be visibile. | 413 // Showing a widget in the lock screen should force the shelf to be visibile. |
414 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 414 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
415 | 415 |
416 Shell::GetInstance()->delegate()->UnlockScreen(); | 416 Shell::GetInstance()->delegate()->UnlockScreen(); |
417 shelf->UpdateVisibilityState(); | 417 shelf->UpdateVisibilityState(); |
418 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | 418 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); |
419 } | 419 } |
420 | 420 |
421 // Assertions around SetAutoHideBehavior. | |
422 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { | |
423 // Since ShelfLayoutManager queries for mouse location, move the mouse so | |
424 // it isn't over the shelf. | |
425 aura::test::EventGenerator generator( | |
426 Shell::GetPrimaryRootWindow(), gfx::Point()); | |
427 generator.MoveMouseTo(0, 0); | |
428 | |
429 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | |
430 views::Widget* widget = new views::Widget; | |
431 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
432 params.bounds = gfx::Rect(0, 0, 200, 200); | |
433 // Widget is now owned by the parent window. | |
434 widget->Init(params); | |
435 widget->Show(); | |
436 aura::Window* window = widget->GetNativeWindow(); | |
437 gfx::Rect display_bounds( | |
438 gfx::Screen::GetDisplayNearestWindow(window).bounds()); | |
439 | |
440 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
441 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | |
442 EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, | |
443 shelf->GetMaximizedWindowBounds(window).bottom()); | |
444 | |
445 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
446 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | |
447 EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, | |
448 shelf->GetMaximizedWindowBounds(window).bottom()); | |
449 | |
450 widget->Maximize(); | |
451 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | |
452 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), | |
453 widget->GetWorkAreaBoundsInScreen().bottom()); | |
454 | |
455 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
456 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); | |
457 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), | |
458 widget->GetWorkAreaBoundsInScreen().bottom()); | |
459 | |
460 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
461 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | |
462 EXPECT_EQ(gfx::Screen::GetDisplayNearestWindow(window).work_area().bottom(), | |
463 widget->GetWorkAreaBoundsInScreen().bottom()); | |
464 } | |
465 | |
466 // Verifies the shelf is visible when status/launcher is focused. | 421 // Verifies the shelf is visible when status/launcher is focused. |
467 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { | 422 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { |
468 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 423 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
469 // it isn't over the shelf. | 424 // it isn't over the shelf. |
470 aura::test::EventGenerator generator( | 425 aura::test::EventGenerator generator( |
471 Shell::GetPrimaryRootWindow(), gfx::Point()); | 426 Shell::GetPrimaryRootWindow(), gfx::Point()); |
472 generator.MoveMouseTo(0, 0); | 427 generator.MoveMouseTo(0, 0); |
473 | 428 |
474 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 429 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
475 views::Widget* widget = new views::Widget; | 430 views::Widget* widget = new views::Widget; |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 EXPECT_TRUE(status_area->IsMessageBubbleShown()); | 904 EXPECT_TRUE(status_area->IsMessageBubbleShown()); |
950 } else { | 905 } else { |
951 EXPECT_FALSE(shelf->IsVisible()); | 906 EXPECT_FALSE(shelf->IsVisible()); |
952 EXPECT_FALSE(status_area->IsMessageBubbleShown()); | 907 EXPECT_FALSE(status_area->IsMessageBubbleShown()); |
953 } | 908 } |
954 } | 909 } |
955 } | 910 } |
956 | 911 |
957 } // namespace internal | 912 } // namespace internal |
958 } // namespace ash | 913 } // namespace ash |
OLD | NEW |