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

Unified Diff: ppapi/tests/test_input_event.cc

Issue 10873074: ppapi: Make sure the touch-event interface is detected correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 | « ppapi/tests/test_input_event.h ('k') | ppapi/thunk/interfaces_ppb_public_stable.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_input_event.cc
diff --git a/ppapi/tests/test_input_event.cc b/ppapi/tests/test_input_event.cc
index 50bfcccbfbe7ab81fabe9c7bc8bdeb651803cbc4..345275e4fefdc52cac5a6b2403cc02dfe2d18736 100644
--- a/ppapi/tests/test_input_event.cc
+++ b/ppapi/tests/test_input_event.cc
@@ -54,6 +54,7 @@ TestInputEvent::TestInputEvent(TestingInstance* instance)
mouse_input_event_interface_(NULL),
wheel_input_event_interface_(NULL),
keyboard_input_event_interface_(NULL),
+ touch_input_event_interface_(NULL),
view_rect_(),
expected_input_event_(0),
received_expected_event_(false),
@@ -83,12 +84,16 @@ bool TestInputEvent::Init() {
keyboard_input_event_interface_ = static_cast<const PPB_KeyboardInputEvent*>(
pp::Module::Get()->GetBrowserInterface(
PPB_KEYBOARD_INPUT_EVENT_INTERFACE));
+ touch_input_event_interface_ = static_cast<const PPB_TouchInputEvent*>(
+ pp::Module::Get()->GetBrowserInterface(
+ PPB_TOUCH_INPUT_EVENT_INTERFACE));
bool success =
input_event_interface_ &&
mouse_input_event_interface_ &&
wheel_input_event_interface_ &&
keyboard_input_event_interface_ &&
+ touch_input_event_interface_ &&
CheckTestingInterface();
// Set up a listener for our message that signals that all input events have
@@ -159,6 +164,19 @@ pp::InputEvent TestInputEvent::CreateCharEvent(const std::string& text) {
pp::Var(text));
}
+pp::InputEvent TestInputEvent::CreateTouchEvent(PP_InputEvent_Type type,
+ const pp::FloatPoint& point) {
+ PP_TouchPoint touch_point;
+ touch_point.position = point;
+
+ pp::TouchInputEvent touch_event(instance_, type, 100, 0);
+ touch_event.AddTouchPoint(PP_TOUCHLIST_TYPE_TOUCHES, touch_point);
+ touch_event.AddTouchPoint(PP_TOUCHLIST_TYPE_CHANGEDTOUCHES, touch_point);
+ touch_event.AddTouchPoint(PP_TOUCHLIST_TYPE_TARGETTOUCHES, touch_point);
+
+ return touch_event;
+}
+
// Simulates the input event and calls PostMessage to let us know when
// we have received all resulting events from the browser.
bool TestInputEvent::SimulateInputEvent(
@@ -232,6 +250,44 @@ bool TestInputEvent::AreEquivalentEvents(PP_Resource received,
pp::Var(pp::PASS_REF,
keyboard_input_event_interface_->GetCharacterText(expected));
+ case PP_INPUTEVENT_TYPE_TOUCHSTART:
+ case PP_INPUTEVENT_TYPE_TOUCHMOVE:
+ case PP_INPUTEVENT_TYPE_TOUCHEND:
+ case PP_INPUTEVENT_TYPE_TOUCHCANCEL: {
+ if (!touch_input_event_interface_->IsTouchInputEvent(received) ||
+ !touch_input_event_interface_->IsTouchInputEvent(expected))
+ return false;
+
+ uint32_t touch_count = touch_input_event_interface_->GetTouchCount(
+ received, PP_TOUCHLIST_TYPE_TOUCHES);
+ if (touch_count <= 0 ||
+ touch_count != touch_input_event_interface_->GetTouchCount(expected,
+ PP_TOUCHLIST_TYPE_TOUCHES))
+ return false;
+
+ for (uint32_t i = 0; i < touch_count; ++i) {
+ PP_TouchPoint expected_point = touch_input_event_interface_->
+ GetTouchByIndex(expected, PP_TOUCHLIST_TYPE_TOUCHES, i);
+ PP_TouchPoint received_point = touch_input_event_interface_->
+ GetTouchByIndex(received, PP_TOUCHLIST_TYPE_TOUCHES, i);
+
+ if (expected_point.id != received_point.id ||
+ expected_point.radius != received_point.radius ||
+ expected_point.rotation_angle != received_point.rotation_angle ||
+ expected_point.pressure != received_point.pressure)
+ return false;
+
+ // The expected position is in the page coordinate system, and the
+ // received event is in the plugins coordinate system.
+ if (expected_point.position.x != received_point.position.x +
+ view_rect_.x() ||
+ expected_point.position.y != received_point.position.y +
+ view_rect_.y())
+ return false;
+ }
+ return true;
+ }
+
default:
break;
}
@@ -297,6 +353,14 @@ std::string TestInputEvent::TestEvents() {
ASSERT_FALSE(
SimulateInputEvent(CreateCharEvent(kSpaceString)));
+#if !defined(PPAPI_OS_WIN)
sadrul 2012/08/28 19:18:40 The test passes on debug builds, but fails on rele
+ // This fails on windows. See http://crbug.com/145236
+ // Request touch events.
+ input_event_interface_->RequestInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_TOUCH);
+ ASSERT_TRUE(SimulateInputEvent(CreateTouchEvent(PP_INPUTEVENT_TYPE_TOUCHSTART,
+ pp::FloatPoint(12, 23))));
+#endif
PASS();
}
« no previous file with comments | « ppapi/tests/test_input_event.h ('k') | ppapi/thunk/interfaces_ppb_public_stable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698