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

Unified Diff: ppapi/tests/test_input_event.cc

Issue 10665007: ppapi: Add test for touch-event support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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/tests/testing_instance.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 73b76355bb31ee70dc093e6a98820484c285dd42..5803ef3928ae435cf61a943f3b43f62160761d43 100644
--- a/ppapi/tests/test_input_event.cc
+++ b/ppapi/tests/test_input_event.cc
@@ -31,6 +31,21 @@ pp::Point GetCenter(const pp::Rect& rect) {
void TestInputEvent::RunTests(const std::string& filter) {
RUN_TEST(Events, filter);
+
+// Like RUN_TEST, but does an exact match with the filter (which means it does
+// not run the test if filter is empty).
+#define RUN_TEST_EXACT_MATCH(name, test_filter) \
+ if (test_filter == #name) { \
+ set_callback_type(PP_OPTIONAL); \
+ instance_->LogTest(#name, CheckResourcesAndVars(Test##name())); \
+ }
+
+ RUN_TEST_EXACT_MATCH(AcceptTouchEvent_1, filter);
+ RUN_TEST_EXACT_MATCH(AcceptTouchEvent_2, filter);
+ RUN_TEST_EXACT_MATCH(AcceptTouchEvent_3, filter);
+ RUN_TEST_EXACT_MATCH(AcceptTouchEvent_4, filter);
+
+#undef RUN_TEST_EXACT_MATCH
}
TestInputEvent::TestInputEvent(TestingInstance* instance)
@@ -285,3 +300,61 @@ std::string TestInputEvent::TestEvents() {
PASS();
}
+std::string TestInputEvent::TestAcceptTouchEvent_1() {
+ // The browser normally sends touch-events to the renderer only if the page
+ // has touch-event handlers. Since test-case.html does not have any
+ // touch-event handler, it would normally not receive any touch events from
+ // the browser. However, if a plugin in the page does accept touch events,
+ // then the browser should start sending touch-events to the page. In this
+ // test, the plugin simply registers for touch-events. The real test is to
+ // verify that the browser knows to send touch-events to the renderer.
+ // If the plugin is removed from the page, then there are no more touch-event
+ // handlers in the page, and browser stops sending touch-events. So to make
+ // it possible to test this properly, the plugin is not removed from the page
+ // at the end of the test.
+ instance_->set_remove_plugin(false);
+ input_event_interface_->RequestInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_MOUSE |
+ PP_INPUTEVENT_CLASS_WHEEL |
+ PP_INPUTEVENT_CLASS_KEYBOARD |
+ PP_INPUTEVENT_CLASS_TOUCH);
+ PASS();
+}
+
+std::string TestInputEvent::TestAcceptTouchEvent_2() {
+ // See comment in TestAcceptTouchEvent_1.
+ instance_->set_remove_plugin(false);
+ input_event_interface_->RequestInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_MOUSE |
+ PP_INPUTEVENT_CLASS_WHEEL |
+ PP_INPUTEVENT_CLASS_KEYBOARD |
+ PP_INPUTEVENT_CLASS_TOUCH);
+ input_event_interface_->ClearInputEventRequest(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_TOUCH);
+ PASS();
+}
+
+std::string TestInputEvent::TestAcceptTouchEvent_3() {
+ // See comment in TestAcceptTouchEvent_1.
+ instance_->set_remove_plugin(false);
+ input_event_interface_->RequestInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_MOUSE |
+ PP_INPUTEVENT_CLASS_WHEEL |
+ PP_INPUTEVENT_CLASS_KEYBOARD);
+ input_event_interface_->RequestFilteringInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_TOUCH);
+ PASS();
+}
+
+std::string TestInputEvent::TestAcceptTouchEvent_4() {
+ // See comment in TestAcceptTouchEvent_1.
+ instance_->set_remove_plugin(false);
+ input_event_interface_->RequestInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_MOUSE |
+ PP_INPUTEVENT_CLASS_WHEEL |
+ PP_INPUTEVENT_CLASS_KEYBOARD);
+ input_event_interface_->RequestInputEvents(instance_->pp_instance(),
+ PP_INPUTEVENT_CLASS_TOUCH);
+ PASS();
+}
+
« no previous file with comments | « ppapi/tests/test_input_event.h ('k') | ppapi/tests/testing_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698