summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authortdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-02 18:02:51 +0000
committertdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-02 18:02:51 +0000
commitd476bfa9ea0986f1395ae6987b2f3092bfd036eb (patch)
tree196fcb7b185de4927e6996717e65e29d11740e26 /ui/aura
parent89670af7c862905ba4b1e76717fa140f7c65a95c (diff)
downloadchromium_src-d476bfa9ea0986f1395ae6987b2f3092bfd036eb.zip
chromium_src-d476bfa9ea0986f1395ae6987b2f3092bfd036eb.tar.gz
chromium_src-d476bfa9ea0986f1395ae6987b2f3092bfd036eb.tar.bz2
Prepare for Unified Gesture Recognizer landing in Aura
This is the final cleanup before the unified gesture recognizer is turned on. Tests are passing with the unified GR flag on and with the flag off. BUG=332418 Test=GestureRecognizerTest.*, GestureProviderTest.* Review URL: https://codereview.chromium.org/306483003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc5
-rw-r--r--ui/aura/window_event_dispatcher_unittest.cc94
2 files changed, 62 insertions, 37 deletions
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 5e0b543..aab2898 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -689,11 +689,6 @@ class GestureRecognizerTest : public AuraTestBase,
AuraTestBase::SetUp();
}
- virtual void TearDown() OVERRIDE {
- AuraTestBase::TearDown();
- RunAllPendingInMessageLoop();
- }
-
DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest);
};
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
index 9c3a77e..86b6046 100644
--- a/ui/aura/window_event_dispatcher_unittest.cc
+++ b/ui/aura/window_event_dispatcher_unittest.cc
@@ -395,14 +395,16 @@ TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) {
gfx::Point position = root_window()->bounds().origin();
position.Offset(-10, -10);
- ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, 0, base::TimeDelta());
+ ui::TouchEvent press(
+ ui::ET_TOUCH_PRESSED, position, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ(1, handler.num_touch_events());
position = root_window()->bounds().origin();
position.Offset(root_window()->bounds().width() + 10,
root_window()->bounds().height() + 10);
- ui::TouchEvent release(ui::ET_TOUCH_RELEASED, position, 0, base::TimeDelta());
+ ui::TouchEvent release(
+ ui::ET_TOUCH_RELEASED, position, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&release);
EXPECT_EQ(2, handler.num_touch_events());
}
@@ -499,6 +501,10 @@ class EventFilterRecorder : public ui::EventHandler {
touch_locations_.push_back(event->location());
}
+ bool HasReceivedEvent(ui::EventType type) {
+ return std::find(events_.begin(), events_.end(), type) != events_.end();
+ }
+
private:
scoped_ptr<base::RunLoop> run_loop_;
ui::EventType wait_until_event_;
@@ -727,8 +733,8 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// Starting the touch and throwing out the first few events, since the system
// is going to generate synthetic mouse events that are not relevant to the
// test.
- ui::TouchEvent touch_pressed_event(ui::ET_TOUCH_PRESSED, touch_location,
- 0, base::TimeDelta());
+ ui::TouchEvent touch_pressed_event(
+ ui::ET_TOUCH_PRESSED, touch_location, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&touch_pressed_event);
recorder.WaitUntilReceivedEvent(ui::ET_GESTURE_SHOW_PRESS);
recorder.Reset();
@@ -736,8 +742,8 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
host()->dispatcher()->HoldPointerMoves();
// Check that we don't immediately dispatch the TOUCH_MOVED event.
- ui::TouchEvent touch_moved_event(ui::ET_TOUCH_MOVED, touch_location,
- 0, base::TimeDelta());
+ ui::TouchEvent touch_moved_event(
+ ui::ET_TOUCH_MOVED, touch_location, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&touch_moved_event);
EXPECT_TRUE(recorder.events().empty());
@@ -753,13 +759,13 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// If another touch event occurs then the held touch should be dispatched
// immediately before it.
- ui::TouchEvent touch_released_event(ui::ET_TOUCH_RELEASED, touch_location,
- 0, base::TimeDelta());
+ ui::TouchEvent touch_released_event(
+ ui::ET_TOUCH_RELEASED, touch_location, 0, ui::EventTimeForNow());
recorder.Reset();
host()->dispatcher()->HoldPointerMoves();
DispatchEventUsingWindowDispatcher(&touch_moved_event);
DispatchEventUsingWindowDispatcher(&touch_released_event);
- EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP_CANCEL GESTURE_END",
+ EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP GESTURE_END",
EventTypesToString(recorder.events()));
recorder.Reset();
host()->dispatcher()->ReleasePointerMoves();
@@ -1213,14 +1219,13 @@ TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) {
ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN, 0.0f, 0.0f);
gfx::Point point(10, 10);
- ui::GestureEvent event(
- ui::ET_GESTURE_TAP_DOWN,
- point.x(),
- point.y(),
- 0,
- ui::EventTimeForNow(),
- details,
- 0);
+ ui::GestureEvent event(ui::ET_GESTURE_TAP_DOWN,
+ point.x(),
+ point.y(),
+ 0,
+ ui::EventTimeForNow(),
+ details,
+ 0);
host()->dispatcher()->RepostEvent(event);
RunAllPendingInMessageLoop();
// TODO(rbyers): Currently disabled - crbug.com/170987
@@ -1574,7 +1579,8 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) {
&delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
gfx::Point position1 = root_window()->bounds().origin();
- ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position1, 0, base::TimeDelta());
+ ui::TouchEvent press(
+ ui::ET_TOUCH_PRESSED, position1, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN",
@@ -1582,8 +1588,10 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) {
window->Hide();
- EXPECT_EQ("TOUCH_CANCELLED GESTURE_TAP_CANCEL GESTURE_END",
- EventTypesToString(recorder.events()));
+ EXPECT_EQ(ui::ET_TOUCH_CANCELLED, recorder.events()[0]);
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_TAP_CANCEL));
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_END));
+ EXPECT_EQ(3U, recorder.events().size());
root_window()->RemovePreTargetHandler(&recorder);
}
@@ -1597,25 +1605,45 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) {
gfx::Point position1 = root_window()->bounds().origin();
gfx::Point position2 = root_window()->bounds().CenterPoint();
- ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position1, 0, base::TimeDelta());
+ ui::TouchEvent press(
+ ui::ET_TOUCH_PRESSED, position1, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
- ui::TouchEvent move(ui::ET_TOUCH_MOVED, position2, 0, base::TimeDelta());
+ ui::TouchEvent move(
+ ui::ET_TOUCH_MOVED, position2, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&move);
- ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, position1, 1, base::TimeDelta());
+ ui::TouchEvent press2(
+ ui::ET_TOUCH_PRESSED, position1, 1, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press2);
- EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
- "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
- "TOUCH_PRESSED GESTURE_BEGIN GESTURE_PINCH_BEGIN",
- EventTypesToString(recorder.GetAndResetEvents()));
+ // TODO(tdresser): once the unified Gesture Recognizer has stuck, remove the
+ // special casing here. See crbug.com/332418 for details.
+ std::string expected =
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_PINCH_BEGIN";
+
+ std::string expected_ugr =
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
+ "TOUCH_PRESSED GESTURE_BEGIN";
+
+ std::string events_string = EventTypesToString(recorder.GetAndResetEvents());
+ EXPECT_TRUE((expected == events_string) || (expected_ugr == events_string));
window->Hide();
- EXPECT_EQ("TOUCH_CANCELLED GESTURE_PINCH_END GESTURE_END TOUCH_CANCELLED "
- "GESTURE_SCROLL_END GESTURE_END",
- EventTypesToString(recorder.events()));
+ expected =
+ "TOUCH_CANCELLED GESTURE_PINCH_END GESTURE_END TOUCH_CANCELLED "
+ "GESTURE_SCROLL_END GESTURE_END";
+ expected_ugr =
+ "TOUCH_CANCELLED GESTURE_SCROLL_END GESTURE_END GESTURE_END "
+ "TOUCH_CANCELLED";
+
+ events_string = EventTypesToString(recorder.GetAndResetEvents());
+ EXPECT_TRUE((expected == events_string) || (expected_ugr == events_string));
+
root_window()->RemovePreTargetHandler(&recorder);
}
@@ -1635,11 +1663,13 @@ TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) {
window2->AddPreTargetHandler(&recorder2);
gfx::Point position = window1->bounds().origin();
- ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, 0, base::TimeDelta());
+ ui::TouchEvent press(
+ ui::ET_TOUCH_PRESSED, position, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press);
gfx::Point position2 = window1->bounds().CenterPoint();
- ui::TouchEvent move(ui::ET_TOUCH_MOVED, position2, 0, base::TimeDelta());
+ ui::TouchEvent move(
+ ui::ET_TOUCH_MOVED, position2, 0, ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&move);
window2->SetCapture();