summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authormustaq <mustaq@chromium.org>2014-09-02 07:34:15 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-02 14:36:11 +0000
commit0ee22a13b49e9898c070d56655542f9f4843dc8f (patch)
tree2fe4e2dc754808042fe41e2bf76901fde38522c3 /ui
parentc1d45773f9a9025c13d1d013988f5ef2649bb482 (diff)
downloadchromium_src-0ee22a13b49e9898c070d56655542f9f4843dc8f.zip
chromium_src-0ee22a13b49e9898c070d56655542f9f4843dc8f.tar.gz
chromium_src-0ee22a13b49e9898c070d56655542f9f4843dc8f.tar.bz2
Make touch orientation attributes visible in Blink.
Completed the path for touch orientation attributes (i.e. radiusX, radiusY and rotationAngle of a touch ellipse) from android to Blink. BUG=381394 Review URL: https://codereview.chromium.org/494833003 Cr-Commit-Position: refs/heads/master@{#292923}
Diffstat (limited to 'ui')
-rw-r--r--ui/events/gesture_detection/motion_event.cc2
-rw-r--r--ui/events/gesture_detection/motion_event.h10
-rw-r--r--ui/events/gesture_detection/motion_event_buffer.cc30
-rw-r--r--ui/events/gesture_detection/motion_event_buffer_unittest.cc2
-rw-r--r--ui/events/gesture_detection/motion_event_generic.cc18
-rw-r--r--ui/events/gesture_detection/motion_event_generic.h4
-rw-r--r--ui/events/gestures/gesture_provider_aura_unittest.cc8
-rw-r--r--ui/events/gestures/motion_event_aura.cc53
-rw-r--r--ui/events/gestures/motion_event_aura.h6
-rw-r--r--ui/events/gestures/motion_event_aura_unittest.cc144
10 files changed, 227 insertions, 50 deletions
diff --git a/ui/events/gesture_detection/motion_event.cc b/ui/events/gesture_detection/motion_event.cc
index d3646cc..71a6912 100644
--- a/ui/events/gesture_detection/motion_event.cc
+++ b/ui/events/gesture_detection/motion_event.cc
@@ -63,6 +63,8 @@ bool operator==(const MotionEvent& lhs, const MotionEvent& rhs) {
lhs.GetRawX(i) != rhs.GetRawX(rhsi) ||
lhs.GetRawY(i) != rhs.GetRawY(rhsi) ||
lhs.GetTouchMajor(i) != rhs.GetTouchMajor(rhsi) ||
+ lhs.GetTouchMinor(i) != rhs.GetTouchMinor(rhsi) ||
+ lhs.GetOrientation(i) != rhs.GetOrientation(rhsi) ||
lhs.GetPressure(i) != rhs.GetPressure(rhsi) ||
lhs.GetToolType(i) != rhs.GetToolType(rhsi))
return false;
diff --git a/ui/events/gesture_detection/motion_event.h b/ui/events/gesture_detection/motion_event.h
index c2e0562..0a8ace7 100644
--- a/ui/events/gesture_detection/motion_event.h
+++ b/ui/events/gesture_detection/motion_event.h
@@ -58,6 +58,8 @@ class GESTURE_DETECTION_EXPORT MotionEvent {
virtual float GetRawX(size_t pointer_index) const = 0;
virtual float GetRawY(size_t pointer_index) const = 0;
virtual float GetTouchMajor(size_t pointer_index) const = 0;
+ virtual float GetTouchMinor(size_t pointer_index) const = 0;
+ virtual float GetOrientation(size_t pointer_index) const = 0;
virtual float GetPressure(size_t pointer_index) const = 0;
virtual ToolType GetToolType(size_t pointer_index) const = 0;
virtual int GetButtonState() const = 0;
@@ -76,14 +78,20 @@ class GESTURE_DETECTION_EXPORT MotionEvent {
virtual scoped_ptr<MotionEvent> Clone() const = 0;
virtual scoped_ptr<MotionEvent> Cancel() const = 0;
- // Utility accessor methods for convenience.
float GetX() const { return GetX(0); }
float GetY() const { return GetY(0); }
float GetRawX() const { return GetRawX(0); }
float GetRawY() const { return GetRawY(0); }
float GetRawOffsetX() const { return GetRawX() - GetX(); }
float GetRawOffsetY() const { return GetRawY() - GetY(); }
+
float GetTouchMajor() const { return GetTouchMajor(0); }
+ float GetTouchMinor() const { return GetTouchMinor(0); }
+
+ // Returns the orientation of the major axis clockwise from vertical, in
+ // radians. The return value lies in [-PI/2, PI/2].
+ float GetOrientation() const { return GetOrientation(0); }
+
float GetPressure() const { return GetPressure(0); }
ToolType GetToolType() const { return GetToolType(0); }
diff --git a/ui/events/gesture_detection/motion_event_buffer.cc b/ui/events/gesture_detection/motion_event_buffer.cc
index 4fbdc4e..c65df6d 100644
--- a/ui/events/gesture_detection/motion_event_buffer.cc
+++ b/ui/events/gesture_detection/motion_event_buffer.cc
@@ -97,6 +97,8 @@ PointerProperties PointerFromMotionEvent(const MotionEvent& event,
result.raw_y = event.GetRawY(pointer_index);
result.pressure = event.GetPressure(pointer_index);
result.touch_major = event.GetTouchMajor(pointer_index);
+ result.touch_minor = event.GetTouchMinor(pointer_index);
+ result.orientation = event.GetOrientation(pointer_index);
return result;
}
@@ -174,65 +176,92 @@ class CompoundMotionEvent : public ui::MotionEvent {
virtual ~CompoundMotionEvent() {}
virtual int GetId() const OVERRIDE { return latest().GetId(); }
+
virtual Action GetAction() const OVERRIDE { return latest().GetAction(); }
+
virtual int GetActionIndex() const OVERRIDE {
return latest().GetActionIndex();
}
+
virtual size_t GetPointerCount() const OVERRIDE {
return latest().GetPointerCount();
}
+
virtual int GetPointerId(size_t pointer_index) const OVERRIDE {
return latest().GetPointerId(pointer_index);
}
+
virtual float GetX(size_t pointer_index) const OVERRIDE {
return latest().GetX(pointer_index);
}
+
virtual float GetY(size_t pointer_index) const OVERRIDE {
return latest().GetY(pointer_index);
}
+
virtual float GetRawX(size_t pointer_index) const OVERRIDE {
return latest().GetRawX(pointer_index);
}
+
virtual float GetRawY(size_t pointer_index) const OVERRIDE {
return latest().GetRawY(pointer_index);
}
+
virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE {
return latest().GetTouchMajor(pointer_index);
}
+
+ virtual float GetTouchMinor(size_t pointer_index) const OVERRIDE {
+ return latest().GetTouchMinor(pointer_index);
+ }
+
+ virtual float GetOrientation(size_t pointer_index) const OVERRIDE {
+ return latest().GetOrientation(pointer_index);
+ }
+
virtual float GetPressure(size_t pointer_index) const OVERRIDE {
return latest().GetPressure(pointer_index);
}
+
virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE {
return latest().GetToolType(pointer_index);
}
+
virtual int GetButtonState() const OVERRIDE {
return latest().GetButtonState();
}
+
virtual base::TimeTicks GetEventTime() const OVERRIDE {
return latest().GetEventTime();
}
+
virtual size_t GetHistorySize() const OVERRIDE { return events_.size() - 1; }
+
virtual base::TimeTicks GetHistoricalEventTime(
size_t historical_index) const OVERRIDE {
DCHECK_LT(historical_index, GetHistorySize());
return events_[historical_index]->GetEventTime();
}
+
virtual float GetHistoricalTouchMajor(
size_t pointer_index,
size_t historical_index) const OVERRIDE {
DCHECK_LT(historical_index, GetHistorySize());
return events_[historical_index]->GetTouchMajor();
}
+
virtual float GetHistoricalX(size_t pointer_index,
size_t historical_index) const OVERRIDE {
DCHECK_LT(historical_index, GetHistorySize());
return events_[historical_index]->GetX(pointer_index);
}
+
virtual float GetHistoricalY(size_t pointer_index,
size_t historical_index) const OVERRIDE {
DCHECK_LT(historical_index, GetHistorySize());
return events_[historical_index]->GetY(pointer_index);
}
+
virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE {
MotionEventVector cloned_events;
cloned_events.reserve(events_.size());
@@ -241,6 +270,7 @@ class CompoundMotionEvent : public ui::MotionEvent {
return scoped_ptr<MotionEvent>(
new CompoundMotionEvent(cloned_events.Pass()));
}
+
virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE {
return latest().Cancel();
}
diff --git a/ui/events/gesture_detection/motion_event_buffer_unittest.cc b/ui/events/gesture_detection/motion_event_buffer_unittest.cc
index a47e720..f51897f 100644
--- a/ui/events/gesture_detection/motion_event_buffer_unittest.cc
+++ b/ui/events/gesture_detection/motion_event_buffer_unittest.cc
@@ -96,6 +96,8 @@ class MotionEventBufferTest : public testing::Test,
EXPECT_EQ(a.GetRawX(i), b.GetRawX(bi));
EXPECT_EQ(a.GetRawY(i), b.GetRawY(bi));
EXPECT_EQ(a.GetTouchMajor(i), b.GetTouchMajor(bi));
+ EXPECT_EQ(a.GetTouchMinor(i), b.GetTouchMinor(bi));
+ EXPECT_EQ(a.GetOrientation(i), b.GetOrientation(bi));
EXPECT_EQ(a.GetPressure(i), b.GetPressure(bi));
EXPECT_EQ(a.GetToolType(i), b.GetToolType(bi));
}
diff --git a/ui/events/gesture_detection/motion_event_generic.cc b/ui/events/gesture_detection/motion_event_generic.cc
index b76a37e..eff0345 100644
--- a/ui/events/gesture_detection/motion_event_generic.cc
+++ b/ui/events/gesture_detection/motion_event_generic.cc
@@ -16,7 +16,9 @@ PointerProperties::PointerProperties()
raw_x(0),
raw_y(0),
pressure(0),
- touch_major(0) {
+ touch_major(0),
+ touch_minor(0),
+ orientation(0) {
}
PointerProperties::PointerProperties(float x, float y)
@@ -27,7 +29,9 @@ PointerProperties::PointerProperties(float x, float y)
raw_x(x),
raw_y(y),
pressure(0),
- touch_major(0) {
+ touch_major(0),
+ touch_minor(0),
+ orientation(0) {
}
MotionEventGeneric::MotionEventGeneric()
@@ -103,6 +107,16 @@ float MotionEventGeneric::GetTouchMajor(size_t pointer_index) const {
return pointers_[pointer_index].touch_major;
}
+float MotionEventGeneric::GetTouchMinor(size_t pointer_index) const {
+ DCHECK_LT(pointer_index, pointers_->size());
+ return pointers_[pointer_index].touch_minor;
+}
+
+float MotionEventGeneric::GetOrientation(size_t pointer_index) const {
+ DCHECK_LT(pointer_index, pointers_->size());
+ return pointers_[pointer_index].orientation;
+}
+
float MotionEventGeneric::GetPressure(size_t pointer_index) const {
DCHECK_LT(pointer_index, pointers_->size());
return pointers_[pointer_index].pressure;
diff --git a/ui/events/gesture_detection/motion_event_generic.h b/ui/events/gesture_detection/motion_event_generic.h
index 38f4f2c..918b0eb 100644
--- a/ui/events/gesture_detection/motion_event_generic.h
+++ b/ui/events/gesture_detection/motion_event_generic.h
@@ -24,6 +24,8 @@ struct GESTURE_DETECTION_EXPORT PointerProperties {
float raw_y;
float pressure;
float touch_major;
+ float touch_minor;
+ float orientation;
};
// A generic MotionEvent implementation.
@@ -47,6 +49,8 @@ class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent {
virtual float GetRawX(size_t pointer_index) const OVERRIDE;
virtual float GetRawY(size_t pointer_index) const OVERRIDE;
virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE;
+ virtual float GetTouchMinor(size_t pointer_index) const OVERRIDE;
+ virtual float GetOrientation(size_t pointer_index) const OVERRIDE;
virtual float GetPressure(size_t pointer_index) const OVERRIDE;
virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE;
virtual int GetButtonState() const OVERRIDE;
diff --git a/ui/events/gestures/gesture_provider_aura_unittest.cc b/ui/events/gestures/gesture_provider_aura_unittest.cc
index b51ca61..e2b1523 100644
--- a/ui/events/gestures/gesture_provider_aura_unittest.cc
+++ b/ui/events/gestures/gesture_provider_aura_unittest.cc
@@ -62,10 +62,10 @@ TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) {
}
TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) {
- const float kRadiusX = 20;
- const float kRadiusY = 30;
- const float kAngle = 120;
- const float kForce = 40;
+ const float kRadiusX = 20.f;
+ const float kRadiusY = 30.f;
+ const float kAngle = 0.321f;
+ const float kForce = 40.f;
const int kTouchId0 = 5;
const int kTouchId1 = 3;
diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc
index bfe3321..a8b46b3 100644
--- a/ui/events/gestures/motion_event_aura.cc
+++ b/ui/events/gestures/motion_event_aura.cc
@@ -2,8 +2,13 @@
// 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 "ui/events/gestures/motion_event_aura.h"
+#include <cmath>
+
#include "base/logging.h"
#include "ui/events/gestures/gesture_configuration.h"
@@ -41,11 +46,33 @@ MotionEventAura::PointData MotionEventAura::GetPointDataFromTouchEvent(
point_data.pressure = touch.force();
point_data.source_device_id = touch.source_device_id();
- // TODO(tdresser): at some point we should start using both radii if they are
- // available, but for now we use the max.
- point_data.major_radius = std::max(touch.radius_x(), touch.radius_y());
- if (!point_data.major_radius)
- point_data.major_radius = GestureConfiguration::default_radius();
+ float radius_x = touch.radius_x();
+ float radius_y = touch.radius_y();
+ float rotation_angle_rad = touch.rotation_angle() * M_PI / 180.f;
+ DCHECK_GE(radius_x, 0) << "Unexpected x-radius < 0";
+ DCHECK_GE(radius_y, 0) << "Unexpected y-radius < 0";
+ DCHECK(0 <= rotation_angle_rad && rotation_angle_rad <= M_PI_2)
+ << "Unexpected touch rotation angle";
+
+ if (radius_x > radius_y) {
+ // The case radius_x == radius_y is omitted from here on purpose: for
+ // circles, we want to pass the angle (which could be any value in such
+ // cases but always seem to be set to zero) unchanged.
+ point_data.touch_major = 2.f * radius_x;
+ point_data.touch_minor = 2.f * radius_y;
+ point_data.orientation = rotation_angle_rad - M_PI_2;
+ } else {
+ point_data.touch_major = 2.f * radius_y;
+ point_data.touch_minor = 2.f * radius_x;
+ point_data.orientation = rotation_angle_rad;
+ }
+
+ if (!point_data.touch_major) {
+ point_data.touch_major = 2.f * GestureConfiguration::default_radius();
+ point_data.touch_minor = 2.f * GestureConfiguration::default_radius();
+ point_data.orientation = 0;
+ }
+
return point_data;
}
@@ -118,7 +145,17 @@ float MotionEventAura::GetRawY(size_t pointer_index) const {
float MotionEventAura::GetTouchMajor(size_t pointer_index) const {
DCHECK_LT(pointer_index, pointer_count_);
- return active_touches_[pointer_index].major_radius * 2;
+ return active_touches_[pointer_index].touch_major;
+}
+
+float MotionEventAura::GetTouchMinor(size_t pointer_index) const {
+ DCHECK_LE(pointer_index, pointer_count_);
+ return active_touches_[pointer_index].touch_minor;
+}
+
+float MotionEventAura::GetOrientation(size_t pointer_index) const {
+ DCHECK_LE(pointer_index, pointer_count_);
+ return active_touches_[pointer_index].orientation;
}
float MotionEventAura::GetPressure(size_t pointer_index) const {
@@ -172,7 +209,9 @@ MotionEventAura::PointData::PointData()
touch_id(0),
pressure(0),
source_device_id(0),
- major_radius(0) {
+ touch_major(0),
+ touch_minor(0),
+ orientation(0) {
}
int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const {
diff --git a/ui/events/gestures/motion_event_aura.h b/ui/events/gestures/motion_event_aura.h
index 6f94ddb..c89275e 100644
--- a/ui/events/gestures/motion_event_aura.h
+++ b/ui/events/gestures/motion_event_aura.h
@@ -34,6 +34,8 @@ class EVENTS_EXPORT MotionEventAura : public MotionEvent {
virtual float GetRawX(size_t pointer_index) const OVERRIDE;
virtual float GetRawY(size_t pointer_index) const OVERRIDE;
virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE;
+ virtual float GetTouchMinor(size_t pointer_index) const OVERRIDE;
+ virtual float GetOrientation(size_t pointer_index) const OVERRIDE;
virtual float GetPressure(size_t pointer_index) const OVERRIDE;
virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE;
virtual int GetButtonState() const OVERRIDE;
@@ -61,7 +63,9 @@ class EVENTS_EXPORT MotionEventAura : public MotionEvent {
int touch_id;
float pressure;
int source_device_id;
- float major_radius;
+ float touch_major;
+ float touch_minor;
+ float orientation;
};
MotionEventAura(
diff --git a/ui/events/gestures/motion_event_aura_unittest.cc b/ui/events/gestures/motion_event_aura_unittest.cc
index 3ef793e..e703612 100644
--- a/ui/events/gestures/motion_event_aura_unittest.cc
+++ b/ui/events/gestures/motion_event_aura_unittest.cc
@@ -2,6 +2,11 @@
// 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"
#include "ui/events/gestures/motion_event_aura.h"
@@ -18,22 +23,39 @@ ui::TouchEvent TouchWithPosition(ui::EventType type,
float x,
float y,
float raw_x,
- float raw_y,
- float radius,
- float pressure) {
+ float raw_y) {
ui::TouchEvent event(type,
gfx::PointF(x, y),
0,
id,
base::TimeDelta::FromMilliseconds(0),
- radius,
- radius,
0,
- pressure);
+ 0,
+ 0,
+ 0);
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;
+}
+
ui::TouchEvent TouchWithTime(ui::EventType type, int id, int ms) {
return ui::TouchEvent(
type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(ms));
@@ -85,6 +107,7 @@ TEST(MotionEventAuraTest, PointerCountAndIds) {
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));
@@ -149,17 +172,13 @@ TEST(MotionEventAuraTest, PointerLocations) {
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, r, p);
+ TouchWithPosition(ET_TOUCH_PRESSED, ids[0], x, y, raw_x, raw_y);
event.OnTouch(press0);
EXPECT_EQ(1U, event.GetPointerCount());
@@ -167,17 +186,13 @@ TEST(MotionEventAuraTest, PointerLocations) {
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, r, p);
+ TouchWithPosition(ET_TOUCH_PRESSED, ids[1], x, y, raw_x, raw_y);
event.OnTouch(press1);
EXPECT_EQ(2U, event.GetPointerCount());
@@ -185,52 +200,111 @@ TEST(MotionEventAuraTest, PointerLocations) {
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();
- 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));
+ {
+ 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));
+ }
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, r, p);
+ TouchWithPosition(ET_TOUCH_MOVED, ids[1], x, y, raw_x, raw_y);
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, r, p);
+ TouchWithPosition(ET_TOUCH_MOVED, ids[0], x, y, raw_x, raw_y);
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));
- EXPECT_FLOAT_EQ(r, event.GetTouchMajor(0) / 2);
- EXPECT_FLOAT_EQ(p, event.GetPressure(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));
}
TEST(MotionEventAuraTest, Timestamps) {