Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 156783006: Consuming a touch move prevents only the next scroll update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental whitespace change. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 tes.LeapForward(40)); 4031 tes.LeapForward(40));
4032 DispatchEventUsingWindowDispatcher(&move4); 4032 DispatchEventUsingWindowDispatcher(&move4);
4033 EXPECT_FALSE(delegate->scroll_begin()); 4033 EXPECT_FALSE(delegate->scroll_begin());
4034 EXPECT_TRUE(delegate->scroll_update()); 4034 EXPECT_TRUE(delegate->scroll_update());
4035 EXPECT_EQ(1, delegate->scroll_x()); 4035 EXPECT_EQ(1, delegate->scroll_x());
4036 EXPECT_EQ(0, delegate->scroll_x_hint()); 4036 EXPECT_EQ(0, delegate->scroll_x_hint());
4037 delegate->Reset(); 4037 delegate->Reset();
4038 4038
4039 } 4039 }
4040 4040
4041 TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
4042 scoped_ptr<QueueTouchEventDelegate> delegate(
4043 new QueueTouchEventDelegate(dispatcher()));
4044 TimedEvents tes;
4045 const int kWindowWidth = 3000;
4046 const int kWindowHeight = 3000;
4047 const int kTouchId = 2;
4048 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
4049 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4050 delegate.get(), -1234, bounds, root_window()));
4051
4052 delegate->Reset();
4053
4054 int x = 0;
4055 int y = 0;
4056
4057 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(x, y),
4058 kTouchId, tes.Now());
4059 DispatchEventUsingWindowDispatcher(&press1);
4060 delegate->ReceivedAck();
4061 EXPECT_FALSE(delegate->scroll_begin());
4062 EXPECT_FALSE(delegate->scroll_update());
4063 delegate->Reset();
4064
4065 x += 100;
4066 y += 100;
4067 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(x, y),
4068 kTouchId, tes.Now());
4069 DispatchEventUsingWindowDispatcher(&move1);
4070 delegate->ReceivedAck();
4071 EXPECT_TRUE(delegate->scroll_begin());
4072 EXPECT_TRUE(delegate->scroll_update());
4073 delegate->Reset();
4074
4075 for (int i = 0; i < 3; ++i) {
4076 x += 10;
4077 y += 10;
4078 ui::TouchEvent move2(
4079 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId, tes.Now());
4080 DispatchEventUsingWindowDispatcher(&move2);
4081 delegate->ReceivedAck();
4082 EXPECT_FALSE(delegate->scroll_begin());
4083 EXPECT_TRUE(delegate->scroll_update());
4084 delegate->Reset();
4085
4086 x -= 10;
4087 y += 10;
4088 ui::TouchEvent move3(
4089 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId, tes.Now());
4090 DispatchEventUsingWindowDispatcher(&move3);
4091 delegate->ReceivedAckPreventDefaulted();
4092 EXPECT_FALSE(delegate->scroll_begin());
4093 EXPECT_FALSE(delegate->scroll_update());
4094 delegate->Reset();
4095 }
4096 }
4097
4041 } // namespace test 4098 } // namespace test
4042 } // namespace aura 4099 } // namespace aura
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue_unittest.cc ('k') | ui/events/gestures/gesture_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698