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

Side by Side Diff: net/test/remote_test_server.cc

Issue 10896050: Android: Use external storage for test data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/test_package_apk.py ('k') | no next file » | 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 "net/test/remote_test_server.h" 5 #include "net/test/remote_test_server.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h"
10 #include "base/file_path.h"
9 #include "base/file_util.h" 11 #include "base/file_util.h"
10 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/path_service.h" 14 #include "base/path_service.h"
13 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
14 #include "base/string_split.h" 16 #include "base/string_split.h"
15 #include "base/values.h" 17 #include "base/values.h"
16 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
17 #include "net/base/host_port_pair.h" 19 #include "net/base/host_port_pair.h"
18 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
19 #include "net/test/spawner_communicator.h" 21 #include "net/test/spawner_communicator.h"
20 22
21 namespace net { 23 namespace net {
22 24
23 namespace { 25 namespace {
24 26
25 // To reduce the running time of tests, tests may be sharded across several 27 // To reduce the running time of tests, tests may be sharded across several
26 // devices. This means that it may be necessary to support multiple instances 28 // devices. This means that it may be necessary to support multiple instances
27 // of the test server spawner and the Python test server simultaneously on the 29 // of the test server spawner and the Python test server simultaneously on the
28 // same host. Each pair of (test server spawner, Python test server) correspond 30 // same host. Each pair of (test server spawner, Python test server) correspond
29 // to a single testing device. 31 // to a single testing device.
30 // The mapping between the test server spawner and the individual Python test 32 // The mapping between the test server spawner and the individual Python test
31 // servers is written to a file on the device prior to executing any tests. 33 // servers is written to a file on the device prior to executing any tests.
32 const char kTestServerPortInfoFile[] = "/data/local/tmp/net-test-server-ports"; 34 FilePath GetTestServerPortInfoFile() {
35 #if !defined(OS_ANDROID)
36 return FilePath("/tmp/net-test-server-ports");
37 #else
38 FilePath test_data_dir;
39 PathService::Get(base::DIR_ANDROID_EXTERNAL_STORAGE, &test_data_dir);
40 test_data_dir.Append("net-test-server-ports");
41 return test_data_dir;
42 #endif
43 }
33 44
34 // Please keep it sync with dictionary SERVER_TYPES in testserver.py 45 // Please keep it sync with dictionary SERVER_TYPES in testserver.py
35 std::string GetServerTypeString(BaseTestServer::Type type) { 46 std::string GetServerTypeString(BaseTestServer::Type type) {
36 switch (type) { 47 switch (type) {
37 case BaseTestServer::TYPE_FTP: 48 case BaseTestServer::TYPE_FTP:
38 return "ftp"; 49 return "ftp";
39 case BaseTestServer::TYPE_GDATA: 50 case BaseTestServer::TYPE_GDATA:
40 case BaseTestServer::TYPE_HTTP: 51 case BaseTestServer::TYPE_HTTP:
41 case BaseTestServer::TYPE_HTTPS: 52 case BaseTestServer::TYPE_HTTPS:
42 return "http"; 53 return "http";
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 143
133 bool RemoteTestServer::Init(const FilePath& document_root) { 144 bool RemoteTestServer::Init(const FilePath& document_root) {
134 if (document_root.IsAbsolute()) 145 if (document_root.IsAbsolute())
135 return false; 146 return false;
136 147
137 // Gets ports information used by test server spawner and Python test server. 148 // Gets ports information used by test server spawner and Python test server.
138 int test_server_port = 0; 149 int test_server_port = 0;
139 150
140 // Parse file to extract the ports information. 151 // Parse file to extract the ports information.
141 std::string port_info; 152 std::string port_info;
142 if (!file_util::ReadFileToString(FilePath(kTestServerPortInfoFile), 153 if (!file_util::ReadFileToString(GetTestServerPortInfoFile(),
143 &port_info) || 154 &port_info) ||
144 port_info.empty()) { 155 port_info.empty()) {
145 return false; 156 return false;
146 } 157 }
147 158
148 std::vector<std::string> ports; 159 std::vector<std::string> ports;
149 base::SplitString(port_info, ':', &ports); 160 base::SplitString(port_info, ':', &ports);
150 if (ports.size() != 2u) 161 if (ports.size() != 2u)
151 return false; 162 return false;
152 163
(...skipping 12 matching lines...) Expand all
165 176
166 SetResourcePath(document_root, FilePath().AppendASCII("net") 177 SetResourcePath(document_root, FilePath().AppendASCII("net")
167 .AppendASCII("data") 178 .AppendASCII("data")
168 .AppendASCII("ssl") 179 .AppendASCII("ssl")
169 .AppendASCII("certificates")); 180 .AppendASCII("certificates"));
170 return true; 181 return true;
171 } 182 }
172 183
173 } // namespace net 184 } // namespace net
174 185
OLDNEW
« no previous file with comments | « build/android/pylib/test_package_apk.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698