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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_input_event.h ('k') | ppapi/tests/testing_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Like RUN_TEST, but does an exact match with the filter (which means it does
36 // not run the test if filter is empty).
37 #define RUN_TEST_EXACT_MATCH(name, test_filter) \
38 if (test_filter == #name) { \
39 set_callback_type(PP_OPTIONAL); \
40 instance_->LogTest(#name, CheckResourcesAndVars(Test##name())); \
41 }
42
43 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_1, filter);
44 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_2, filter);
45 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_3, filter);
46 RUN_TEST_EXACT_MATCH(AcceptTouchEvent_4, filter);
47
48 #undef RUN_TEST_EXACT_MATCH
34 } 49 }
35 50
36 TestInputEvent::TestInputEvent(TestingInstance* instance) 51 TestInputEvent::TestInputEvent(TestingInstance* instance)
37 : TestCase(instance), 52 : TestCase(instance),
38 input_event_interface_(NULL), 53 input_event_interface_(NULL),
39 mouse_input_event_interface_(NULL), 54 mouse_input_event_interface_(NULL),
40 wheel_input_event_interface_(NULL), 55 wheel_input_event_interface_(NULL),
41 keyboard_input_event_interface_(NULL), 56 keyboard_input_event_interface_(NULL),
42 view_rect_(), 57 view_rect_(),
43 expected_input_event_(0), 58 expected_input_event_(0),
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 SimulateInputEvent(CreateWheelEvent())); 293 SimulateInputEvent(CreateWheelEvent()));
279 ASSERT_FALSE( 294 ASSERT_FALSE(
280 SimulateInputEvent(CreateKeyEvent(PP_INPUTEVENT_TYPE_KEYDOWN, 295 SimulateInputEvent(CreateKeyEvent(PP_INPUTEVENT_TYPE_KEYDOWN,
281 kSpaceChar))); 296 kSpaceChar)));
282 ASSERT_FALSE( 297 ASSERT_FALSE(
283 SimulateInputEvent(CreateCharEvent(kSpaceString))); 298 SimulateInputEvent(CreateCharEvent(kSpaceString)));
284 299
285 PASS(); 300 PASS();
286 } 301 }
287 302
303 std::string TestInputEvent::TestAcceptTouchEvent_1() {
304 // The browser normally sends touch-events to the renderer only if the page
305 // has touch-event handlers. Since test-case.html does not have any
306 // touch-event handler, it would normally not receive any touch events from
307 // the browser. However, if a plugin in the page does accept touch events,
308 // then the browser should start sending touch-events to the page. In this
309 // test, the plugin simply registers for touch-events. The real test is to
310 // verify that the browser knows to send touch-events to the renderer.
311 // If the plugin is removed from the page, then there are no more touch-event
312 // handlers in the page, and browser stops sending touch-events. So to make
313 // it possible to test this properly, the plugin is not removed from the page
314 // at the end of the test.
315 instance_->set_remove_plugin(false);
316 input_event_interface_->RequestInputEvents(instance_->pp_instance(),
317 PP_INPUTEVENT_CLASS_MOUSE |
318 PP_INPUTEVENT_CLASS_WHEEL |
319 PP_INPUTEVENT_CLASS_KEYBOARD |
320 PP_INPUTEVENT_CLASS_TOUCH);
321 PASS();
322 }
323
324 std::string TestInputEvent::TestAcceptTouchEvent_2() {
325 // See comment in TestAcceptTouchEvent_1.
326 instance_->set_remove_plugin(false);
327 input_event_interface_->RequestInputEvents(instance_->pp_instance(),
328 PP_INPUTEVENT_CLASS_MOUSE |
329 PP_INPUTEVENT_CLASS_WHEEL |
330 PP_INPUTEVENT_CLASS_KEYBOARD |
331 PP_INPUTEVENT_CLASS_TOUCH);
332 input_event_interface_->ClearInputEventRequest(instance_->pp_instance(),
333 PP_INPUTEVENT_CLASS_TOUCH);
334 PASS();
335 }
336
337 std::string TestInputEvent::TestAcceptTouchEvent_3() {
338 // See comment in TestAcceptTouchEvent_1.
339 instance_->set_remove_plugin(false);
340 input_event_interface_->RequestInputEvents(instance_->pp_instance(),
341 PP_INPUTEVENT_CLASS_MOUSE |
342 PP_INPUTEVENT_CLASS_WHEEL |
343 PP_INPUTEVENT_CLASS_KEYBOARD);
344 input_event_interface_->RequestFilteringInputEvents(instance_->pp_instance(),
345 PP_INPUTEVENT_CLASS_TOUCH);
346 PASS();
347 }
348
349 std::string TestInputEvent::TestAcceptTouchEvent_4() {
350 // See comment in TestAcceptTouchEvent_1.
351 instance_->set_remove_plugin(false);
352 input_event_interface_->RequestInputEvents(instance_->pp_instance(),
353 PP_INPUTEVENT_CLASS_MOUSE |
354 PP_INPUTEVENT_CLASS_WHEEL |
355 PP_INPUTEVENT_CLASS_KEYBOARD);
356 input_event_interface_->RequestInputEvents(instance_->pp_instance(),
357 PP_INPUTEVENT_CLASS_TOUCH);
358 PASS();
359 }
360
OLDNEW
« 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