summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhalyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-19 13:08:59 +0000
committerhalyavin@google.com <halyavin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-19 13:08:59 +0000
commit592612493c236d4c97bc5de7062b20840fd2b76d (patch)
treee897bad4e5280faa002fa2053fa643420b32e550
parente28a937b1cb87e62afefb5918512ce8b9dfc49d5 (diff)
downloadchromium_src-592612493c236d4c97bc5de7062b20840fd2b76d.zip
chromium_src-592612493c236d4c97bc5de7062b20840fd2b76d.tar.gz
chromium_src-592612493c236d4c97bc5de7062b20840fd2b76d.tar.bz2
Test for --nacl-gdb functionality.
I expanded access rights for NaCl loader (launched under nacl-gdb) process handle from QueryLimitedInformation to QueryInformation because Windows XP doesn't support QueryLimitedInformation. However, this test is switched off on Windows 32-bit due to problems with allocating 1Gb of address space. Future nacl-gdb must have special launching code to solve this problem. BUG= 117010 TEST= browser_tests.exe --gtest_filter=NaClGdbTest.* (on Windows) Review URL: http://codereview.chromium.org/9662055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127453 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc10
-rw-r--r--chrome/browser/nacl_host/test/mock_nacl_gdb.cc64
-rw-r--r--chrome/browser/nacl_host/test/mock_nacl_gdb.gyp25
-rw-r--r--chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc56
-rw-r--r--chrome/chrome_tests.gypi9
-rw-r--r--chrome/test/ui/ppapi_uitest.cc378
-rw-r--r--chrome/test/ui/ppapi_uitest.h80
-rw-r--r--ppapi/ppapi_sources.gypi2
-rw-r--r--ppapi/tests/test_empty.cc26
-rw-r--r--ppapi/tests/test_empty.h24
10 files changed, 470 insertions, 204 deletions
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 97ec93a..450e456 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -279,7 +279,13 @@ NaClProcessHost::~NaClProcessHost() {
}
#if defined(OS_WIN)
if (RunningOnWOW64()) {
- NaClBrokerService::GetInstance()->OnLoaderDied();
+ // If the nacl-gdb switch is not empty, the NaCl loader has been launched
+ // without the broker and so we shouldn't inform the broker about
+ // the loader termination.
+ if (CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kNaClGdb).empty()) {
+ NaClBrokerService::GetInstance()->OnLoaderDied();
+ }
} else {
debug_context_->SetChildProcessHost(NULL);
}
@@ -599,7 +605,7 @@ void NaClProcessHost::OnChannelConnected(int32 peer_pid) {
if (base::OpenProcessHandleWithAccess(
peer_pid,
base::kProcessAccessDuplicateHandle |
- base::kProcessAccessQueryLimitedInfomation |
+ base::kProcessAccessQueryInformation |
base::kProcessAccessWaitForTermination,
&process)) {
process_->SetHandle(process);
diff --git a/chrome/browser/nacl_host/test/mock_nacl_gdb.cc b/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
new file mode 100644
index 0000000..589ab3c
--- /dev/null
+++ b/chrome/browser/nacl_host/test/mock_nacl_gdb.cc
@@ -0,0 +1,64 @@
+// 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.
+
+#include <cstdio>
+#include <cstring>
+
+#include "base/command_line.h"
+#include "base/environment.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/process_util.h"
+
+static const char kArgs[] = "--args";
+static const char kEvalCommand[] = "--eval-command";
+static const char kNaClIrt[] = "nacl-irt ";
+static const char kPass[] = "PASS";
+
+int main(int argc, char** argv) {
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::string mock_nacl_gdb_file;
+ env->GetVar("MOCK_NACL_GDB", &mock_nacl_gdb_file);
+ file_util::WriteFile(FilePath::FromUTF8Unsafe(mock_nacl_gdb_file),
+ kPass, strlen(kPass));
+ CHECK_GE(argc, 3);
+ // First argument should be --eval-command.
+ CHECK_EQ(strcmp(argv[1], kEvalCommand), 0);
+ // Second argument should start with nacl-irt.
+ CHECK_GE(strlen(argv[2]), strlen(kNaClIrt));
+ CHECK_EQ(strncmp(argv[2], kNaClIrt, strlen(kNaClIrt)), 0);
+ char* irt_file_name = &argv[2][strlen(kNaClIrt)];
+ FILE* irt_file = fopen(irt_file_name, "r");
+ // nacl-irt parameter must be a file name.
+ PCHECK(irt_file);
+ fclose(irt_file);
+ int i = 3;
+ // Skip additional --eval-command parameters.
+ while (i < argc) {
+ if (strcmp(argv[i], kArgs) == 0) {
+ i++;
+ break;
+ }
+ if (strcmp(argv[i], kEvalCommand) == 0) {
+ i += 2;
+ // Command line shouldn't end with --eval-command switch without value.
+ CHECK_LE(i, argc);
+ continue;
+ }
+ // Unknown argument.
+ NOTREACHED() << "Invalid argument " << argv[i];
+ }
+ // --args switch must be present.
+ CHECK_LT(i, argc);
+
+ CommandLine::StringVector arguments;
+ for (; i < argc; i++) {
+ arguments.push_back(
+ CommandLine::StringType(argv[i], argv[i] + strlen(argv[i])));
+ }
+ CommandLine cmd_line(arguments);
+ // Process must be launched successfully.
+ PCHECK(base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL));
+ return 0;
+}
diff --git a/chrome/browser/nacl_host/test/mock_nacl_gdb.gyp b/chrome/browser/nacl_host/test/mock_nacl_gdb.gyp
new file mode 100644
index 0000000..a3eac35
--- /dev/null
+++ b/chrome/browser/nacl_host/test/mock_nacl_gdb.gyp
@@ -0,0 +1,25 @@
+# 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.
+{
+ 'conditions': [
+ # TODO(halyavin): Implement this test for Linux.
+ ['disable_nacl==0 and OS=="win"', {
+ 'targets': [
+ {
+ 'target_name': 'mock_nacl_gdb',
+ 'type': 'executable',
+ 'include_dirs': [
+ '../../../../',
+ ],
+ 'sources': [
+ 'mock_nacl_gdb.cc',
+ ],
+ 'dependencies': [
+ '../../../../base/base.gyp:base',
+ ],
+ },
+ ],
+ }],
+ ],
+} \ No newline at end of file
diff --git a/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc b/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc
new file mode 100644
index 0000000..fe5acee
--- /dev/null
+++ b/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc
@@ -0,0 +1,56 @@
+// 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.
+
+#include "base/command_line.h"
+#include "base/environment.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/win/windows_version.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/ui/ppapi_uitest.h"
+
+static const FilePath::CharType kMockNaClGdb[] =
+#if defined(OS_WIN)
+ FILE_PATH_LITERAL("mock_nacl_gdb.exe");
+#else
+ FILE_PATH_LITERAL("mock_nacl_gdb");
+#endif
+
+class NaClGdbTest : public PPAPINaClTest {
+ public:
+ NaClGdbTest() {
+ }
+
+ void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ PPAPINaClTest::SetUpCommandLine(command_line);
+
+ FilePath mock_nacl_gdb;
+ EXPECT_TRUE(PathService::Get(base::DIR_EXE, &mock_nacl_gdb));
+ mock_nacl_gdb = mock_nacl_gdb.Append(kMockNaClGdb);
+ command_line->AppendSwitchPath(switches::kNaClGdb, mock_nacl_gdb);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(NaClGdbTest, Empty) {
+ FilePath mock_nacl_gdb_file;
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::string content;
+ // TODO(halyavin): Make this test to work on Windows 32-bit. Currently this
+ // is not possible because NaCl doesn't work without sandbox since 1Gb of
+ // space is not reserved. We can't reserve 1Gb of space because
+ // base::LaunchProcess doesn't support creating suspended processes. We need
+ // to either add suspended process support to base::LaunchProcess or use
+ // Win API.
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_DISABLED) {
+ return;
+ }
+ EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file));
+ env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe());
+ RunTestViaHTTP("Empty");
+ env->UnSetVar("MOCK_NACL_GDB");
+ EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content));
+ EXPECT_STREQ("PASS", content.c_str());
+ EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false));
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a54cecf..3954d9e 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2955,6 +2955,15 @@
'../ppapi/ppapi_untrusted.gyp:ppapi_nacl_tests',
],
}],
+ # TODO(halyavin): Implement this test for linux.
+ ['OS=="win"', {
+ 'sources': [
+ 'browser/nacl_host/test/nacl_gdb_browsertest.cc',
+ ],
+ 'dependencies': [
+ 'browser/nacl_host/test/mock_nacl_gdb.gyp:mock_nacl_gdb',
+ ],
+ }],
],
}],
['chromeos==0', {
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc
index 2993e9d..cd0f28c9 100644
--- a/chrome/test/ui/ppapi_uitest.cc
+++ b/chrome/test/ui/ppapi_uitest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/test/ui/ppapi_uitest.h"
+
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -110,243 +112,215 @@ class TestFinishObserver : public content::NotificationObserver {
} // namespace
-class PPAPITestBase : public InProcessBrowserTest {
- public:
- PPAPITestBase() {
- EnableDOMAutomation();
- }
+PPAPITestBase::PPAPITestBase() {
+ EnableDOMAutomation();
+}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- // The test sends us the result via a cookie.
- command_line->AppendSwitch(switches::kEnableFileCookies);
+void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) {
+ // The test sends us the result via a cookie.
+ command_line->AppendSwitch(switches::kEnableFileCookies);
- // Some stuff is hung off of the testing interface which is not enabled
- // by default.
- command_line->AppendSwitch(switches::kEnablePepperTesting);
+ // Some stuff is hung off of the testing interface which is not enabled
+ // by default.
+ command_line->AppendSwitch(switches::kEnablePepperTesting);
- // Smooth scrolling confuses the scrollbar test.
- command_line->AppendSwitch(switches::kDisableSmoothScrolling);
- }
+ // Smooth scrolling confuses the scrollbar test.
+ command_line->AppendSwitch(switches::kDisableSmoothScrolling);
+}
- virtual std::string BuildQuery(const std::string& base,
- const std::string& test_case) = 0;
+GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) {
+ FilePath test_path;
+ EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path));
+ test_path = test_path.Append(FILE_PATH_LITERAL("ppapi"));
+ test_path = test_path.Append(FILE_PATH_LITERAL("tests"));
+ test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html"));
- // Returns the URL to load for file: tests.
- GURL GetTestFileUrl(const std::string& test_case) {
- FilePath test_path;
- EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path));
- test_path = test_path.Append(FILE_PATH_LITERAL("ppapi"));
- test_path = test_path.Append(FILE_PATH_LITERAL("tests"));
- test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html"));
+ // Sanity check the file name.
+ EXPECT_TRUE(file_util::PathExists(test_path));
- // Sanity check the file name.
- EXPECT_TRUE(file_util::PathExists(test_path));
+ GURL test_url = net::FilePathToFileURL(test_path);
- GURL test_url = net::FilePathToFileURL(test_path);
+ GURL::Replacements replacements;
+ std::string query = BuildQuery("", test_case);
+ replacements.SetQuery(query.c_str(), url_parse::Component(0, query.size()));
+ return test_url.ReplaceComponents(replacements);
+}
- GURL::Replacements replacements;
- std::string query = BuildQuery("", test_case);
- replacements.SetQuery(query.c_str(), url_parse::Component(0, query.size()));
- return test_url.ReplaceComponents(replacements);
- }
+void PPAPITestBase::RunTest(const std::string& test_case) {
+ GURL url = GetTestFileUrl(test_case);
+ RunTestURL(url);
+}
- void RunTest(const std::string& test_case) {
- GURL url = GetTestFileUrl(test_case);
- RunTestURL(url);
- }
+void PPAPITestBase::RunTestAndReload(const std::string& test_case) {
+ GURL url = GetTestFileUrl(test_case);
+ RunTestURL(url);
+ // If that passed, we simply run the test again, which navigates again.
+ RunTestURL(url);
+}
- // Run the test and reload. This can test for clean shutdown, including leaked
- // instance object vars.
- void RunTestAndReload(const std::string& test_case) {
- GURL url = GetTestFileUrl(test_case);
- RunTestURL(url);
- // If that passed, we simply run the test again, which navigates again.
- RunTestURL(url);
+void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) {
+ // For HTTP tests, we use the output DIR to grab the generated files such
+ // as the NEXEs.
+ FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
+ FilePath src_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
+
+ // TestServer expects a path relative to source. So we must first
+ // generate absolute paths to SRC and EXE and from there generate
+ // a relative path.
+ if (!exe_dir.IsAbsolute()) file_util::AbsolutePath(&exe_dir);
+ if (!src_dir.IsAbsolute()) file_util::AbsolutePath(&src_dir);
+ ASSERT_TRUE(exe_dir.IsAbsolute());
+ ASSERT_TRUE(src_dir.IsAbsolute());
+
+ size_t match, exe_size, src_size;
+ std::vector<FilePath::StringType> src_parts, exe_parts;
+
+ // Determine point at which src and exe diverge, and create a relative path.
+ exe_dir.GetComponents(&exe_parts);
+ src_dir.GetComponents(&src_parts);
+ exe_size = exe_parts.size();
+ src_size = src_parts.size();
+ for (match = 0; match < exe_size && match < src_size; ++match) {
+ if (exe_parts[match] != src_parts[match])
+ break;
}
-
- void RunTestViaHTTP(const std::string& test_case) {
- // For HTTP tests, we use the output DIR to grab the generated files such
- // as the NEXEs.
- FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
- FilePath src_dir;
- ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
-
- // TestServer expects a path relative to source. So we must first
- // generate absolute paths to SRC and EXE and from there generate
- // a relative path.
- if (!exe_dir.IsAbsolute()) file_util::AbsolutePath(&exe_dir);
- if (!src_dir.IsAbsolute()) file_util::AbsolutePath(&src_dir);
- ASSERT_TRUE(exe_dir.IsAbsolute());
- ASSERT_TRUE(src_dir.IsAbsolute());
-
- size_t match, exe_size, src_size;
- std::vector<FilePath::StringType> src_parts, exe_parts;
-
- // Determine point at which src and exe diverge, and create a relative path.
- exe_dir.GetComponents(&exe_parts);
- src_dir.GetComponents(&src_parts);
- exe_size = exe_parts.size();
- src_size = src_parts.size();
- for (match = 0; match < exe_size && match < src_size; ++match) {
- if (exe_parts[match] != src_parts[match])
- break;
- }
- FilePath web_dir;
- for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
- web_dir = web_dir.Append(FILE_PATH_LITERAL(".."));
- }
- for (; match < exe_size; ++match) {
- web_dir = web_dir.Append(exe_parts[match]);
- }
-
- net::TestServer test_server(net::TestServer::TYPE_HTTP,
- net::TestServer::kLocalhost,
- web_dir);
- ASSERT_TRUE(test_server.Start());
- std::string query = BuildQuery("files/test_case.html?", test_case);
-
- GURL url = test_server.GetURL(query);
- RunTestURL(url);
+ FilePath web_dir;
+ for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
+ web_dir = web_dir.Append(FILE_PATH_LITERAL(".."));
}
-
- void RunTestWithWebSocketServer(const std::string& test_case) {
- FilePath websocket_root_dir;
- ASSERT_TRUE(
- PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
-
- ui_test_utils::TestWebSocketServer server;
- int port = server.UseRandomPort();
- ASSERT_TRUE(server.Start(websocket_root_dir));
- std::string url = StringPrintf("%s&websocket_port=%d",
- test_case.c_str(), port);
- RunTestViaHTTP(url);
+ for (; match < exe_size; ++match) {
+ web_dir = web_dir.Append(exe_parts[match]);
}
- std::string StripPrefixes(const std::string& test_name) {
- const char* const prefixes[] = {
- "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" };
- for (size_t i = 0; i < sizeof(prefixes)/sizeof(prefixes[0]); ++i)
- if (test_name.find(prefixes[i]) == 0)
- return test_name.substr(strlen(prefixes[i]));
- return test_name;
- }
+ net::TestServer test_server(net::TestServer::TYPE_HTTP,
+ net::TestServer::kLocalhost,
+ web_dir);
+ ASSERT_TRUE(test_server.Start());
+ std::string query = BuildQuery("files/test_case.html?", test_case);
- protected:
- // Runs the test for a tab given the tab that's already navigated to the
- // given URL.
- void RunTestURL(const GURL& test_url) {
- // See comment above TestingInstance in ppapi/test/testing_instance.h.
- // Basically it sends messages using the DOM automation controller. The
- // value of "..." means it's still working and we should continue to wait,
- // any other value indicates completion (in this case it will start with
- // "PASS" or "FAIL"). This keeps us from timing out on waits for long tests.
- TestFinishObserver observer(
- browser()->GetSelectedWebContents()->GetRenderViewHost(), kTimeoutMs);
+ GURL url = test_server.GetURL(query);
+ RunTestURL(url);
+}
- ui_test_utils::NavigateToURL(browser(), test_url);
+void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
+ FilePath websocket_root_dir;
+ ASSERT_TRUE(
+ PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
+
+ ui_test_utils::TestWebSocketServer server;
+ int port = server.UseRandomPort();
+ ASSERT_TRUE(server.Start(websocket_root_dir));
+ std::string url = StringPrintf("%s&websocket_port=%d",
+ test_case.c_str(), port);
+ RunTestViaHTTP(url);
+}
- ASSERT_TRUE(observer.WaitForFinish()) << "Test timed out.";
+std::string PPAPITestBase::StripPrefixes(const std::string& test_name) {
+ const char* const prefixes[] = {
+ "FAILS_", "FLAKY_", "DISABLED_", "SLOW_" };
+ for (size_t i = 0; i < sizeof(prefixes)/sizeof(prefixes[0]); ++i)
+ if (test_name.find(prefixes[i]) == 0)
+ return test_name.substr(strlen(prefixes[i]));
+ return test_name;
+}
- EXPECT_STREQ("PASS", observer.result().c_str());
- }
-};
+void PPAPITestBase::RunTestURL(const GURL& test_url) {
+ // See comment above TestingInstance in ppapi/test/testing_instance.h.
+ // Basically it sends messages using the DOM automation controller. The
+ // value of "..." means it's still working and we should continue to wait,
+ // any other value indicates completion (in this case it will start with
+ // "PASS" or "FAIL"). This keeps us from timing out on waits for long tests.
+ TestFinishObserver observer(
+ browser()->GetSelectedWebContents()->GetRenderViewHost(), kTimeoutMs);
-// In-process plugin test runner. See OutOfProcessPPAPITest below for the
-// out-of-process version.
-class PPAPITest : public PPAPITestBase {
- public:
- PPAPITest() {
- }
+ ui_test_utils::NavigateToURL(browser(), test_url);
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- PPAPITestBase::SetUpCommandLine(command_line);
-
- // Append the switch to register the pepper plugin.
- // library name = <out dir>/<test_name>.<library_extension>
- // MIME type = application/x-ppapi-<test_name>
- FilePath plugin_dir;
- EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
-
- FilePath plugin_lib = plugin_dir.Append(library_name);
- EXPECT_TRUE(file_util::PathExists(plugin_lib));
- FilePath::StringType pepper_plugin = plugin_lib.value();
- pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests"));
- command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
- pepper_plugin);
- command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
- }
+ ASSERT_TRUE(observer.WaitForFinish()) << "Test timed out.";
- std::string BuildQuery(const std::string& base,
- const std::string& test_case){
- return StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str());
- }
+ EXPECT_STREQ("PASS", observer.result().c_str());
+}
-};
+PPAPITest::PPAPITest() {
+}
-// Variant of PPAPITest that runs plugins out-of-process to test proxy
-// codepaths.
-class OutOfProcessPPAPITest : public PPAPITest {
- public:
- OutOfProcessPPAPITest() {
- }
+void PPAPITest::SetUpCommandLine(CommandLine* command_line) {
+ PPAPITestBase::SetUpCommandLine(command_line);
+
+ // Append the switch to register the pepper plugin.
+ // library name = <out dir>/<test_name>.<library_extension>
+ // MIME type = application/x-ppapi-<test_name>
+ FilePath plugin_dir;
+ EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
+
+ FilePath plugin_lib = plugin_dir.Append(library_name);
+ EXPECT_TRUE(file_util::PathExists(plugin_lib));
+ FilePath::StringType pepper_plugin = plugin_lib.value();
+ pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests"));
+ command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
+ pepper_plugin);
+ command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
+}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- PPAPITest::SetUpCommandLine(command_line);
+std::string PPAPITest::BuildQuery(const std::string& base,
+ const std::string& test_case){
+ return StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str());
+}
- // Run PPAPI out-of-process to exercise proxy implementations.
- command_line->AppendSwitch(switches::kPpapiOutOfProcess);
- }
-};
+OutOfProcessPPAPITest::OutOfProcessPPAPITest() {
+}
-// NaCl plugin test runner.
-class PPAPINaClTest : public PPAPITestBase {
- public:
- PPAPINaClTest() {
- }
+void OutOfProcessPPAPITest::SetUpCommandLine(CommandLine* command_line) {
+ PPAPITest::SetUpCommandLine(command_line);
+
+ // Run PPAPI out-of-process to exercise proxy implementations.
+ command_line->AppendSwitch(switches::kPpapiOutOfProcess);
+}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- PPAPITestBase::SetUpCommandLine(command_line);
+PPAPINaClTest::PPAPINaClTest() {
+}
- FilePath plugin_lib;
- EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
- EXPECT_TRUE(file_util::PathExists(plugin_lib));
+void PPAPINaClTest::SetUpCommandLine(CommandLine* command_line) {
+ PPAPITestBase::SetUpCommandLine(command_line);
- // Enable running NaCl outside of the store.
- command_line->AppendSwitch(switches::kEnableNaCl);
- command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
- }
+ FilePath plugin_lib;
+ EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
+ EXPECT_TRUE(file_util::PathExists(plugin_lib));
- // Append the correct mode and testcase string
- std::string BuildQuery(const std::string& base,
- const std::string& test_case) {
- return StringPrintf("%smode=nacl&testcase=%s", base.c_str(),
- test_case.c_str());
- }
-};
+ // Enable running NaCl outside of the store.
+ command_line->AppendSwitch(switches::kEnableNaCl);
+ command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1");
+}
-class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
- public:
- PPAPINaClTestDisallowedSockets() {
- }
+// Append the correct mode and testcase string
+std::string PPAPINaClTest::BuildQuery(const std::string& base,
+ const std::string& test_case) {
+ return StringPrintf("%smode=nacl&testcase=%s", base.c_str(),
+ test_case.c_str());
+}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- PPAPITestBase::SetUpCommandLine(command_line);
+PPAPINaClTestDisallowedSockets::PPAPINaClTestDisallowedSockets() {
+}
- FilePath plugin_lib;
- EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
- EXPECT_TRUE(file_util::PathExists(plugin_lib));
+void PPAPINaClTestDisallowedSockets::SetUpCommandLine(
+ CommandLine* command_line) {
+ PPAPITestBase::SetUpCommandLine(command_line);
- // Enable running NaCl outside of the store.
- command_line->AppendSwitch(switches::kEnableNaCl);
- }
+ FilePath plugin_lib;
+ EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
+ EXPECT_TRUE(file_util::PathExists(plugin_lib));
- // Append the correct mode and testcase string
- std::string BuildQuery(const std::string& base,
- const std::string& test_case) {
- return StringPrintf("%smode=nacl&testcase=%s", base.c_str(),
- test_case.c_str());
- }
-};
+ // Enable running NaCl outside of the store.
+ command_line->AppendSwitch(switches::kEnableNaCl);
+}
+
+// Append the correct mode and testcase string
+std::string PPAPINaClTestDisallowedSockets::BuildQuery(
+ const std::string& base,
+ const std::string& test_case) {
+ return StringPrintf("%smode=nacl&testcase=%s", base.c_str(),
+ test_case.c_str());
+}
// This macro finesses macro expansion to do what we want.
#define STRIP_PREFIXES(test_name) StripPrefixes(#test_name)
diff --git a/chrome/test/ui/ppapi_uitest.h b/chrome/test/ui/ppapi_uitest.h
new file mode 100644
index 0000000..1f04a21
--- /dev/null
+++ b/chrome/test/ui/ppapi_uitest.h
@@ -0,0 +1,80 @@
+// 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.
+
+#ifndef CHROME_TEST_UI_PPAPI_UITEST_H_
+#define CHROME_TEST_UI_PPAPI_UITEST_H_
+#pragma once
+
+#include <string>
+
+#include "chrome/test/base/in_process_browser_test.h"
+
+class PPAPITestBase : public InProcessBrowserTest {
+ public:
+ PPAPITestBase();
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+
+ virtual std::string BuildQuery(const std::string& base,
+ const std::string& test_case) = 0;
+
+ // Returns the URL to load for file: tests.
+ GURL GetTestFileUrl(const std::string& test_case);
+ void RunTest(const std::string& test_case);
+ // Run the test and reload. This can test for clean shutdown, including leaked
+ // instance object vars.
+ void RunTestAndReload(const std::string& test_case);
+ void RunTestViaHTTP(const std::string& test_case);
+ void RunTestWithWebSocketServer(const std::string& test_case);
+ std::string StripPrefixes(const std::string& test_name);
+
+ protected:
+ // Runs the test for a tab given the tab that's already navigated to the
+ // given URL.
+ void RunTestURL(const GURL& test_url);
+};
+
+// In-process plugin test runner. See OutOfProcessPPAPITest below for the
+// out-of-process version.
+class PPAPITest : public PPAPITestBase {
+ public:
+ PPAPITest();
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+
+ virtual std::string BuildQuery(const std::string& base,
+ const std::string& test_case) OVERRIDE;
+};
+
+// Variant of PPAPITest that runs plugins out-of-process to test proxy
+// codepaths.
+class OutOfProcessPPAPITest : public PPAPITest {
+ public:
+ OutOfProcessPPAPITest();
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+};
+
+// NaCl plugin test runner.
+class PPAPINaClTest : public PPAPITestBase {
+ public:
+ PPAPINaClTest();
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+
+ virtual std::string BuildQuery(const std::string& base,
+ const std::string& test_case) OVERRIDE;
+};
+
+class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
+ public:
+ PPAPINaClTestDisallowedSockets();
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+
+ virtual std::string BuildQuery(const std::string& base,
+ const std::string& test_case) OVERRIDE;
+};
+
+#endif // CHROME_TEST_UI_PPAPI_UITEST_H_
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 2770212..f3c7b5f 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -305,6 +305,8 @@
'tests/pp_thread.h',
'tests/test_case.cc',
'tests/test_case.h',
+ 'tests/test_empty.cc',
+ 'tests/test_empty.h',
'tests/test_net_address_private_untrusted.cc',
'tests/test_net_address_private_untrusted.h',
'tests/test_tcp_server_socket_private.cc',
diff --git a/ppapi/tests/test_empty.cc b/ppapi/tests/test_empty.cc
new file mode 100644
index 0000000..9a9fe74
--- /dev/null
+++ b/ppapi/tests/test_empty.cc
@@ -0,0 +1,26 @@
+// 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.
+
+#include "ppapi/tests/test_empty.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(Empty);
+// This test checks only that the NaCl module loads successfully.
+// This is needed when the NaCl module is launched under the debugger and
+// so we want to check only the launching sequence.
+TestEmpty::TestEmpty(TestingInstance* instance)
+ : TestCase(instance) {
+}
+
+bool TestEmpty::Init() {
+ return true;
+}
+
+void TestEmpty::RunTests(const std::string& filter) {
+ RUN_TEST(NaClLoad, filter);
+}
+
+std::string TestEmpty::TestNaClLoad() {
+ PASS();
+}
diff --git a/ppapi/tests/test_empty.h b/ppapi/tests/test_empty.h
new file mode 100644
index 0000000..3c2ca6e
--- /dev/null
+++ b/ppapi/tests/test_empty.h
@@ -0,0 +1,24 @@
+// 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.
+
+#ifndef PPAPI_TESTS_TEST_EMPTY_H_
+#define PPAPI_TESTS_TEST_EMPTY_H_
+
+#include <string>
+
+#include "ppapi/tests/test_case.h"
+
+class TestEmpty : public TestCase {
+ public:
+ explicit TestEmpty(TestingInstance* instance);
+
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTests(const std::string& filter);
+
+ private:
+ std::string TestNaClLoad();
+};
+
+#endif // PPAPI_TESTS_TEST_EMPTY_H_