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

Side by Side Diff: sync/test/local_sync_test_server.cc

Issue 11971025: [sync] Divorce python sync test server chromiumsync.py from testserver.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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 | « sync/test/local_sync_test_server.h ('k') | sync/tools/testserver/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sync/test/local_sync_test_server.h"
6
7 #include "base/command_line.h"
8 #include "base/path_service.h"
9 #include "base/string_number_conversions.h"
10 #include "base/values.h"
11 #include "net/test/python_utils.h"
12 #include "net/test/test_server.h"
13
14 namespace syncer {
15
16 LocalSyncTestServer::LocalSyncTestServer()
17 : LocalTestServer(net::TestServer::TYPE_HTTP, // Sync uses the HTTP scheme.
18 net::TestServer::kLocalhost,
19 FilePath()),
20 xmpp_port_(0) {}
21
22 LocalSyncTestServer::LocalSyncTestServer(uint16 port, uint16 xmpp_port)
23 : LocalTestServer(net::TestServer::TYPE_HTTP, // Sync uses the HTTP scheme.
24 net::TestServer::kLocalhost,
25 FilePath()),
26 xmpp_port_(xmpp_port) {
27 SetPort(port);
28 }
29
30 LocalSyncTestServer::~LocalSyncTestServer() {}
31
32 bool LocalSyncTestServer::AddCommandLineArguments(
33 CommandLine* command_line) const {
34 if (!LocalTestServer::AddCommandLineArguments(command_line))
35 return false;
36 if (xmpp_port_ != 0) {
37 std::string xmpp_port_str = base::IntToString(xmpp_port_);
38 command_line->AppendArg("--xmpp-port=" + xmpp_port_str);
39 }
40 return true;
41 }
42
43 bool LocalSyncTestServer::GetTestServerPath(FilePath* testserver_path) const {
44 FilePath testserver_dir;
45 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_dir)) {
46 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
47 return false;
48 }
49 testserver_dir = testserver_dir.Append(FILE_PATH_LITERAL("sync"))
50 .Append(FILE_PATH_LITERAL("tools"))
51 .Append(FILE_PATH_LITERAL("testserver"));
52
53 *testserver_path =
54 testserver_dir.Append(FILE_PATH_LITERAL("sync_testserver.py"));
55 return true;
56 }
57
58 bool LocalSyncTestServer::GetTestScriptPath(
59 const FilePath::StringType& test_script_name,
60 FilePath* test_script_path) const {
61 FilePath testserver_path;
62 if (!GetTestServerPath(&testserver_path))
63 return false;
64 *test_script_path = testserver_path.DirName().Append(test_script_name);
65 return true;
66 }
67
68 bool LocalSyncTestServer::SetPythonPath() const {
69 if (!LocalTestServer::SetPythonPath())
70 return false;
71
72 // Add the net/tools/testserver directory to the path, so that testserver_base
73 // can be imported.
74 FilePath net_testserver_path;
75 if (!LocalTestServer::GetTestServerPath(&net_testserver_path)) {
76 LOG(ERROR) << "Failed to get net testserver path.";
77 return false;
78 }
79 AppendToPythonPath(net_testserver_path.DirName());
80
81 // Locate the Python code generated by the sync protocol buffers compiler.
82 FilePath pyproto_dir;
83 if (!GetPyProtoPath(&pyproto_dir)) {
84 LOG(WARNING) << "Cannot find pyproto dir for generated code. "
85 << "Testserver features that rely on it will not work";
86 return true;
87 }
88 AppendToPythonPath(pyproto_dir.AppendASCII("sync").AppendASCII("protocol"));
89 return true;
90 }
91
92 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/local_sync_test_server.h ('k') | sync/tools/testserver/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698