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

Side by Side Diff: chrome/browser/extensions/extension_apitest.cc

Issue 166793003: Allow FTP requests by Chromium extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/common/extensions/api/test.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 15 matching lines...) Expand all
26 #include "net/test/embedded_test_server/http_request.h" 26 #include "net/test/embedded_test_server/http_request.h"
27 #include "net/test/embedded_test_server/http_response.h" 27 #include "net/test/embedded_test_server/http_response.h"
28 #include "net/test/spawned_test_server/spawned_test_server.h" 28 #include "net/test/spawned_test_server/spawned_test_server.h"
29 29
30 namespace { 30 namespace {
31 31
32 const char kTestCustomArg[] = "customArg"; 32 const char kTestCustomArg[] = "customArg";
33 const char kTestServerPort[] = "testServer.port"; 33 const char kTestServerPort[] = "testServer.port";
34 const char kTestDataDirectory[] = "testDataDirectory"; 34 const char kTestDataDirectory[] = "testDataDirectory";
35 const char kTestWebSocketPort[] = "testWebSocketPort"; 35 const char kTestWebSocketPort[] = "testWebSocketPort";
36 const char kFtpServerPort[] = "ftpServer.port";
36 const char kSpawnedTestServerPort[] = "spawnedTestServer.port"; 37 const char kSpawnedTestServerPort[] = "spawnedTestServer.port";
37 38
38 scoped_ptr<net::test_server::HttpResponse> HandleServerRedirectRequest( 39 scoped_ptr<net::test_server::HttpResponse> HandleServerRedirectRequest(
39 const net::test_server::HttpRequest& request) { 40 const net::test_server::HttpRequest& request) {
40 if (!StartsWithASCII(request.relative_url, "/server-redirect?", true)) 41 if (!StartsWithASCII(request.relative_url, "/server-redirect?", true))
41 return scoped_ptr<net::test_server::HttpResponse>(); 42 return scoped_ptr<net::test_server::HttpResponse>();
42 43
43 size_t query_string_pos = request.relative_url.find('?'); 44 size_t query_string_pos = request.relative_url.find('?');
44 std::string redirect_target = 45 std::string redirect_target =
45 request.relative_url.substr(query_string_pos + 1); 46 request.relative_url.substr(query_string_pos + 1);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 443
443 if (!websocket_server_->Start()) 444 if (!websocket_server_->Start())
444 return false; 445 return false;
445 446
446 test_config_->SetInteger(kTestWebSocketPort, 447 test_config_->SetInteger(kTestWebSocketPort,
447 websocket_server_->host_port_pair().port()); 448 websocket_server_->host_port_pair().port());
448 449
449 return true; 450 return true;
450 } 451 }
451 452
453 bool ExtensionApiTest::StartFTPServer(const base::FilePath& root_directory) {
454 ftp_server_.reset(new net::SpawnedTestServer(
455 net::SpawnedTestServer::TYPE_FTP,
456 net::SpawnedTestServer::kLocalhost,
457 root_directory));
458
459 if (!ftp_server_->Start())
460 return false;
461
462 test_config_->SetInteger(kFtpServerPort,
463 ftp_server_->host_port_pair().port());
464
465 return true;
466 }
467
452 bool ExtensionApiTest::StartSpawnedTestServer() { 468 bool ExtensionApiTest::StartSpawnedTestServer() {
453 if (!test_server()->Start()) 469 if (!test_server()->Start())
454 return false; 470 return false;
455 471
456 // Build a dictionary of values that tests can use to build URLs that 472 // Build a dictionary of values that tests can use to build URLs that
457 // access the test server and local file system. Tests can see these values 473 // access the test server and local file system. Tests can see these values
458 // using the extension API function chrome.test.getConfig(). 474 // using the extension API function chrome.test.getConfig().
459 test_config_->SetInteger(kSpawnedTestServerPort, 475 test_config_->SetInteger(kSpawnedTestServerPort,
460 test_server()->host_port_pair().port()); 476 test_server()->host_port_pair().port());
461 477
462 return true; 478 return true;
463 } 479 }
464 480
465 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { 481 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) {
466 ExtensionBrowserTest::SetUpCommandLine(command_line); 482 ExtensionBrowserTest::SetUpCommandLine(command_line);
467 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); 483 test_data_dir_ = test_data_dir_.AppendASCII("api_test");
468 } 484 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/common/extensions/api/test.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698