Chromium Code Reviews| Index: ash/wm/window_selector_unittest.cc |
| diff --git a/ash/wm/window_selector_unittest.cc b/ash/wm/window_selector_unittest.cc |
| index 01a96bf08792e4a90794511686bc39362bbdac0f..2c03f7f1f43c547ef1c3aa11a9435378484f401e 100644 |
| --- a/ash/wm/window_selector_unittest.cc |
| +++ b/ash/wm/window_selector_unittest.cc |
| @@ -107,6 +107,29 @@ class WindowSelectorTest : public test::AshTestBase { |
| } |
| } |
| + void Cycle(WindowSelector::Direction direction) { |
| + if (!IsSelecting()) { |
| + std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> |
| + mru_window_tracker()->BuildMruWindowList(); |
| + ScopedVector<LayerAnimationObserver> animations; |
| + for (size_t i = 0; i < windows.size(); ++i) { |
|
Daniel Erat
2013/08/09 20:54:35
nit: don't need curly brackets here
flackr
2013/08/09 22:15:36
Done.
|
| + animations.push_back(new LayerAnimationObserver(windows[i]->layer())); |
| + } |
| + ash::Shell::GetInstance()->window_selector_controller()-> |
| + HandleCycleWindow(direction); |
| + for (size_t i = 0; i < animations.size(); ++i) { |
|
Daniel Erat
2013/08/09 20:54:35
nit: or here
flackr
2013/08/09 22:15:36
Done.
|
| + animations[i]->WaitUntilDone(); |
| + } |
| + } else { |
| + ash::Shell::GetInstance()->window_selector_controller()-> |
| + HandleCycleWindow(direction); |
| + } |
| + } |
| + |
| + void StopCycling() { |
| + ash::Shell::GetInstance()->window_selector_controller()->AltKeyReleased(); |
| + } |
| + |
| gfx::RectF GetTransformedBounds(aura::Window* window) { |
| gfx::RectF bounds(window->layer()->bounds()); |
| window->layer()->transform().TransformRect(&bounds); |
| @@ -125,6 +148,11 @@ class WindowSelectorTest : public test::AshTestBase { |
| event_generator.ClickLeftButton(); |
| } |
| + bool IsSelecting() { |
| + return ash::Shell::GetInstance()->window_selector_controller()-> |
| + IsSelecting(); |
| + } |
| + |
| private: |
| aura::test::TestWindowDelegate wd; |
| @@ -151,6 +179,29 @@ TEST_F(WindowSelectorTest, Basic) { |
| EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| } |
| +// Tests entering overview mode with three windows and cycling through them. |
| +TEST_F(WindowSelectorTest, BasicCycle) { |
| + gfx::Rect bounds(0, 0, 400, 400); |
| + scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
| + scoped_ptr<aura::Window> window2(CreateWindow(bounds)); |
| + scoped_ptr<aura::Window> window3(CreateWindow(bounds)); |
| + wm::ActivateWindow(window3.get()); |
| + wm::ActivateWindow(window2.get()); |
| + wm::ActivateWindow(window1.get()); |
| + EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(window3.get())); |
| + |
| + Cycle(WindowSelector::FORWARD); |
| + EXPECT_TRUE(IsSelecting()); |
| + Cycle(WindowSelector::FORWARD); |
| + StopCycling(); |
| + EXPECT_FALSE(IsSelecting()); |
| + EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| + EXPECT_TRUE(wm::IsActiveWindow(window3.get())); |
| +} |
| + |
| // Tests that overview mode is exited if the last remaining window is destroyed. |
| TEST_F(WindowSelectorTest, LastWindowDestroyed) { |
| gfx::Rect bounds(0, 0, 400, 400); |
| @@ -160,8 +211,7 @@ TEST_F(WindowSelectorTest, LastWindowDestroyed) { |
| window1.reset(); |
| window2.reset(); |
| - EXPECT_FALSE(ash::Shell::GetInstance()->window_selector_controller()-> |
| - IsSelecting()); |
| + EXPECT_FALSE(IsSelecting()); |
| } |
| // Tests that windows remain on the display they are currently on in overview |