summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 00:13:49 +0000
committerncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 00:13:49 +0000
commit9333c3a8fd93fdba695ad524870b0c0db265aab8 (patch)
tree5890ebb46fd9e21a5ba354eb004821ea3f8f617b /ppapi
parent72d44e8b5095094809a5a1137038fb5dfe422134 (diff)
downloadchromium_src-9333c3a8fd93fdba695ad524870b0c0db265aab8.zip
chromium_src-9333c3a8fd93fdba695ad524870b0c0db265aab8.tar.gz
chromium_src-9333c3a8fd93fdba695ad524870b0c0db265aab8.tar.bz2
Migrate nacl_integration pm_redir_test to browser_tests.
BUG=154400 Review URL: https://codereview.chromium.org/108143007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240227 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/postmessage_redir/nacl.scons58
-rw-r--r--ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.cc195
-rw-r--r--ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.html89
4 files changed, 0 insertions, 343 deletions
diff --git a/ppapi/native_client/chrome_main.scons b/ppapi/native_client/chrome_main.scons
index 8f41ab0..eef13dc 100644
--- a/ppapi/native_client/chrome_main.scons
+++ b/ppapi/native_client/chrome_main.scons
@@ -39,7 +39,6 @@ ppapi_scons_files['nonvariant_test_scons_files'] = [
'tests/nacl_browser/browser_dynamic_library/nacl.scons',
'tests/nacl_browser/manifest_file/nacl.scons',
'tests/nacl_browser/nameservice/nacl.scons',
- 'tests/nacl_browser/postmessage_redir/nacl.scons',
'tests/ppapi_browser/bad/nacl.scons',
'tests/ppapi_browser/crash/nacl.scons',
'tests/ppapi_browser/extension_mime_handler/nacl.scons',
diff --git a/ppapi/native_client/tests/nacl_browser/postmessage_redir/nacl.scons b/ppapi/native_client/tests/nacl_browser/postmessage_redir/nacl.scons
deleted file mode 100644
index ee43d8d..0000000
--- a/ppapi/native_client/tests/nacl_browser/postmessage_redir/nacl.scons
+++ /dev/null
@@ -1,58 +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')
-
-pm_rd_obj = env.ComponentObject('pm_redir_test.o',
- 'pm_redir_test.cc')
-pm_rd_nexe_name = env.ProgramNameForNmf('pm_redir_test')
-pm_rd_nexe = env.ComponentProgram(pm_rd_nexe_name,
- pm_rd_obj,
- EXTRA_LIBS=['weak_ref',
- 'ppapi_cpp',
- 'pthread',
- 'platform',
- 'gio',
- ])
-env.Publish(pm_rd_nexe_name, 'run',
- ['pm_redir_test.html'])
-
-for (ostr, thr, delay_us, envar) in [
- ('stdout', 'fg', '0', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- ('stderr', 'fg', '0', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- ('stdout', 'bg', '0', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- ('stderr', 'bg', '0', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- # 1 millisecond
- ('stdout', 'fg', '1000', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- ('stderr', 'fg', '1000', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- ('stdout', 'bg', '1000', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- ('stderr', 'bg', '1000', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- # 1 second
- ('stdout', 'fg', '1000000', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- ('stderr', 'fg', '1000000', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- ('stdout', 'bg', '1000000', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- ('stderr', 'bg', '1000000', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- # 5 seconds -- disabled so we don't make the bots slow...
- # ('stdout', 'fg', '5000000', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- # ('stderr', 'fg', '5000000', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- # ('stdout', 'bg', '5000000', 'NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage'),
- # ('stderr', 'bg', '5000000', 'NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage'),
- ]:
-
- node = env.PPAPIBrowserTester(
- 'pm_redir_'+ ostr + '_' + thr + '_' + delay_us + '_test.out',
- url='pm_redir_test.html',
- nmf_names=['pm_redir_test'],
- files=env.ExtractPublishedFiles(pm_rd_nexe_name),
- # args=['--debug'], # debug turns on srpc-level output, also on stdout
- test_args=[('stream', ostr), ('thread', thr), ('delay_us', delay_us)],
- # nacl_exe_stdout='DEBUG_ONLY:dev://postmessage'
- osenv=[envar])
-
- env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- ('run_pm_redir_' + ostr + '_' + thr +
- '_' + delay_us + '_chrome_browser_test'),
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.cc b/ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.cc
deleted file mode 100644
index d9f1eb8..0000000
--- a/ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.cc
+++ /dev/null
@@ -1,195 +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.
- */
-
-//
-// Post-message based test for simple rpc based access to name services.
-//
-
-#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 <pthread.h>
-
-#include "native_client/src/include/nacl_base.h"
-
-#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/module.h"
-#include "ppapi/cpp/var.h"
-
-
-class MyInstance : public pp::Instance {
- public:
- explicit MyInstance(PP_Instance instance);
- virtual ~MyInstance();
- virtual void HandleMessage(const pp::Var& message_data);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MyInstance);
-};
-
-// ---------------------------------------------------------------------------
-
-MyInstance::MyInstance(PP_Instance instance)
- : pp::Instance(instance) {
-}
-
-MyInstance::~MyInstance() {
-}
-
-typedef std::map<std::string, std::string> KeyValueMap;
-
-static void ParseMapEntry(KeyValueMap* map,
- std::string const& entry) {
- std::string::size_type eq = entry.find('=');
- std::string key;
- std::string val = "";
- if (std::string::npos != eq) {
- key = entry.substr(0, eq);
- val = entry.substr(eq+1);
- } else {
- key = entry;
- }
- (*map)[key] = val;
-}
-
-//
-// parse a name1=value1,name2=value2 string into a map, using NRVO. spaces
-// are significant (!).
-//
-static KeyValueMap ParseMap(std::string const& str_map) {
- KeyValueMap nrvo;
- std::string::size_type s = 0;
- std::string::size_type comma;
-
- while (std::string::npos != (comma = str_map.find(',', s))) {
- std::string sub = str_map.substr(s, comma - s);
- s = comma + 1;
- ParseMapEntry(&nrvo, sub);
- }
- if (s != str_map.size()) {
- std::string sub = str_map.substr(s);
- ParseMapEntry(&nrvo, sub);
- }
- return nrvo;
-}
-
-
-static std::string quotes[] = {
- "In the year 1878 I took my degree of Doctor of Medicine...\n",
- "A merry little surge of electricity piped by automatic alarm...\n",
- "Squire Trelawney, Dr. Livesey, and the rest of these gentlemen...\n",
- ("It is a truth universally acknowledged,"
- " that a single man in possession...\n"),
-};
-
-void output_quote(int desc, size_t ix) {
- const char* out = quotes[ix].c_str();
- size_t len = strlen(out);
- (void) write(desc, out, len); /* assumes no partial writes! */
-}
-
-//
-// thread start function -- output asynchronously.
-//
-/* calling conv */ extern "C" {
-static void* bg_thread(void* state) {
- KeyValueMap* kvm(reinterpret_cast<KeyValueMap*>(state));
-
- std::string out = (*kvm)["stream"];
- std::string sleep_str;
- int sleep_us = 0;
-
- if ((*kvm).find("delay_us") != (*kvm).end()) {
- sleep_str = (*kvm)["delay_us"];
- if (sleep_str.length() > 0) {
- sleep_us = strtoul(sleep_str.c_str(), 0, 0);
- }
- }
- // Try to check that output works when the event handler thread has
- // already returned back to JavaScript, as opposed to output
- // occuring while the plugin is still executing the event handler
- // and blocking the JavaScript main thread.
- if (sleep_us > 0) {
- usleep(sleep_us);
- }
- if (out == "stdout") {
- output_quote(1, 2);
- } else if (out == "stderr") {
- output_quote(2, 3);
- } else {
- fprintf(stderr, "bg_thread: unrecognized output stream %s\n",
- out.c_str());
- }
- return NULL;
-}
-} // extern "C"
-
-// 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 -- essentially treating this as a string-based RPC.
-void MyInstance::HandleMessage(const pp::Var& message) {
- std::string msg = "None";
- if (message.is_string()) {
- msg = message.AsString();
- KeyValueMap test_arg(ParseMap(msg));
- if (test_arg["thread"] == "fg") {
- std::string out = test_arg["stream"];
- if (out == "stdout") {
- output_quote(1, 0);
- } else if (out == "stderr") {
- output_quote(2, 1);
- } else {
- fprintf(stderr, "HandleMessage: unrecognized output stream %s\n",
- out.c_str());
- }
- } else {
- /* spawn thread to do output */
- pthread_t tid;
-
- pthread_create(&tid,
- reinterpret_cast<const pthread_attr_t *>(NULL),
- bg_thread,
- reinterpret_cast<void *>(new KeyValueMap(test_arg)));
- pthread_detach(tid);
- }
- } else {
- fprintf(stderr, "HandleMessage: message is not a string\n");
- fflush(NULL);
- }
-}
-
-// 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);
-
- DISALLOW_COPY_AND_ASSIGN(MyModule);
-};
-
-pp::Instance *MyModule::CreateInstance(PP_Instance pp_instance) {
- return new MyInstance(pp_instance);
-}
-
-namespace pp {
-
-// Factory function for your specialization of the Module object.
-Module* CreateModule() {
- return new MyModule();
-}
-
-} // namespace pp
diff --git a/ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.html b/ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.html
deleted file mode 100644
index cbb4149..0000000
--- a/ppapi/native_client/tests/nacl_browser/postmessage_redir/pm_redir_test.html
+++ /dev/null
@@ -1,89 +0,0 @@
-<!--
- Copyright 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 I/O Redirection to Post Message Test</title>
- </head>
-
- <body>
- <h1>Native Client I/O Redirection to Post Message Test</h1>
- <div>
- <embed id="naclModule"
- name="naclModule"
- width=400 height=400
- src="pm_redir_test.nmf"
- basic_tests="2"
- stress_tests="0"
- style="background-color:gray"
- type="application/x-nacl" />
- </div>
-
- <script type="text/javascript">
- //<![CDATA[
-function setupTests(tester, plugin) {
- tester.addAsyncTest('Test_output', function(status) {
- plugin.addEventListener('message', function(message_event) {
- var prefix = 'DEBUG_POSTMESSAGE:';
- if (message_event.data.indexOf(prefix) == 0) {
- var expected_output = 'BOGUS STRING';
- if (args.stream == 'stdout' && args.thread == 'fg') {
- expected_output =
- ('In the year 1878 I took my degree of Doctor of Medicine...\n');
- } else if (args.stream == 'stderr' && args.thread == 'fg') {
- expected_output =
- ('A merry little surge of electricity piped by automatic'
- +' alarm...\n');
- } else if (args.stream == 'stdout' && args.thread == 'bg') {
- expected_output =
- ('Squire Trelawney, Dr. Livesey, and the rest of these'
- +' gentlemen...\n');
- } else if (args.stream == 'stderr' && args.thread == 'bg') {
- expected_output =
- ('It is a truth universally acknowledged, that a single man'
- +' in possession...\n');
- }
- var msg_string = message_event.data.substring(prefix.length);
- console.log('expected output ' + expected_output);
-
- console.log(msg_string);
- if (msg_string == expected_output) {
- console.log('pass!');
- this.removeEventListener('message', arguments.callee, true);
- status.pass();
- } else {
- // comment this out if test framework args=['--debug'] is
- // used, since that causes lots of SRPC and PPAPI_PROXY
- // debug output to be generated on stdout/err, and the test
- // has no debugging output
- //
- status.fail('unexpected output: ' + msg_string);
- }
- }
- }, true);
- message=('stream=' + args.stream + ',thread=' + args.thread +
- ',delay_us=' + args.delay_us);
-console.log(message);
- plugin.postMessage(message);
- });
-}
-
-var tester = new Tester();
-var args = getTestArguments({
- 'stream' : 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead',
- 'thread' : 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead',
-});
-setupTests(tester, $('naclModule'));
-tester.waitFor($('naclModule'));
-tester.run();
- //]]>
- </script>
- </body>
-</html>