Chromium Code Reviews| Index: chrome/test/ui/ppapi_uitest.cc |
| diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc |
| index cd0f28c9d905ac7069bc38c665abdd022d2fc23d..6f406c09f780e0a64d5876a14142312993099ed3 100644 |
| --- a/chrome/test/ui/ppapi_uitest.cc |
| +++ b/chrome/test/ui/ppapi_uitest.cc |
| @@ -159,40 +159,8 @@ 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]); |
| - } |
| - |
| + ASSERT_TRUE(GetHTTPDocumentRoot(&web_dir)); |
| net::TestServer test_server(net::TestServer::TYPE_HTTP, |
| net::TestServer::kLocalhost, |
| web_dir); |
| @@ -203,6 +171,18 @@ void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { |
| RunTestURL(url); |
| } |
| +void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { |
| + FilePath web_dir; |
| + ASSERT_TRUE(GetHTTPDocumentRoot(&web_dir)); |
| + net::TestServer test_server(net::BaseTestServer::HTTPSOptions(), web_dir); |
| + ASSERT_TRUE(test_server.Start()); |
| + |
| + uint16_t port = test_server.host_port_pair().port(); |
| + std::string url = StringPrintf("%s&ssl_server_port=%d", |
| + test_case.c_str(), port); |
| + RunTestViaHTTP(url); |
|
yzshen1
2012/03/21 22:37:58
nit:
It might be better to have a private method n
raymes
2012/03/21 23:33:07
Hmm, I'm not sure exactly what you mean here. Can
yzshen1
2012/03/21 23:42:12
The current code calls RunTestViaHTTP() directly,
|
| +} |
| + |
| void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { |
| FilePath websocket_root_dir; |
| ASSERT_TRUE( |
| @@ -241,6 +221,45 @@ void PPAPITestBase::RunTestURL(const GURL& test_url) { |
| EXPECT_STREQ("PASS", observer.result().c_str()); |
| } |
| +bool PPAPITestBase::GetHTTPDocumentRoot(FilePath* web_dir) { |
| + // 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) { |
| + *web_dir = web_dir->Append(FILE_PATH_LITERAL("..")); |
| + } |
| + for (; match < exe_size; ++match) { |
| + *web_dir = web_dir->Append(exe_parts[match]); |
| + } |
| + return true; |
| +} |
| + |
| PPAPITest::PPAPITest() { |
| } |
| @@ -346,6 +365,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) { \ |
| @@ -803,9 +832,7 @@ TEST_PPAPI_IN_PROCESS(NetworkMonitorPrivate_Basic) |
| TEST_PPAPI_IN_PROCESS(NetworkMonitorPrivate_2Monitors) |
| // PPB_TCPSocket_Private currently isn't supported in-process. |
| -IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, TCPSocketPrivate) { |
| - RunTestViaHTTP("TCPSocketPrivate"); |
| -} |
| +TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate); |
|
yzshen1
2012/03/21 22:37:58
Please update this accordingly once you check in t
raymes
2012/03/21 23:33:07
Done.
|
| TEST_PPAPI_IN_PROCESS(Flash_SetInstanceAlwaysOnTop) |
| TEST_PPAPI_IN_PROCESS(Flash_GetProxyForURL) |