Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/tests/test_input_event.h" | 5 #include "ppapi/tests/test_input_event.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_testing_dev.h" | 7 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/ppb_input_event.h" | 9 #include "ppapi/c/ppb_input_event.h" |
| 10 #include "ppapi/cpp/input_event.h" | 10 #include "ppapi/cpp/input_event.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 pp::Point GetCenter(const pp::Rect& rect) { | 24 pp::Point GetCenter(const pp::Rect& rect) { |
| 25 return pp::Point( | 25 return pp::Point( |
| 26 rect.x() + rect.width() / 2, | 26 rect.x() + rect.width() / 2, |
| 27 rect.y() + rect.height() / 2); | 27 rect.y() + rect.height() / 2); |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 void TestInputEvent::RunTests(const std::string& filter) { | 32 void TestInputEvent::RunTests(const std::string& filter) { |
| 33 RUN_TEST(Events, filter); | 33 RUN_TEST(Events, filter); |
| 34 | |
| 35 #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.
| |
| 36 if (test_filter == #name) { \ | |
| 37 set_callback_type(PP_OPTIONAL); \ | |
| 38 instance_->LogTest(#name, CheckResourcesAndVars(Test##name())); \ | |
| 39 } | |
| 40 | |
| 41 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_1, filter); | |
| 42 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_2, filter); | |
| 43 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_3, filter); | |
| 44 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_4, filter); | |
| 45 | |
| 46 #undef RUN_TEST_EXACT_MATCH | |
| 34 } | 47 } |
| 35 | 48 |
| 36 TestInputEvent::TestInputEvent(TestingInstance* instance) | 49 TestInputEvent::TestInputEvent(TestingInstance* instance) |
| 37 : TestCase(instance), | 50 : TestCase(instance), |
| 38 input_event_interface_(NULL), | 51 input_event_interface_(NULL), |
| 39 mouse_input_event_interface_(NULL), | 52 mouse_input_event_interface_(NULL), |
| 40 wheel_input_event_interface_(NULL), | 53 wheel_input_event_interface_(NULL), |
| 41 keyboard_input_event_interface_(NULL), | 54 keyboard_input_event_interface_(NULL), |
| 42 view_rect_(), | 55 view_rect_(), |
| 43 expected_input_event_(0), | 56 expected_input_event_(0), |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 SimulateInputEvent(CreateWheelEvent())); | 291 SimulateInputEvent(CreateWheelEvent())); |
| 279 ASSERT_FALSE( | 292 ASSERT_FALSE( |
| 280 SimulateInputEvent(CreateKeyEvent(PP_INPUTEVENT_TYPE_KEYDOWN, | 293 SimulateInputEvent(CreateKeyEvent(PP_INPUTEVENT_TYPE_KEYDOWN, |
| 281 kSpaceChar))); | 294 kSpaceChar))); |
| 282 ASSERT_FALSE( | 295 ASSERT_FALSE( |
| 283 SimulateInputEvent(CreateCharEvent(kSpaceString))); | 296 SimulateInputEvent(CreateCharEvent(kSpaceString))); |
| 284 | 297 |
| 285 PASS(); | 298 PASS(); |
| 286 } | 299 } |
| 287 | 300 |
| 301 std::string TestInputEvent::TestAcceptTouchEvent_1() { | |
| 302 // The browser normally sends touch-events to the renderer only if the page | |
| 303 // has touch-event handlers. Since test-case.html does not have any | |
| 304 // touch-event handler, it would normally not receive any touch events from | |
| 305 // the browser. However, if a plugin in the page does accept touch events, | |
| 306 // then the browser should start sending touch-events to the page. In this | |
| 307 // test, the plugin simply registers for touch-events. The real test is to | |
| 308 // verify that the browser knows to send touch-events to the renderer. | |
| 309 // If the plugin is removed from the page, then there are no more touch-event | |
| 310 // handlers in the page, and browser stops sending touch-events. So to make | |
| 311 // it possible to test this properly, the plugin is not removed from the page | |
| 312 // at the end of the test. | |
| 313 instance_->set_remove_plugin(false); | |
| 314 input_event_interface_->RequestInputEvents(instance_->pp_instance(), | |
| 315 PP_INPUTEVENT_CLASS_MOUSE | | |
| 316 PP_INPUTEVENT_CLASS_WHEEL | | |
| 317 PP_INPUTEVENT_CLASS_KEYBOARD | | |
| 318 PP_INPUTEVENT_CLASS_TOUCH); | |
| 319 PASS(); | |
| 320 } | |
| 321 | |
| 322 std::string TestInputEvent::TestAcceptTouchEvent_2() { | |
| 323 // See comment in TestAcceptTouchEvent_1. | |
| 324 instance_->set_remove_plugin(false); | |
| 325 input_event_interface_->RequestInputEvents(instance_->pp_instance(), | |
| 326 PP_INPUTEVENT_CLASS_MOUSE | | |
| 327 PP_INPUTEVENT_CLASS_WHEEL | | |
| 328 PP_INPUTEVENT_CLASS_KEYBOARD | | |
| 329 PP_INPUTEVENT_CLASS_TOUCH); | |
| 330 input_event_interface_->ClearInputEventRequest(instance_->pp_instance(), | |
| 331 PP_INPUTEVENT_CLASS_TOUCH); | |
| 332 PASS(); | |
| 333 } | |
| 334 | |
| 335 std::string TestInputEvent::TestAcceptTouchEvent_3() { | |
| 336 // See comment in TestAcceptTouchEvent_1. | |
| 337 instance_->set_remove_plugin(false); | |
| 338 input_event_interface_->RequestInputEvents(instance_->pp_instance(), | |
| 339 PP_INPUTEVENT_CLASS_MOUSE | | |
| 340 PP_INPUTEVENT_CLASS_WHEEL | | |
| 341 PP_INPUTEVENT_CLASS_KEYBOARD); | |
| 342 input_event_interface_->RequestFilteringInputEvents(instance_->pp_instance(), | |
| 343 PP_INPUTEVENT_CLASS_TOUCH); | |
| 344 PASS(); | |
| 345 } | |
| 346 | |
| 347 std::string TestInputEvent::TestAcceptTouchEvent_4() { | |
| 348 // See comment in TestAcceptTouchEvent_1. | |
| 349 instance_->set_remove_plugin(false); | |
| 350 input_event_interface_->RequestInputEvents(instance_->pp_instance(), | |
| 351 PP_INPUTEVENT_CLASS_MOUSE | | |
| 352 PP_INPUTEVENT_CLASS_WHEEL | | |
| 353 PP_INPUTEVENT_CLASS_KEYBOARD); | |
| 354 input_event_interface_->RequestInputEvents(instance_->pp_instance(), | |
| 355 PP_INPUTEVENT_CLASS_TOUCH); | |
| 356 PASS(); | |
| 357 } | |
| 358 | |
| OLD | NEW |