Chromium Code Reviews| 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..19f4a332c9eb36789bd8b9ea7bd456488a28bcf9 100644 |
| --- a/ppapi/tests/test_input_event.cc |
| +++ b/ppapi/tests/test_input_event.cc |
| @@ -31,6 +31,19 @@ pp::Point GetCenter(const pp::Rect& rect) { |
| void TestInputEvent::RunTests(const std::string& filter) { |
| RUN_TEST(Events, filter); |
| + |
| +#define RUN_TEST_EXACT_MATCH(name, test_filter) \ |
|
brettw
2012/06/28 20:25:07
Can you add a comment here about what you're tryin
sadrul
2012/06/28 20:49:22
Done.
|
| + 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 +298,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(); |
| +} |
| + |