Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/wm/overview/window_selector_controller.h" | 5 #include "ash/common/wm/overview/window_selector_controller.h" |
| 6 #include "ash/common/wm_shell.h" | 6 #include "ash/common/wm_shell.h" |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/window_util.h" | |
| 10 #include "ui/aura/test/test_window_delegate.h" | 11 #include "ui/aura/test/test_window_delegate.h" |
| 11 #include "ui/aura/test/test_windows.h" | 12 #include "ui/aura/test/test_windows.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/events/test/event_generator.h" | 15 #include "ui/events/test/event_generator.h" |
| 15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 16 | 17 |
| 17 namespace ash { | 18 namespace ash { |
| 18 | 19 |
| 19 class OverviewGestureHandlerTest : public test::AshTestBase { | 20 class OverviewGestureHandlerTest : public test::AshTestBase { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | 57 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| 57 0, 500, 100, 3); | 58 0, 500, 100, 3); |
| 58 EXPECT_FALSE(IsSelecting()); | 59 EXPECT_FALSE(IsSelecting()); |
| 59 | 60 |
| 60 // Swiping down again does nothing. | 61 // Swiping down again does nothing. |
| 61 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | 62 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| 62 0, 500, 100, 3); | 63 0, 500, 100, 3); |
| 63 EXPECT_FALSE(IsSelecting()); | 64 EXPECT_FALSE(IsSelecting()); |
| 64 } | 65 } |
| 65 | 66 |
| 67 // Tests a swipe up with three fingers to enter overview and a swipe right or | |
| 68 // left to move selection. | |
| 69 TEST_F(OverviewGestureHandlerTest, VerticalThenHorizontalSwipe) { | |
| 70 gfx::Rect bounds(0, 0, 400, 400); | |
| 71 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | |
| 72 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | |
| 73 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | |
| 74 std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); | |
| 75 std::unique_ptr<aura::Window> window4(CreateWindow(bounds)); | |
| 76 std::unique_ptr<aura::Window> window5(CreateWindow(bounds)); | |
| 77 ui::test::EventGenerator generator(root_window, root_window); | |
| 78 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | |
| 79 0, -500, 100, 3); | |
|
tdanderson
2017/02/06 20:13:58
nit: It might be nice to make use of kVerticalSwip
varkha
2017/02/08 20:41:13
Done.
| |
| 80 EXPECT_TRUE(IsSelecting()); | |
| 81 | |
| 82 // Long swipe right moves selection to the fourth window. | |
|
tdanderson
2017/02/06 20:13:58
Consider adding a test to verify that horizontal t
varkha
2017/02/08 20:41:13
(Or come to think of it, maybe we would want three
| |
| 83 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | |
| 84 500, 0, 100, 3); | |
| 85 EXPECT_TRUE(IsSelecting()); | |
| 86 | |
| 87 // Short swipe left moves selection to the third window. | |
| 88 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | |
| 89 -200, 0, 100, 3); | |
| 90 EXPECT_TRUE(IsSelecting()); | |
| 91 | |
| 92 // Short swipe left moves selection to the second window. | |
| 93 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | |
| 94 -150, 0, 100, 3); | |
| 95 EXPECT_TRUE(IsSelecting()); | |
| 96 | |
| 97 // Swiping down exits. | |
|
tdanderson
2017/02/06 20:13:58
nit: swiping down exists and selects the currently
varkha
2017/02/08 20:41:13
Done.
| |
| 98 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | |
| 99 0, 500, 100, 3); | |
| 100 EXPECT_FALSE(IsSelecting()); | |
| 101 | |
| 102 // Second MRU window is selected (i.e. |window4|). | |
| 103 EXPECT_EQ(window4.get(), wm::GetActiveWindow()); | |
| 104 } | |
| 105 | |
| 66 // Tests that a mostly horizontal swipe does not trigger overview. | 106 // Tests that a mostly horizontal swipe does not trigger overview. |
| 67 TEST_F(OverviewGestureHandlerTest, HorizontalSwipes) { | 107 TEST_F(OverviewGestureHandlerTest, HorizontalSwipes) { |
| 68 gfx::Rect bounds(0, 0, 400, 400); | 108 gfx::Rect bounds(0, 0, 400, 400); |
| 69 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 109 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 70 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 110 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 71 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); | 111 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 72 ui::test::EventGenerator generator(root_window, root_window); | 112 ui::test::EventGenerator generator(root_window, root_window); |
| 73 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), | 113 generator.ScrollSequence(gfx::Point(), base::TimeDelta::FromMilliseconds(5), |
| 74 600, -500, 100, 3); | 114 600, -500, 100, 3); |
| 75 EXPECT_FALSE(IsSelecting()); | 115 EXPECT_FALSE(IsSelecting()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 generator.Dispatch(&move); | 153 generator.Dispatch(&move); |
| 114 } | 154 } |
| 115 | 155 |
| 116 EXPECT_FALSE(IsSelecting()); | 156 EXPECT_FALSE(IsSelecting()); |
| 117 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, start, timestamp, 0, 0, | 157 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, start, timestamp, 0, 0, |
| 118 10, 0, 10, num_fingers); | 158 10, 0, 10, num_fingers); |
| 119 generator.Dispatch(&fling_start); | 159 generator.Dispatch(&fling_start); |
| 120 } | 160 } |
| 121 | 161 |
| 122 } // namespace ash | 162 } // namespace ash |
| OLD | NEW |