summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-12 02:20:27 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-12 02:20:27 +0000
commita358fd8076527132d37e0262823abe3807da16b8 (patch)
tree1eec17f4fdb7d112d917ff5dcb9907270a0a4173 /chrome
parent640a7ba34abc2d48327034138d5f675378d33fb9 (diff)
downloadchromium_src-a358fd8076527132d37e0262823abe3807da16b8.zip
chromium_src-a358fd8076527132d37e0262823abe3807da16b8.tar.gz
chromium_src-a358fd8076527132d37e0262823abe3807da16b8.tar.bz2
[Sync] Added a separate type for a sync server for testserver.py
Made live_sync_test.cc use its own test server instance. Decomped all sync server code into their own classes (SyncHTTPServer and SyncPageHandler). BUG=53934 TEST=sync integration tests Review URL: http://codereview.chromium.org/4209002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65893 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/test/live_sync/live_sync_test.cc35
-rw-r--r--chrome/test/live_sync/live_sync_test.h28
2 files changed, 34 insertions, 29 deletions
diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc
index 2ae08cc..888527a 100644
--- a/chrome/test/live_sync/live_sync_test.cc
+++ b/chrome/test/live_sync/live_sync_test.cc
@@ -27,6 +27,7 @@
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
#include "net/base/network_change_notifier.h"
+#include "net/test/test_server.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_service.h"
@@ -86,6 +87,32 @@ class SetProxyConfigTask : public Task {
net::ProxyConfig proxy_config_;
};
+LiveSyncTest::LiveSyncTest(TestType test_type)
+ : sync_server_(net::TestServer::TYPE_SYNC, FilePath()),
+ test_type_(test_type),
+ num_clients_(-1),
+ test_server_handle_(base::kNullProcessHandle) {
+ InProcessBrowserTest::set_show_window(true);
+ switch (test_type_) {
+ case SINGLE_CLIENT: {
+ num_clients_ = 1;
+ break;
+ }
+ case TWO_CLIENT: {
+ num_clients_ = 2;
+ break;
+ }
+ case MULTIPLE_CLIENT: {
+ num_clients_ = 3;
+ break;
+ }
+ case MANY_CLIENT: {
+ num_clients_ = 10;
+ break;
+ }
+ }
+}
+
void LiveSyncTest::SetUp() {
// At this point, the browser hasn't been launched, and no services are
// available. But we can verify our command line parameters and fail
@@ -292,13 +319,11 @@ void LiveSyncTest::SetUpTestServerIfRequired() {
}
bool LiveSyncTest::SetUpLocalPythonTestServer() {
- EXPECT_TRUE(test_server()->Start())
+ EXPECT_TRUE(sync_server_.Start())
<< "Could not launch local python test server.";
CommandLine* cl = CommandLine::ForCurrentProcess();
- std::string sync_service_url = StringPrintf("http://%s:%d/chromiumsync",
- test_server()->host_port_pair().host().c_str(),
- test_server()->host_port_pair().port());
+ std::string sync_service_url = sync_server_.GetURL("chromiumsync").spec();
cl->AppendSwitchASCII(switches::kSyncServiceURL, sync_service_url);
VLOG(1) << "Started local python test server at " << sync_service_url;
@@ -337,7 +362,7 @@ bool LiveSyncTest::SetUpLocalTestServer() {
}
bool LiveSyncTest::TearDownLocalPythonTestServer() {
- if (!test_server()->Stop()) {
+ if (!sync_server_.Stop()) {
LOG(ERROR) << "Could not stop local python test server.";
return false;
}
diff --git a/chrome/test/live_sync/live_sync_test.h b/chrome/test/live_sync/live_sync_test.h
index 1e93b64..1759d93 100644
--- a/chrome/test/live_sync/live_sync_test.h
+++ b/chrome/test/live_sync/live_sync_test.h
@@ -55,30 +55,7 @@ class LiveSyncTest : public InProcessBrowserTest {
};
// A LiveSyncTest must be associated with a particular test type.
- explicit LiveSyncTest(TestType test_type)
- : test_type_(test_type),
- num_clients_(-1),
- test_server_handle_(base::kNullProcessHandle) {
- InProcessBrowserTest::set_show_window(true);
- switch (test_type_) {
- case SINGLE_CLIENT: {
- num_clients_ = 1;
- break;
- }
- case TWO_CLIENT: {
- num_clients_ = 2;
- break;
- }
- case MULTIPLE_CLIENT: {
- num_clients_ = 3;
- break;
- }
- case MANY_CLIENT: {
- num_clients_ = 10;
- break;
- }
- }
- }
+ explicit LiveSyncTest(TestType test_type);
virtual ~LiveSyncTest() {}
@@ -194,6 +171,9 @@ class LiveSyncTest : public InProcessBrowserTest {
void SetProxyConfig(URLRequestContextGetter* context,
const net::ProxyConfig& proxy_config);
+ // Test server of type sync, started on demand.
+ net::TestServer sync_server_;
+
// Used to differentiate between single-client, two-client, multi-client and
// many-client tests.
TestType test_type_;