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/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "net/test/spawned_test_server/spawned_test_server.h" | 31 #include "net/test/spawned_test_server/spawned_test_server.h" |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kTestCustomArg[] = "customArg"; | 35 const char kTestCustomArg[] = "customArg"; |
36 const char kTestServerPort[] = "testServer.port"; | 36 const char kTestServerPort[] = "testServer.port"; |
37 const char kTestDataDirectory[] = "testDataDirectory"; | 37 const char kTestDataDirectory[] = "testDataDirectory"; |
38 const char kTestWebSocketPort[] = "testWebSocketPort"; | 38 const char kTestWebSocketPort[] = "testWebSocketPort"; |
39 const char kSitePerProcess[] = "sitePerProcess"; | 39 const char kSitePerProcess[] = "sitePerProcess"; |
40 const char kFtpServerPort[] = "ftpServer.port"; | 40 const char kFtpServerPort[] = "ftpServer.port"; |
41 const char kSpawnedTestServerPort[] = "spawnedTestServer.port"; | 41 const char kEmbeddedTestServerPort[] = "embeddedTestServer.port"; |
42 | 42 |
43 scoped_ptr<net::test_server::HttpResponse> HandleServerRedirectRequest( | 43 scoped_ptr<net::test_server::HttpResponse> HandleServerRedirectRequest( |
44 const net::test_server::HttpRequest& request) { | 44 const net::test_server::HttpRequest& request) { |
45 if (!base::StartsWith(request.relative_url, "/server-redirect?", | 45 if (!base::StartsWith(request.relative_url, "/server-redirect?", |
46 base::CompareCase::SENSITIVE)) | 46 base::CompareCase::SENSITIVE)) |
47 return nullptr; | 47 return nullptr; |
48 | 48 |
49 size_t query_string_pos = request.relative_url.find('?'); | 49 size_t query_string_pos = request.relative_url.find('?'); |
50 std::string redirect_target = | 50 std::string redirect_target = |
51 request.relative_url.substr(query_string_pos + 1); | 51 request.relative_url.substr(query_string_pos + 1); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 } | 363 } |
364 | 364 |
365 if (!result) { | 365 if (!result) { |
366 message_ = "extension pointer is NULL."; | 366 message_ = "extension pointer is NULL."; |
367 return NULL; | 367 return NULL; |
368 } | 368 } |
369 return result; | 369 return result; |
370 } | 370 } |
371 | 371 |
372 bool ExtensionApiTest::StartEmbeddedTestServer() { | 372 bool ExtensionApiTest::StartEmbeddedTestServer() { |
373 if (!embedded_test_server()->InitializeAndWaitUntilReady()) | 373 if (!embedded_test_server()->Start()) |
374 return false; | 374 return false; |
375 | 375 |
376 // Build a dictionary of values that tests can use to build URLs that | 376 // Build a dictionary of values that tests can use to build URLs that |
377 // access the test server and local file system. Tests can see these values | 377 // access the test server and local file system. Tests can see these values |
378 // using the extension API function chrome.test.getConfig(). | 378 // using the extension API function chrome.test.getConfig(). |
379 test_config_->SetInteger(kTestServerPort, | 379 test_config_->SetInteger(kTestServerPort, |
380 embedded_test_server()->port()); | 380 embedded_test_server()->port()); |
381 | 381 |
382 return true; | 382 return true; |
383 } | 383 } |
(...skipping 22 matching lines...) Expand all Loading... | |
406 | 406 |
407 if (!ftp_server_->Start()) | 407 if (!ftp_server_->Start()) |
408 return false; | 408 return false; |
409 | 409 |
410 test_config_->SetInteger(kFtpServerPort, | 410 test_config_->SetInteger(kFtpServerPort, |
411 ftp_server_->host_port_pair().port()); | 411 ftp_server_->host_port_pair().port()); |
412 | 412 |
413 return true; | 413 return true; |
414 } | 414 } |
415 | 415 |
416 bool ExtensionApiTest::StartSpawnedTestServer() { | 416 bool ExtensionApiTest::StartTestServer() { |
mmenke
2015/11/17 21:54:12
This is now identical to StartEmbeddedTestServer,
svaldez
2015/11/17 22:18:53
Done.
| |
417 if (!test_server()->Start()) | 417 if (!embedded_test_server()->Start()) |
418 return false; | 418 return false; |
419 | 419 |
420 // Build a dictionary of values that tests can use to build URLs that | 420 // Build a dictionary of values that tests can use to build URLs that |
421 // access the test server and local file system. Tests can see these values | 421 // access the test server and local file system. Tests can see these values |
422 // using the extension API function chrome.test.getConfig(). | 422 // using the extension API function chrome.test.getConfig(). |
423 test_config_->SetInteger(kSpawnedTestServerPort, | 423 test_config_->SetInteger(kEmbeddedTestServerPort, |
424 test_server()->host_port_pair().port()); | 424 embedded_test_server()->host_port_pair().port()); |
425 | 425 |
426 return true; | 426 return true; |
427 } | 427 } |
428 | 428 |
429 void ExtensionApiTest::SetUpCommandLine(base::CommandLine* command_line) { | 429 void ExtensionApiTest::SetUpCommandLine(base::CommandLine* command_line) { |
430 ExtensionBrowserTest::SetUpCommandLine(command_line); | 430 ExtensionBrowserTest::SetUpCommandLine(command_line); |
431 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); | 431 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); |
432 // Backgrounded renderer processes run at a lower priority, causing the | 432 // Backgrounded renderer processes run at a lower priority, causing the |
433 // tests to take more time to complete. Disable backgrounding so that the | 433 // tests to take more time to complete. Disable backgrounding so that the |
434 // tests don't time out. | 434 // tests don't time out. |
435 command_line->AppendSwitch(switches::kDisableRendererBackgrounding); | 435 command_line->AppendSwitch(switches::kDisableRendererBackgrounding); |
436 } | 436 } |
OLD | NEW |