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

Unified Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/gestures/gesture_recognizer_unittest.cc
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 7e0faa5c1e1418819867614d7fdadf827e88789e..0af8c1192b0098caf1c4dc2dd407730bc90761c5 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -19,7 +19,7 @@
#include "ui/events/event.h"
#include "ui/events/event_switches.h"
#include "ui/events/event_utils.h"
-#include "ui/events/gestures/gesture_configuration.h"
+#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/gestures/gesture_recognizer_impl.h"
#include "ui/events/gestures/gesture_types.h"
#include "ui/events/test/event_generator.h"
@@ -228,6 +228,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
break;
case ui::ET_GESTURE_SCROLL_UPDATE:
scroll_update_ = true;
+ // base::debug::StackTrace().Print();
+
scroll_x_ += gesture->details().scroll_x();
scroll_y_ += gesture->details().scroll_y();
break;
@@ -635,8 +637,8 @@ class GestureRecognizerTest : public AuraTestBase,
virtual void SetUp() OVERRIDE {
AuraTestBase::SetUp();
- ui::GestureConfiguration::set_show_press_delay_in_ms(2);
- ui::GestureConfiguration::set_long_press_time_in_seconds(0.003);
+ ui::GestureConfiguration::GetInstance()->set_show_press_delay_in_ms(2);
+ ui::GestureConfiguration::GetInstance()->set_long_press_timeout_in_ms(3);
}
DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest);
@@ -655,6 +657,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
delegate.get(), -1234, bounds, root_window()));
delegate->Reset();
+
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&press);
@@ -938,8 +941,9 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
// We'll start by moving the touch point by (10.5, 10.5). We want 5 dips of
// that distance to be consumed by the slop, so we set the slop radius to
// sqrt(5 * 5 + 5 * 5).
- ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(
- sqrt(static_cast<double>(5 * 5 + 5 * 5)));
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_move_in_pixels_for_click(
+ sqrt(static_cast<double>(5 * 5 + 5 * 5)));
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
@@ -1009,8 +1013,9 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
// We'll start by moving the touch point by (5, 5). We want all of that
// distance to be consumed by the slop, so we set the slop radius to
// sqrt(5 * 5 + 5 * 5).
- ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(
- sqrt(static_cast<double>(5 * 5 + 5 * 5)));
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_move_in_pixels_for_click(
+ sqrt(static_cast<double>(5 * 5 + 5 * 5)));
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
@@ -1081,7 +1086,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
TimedEvents tes;
for (int radius = 1; radius <= 10; ++radius) {
- ui::GestureConfiguration::set_default_radius(radius);
+ ui::GestureConfiguration::GetInstance()->set_default_radius(radius);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
@@ -1130,7 +1135,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
radius * 2).ToString(),
delegate->bounding_box().ToString());
}
- ui::GestureConfiguration::set_default_radius(0);
+ ui::GestureConfiguration::GetInstance()->set_default_radius(0);
}
// Check Scroll End Events report correct velocities
@@ -1158,6 +1163,7 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
// Move the touch-point horizontally enough that it is considered a
// horizontal scroll.
tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get());
+
EXPECT_FLOAT_EQ(0, delegate->scroll_y());
EXPECT_FLOAT_EQ(20, delegate->scroll_x());
@@ -1239,7 +1245,8 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
// Check Scroll End Events report non-zero velocities if the user is not on a
// rail
TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
- ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0);
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_move_in_pixels_for_click(0);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
@@ -1366,8 +1373,8 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
// Check that appropriate touch events generate long tap events
TEST_F(GestureRecognizerTest, GestureEventLongTap) {
- ui::GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click(
- 0.0025);
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_down_duration_in_seconds_for_click(0.0025);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
@@ -1573,8 +1580,9 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// We'll start by moving the touch point by (5, 5). We want all of that
// distance to be consumed by the slop, so we set the slop radius to
// sqrt(5 * 5 + 5 * 5).
- ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(
- sqrt(static_cast<double>(5 * 5 + 5 * 5)));
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_move_in_pixels_for_click(
+ sqrt(static_cast<double>(5 * 5 + 5 * 5)));
// First, tap. Then, do a scroll using the same touch-id.
scoped_ptr<GestureEventConsumeDelegate> delegate(
@@ -1831,7 +1839,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// should generate both SCROLL_BEGIN and PINCH_BEGIN gestures.
queued_delegate->Reset();
delegate->Reset();
- int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click();
+ int x_move = ui::GestureConfiguration::GetInstance()
+ ->max_touch_move_in_pixels_for_click();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(203 + x_move, 303), kTouchId2, tes.Now());
DispatchEventUsingWindowDispatcher(&move);
@@ -2132,8 +2141,8 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
scoped_ptr<GestureEventConsumeDelegate*[]> delegates(
new GestureEventConsumeDelegate*[kNumWindows]);
- ui::GestureConfiguration::
- set_max_separation_for_gesture_touches_in_pixels(499);
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_separation_for_gesture_touches_in_pixels(499);
scoped_ptr<gfx::Rect[]> window_bounds(new gfx::Rect[kNumWindows]);
window_bounds[0] = gfx::Rect(0, 0, 1, 1);
@@ -3460,7 +3469,8 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
// Checks that slow scrolls deliver the correct deltas.
// In particular, fix for http;//crbug.com/150573.
TEST_F(GestureRecognizerTest, NoDriftInScroll) {
- ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_move_in_pixels_for_click(3);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 234;
@@ -3811,7 +3821,8 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) {
// Tests that the deltas are correct when leaving the slop region very slowly.
TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
- ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_touch_move_in_pixels_for_click(3);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 234;

Powered by Google App Engine
This is Rietveld 408576698