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

Unified Diff: chrome/test/ui/ppapi_uitest.cc

Issue 8539019: Test NaCl version of ppapi_tests via ui_tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/ui/ppapi_uitest.cc
===================================================================
--- chrome/test/ui/ppapi_uitest.cc (revision 109675)
+++ chrome/test/ui/ppapi_uitest.cc (working copy)
@@ -6,7 +6,9 @@
#include "base/path_service.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
+#include "content/browser/plugin_service.h"
#include "content/public/common/content_switches.h"
+#include "content/common/pepper_plugin_registry.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/ui_test.h"
@@ -19,32 +21,20 @@
// Platform-specific filename relative to the chrome executable.
#if defined(OS_WIN)
const wchar_t library_name[] = L"ppapi_tests.dll";
+const wchar_t nacl_library_name[] = L"ppGoogleNaClPluginChrome.dll";
#elif defined(OS_MACOSX)
const char library_name[] = "ppapi_tests.plugin";
+const char nacl_library_name[] = "ppGoogleNaClPluginChrome.plugin";
#elif defined(OS_POSIX)
const char library_name[] = "libppapi_tests.so";
+const char nacl_library_name[] = "libppGoogleNaClPluginChrome.so";
Paweł Hajdan Jr. 2011/11/14 12:31:06 Isn't this duplicating kInternalNaClPluginFileName
noelallen1 2011/11/14 22:28:17 Done.
#endif
} // namespace
-// In-process plugin test runner. See OutOfProcessPPAPITest below for the
-// out-of-process version.
-class PPAPITest : public UITest {
+class PPAPITestBase : public UITest {
public:
- PPAPITest() {
- // 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;
- PathService::Get(base::DIR_EXE, &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"));
- launch_arguments_.AppendSwitchNative(switches::kRegisterPepperPlugins,
- pepper_plugin);
-
+ PPAPITestBase() {
// The test sends us the result via a cookie.
launch_arguments_.AppendSwitch(switches::kEnableFileCookies);
@@ -56,6 +46,8 @@
launch_arguments_.AppendSwitch(switches::kDisableSmoothScrolling);
}
+ virtual void AppendQuery(std::string* query, const std::string& test_case)=0;
+
void RunTest(const std::string& test_case) {
FilePath test_path;
PathService::Get(base::DIR_SOURCE_ROOT, &test_path);
@@ -67,20 +59,21 @@
EXPECT_TRUE(file_util::PathExists(test_path));
GURL::Replacements replacements;
- std::string query("testcase=");
- query += test_case;
+ std::string query;
+ AppendQuery(&query, test_case);
replacements.SetQuery(query.c_str(), url_parse::Component(0, query.size()));
GURL test_url = net::FilePathToFileURL(test_path);
RunTestURL(test_url.ReplaceComponents(replacements));
}
void RunTestViaHTTP(const std::string& test_case) {
+ FilePath fp = CommandLine::ForCurrentProcess()->GetProgram();
net::TestServer test_server(
- net::TestServer::TYPE_HTTP,
- FilePath(FILE_PATH_LITERAL("ppapi/tests")));
+ net::TestServer::TYPE_HTTP, fp.DirName());
ASSERT_TRUE(test_server.Start());
- RunTestURL(
- test_server.GetURL("files/test_case.html?testcase=" + test_case));
+ std::string query("files/test_case.html?");
+ AppendQuery(&query, test_case);
+ RunTestURL(test_server.GetURL(query));
}
private:
@@ -119,6 +112,32 @@
}
};
+// In-process plugin test runner. See OutOfProcessPPAPITest below for the
+// out-of-process version.
+class PPAPITest : public PPAPITestBase {
+ public:
+ PPAPITest() {
+ // 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;
+ PathService::Get(base::DIR_EXE, &plugin_dir);
Paweł Hajdan Jr. 2011/11/14 12:31:06 nit: Check the return value (EXPECT_TRUE).
noelallen1 2011/11/14 22:28:17 Done.
+
+ 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"));
+ launch_arguments_.AppendSwitchNative(switches::kRegisterPepperPlugins,
+ pepper_plugin);
+ }
+
+ void AppendQuery(std::string* query, const std::string& test_case) {
Paweł Hajdan Jr. 2011/11/14 12:31:06 I don't like this design. How about BuildQuery(con
noelallen1 2011/11/14 22:28:17 Done.
+ (*query) += "testcase=";
+ (*query) += test_case;
+ }
+
+};
+
// Variant of PPAPITest that runs plugins out-of-process to test proxy
// codepaths.
class OutOfProcessPPAPITest : public PPAPITest {
@@ -129,6 +148,28 @@
}
};
+// NaCl plugin test runner.
+class PPAPINaClTest : public PPAPITestBase {
+ public:
+ PPAPINaClTest() {
+ FilePath plugin_dir;
+ PathService::Get(base::DIR_EXE, &plugin_dir);
Paweł Hajdan Jr. 2011/11/14 12:31:06 nit: Please check return value here too.
noelallen1 2011/11/14 22:28:17 Done.
+
+ FilePath plugin_lib = plugin_dir.Append(nacl_library_name);
+ EXPECT_TRUE(file_util::PathExists(plugin_lib));
+
+ // Enable running NaCl outside of the store.
+ launch_arguments_.AppendSwitch(switches::kEnableNaCl);
+ }
+
+ // Append the correct mode and testcase string
+ void AppendQuery(std::string* query, const std::string& test_case) {
+ (*query) += "mode=nacl&testcase=";
+ (*query) += test_case;
+ }
+};
+
+
// Use these macros to run the tests for a specific interface.
// Most interfaces should be tested with both macros.
#define TEST_PPAPI_IN_PROCESS(test_name) \
@@ -151,6 +192,12 @@
}
+// NaCl based PPAPI tests
+#define TEST_PPAPI_NACL_VIA_HTTP(test_name) \
+ TEST_F(PPAPINaClTest, test_name) { \
+ RunTestViaHTTP(#test_name); \
+}
+
//
// Interface tests.
//
@@ -163,6 +210,7 @@
TEST_PPAPI_IN_PROCESS(CursorControl)
TEST_PPAPI_OUT_OF_PROCESS(CursorControl)
+TEST_PPAPI_NACL_VIA_HTTP(CursorControl)
TEST_PPAPI_IN_PROCESS(Instance)
// http://crbug.com/91729
@@ -170,15 +218,16 @@
TEST_PPAPI_IN_PROCESS(Graphics2D)
TEST_PPAPI_OUT_OF_PROCESS(Graphics2D)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D)
TEST_PPAPI_IN_PROCESS(ImageData)
TEST_PPAPI_OUT_OF_PROCESS(ImageData)
+TEST_PPAPI_NACL_VIA_HTTP(ImageData)
TEST_PPAPI_IN_PROCESS(Buffer)
TEST_PPAPI_OUT_OF_PROCESS(Buffer)
TEST_PPAPI_IN_PROCESS_VIA_HTTP(URLLoader)
-
// http://crbug.com/89961
#if defined(OS_WIN)
// It often takes too long time (and fails otherwise) on Windows.
@@ -186,19 +235,22 @@
#else
#define MAYBE_URLLoader FAILS_URLLoader
#endif
-
TEST_F(OutOfProcessPPAPITest, MAYBE_URLLoader) {
RunTestViaHTTP("URLLoader");
}
+
+
TEST_PPAPI_IN_PROCESS(PaintAggregator)
TEST_PPAPI_OUT_OF_PROCESS(PaintAggregator)
+TEST_PPAPI_NACL_VIA_HTTP(PaintAggregator)
TEST_PPAPI_IN_PROCESS(Scrollbar)
// http://crbug.com/89961
TEST_F(OutOfProcessPPAPITest, FAILS_Scrollbar) {
RunTest("Scrollbar");
}
+TEST_PPAPI_NACL_VIA_HTTP(Scrollbar)
TEST_PPAPI_IN_PROCESS(URLUtil)
TEST_PPAPI_OUT_OF_PROCESS(URLUtil)
@@ -214,6 +266,7 @@
TEST_F(OutOfProcessPPAPITest, FAILS_Var) {
RunTest("Var");
}
+TEST_PPAPI_NACL_VIA_HTTP(Var)
TEST_PPAPI_IN_PROCESS(VarDeprecated)
// Disabled because it times out: http://crbug.com/89961
@@ -231,6 +284,7 @@
TEST_PPAPI_IN_PROCESS(Memory)
TEST_PPAPI_OUT_OF_PROCESS(Memory)
+TEST_PPAPI_NACL_VIA_HTTP(Memory)
TEST_PPAPI_IN_PROCESS(VideoDecoder)
TEST_PPAPI_OUT_OF_PROCESS(VideoDecoder)
@@ -243,13 +297,18 @@
TEST_F(OutOfProcessPPAPITest, DISABLED_FileIO) {
RunTestViaHTTP("FileIO");
}
+TEST_PPAPI_NACL_VIA_HTTP(DISABLED_FileIO)
+
TEST_PPAPI_IN_PROCESS_VIA_HTTP(FileRef)
// Disabled because it times out: http://crbug.com/89961
//TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(FileRef)
+TEST_PPAPI_NACL_VIA_HTTP(FileRef)
+
TEST_PPAPI_IN_PROCESS_VIA_HTTP(FileSystem)
TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(FileSystem)
+TEST_PPAPI_NACL_VIA_HTTP(FileSystem)
// http://crbug.com/96767
#if !defined(OS_MACOSX)
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | net/test/test_server.cc » ('j') | net/test/test_server.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698