summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorncbray@google.com <ncbray@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-12 23:47:00 +0000
committerncbray@google.com <ncbray@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-12 23:47:00 +0000
commit1f56e7f06b860ed7454cdd897122e6a5cc1f48ad (patch)
tree338eb404a9d4d5d197bb521574a355c33417a4e7 /ppapi
parent5f2391ea4843068d7d02274774c6ba1c986acd04 (diff)
downloadchromium_src-1f56e7f06b860ed7454cdd897122e6a5cc1f48ad.zip
chromium_src-1f56e7f06b860ed7454cdd897122e6a5cc1f48ad.tar.gz
chromium_src-1f56e7f06b860ed7454cdd897122e6a5cc1f48ad.tar.bz2
Port nacl_integration exit_status test to browser_tests.
This CL removes a sanity check in nacl_browsertest_util.cc because it is no longer guanteed a "test" will be a simple file name. Tests may now include a query string. BUG= http://code.google.com/p/nativeclient/issues/detail?id=2959 Review URL: https://chromiumcodereview.appspot.com/10918152 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156422 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/chrome_main.scons1
-rw-r--r--ppapi/native_client/tests/nacl_browser/exit_status/nacl.scons50
-rw-r--r--ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.cc136
-rw-r--r--ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.html64
-rw-r--r--ppapi/native_client/tools/browser_tester/browserdata/nacltest.js10
5 files changed, 9 insertions, 252 deletions
diff --git a/ppapi/native_client/chrome_main.scons b/ppapi/native_client/chrome_main.scons
index 8eec055..36b989e 100644
--- a/ppapi/native_client/chrome_main.scons
+++ b/ppapi/native_client/chrome_main.scons
@@ -41,7 +41,6 @@ ppapi_scons_files['nonvariant_test_scons_files'] = ExtendFileList(
ppapi_scons_files.get('nonvariant_test_scons_files', []), [
'tests/nacl_browser/browser_dynamic_library/nacl.scons',
'tests/nacl_browser/browser_startup_time/nacl.scons',
- 'tests/nacl_browser/exit_status/nacl.scons',
'tests/nacl_browser/inbrowser_test_runner/nacl.scons',
'tests/nacl_browser/manifest_file/nacl.scons',
'tests/nacl_browser/nameservice/nacl.scons',
diff --git a/ppapi/native_client/tests/nacl_browser/exit_status/nacl.scons b/ppapi/native_client/tests/nacl_browser/exit_status/nacl.scons
deleted file mode 100644
index 9774f4b..0000000
--- a/ppapi/native_client/tests/nacl_browser/exit_status/nacl.scons
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- python -*-
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-Import('env')
-
-# postmessage test to check that exit status is available to
-# JavaScript
-
-pm_es_obj = env.ComponentObject('pm_exit_status_test.o',
- 'pm_exit_status_test.cc')
-pm_es_nexe_name = env.ProgramNameForNmf('pm_exit_status_test')
-pm_es_nexe = env.ComponentProgram(pm_es_nexe_name,
- pm_es_obj,
- EXTRA_LIBS=['ppapi_cpp'])
-env.Publish(pm_es_nexe_name, 'run',
- ['pm_exit_status_test.html'])
-
-# chrome_browser_tests
-
-for out_name, run_name, test_args in [
- ['pm_exit0_status_browser_test.out',
- 'run_pm_exit0_status_chrome_browser_test',
- [('trigger', 'exit0'), ('expected_exit', '0')]],
- ['pm_exit7_status_browser_test.out',
- 'run_pm_exit7_status_chrome_browser_test',
- [('trigger', 'exit7'), ('expected_exit', '7')]],
- ['pm_exit254_status_browser_test.out',
- 'run_pm_exit254_status_chrome_browser_test',
- [('trigger', 'exit254'), ('expected_exit', '254')]],
- ['pm_exitneg2_status_browser_test.out',
- 'run_pm_exitneg2_status_chrome_browser_test',
- [('trigger', 'exitneg2'), ('expected_exit', '254')]],
- ]:
-
- node = env.PPAPIBrowserTester(
- out_name,
- url='pm_exit_status_test.html',
- nmf_names=['pm_exit_status_test'],
- files=env.ExtractPublishedFiles(pm_es_nexe_name),
- args=['--debug'],
- test_args=test_args,
- osenv=['NACLVERBOSITY=0:pp_weak_ref=0:weak_ref=0']
- )
-
- env.AddNodeToTestSuite(node,
- ['chrome_browser_tests', 'exit_status_tests'],
- run_name,
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.cc b/ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.cc
deleted file mode 100644
index 5965ea0..0000000
--- a/ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * Post-message based test for testing crash detection.
- */
-#include <string>
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <sys/fcntl.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sys/nacl_syscalls.h>
-
-#include "native_client/src/shared/srpc/nacl_srpc.h"
-#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/module.h"
-#include "ppapi/cpp/var.h"
-
-void Initialize(const pp::Var& message_data, std::string* out) {
- *out = "hello world";
-}
-
-void RunExit0(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(0);
-}
-
-void RunExit7(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(7);
-}
-
-void RunExit254(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(254);
-}
-
-void RunExitNeg2(const pp::Var& message_data, std::string* out) {
- *out = "good bye cruel world";
- // the out string should not actually get sent back in reply, since
- // we exit immediately.
- exit(-2);
-}
-
-struct PostMessageHandlerDesc {
- char const *request;
- void (*handler)(const pp::Var& message_data, std::string* out);
-};
-
-// This object represents one time the page says <embed>.
-class MyInstance : public pp::Instance {
- public:
- explicit MyInstance(PP_Instance instance) : pp::Instance(instance) {}
- virtual ~MyInstance() {}
- virtual void HandleMessage(const pp::Var& message_data);
-};
-
-// HandleMessage gets invoked when postMessage is called on the DOM
-// element associated with this plugin instance. In this case, if we
-// are given a string, we'll post a message back to JavaScript with a
-// reply string -- essentially treating this as a string-based RPC.
-void MyInstance::HandleMessage(const pp::Var& message_data) {
- static struct PostMessageHandlerDesc kMsgHandlers[] = {
- { "init", Initialize },
- { "exit0", RunExit0 },
- { "exit7", RunExit7 },
- { "exit254", RunExit254 },
- { "exitneg2", RunExitNeg2 },
- { reinterpret_cast<char const *>(NULL),
- reinterpret_cast<void (*)(const pp::Var&, std::string*)>(NULL) }
- };
-
- if (message_data.is_string()) {
- std::string op_name(message_data.AsString());
- size_t len;
-
- fprintf(stderr, "Searching for handler for request \"%s\".\n",
- op_name.c_str());
-
- std::string sb;
-
- for (size_t ix = 0; kMsgHandlers[ix].request != NULL; ++ix) {
- if (op_name == kMsgHandlers[ix].request) {
- fprintf(stderr, "found at index %u\n", ix);
- kMsgHandlers[ix].handler(message_data, &sb);
- break;
- }
- }
-
- len = strlen(sb.c_str());
- fprintf(stderr, "posting reply len %d\n", len);
- fprintf(stderr, "posting reply \"%s\".\n", sb.c_str());
- fflush(stderr);
-
- PostMessage(pp::Var(sb));
- fprintf(stderr, "returning\n");
- fflush(stderr);
- }
-}
-
-// This object is the global object representing this plugin library as long
-// as it is loaded.
-class MyModule : public pp::Module {
- public:
- MyModule() : pp::Module() {}
- virtual ~MyModule() {}
-
- // Override CreateInstance to create your customized Instance object.
- virtual pp::Instance* CreateInstance(PP_Instance instance) {
- return new MyInstance(instance);
- }
-};
-
-namespace pp {
-
-// Factory function for your specialization of the Module object.
-Module* CreateModule() {
- printf("hello world from CreateModule\n"); fflush(NULL);
- return new MyModule();
-}
-
-} // namespace pp
diff --git a/ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.html b/ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.html
deleted file mode 100644
index 3f3473e..0000000
--- a/ppapi/native_client/tests/nacl_browser/exit_status/pm_exit_status_test.html
+++ /dev/null
@@ -1,64 +0,0 @@
-<!--
- Copyright (c) 2011 The Chromium Authors. All rights reserved.
- Use of this source code is governed by a BSD-style license that can
- be found in the LICENSE file.
--->
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
- <head>
- <meta http-equiv="Pragma" content="no-cache" />
- <meta http-equiv="Expires" content="-1" />
- <script type="text/javascript" src="nacltest.js"></script>
- <title>Native Client Exit Status Test</title>
- </head>
-
- <body>
- <h1>Native Client Exit Status Test</h1>
- <div>
- <embed id="naclModule"
- name="naclModule"
- width=400 height=400
- src="pm_exit_status_test.nmf"
- basic_tests="2"
- stress_tests="0"
- style="background-color:gray"
- type="application/x-nacl" />
- </div>
-
- <script type="text/javascript">
- //<![CDATA[
-var tester = new Tester($('body'));
-var args = getTestArguments({'expected_exit' :
- 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead'});
-
-function setupTests(tester, plugin) {
- tester.addAsyncTest('StartTest', function(status) {
- plugin.addEventListener('message', status.wrap(function(message_event) {
- this.removeEventListener('message', arguments.callee, false);
- status.assertEqual(message_event.data,
- 'hello world');
- status.pass();
- }), true);
- plugin.postMessage('init');
- });
- tester.addAsyncTest('Exit0Test', function(status) {
- plugin.addEventListener('crash', status.wrap(function(crash_event) {
- this.removeEventListener('crash', arguments.callee, false);
- status.assertEqual($('naclModule').exitStatus,
- parseInt(args.expected_exit));
- status.pass();
- }), true);
- plugin.postMessage(args.trigger);
- });
-}
-
-var tester = new Tester();
-setupTests(tester, $('naclModule'));
-tester.waitFor($('naclModule'));
-tester.run();
-// otherwise trivially passes
- //]]>
- </script>
- </body>
-</html>
diff --git a/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js b/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js
index 7dc9083..d71ebb7 100644
--- a/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js
+++ b/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js
@@ -117,7 +117,15 @@ function RPCWrapper() {
// Performs a URL-encoded RPC call, given a function name and a dictionary
// (actually just an object - it's a JS idiom) of parameters.
function rpcCall(name, params) {
- if (this_.rpc_available) {
+ if (window.domAutomationController !== undefined) {
+ // Running as a Chrome browser_test.
+ var msg = {type: name};
+ for (var pname in params) {
+ msg[pname] = params[pname];
+ }
+ domAutomationController.setAutomationId(0);
+ domAutomationController.send(JSON.stringify(msg));
+ } else if (this_.rpc_available) {
// Construct the URL for the RPC request.
var args = [];
for (var pname in params) {