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

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

Issue 9791003: Added pepper test for SSLHandshake (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 months 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
« no previous file with comments | « chrome/test/ui/ppapi_uitest.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui/ppapi_uitest.cc
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc
index 8448aa394b7b58b0f04b6e3beac05bd85675b5bc..e41376a0d3f038508aa806c10921e2d398a05c90 100644
--- a/chrome/test/ui/ppapi_uitest.cc
+++ b/chrome/test/ui/ppapi_uitest.cc
@@ -159,61 +159,33 @@ void PPAPITestBase::RunTestAndReload(const std::string& test_case) {
}
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;
- }
- 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]);
- }
+ FilePath document_root;
+ ASSERT_TRUE(GetHTTPDocumentRoot(&document_root));
+ RunHTTPTestServer(document_root, test_case, "");
+}
- net::TestServer test_server(net::TestServer::TYPE_HTTP,
- net::TestServer::kLocalhost,
- web_dir);
+void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) {
+ FilePath document_root;
+ ASSERT_TRUE(GetHTTPDocumentRoot(&document_root));
+ net::TestServer test_server(net::BaseTestServer::HTTPSOptions(),
+ document_root);
ASSERT_TRUE(test_server.Start());
- std::string query = BuildQuery("files/test_case.html?", test_case);
-
- GURL url = test_server.GetURL(query);
- RunTestURL(url);
+ uint16_t port = test_server.host_port_pair().port();
+ RunHTTPTestServer(document_root, test_case,
+ StringPrintf("ssl_server_port=%d", port));
}
void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
FilePath websocket_root_dir;
ASSERT_TRUE(
PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
-
+ FilePath http_document_root;
+ ASSERT_TRUE(GetHTTPDocumentRoot(&http_document_root));
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);
+ int port = server.UseRandomPort();
+ RunHTTPTestServer(http_document_root, test_case,
+ StringPrintf("websocket_port=%d", port));
}
std::string PPAPITestBase::StripPrefixes(const std::string& test_name) {
@@ -241,6 +213,61 @@ void PPAPITestBase::RunTestURL(const GURL& test_url) {
EXPECT_STREQ("PASS", observer.result().c_str());
}
+void PPAPITestBase::RunHTTPTestServer(
+ const FilePath& document_root,
+ const std::string& test_case,
+ const std::string& extra_params) {
+ net::TestServer test_server(net::TestServer::TYPE_HTTP,
+ net::TestServer::kLocalhost,
+ document_root);
+ ASSERT_TRUE(test_server.Start());
+ std::string query = BuildQuery("files/test_case.html?", test_case);
+ if (extra_params.length() > 0)
yzshen1 2012/03/22 00:54:59 nit: if (!extra_params.empty())
+ query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str());
+
+ GURL url = test_server.GetURL(query);
+ RunTestURL(url);
+}
+
+bool PPAPITestBase::GetHTTPDocumentRoot(FilePath* document_root) {
+ // 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;
+ if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
+ return false;
+
+ // 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);
+ if (!exe_dir.IsAbsolute())
+ return false;
+ if (!src_dir.IsAbsolute())
+ return false;
+
+ 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;
+ }
+ for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
+ *document_root = document_root->Append(FILE_PATH_LITERAL(".."));
+ }
+ for (; match < exe_size; ++match) {
+ *document_root = document_root->Append(exe_parts[match]);
+ }
+ return true;
+}
+
PPAPITest::PPAPITest() {
}
@@ -346,6 +373,16 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
+// Similar macros that test with an SSL server.
+#define TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(test_name) \
+ IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
+ RunTestWithSSLServer(STRIP_PREFIXES(test_name)); \
+ }
+#define TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(test_name) \
+ IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, test_name) { \
+ RunTestWithSSLServer(STRIP_PREFIXES(test_name)); \
+ }
+
// Similar macros that test with WebSocket server
#define TEST_PPAPI_IN_PROCESS_WITH_WS(test_name) \
IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
@@ -375,6 +412,12 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
+// NaCl based PPAPI tests with SSL server
+#define TEST_PPAPI_NACL_VIA_HTTP_WITH_SSL_SERVER(test_name) \
+ IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \
+ RunTestWithSSLServer(STRIP_PREFIXES(test_name)); \
+ }
+
// NaCl based PPAPI tests with WebSocket server
#define TEST_PPAPI_NACL_VIA_HTTP_WITH_WS(test_name) \
IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \
@@ -459,19 +502,13 @@ TEST_PPAPI_OUT_OF_PROCESS(BrowserFont)
TEST_PPAPI_IN_PROCESS(Buffer)
TEST_PPAPI_OUT_OF_PROCESS(Buffer)
-// TODO(ygorshenin): investigate why
-// TEST_PPAPI_IN_PROCESS(TCPSocketPrivateShared) fails,
-// http://crbug.com/105860.
-TEST_PPAPI_IN_PROCESS_VIA_HTTP(TCPSocketPrivateShared)
-TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(TCPSocketPrivateShared)
-TEST_PPAPI_NACL_VIA_HTTP(TCPSocketPrivateShared)
+TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate)
+TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate)
+TEST_PPAPI_NACL_VIA_HTTP_WITH_SSL_SERVER(TCPSocketPrivate)
-// TODO(ygorshenin): investigate why
-// TEST_PPAPI_IN_PROCESS(UDPSocketPrivateShared) fails,
-// http://crbug.com/105860.
-TEST_PPAPI_IN_PROCESS_VIA_HTTP(UDPSocketPrivateShared)
-TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(UDPSocketPrivateShared)
-TEST_PPAPI_NACL_VIA_HTTP(UDPSocketPrivateShared)
+TEST_PPAPI_IN_PROCESS_VIA_HTTP(UDPSocketPrivate)
+TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(UDPSocketPrivate)
+TEST_PPAPI_NACL_VIA_HTTP(UDPSocketPrivate)
TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(TCPServerSocketPrivateDisallowed)
TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(TCPSocketPrivateDisallowed)
@@ -806,11 +843,6 @@ TEST_PPAPI_OUT_OF_PROCESS(NetworkMonitorPrivate_2Monitors)
TEST_PPAPI_IN_PROCESS(NetworkMonitorPrivate_DeleteInCallback)
TEST_PPAPI_OUT_OF_PROCESS(NetworkMonitorPrivate_DeleteInCallback)
-// PPB_TCPSocket_Private currently isn't supported in-process.
-IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, TCPSocketPrivate) {
- RunTestViaHTTP("TCPSocketPrivate");
-}
-
TEST_PPAPI_IN_PROCESS(Flash_SetInstanceAlwaysOnTop)
TEST_PPAPI_IN_PROCESS(Flash_GetProxyForURL)
TEST_PPAPI_IN_PROCESS(Flash_MessageLoop)
« no previous file with comments | « chrome/test/ui/ppapi_uitest.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698