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

Side by Side Diff: ppapi/tests/test_input_event.cc

Issue 8920005: Add TestingInstance::EvalScript method which posts a message that the test page can eval(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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_case.html ('k') | ppapi/tests/test_post_message.cc » ('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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 TestInputEvent::~TestInputEvent() { 47 TestInputEvent::~TestInputEvent() {
48 // Remove the special listener that only responds to a 48 // Remove the special listener that only responds to a
49 // FINISHED_WAITING_MESSAGE string. See Init for where it gets added. 49 // FINISHED_WAITING_MESSAGE string. See Init for where it gets added.
50 std::string js_code; 50 std::string js_code;
51 js_code += "var plugin = document.getElementById('plugin');" 51 js_code += "var plugin = document.getElementById('plugin');"
52 "plugin.removeEventListener('message'," 52 "plugin.removeEventListener('message',"
53 " plugin.wait_for_messages_handler);" 53 " plugin.wait_for_messages_handler);"
54 "delete plugin.wait_for_messages_handler;"; 54 "delete plugin.wait_for_messages_handler;";
55 pp::Var exception; 55 instance_->EvalScript(js_code);
56 instance_->ExecuteScript(js_code, &exception);
57 } 56 }
58 57
59 bool TestInputEvent::Init() { 58 bool TestInputEvent::Init() {
60 input_event_interface_ = static_cast<const PPB_InputEvent*>( 59 input_event_interface_ = static_cast<const PPB_InputEvent*>(
61 pp::Module::Get()->GetBrowserInterface(PPB_INPUT_EVENT_INTERFACE)); 60 pp::Module::Get()->GetBrowserInterface(PPB_INPUT_EVENT_INTERFACE));
62 mouse_input_event_interface_ = static_cast<const PPB_MouseInputEvent*>( 61 mouse_input_event_interface_ = static_cast<const PPB_MouseInputEvent*>(
63 pp::Module::Get()->GetBrowserInterface( 62 pp::Module::Get()->GetBrowserInterface(
64 PPB_MOUSE_INPUT_EVENT_INTERFACE)); 63 PPB_MOUSE_INPUT_EVENT_INTERFACE));
65 wheel_input_event_interface_ = static_cast<const PPB_WheelInputEvent*>( 64 wheel_input_event_interface_ = static_cast<const PPB_WheelInputEvent*>(
66 pp::Module::Get()->GetBrowserInterface( 65 pp::Module::Get()->GetBrowserInterface(
(...skipping 20 matching lines...) Expand all
87 js_code += "var plugin = document.getElementById('plugin');" 86 js_code += "var plugin = document.getElementById('plugin');"
88 "var wait_for_messages_handler = function(message_event) {" 87 "var wait_for_messages_handler = function(message_event) {"
89 " if (!IsTestingMessage(message_event.data) &&" 88 " if (!IsTestingMessage(message_event.data) &&"
90 " message_event.data === '" FINISHED_WAITING_MESSAGE "') {" 89 " message_event.data === '" FINISHED_WAITING_MESSAGE "') {"
91 " plugin.postMessage('" FINISHED_WAITING_MESSAGE "');" 90 " plugin.postMessage('" FINISHED_WAITING_MESSAGE "');"
92 " }" 91 " }"
93 "};" 92 "};"
94 "plugin.addEventListener('message', wait_for_messages_handler);" 93 "plugin.addEventListener('message', wait_for_messages_handler);"
95 // Stash it on the plugin so we can remove it in the destructor. 94 // Stash it on the plugin so we can remove it in the destructor.
96 "plugin.wait_for_messages_handler = wait_for_messages_handler;"; 95 "plugin.wait_for_messages_handler = wait_for_messages_handler;";
97 pp::Var exception; 96 instance_->EvalScript(js_code);
98 instance_->ExecuteScript(js_code, &exception);
99 success = success && exception.is_undefined();
100 97
101 return success; 98 return success;
102 } 99 }
103 100
104 pp::InputEvent TestInputEvent::CreateMouseEvent( 101 pp::InputEvent TestInputEvent::CreateMouseEvent(
105 PP_InputEvent_Type type, 102 PP_InputEvent_Type type,
106 PP_InputEvent_MouseButton buttons) { 103 PP_InputEvent_MouseButton buttons) {
107 return pp::MouseInputEvent( 104 return pp::MouseInputEvent(
108 instance_, 105 instance_,
109 type, 106 type,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 SimulateInputEvent(CreateWheelEvent())); 278 SimulateInputEvent(CreateWheelEvent()));
282 ASSERT_FALSE( 279 ASSERT_FALSE(
283 SimulateInputEvent(CreateKeyEvent(PP_INPUTEVENT_TYPE_KEYDOWN, 280 SimulateInputEvent(CreateKeyEvent(PP_INPUTEVENT_TYPE_KEYDOWN,
284 kSpaceChar))); 281 kSpaceChar)));
285 ASSERT_FALSE( 282 ASSERT_FALSE(
286 SimulateInputEvent(CreateCharEvent(kSpaceString))); 283 SimulateInputEvent(CreateCharEvent(kSpaceString)));
287 284
288 PASS(); 285 PASS();
289 } 286 }
290 287
OLDNEW
« no previous file with comments | « ppapi/tests/test_case.html ('k') | ppapi/tests/test_post_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698