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

Side by Side Diff: chrome/test/ppapi/ppapi_test.cc

Issue 1431653003: Migrating tests to use EmbeddedTestServer (misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More test movement. Created 5 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 unified diff | Download patch
OLDNEW
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/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 15 matching lines...) Expand all
26 #include "components/infobars/core/confirm_infobar_delegate.h" 26 #include "components/infobars/core/confirm_infobar_delegate.h"
27 #include "components/infobars/core/infobar.h" 27 #include "components/infobars/core/infobar.h"
28 #include "components/nacl/common/nacl_switches.h" 28 #include "components/nacl/common/nacl_switches.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/test/ppapi_test_utils.h" 32 #include "content/public/test/ppapi_test_utils.h"
33 #include "media/base/media_switches.h" 33 #include "media/base/media_switches.h"
34 #include "net/base/filename_util.h" 34 #include "net/base/filename_util.h"
35 #include "net/base/test_data_directory.h" 35 #include "net/base/test_data_directory.h"
36 #include "net/test/embedded_test_server/embedded_test_server.h"
mmenke 2015/11/05 17:38:13 This is already included in the header for this fi
svaldez 2015/11/05 18:15:55 Done.
37 #include "net/test/spawned_test_server/spawned_test_server.h"
36 #include "ppapi/shared_impl/ppapi_switches.h" 38 #include "ppapi/shared_impl/ppapi_switches.h"
37 #include "ui/gl/gl_switches.h" 39 #include "ui/gl/gl_switches.h"
38 40
39 using content::RenderViewHost; 41 using content::RenderViewHost;
40 using content::TestMessageHandler; 42 using content::TestMessageHandler;
41 43
42 namespace { 44 namespace {
43 45
44 void AddPrivateSwitches(base::CommandLine* command_line) { 46 void AddPrivateSwitches(base::CommandLine* command_line) {
45 // For TestRequestOSFileHandle. 47 // For TestRequestOSFileHandle.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 170 }
169 171
170 void PPAPITestBase::RunTest(const std::string& test_case) { 172 void PPAPITestBase::RunTest(const std::string& test_case) {
171 GURL url = GetTestFileUrl(test_case); 173 GURL url = GetTestFileUrl(test_case);
172 RunTestURL(url); 174 RunTestURL(url);
173 } 175 }
174 176
175 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { 177 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) {
176 base::FilePath document_root; 178 base::FilePath document_root;
177 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root)); 179 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root));
178 net::SpawnedTestServer http_server(net::SpawnedTestServer::TYPE_HTTP, 180 net::EmbeddedTestServer http_server;
179 net::SpawnedTestServer::kLocalhost, 181 http_server.AddDefaultHandlers(document_root);
180 document_root);
181 ASSERT_TRUE(http_server.Start()); 182 ASSERT_TRUE(http_server.Start());
182 RunTestURL(GetTestURL(http_server, test_case, std::string())); 183 RunTestURL(GetTestURL(http_server, test_case, std::string()));
183 } 184 }
184 185
185 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { 186 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) {
186 base::FilePath http_document_root; 187 base::FilePath http_document_root;
187 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); 188 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
188 net::SpawnedTestServer http_server(net::SpawnedTestServer::TYPE_HTTP, 189 net::EmbeddedTestServer http_server;
189 net::SpawnedTestServer::kLocalhost, 190 http_server.AddDefaultHandlers(http_document_root);
190 http_document_root); 191 net::EmbeddedTestServer ssl_server(net::EmbeddedTestServer::TYPE_HTTPS);
191 net::SpawnedTestServer ssl_server(net::SpawnedTestServer::TYPE_HTTPS, 192 ssl_server.AddDefaultHandlers(http_document_root);
192 net::BaseTestServer::SSLOptions(),
193 http_document_root);
194 // Start the servers in parallel. 193 // Start the servers in parallel.
mmenke 2015/11/05 17:38:13 Comment outdated.
svaldez 2015/11/05 18:15:55 Done.
195 ASSERT_TRUE(http_server.StartInBackground()); 194 ASSERT_TRUE(http_server.Start());
196 ASSERT_TRUE(ssl_server.StartInBackground()); 195 ASSERT_TRUE(ssl_server.Start());
197 // Wait until they are both finished before continuing.
198 ASSERT_TRUE(http_server.BlockUntilStarted());
199 ASSERT_TRUE(ssl_server.BlockUntilStarted());
200 196
201 uint16_t port = ssl_server.host_port_pair().port(); 197 uint16_t port = ssl_server.host_port_pair().port();
202 RunTestURL(GetTestURL(http_server, 198 RunTestURL(GetTestURL(http_server,
203 test_case, 199 test_case,
204 base::StringPrintf("ssl_server_port=%d", port))); 200 base::StringPrintf("ssl_server_port=%d", port)));
205 } 201 }
206 202
207 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { 203 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
208 base::FilePath http_document_root; 204 base::FilePath http_document_root;
209 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root)); 205 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
210 net::SpawnedTestServer http_server(net::SpawnedTestServer::TYPE_HTTP, 206 net::EmbeddedTestServer http_server;
211 net::SpawnedTestServer::kLocalhost, 207 http_server.AddDefaultHandlers(http_document_root);
212 http_document_root);
213 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, 208 net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS,
214 net::SpawnedTestServer::kLocalhost, 209 net::SpawnedTestServer::kLocalhost,
215 net::GetWebSocketTestDataDirectory()); 210 net::GetWebSocketTestDataDirectory());
216 // Start the servers in parallel. 211 // Start the servers in parallel.
mmenke 2015/11/05 17:38:13 Remove comment.
svaldez 2015/11/05 18:15:55 Done.
217 ASSERT_TRUE(http_server.StartInBackground()); 212 ASSERT_TRUE(http_server.Start());
218 ASSERT_TRUE(ws_server.StartInBackground()); 213 ASSERT_TRUE(ws_server.StartInBackground());
mmenke 2015/11/05 17:38:13 I don't think we get anything out of using calls h
svaldez 2015/11/05 18:15:55 Done.
219 // Wait until they are both finished before continuing. 214 // Wait until they are both finished before continuing.
220 ASSERT_TRUE(http_server.BlockUntilStarted());
221 ASSERT_TRUE(ws_server.BlockUntilStarted()); 215 ASSERT_TRUE(ws_server.BlockUntilStarted());
222 216
223 std::string host = ws_server.host_port_pair().HostForURL(); 217 std::string host = ws_server.host_port_pair().HostForURL();
224 uint16_t port = ws_server.host_port_pair().port(); 218 uint16_t port = ws_server.host_port_pair().port();
225 RunTestURL(GetTestURL(http_server, 219 RunTestURL(GetTestURL(http_server,
226 test_case, 220 test_case,
227 base::StringPrintf( 221 base::StringPrintf(
228 "websocket_host=%s&websocket_port=%d", 222 "websocket_host=%s&websocket_port=%d",
229 host.c_str(), 223 host.c_str(),
230 port))); 224 port)));
(...skipping 28 matching lines...) Expand all
259 content::JavascriptTestObserver observer( 253 content::JavascriptTestObserver observer(
260 browser()->tab_strip_model()->GetActiveWebContents(), 254 browser()->tab_strip_model()->GetActiveWebContents(),
261 &handler); 255 &handler);
262 256
263 ui_test_utils::NavigateToURL(browser(), test_url); 257 ui_test_utils::NavigateToURL(browser(), test_url);
264 258
265 ASSERT_TRUE(observer.Run()) << handler.error_message(); 259 ASSERT_TRUE(observer.Run()) << handler.error_message();
266 EXPECT_STREQ("PASS", handler.message().c_str()); 260 EXPECT_STREQ("PASS", handler.message().c_str());
267 } 261 }
268 262
269 GURL PPAPITestBase::GetTestURL( 263 GURL PPAPITestBase::GetTestURL(const net::EmbeddedTestServer& http_server,
270 const net::SpawnedTestServer& http_server, 264 const std::string& test_case,
271 const std::string& test_case, 265 const std::string& extra_params) {
272 const std::string& extra_params) { 266 std::string query = BuildQuery("/test_case.html?", test_case);
273 std::string query = BuildQuery("files/test_case.html?", test_case);
274 if (!extra_params.empty()) 267 if (!extra_params.empty())
275 query = base::StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); 268 query = base::StringPrintf("%s&%s", query.c_str(), extra_params.c_str());
276 269
277 return http_server.GetURL(query); 270 return http_server.GetURL(query);
278 } 271 }
279 272
280 PPAPITest::PPAPITest() : in_process_(true) { 273 PPAPITest::PPAPITest() : in_process_(true) {
281 } 274 }
282 275
283 void PPAPITest::SetUpCommandLine(base::CommandLine* command_line) { 276 void PPAPITest::SetUpCommandLine(base::CommandLine* command_line) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 const std::string& base, 441 const std::string& base,
449 const std::string& test_case) { 442 const std::string& test_case) {
450 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), 443 return base::StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(),
451 test_case.c_str()); 444 test_case.c_str());
452 } 445 }
453 446
454 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { 447 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() {
455 // The default content setting for the PPAPI broker is ASK. We purposefully 448 // The default content setting for the PPAPI broker is ASK. We purposefully
456 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. 449 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way.
457 } 450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698