OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/ppapi/ppapi_test.h" | 5 #include "chrome/test/ppapi/ppapi_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "content/public/browser/dom_operation_notification_details.h" | 27 #include "content/public/browser/dom_operation_notification_details.h" |
28 #include "content/public/test/test_renderer_host.h" | 28 #include "content/public/test/test_renderer_host.h" |
29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "content/public/common/content_paths.h" | 32 #include "content/public/common/content_paths.h" |
33 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
34 #include "content/public/test/browser_test_utils.h" | 34 #include "content/public/test/browser_test_utils.h" |
35 #include "net/base/net_util.h" | 35 #include "net/base/net_util.h" |
36 #include "net/base/test_data_directory.h" | 36 #include "net/base/test_data_directory.h" |
37 #include "net/test/test_server.h" | |
38 #include "ppapi/shared_impl/ppapi_switches.h" | 37 #include "ppapi/shared_impl/ppapi_switches.h" |
39 #include "ui/gl/gl_switches.h" | 38 #include "ui/gl/gl_switches.h" |
40 #include "webkit/plugins/plugin_switches.h" | 39 #include "webkit/plugins/plugin_switches.h" |
41 | 40 |
42 using content::DomOperationNotificationDetails; | 41 using content::DomOperationNotificationDetails; |
43 using content::RenderViewHost; | 42 using content::RenderViewHost; |
44 | 43 |
45 namespace { | 44 namespace { |
46 | 45 |
47 // Platform-specific filename relative to the chrome executable. | 46 // Platform-specific filename relative to the chrome executable. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 void PPAPITestBase::RunTestAndReload(const std::string& test_case) { | 165 void PPAPITestBase::RunTestAndReload(const std::string& test_case) { |
167 GURL url = GetTestFileUrl(test_case); | 166 GURL url = GetTestFileUrl(test_case); |
168 RunTestURL(url); | 167 RunTestURL(url); |
169 // If that passed, we simply run the test again, which navigates again. | 168 // If that passed, we simply run the test again, which navigates again. |
170 RunTestURL(url); | 169 RunTestURL(url); |
171 } | 170 } |
172 | 171 |
173 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { | 172 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { |
174 FilePath document_root; | 173 FilePath document_root; |
175 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); | 174 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); |
176 RunHTTPTestServer(document_root, test_case, ""); | 175 RunHTTPTestServer(document_root, test_case, "", NULL); |
177 } | 176 } |
178 | 177 |
179 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { | 178 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { |
180 FilePath document_root; | 179 FilePath document_root; |
181 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); | 180 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); |
182 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 181 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
183 net::BaseTestServer::SSLOptions(), | 182 net::BaseTestServer::SSLOptions(), |
184 document_root); | 183 document_root); |
185 ASSERT_TRUE(test_server.Start()); | 184 ASSERT_TRUE(test_server.StartInBackground()); |
186 uint16_t port = test_server.host_port_pair().port(); | 185 uint16_t port = test_server.host_port_pair().port(); |
187 RunHTTPTestServer(document_root, test_case, | 186 RunHTTPTestServer(document_root, |
188 StringPrintf("ssl_server_port=%d", port)); | 187 test_case, |
| 188 StringPrintf("ssl_server_port=%d", port), |
| 189 &test_server); |
189 } | 190 } |
190 | 191 |
191 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { | 192 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { |
192 net::TestServer server(net::TestServer::TYPE_WS, | 193 net::TestServer server(net::TestServer::TYPE_WS, |
193 net::TestServer::kLocalhost, | 194 net::TestServer::kLocalhost, |
194 net::GetWebSocketTestDataDirectory()); | 195 net::GetWebSocketTestDataDirectory()); |
195 ASSERT_TRUE(server.Start()); | 196 ASSERT_TRUE(server.StartInBackground()); |
196 uint16_t port = server.host_port_pair().port(); | 197 uint16_t port = server.host_port_pair().port(); |
197 FilePath http_document_root; | 198 FilePath http_document_root; |
198 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); | 199 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); |
199 RunHTTPTestServer(http_document_root, test_case, | 200 RunHTTPTestServer(http_document_root, |
200 StringPrintf("websocket_port=%d", port)); | 201 test_case, |
| 202 StringPrintf("websocket_port=%d", port), |
| 203 &server); |
201 } | 204 } |
202 | 205 |
203 void PPAPITestBase::RunTestIfAudioOutputAvailable( | 206 void PPAPITestBase::RunTestIfAudioOutputAvailable( |
204 const std::string& test_case) { | 207 const std::string& test_case) { |
205 RunTest(test_case); | 208 RunTest(test_case); |
206 } | 209 } |
207 | 210 |
208 void PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable( | 211 void PPAPITestBase::RunTestViaHTTPIfAudioOutputAvailable( |
209 const std::string& test_case) { | 212 const std::string& test_case) { |
210 RunTestViaHTTP(test_case); | 213 RunTestViaHTTP(test_case); |
(...skipping 21 matching lines...) Expand all Loading... |
232 | 235 |
233 ui_test_utils::NavigateToURL(browser(), test_url); | 236 ui_test_utils::NavigateToURL(browser(), test_url); |
234 | 237 |
235 ASSERT_TRUE(observer.Run()) << handler.error_message(); | 238 ASSERT_TRUE(observer.Run()) << handler.error_message(); |
236 EXPECT_STREQ("PASS", handler.message().c_str()); | 239 EXPECT_STREQ("PASS", handler.message().c_str()); |
237 } | 240 } |
238 | 241 |
239 void PPAPITestBase::RunHTTPTestServer( | 242 void PPAPITestBase::RunHTTPTestServer( |
240 const FilePath& document_root, | 243 const FilePath& document_root, |
241 const std::string& test_case, | 244 const std::string& test_case, |
242 const std::string& extra_params) { | 245 const std::string& extra_params, |
| 246 net::TestServer* extra_server) { |
243 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 247 net::TestServer test_server(net::TestServer::TYPE_HTTP, |
244 net::TestServer::kLocalhost, | 248 net::TestServer::kLocalhost, |
245 document_root); | 249 document_root); |
246 ASSERT_TRUE(test_server.Start()); | 250 ASSERT_TRUE(test_server.StartInBackground()); |
| 251 if (extra_server) |
| 252 ASSERT_TRUE(extra_server->BlockUntilStarted()); |
| 253 ASSERT_TRUE(test_server.BlockUntilStarted()); |
247 std::string query = BuildQuery("files/test_case.html?", test_case); | 254 std::string query = BuildQuery("files/test_case.html?", test_case); |
248 if (!extra_params.empty()) | 255 if (!extra_params.empty()) |
249 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); | 256 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); |
250 | 257 |
251 GURL url = test_server.GetURL(query); | 258 GURL url = test_server.GetURL(query); |
252 RunTestURL(url); | 259 RunTestURL(url); |
253 } | 260 } |
254 | 261 |
255 PPAPITest::PPAPITest() { | 262 PPAPITest::PPAPITest() { |
256 } | 263 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 const std::string& base, | 338 const std::string& base, |
332 const std::string& test_case) { | 339 const std::string& test_case) { |
333 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), | 340 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), |
334 test_case.c_str()); | 341 test_case.c_str()); |
335 } | 342 } |
336 | 343 |
337 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { | 344 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { |
338 // The default content setting for the PPAPI broker is ASK. We purposefully | 345 // The default content setting for the PPAPI broker is ASK. We purposefully |
339 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. | 346 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. |
340 } | 347 } |
OLD | NEW |