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

Unified Diff: ui/events/gestures/motion_event_aura_unittest.cc

Issue 531133002: Revert of Completed webkit radiusX, radiusY and rotationAngle handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « ui/events/gestures/motion_event_aura.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gestures/motion_event_aura_unittest.cc
diff --git a/ui/events/gestures/motion_event_aura_unittest.cc b/ui/events/gestures/motion_event_aura_unittest.cc
index e70361260780729ba8e7dae5e28072f9d3d0db54..3ef793e7c2bdaf2e2b8bab15178750653aa0d056 100644
--- a/ui/events/gestures/motion_event_aura_unittest.cc
+++ b/ui/events/gestures/motion_event_aura_unittest.cc
@@ -1,11 +1,6 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-// MSVC++ requires this to be set before any other includes to get M_PI.
-#define _USE_MATH_DEFINES
-
-#include <cmath>
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h"
@@ -23,36 +18,19 @@
float x,
float y,
float raw_x,
- float raw_y) {
+ float raw_y,
+ float radius,
+ float pressure) {
ui::TouchEvent event(type,
gfx::PointF(x, y),
0,
id,
base::TimeDelta::FromMilliseconds(0),
+ radius,
+ radius,
0,
- 0,
- 0,
- 0);
+ pressure);
event.set_root_location(gfx::PointF(raw_x, raw_y));
- return event;
-}
-
-ui::TouchEvent TouchWithTapParams(ui::EventType type,
- int id,
- float radius_x,
- float radius_y,
- float rotation_angle,
- float pressure) {
- ui::TouchEvent event(type,
- gfx::PointF(1, 1),
- 0,
- id,
- base::TimeDelta::FromMilliseconds(0),
- radius_x,
- radius_y,
- rotation_angle,
- pressure);
- event.set_root_location(gfx::PointF(1, 1));
return event;
}
@@ -107,7 +85,6 @@
EXPECT_EQ(ids[2], event.GetPointerId(1));
// Test cloning of pointer count and id information.
- // TODO(mustaq): Make a separate clone test
scoped_ptr<MotionEvent> clone = event.Clone();
EXPECT_EQ(2U, clone->GetPointerCount());
EXPECT_EQ(ids[0], clone->GetPointerId(0));
@@ -172,13 +149,17 @@
float y;
float raw_x;
float raw_y;
+ float r;
+ float p;
x = 14.4f;
y = 17.3f;
raw_x = x + kRawOffsetX;
raw_y = y + kRawOffsetY;
+ r = 25.7f;
+ p = 48.2f;
TouchEvent press0 =
- TouchWithPosition(ET_TOUCH_PRESSED, ids[0], x, y, raw_x, raw_y);
+ TouchWithPosition(ET_TOUCH_PRESSED, ids[0], x, y, raw_x, raw_y, r, p);
event.OnTouch(press0);
EXPECT_EQ(1U, event.GetPointerCount());
@@ -186,13 +167,17 @@
EXPECT_FLOAT_EQ(y, event.GetY(0));
EXPECT_FLOAT_EQ(raw_x, event.GetRawX(0));
EXPECT_FLOAT_EQ(raw_y, event.GetRawY(0));
+ EXPECT_FLOAT_EQ(r, event.GetTouchMajor(0) / 2);
+ EXPECT_FLOAT_EQ(p, event.GetPressure(0));
x = 17.8f;
y = 12.1f;
raw_x = x + kRawOffsetX;
raw_y = y + kRawOffsetY;
+ r = 21.2f;
+ p = 18.4f;
TouchEvent press1 =
- TouchWithPosition(ET_TOUCH_PRESSED, ids[1], x, y, raw_x, raw_y);
+ TouchWithPosition(ET_TOUCH_PRESSED, ids[1], x, y, raw_x, raw_y, r, p);
event.OnTouch(press1);
EXPECT_EQ(2U, event.GetPointerCount());
@@ -200,111 +185,52 @@
EXPECT_FLOAT_EQ(y, event.GetY(1));
EXPECT_FLOAT_EQ(raw_x, event.GetRawX(1));
EXPECT_FLOAT_EQ(raw_y, event.GetRawY(1));
+ EXPECT_FLOAT_EQ(r, event.GetTouchMajor(1) / 2);
+ EXPECT_FLOAT_EQ(p, event.GetPressure(1));
// Test cloning of pointer location information.
scoped_ptr<MotionEvent> clone = event.Clone();
- {
- const MotionEventAura* raw_clone_aura =
- static_cast<MotionEventAura*>(clone.get());
- EXPECT_EQ(2U, raw_clone_aura->GetPointerCount());
- EXPECT_FLOAT_EQ(x, raw_clone_aura->GetX(1));
- EXPECT_FLOAT_EQ(y, raw_clone_aura->GetY(1));
- EXPECT_FLOAT_EQ(raw_x, raw_clone_aura->GetRawX(1));
- EXPECT_FLOAT_EQ(raw_y, raw_clone_aura->GetRawY(1));
- }
+ EXPECT_EQ(2U, clone->GetPointerCount());
+ EXPECT_FLOAT_EQ(x, clone->GetX(1));
+ EXPECT_FLOAT_EQ(y, clone->GetY(1));
+ EXPECT_FLOAT_EQ(raw_x, event.GetRawX(1));
+ EXPECT_FLOAT_EQ(raw_y, event.GetRawY(1));
+ EXPECT_FLOAT_EQ(r, clone->GetTouchMajor(1) / 2);
+ EXPECT_FLOAT_EQ(p, clone->GetPressure(1));
x = 27.9f;
y = 22.3f;
raw_x = x + kRawOffsetX;
raw_y = y + kRawOffsetY;
+ r = 7.6f;
+ p = 82.1f;
TouchEvent move1 =
- TouchWithPosition(ET_TOUCH_MOVED, ids[1], x, y, raw_x, raw_y);
+ TouchWithPosition(ET_TOUCH_MOVED, ids[1], x, y, raw_x, raw_y, r, p);
event.OnTouch(move1);
EXPECT_FLOAT_EQ(x, event.GetX(1));
EXPECT_FLOAT_EQ(y, event.GetY(1));
EXPECT_FLOAT_EQ(raw_x, event.GetRawX(1));
EXPECT_FLOAT_EQ(raw_y, event.GetRawY(1));
+ EXPECT_FLOAT_EQ(r, event.GetTouchMajor(1) / 2);
+ EXPECT_FLOAT_EQ(p, event.GetPressure(1));
x = 34.6f;
y = 23.8f;
raw_x = x + kRawOffsetX;
raw_y = y + kRawOffsetY;
+ r = 12.9f;
+ p = 14.2f;
TouchEvent move0 =
- TouchWithPosition(ET_TOUCH_MOVED, ids[0], x, y, raw_x, raw_y);
+ TouchWithPosition(ET_TOUCH_MOVED, ids[0], x, y, raw_x, raw_y, r, p);
event.OnTouch(move0);
EXPECT_FLOAT_EQ(x, event.GetX(0));
EXPECT_FLOAT_EQ(y, event.GetY(0));
EXPECT_FLOAT_EQ(raw_x, event.GetRawX(0));
EXPECT_FLOAT_EQ(raw_y, event.GetRawY(0));
-}
-
-TEST(MotionEventAuraTest, TapParams) {
- // Test that touch params are stored correctly.
- MotionEventAura event;
-
- int ids[] = {15, 13};
-
- float radius_x;
- float radius_y;
- float rotation_angle;
- float pressure;
-
- radius_x = 123.45f;
- radius_y = 67.89f;
- rotation_angle = 23.f;
- pressure = 0.123f;
- TouchEvent press0 = TouchWithTapParams(
- ET_TOUCH_PRESSED, ids[0], radius_x, radius_y, rotation_angle, pressure);
- event.OnTouch(press0);
-
- EXPECT_EQ(1U, event.GetPointerCount());
- EXPECT_FLOAT_EQ(radius_x, event.GetTouchMajor(0) / 2);
- EXPECT_FLOAT_EQ(radius_y, event.GetTouchMinor(0) / 2);
- EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(0) * 180 / M_PI + 90);
- EXPECT_FLOAT_EQ(pressure, event.GetPressure(0));
-
- radius_x = 67.89f;
- radius_y = 123.45f;
- rotation_angle = 46.f;
- pressure = 0.456f;
- TouchEvent press1 = TouchWithTapParams(
- ET_TOUCH_PRESSED, ids[1], radius_x, radius_y, rotation_angle, pressure);
- event.OnTouch(press1);
-
- EXPECT_EQ(2U, event.GetPointerCount());
- EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2);
- EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2);
- EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI);
- EXPECT_FLOAT_EQ(pressure, event.GetPressure(1));
-
- // Test cloning of tap params
- scoped_ptr<MotionEvent> clone = event.Clone();
- {
- const MotionEventAura* raw_clone_aura =
- static_cast<MotionEventAura*>(clone.get());
- EXPECT_EQ(2U, raw_clone_aura->GetPointerCount());
- EXPECT_FLOAT_EQ(radius_y, raw_clone_aura->GetTouchMajor(1) / 2);
- EXPECT_FLOAT_EQ(radius_x, raw_clone_aura->GetTouchMinor(1) / 2);
- EXPECT_FLOAT_EQ(
- rotation_angle, raw_clone_aura->GetOrientation(1) * 180 / M_PI);
- EXPECT_FLOAT_EQ(pressure, raw_clone_aura->GetPressure(1));
- }
-
- radius_x = 76.98f;
- radius_y = 321.54f;
- rotation_angle = 64.f;
- pressure = 0.654f;
- TouchEvent move1 = TouchWithTapParams(
- ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure);
- event.OnTouch(move1);
-
- EXPECT_EQ(2U, event.GetPointerCount());
- EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2);
- EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2);
- EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI);
- EXPECT_FLOAT_EQ(pressure, event.GetPressure(1));
+ EXPECT_FLOAT_EQ(r, event.GetTouchMajor(0) / 2);
+ EXPECT_FLOAT_EQ(p, event.GetPressure(0));
}
TEST(MotionEventAuraTest, Timestamps) {
« no previous file with comments | « ui/events/gestures/motion_event_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698