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

Side by Side Diff: chrome/test/live_sync/live_sync_test.cc

Issue 3305003: New authorization framework for sync. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/test/live_sync/live_sync_test.h" 5 #include "chrome/test/live_sync/live_sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "base/waitable_event.h" 14 #include "base/waitable_event.h"
15 #include "chrome/browser/chrome_thread.h" 15 #include "chrome/browser/chrome_thread.h"
16 #include "chrome/browser/profile.h" 16 #include "chrome/browser/profile.h"
17 #include "chrome/browser/profile_manager.h" 17 #include "chrome/browser/profile_manager.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/net/url_fetcher.h" 20 #include "chrome/common/net/url_fetcher.h"
21 #include "chrome/common/net/url_request_context_getter.h" 21 #include "chrome/common/net/url_request_context_getter.h"
22 #include "chrome/test/testing_browser_process.h" 22 #include "chrome/test/testing_browser_process.h"
23 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
24 #include "net/base/escape.h" 24 #include "net/base/escape.h"
25 #include "net/base/network_change_notifier.h"
25 #include "net/proxy/proxy_config.h" 26 #include "net/proxy/proxy_config.h"
26 #include "net/proxy/proxy_config_service_fixed.h" 27 #include "net/proxy/proxy_config_service_fixed.h"
27 #include "net/proxy/proxy_service.h" 28 #include "net/proxy/proxy_service.h"
28 #include "net/url_request/url_request_context.h" 29 #include "net/url_request/url_request_context.h"
29 #include "net/url_request/url_request_status.h" 30 #include "net/url_request/url_request_status.h"
30 31
31 namespace switches { 32 namespace switches {
32 const std::string kPasswordFileForTest = "password-file-for-test"; 33 const std::string kPasswordFileForTest = "password-file-for-test";
33 const std::string kSyncUserForTest = "sync-user-for-test"; 34 const std::string kSyncUserForTest = "sync-user-for-test";
34 const std::string kSyncPasswordForTest = "sync-password-for-test"; 35 const std::string kSyncPasswordForTest = "sync-password-for-test";
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // We don't take a reference to |resolver|, but mock_host_resolver_override_ 225 // We don't take a reference to |resolver|, but mock_host_resolver_override_
225 // does, so effectively assumes ownership. 226 // does, so effectively assumes ownership.
226 net::RuleBasedHostResolverProc* resolver = 227 net::RuleBasedHostResolverProc* resolver =
227 new net::RuleBasedHostResolverProc(host_resolver()); 228 new net::RuleBasedHostResolverProc(host_resolver());
228 resolver->AllowDirectLookup("*.google.com"); 229 resolver->AllowDirectLookup("*.google.com");
229 // Allow direct lookup of thawte.com. On Linux, we use Chromium's nss 230 // Allow direct lookup of thawte.com. On Linux, we use Chromium's nss
230 // implementation which uses ocsp.thawte.com for certificate verification. 231 // implementation which uses ocsp.thawte.com for certificate verification.
231 // Without this, running the test case on Linux causes an error as we make an 232 // Without this, running the test case on Linux causes an error as we make an
232 // external DNS lookup of "ocsp.thawte.com". 233 // external DNS lookup of "ocsp.thawte.com".
233 resolver->AllowDirectLookup("*.thawte.com"); 234 resolver->AllowDirectLookup("*.thawte.com");
235 // The new XMPP cert seems to use crl.geotrust.com on Linux.
236 resolver->AllowDirectLookup("*.geotrust.com");
237 // SSL chain.
238 resolver->AllowDirectLookup("*.gstatic.com");
234 mock_host_resolver_override_.reset( 239 mock_host_resolver_override_.reset(
235 new net::ScopedDefaultHostResolverProc(resolver)); 240 new net::ScopedDefaultHostResolverProc(resolver));
236 } 241 }
237 242
238 void LiveSyncTest::TearDownInProcessBrowserTestFixture() { 243 void LiveSyncTest::TearDownInProcessBrowserTestFixture() {
239 mock_host_resolver_override_.reset(); 244 mock_host_resolver_override_.reset();
240 } 245 }
241 246
242 void LiveSyncTest::SetUpLocalTestServer() { 247 void LiveSyncTest::SetUpLocalTestServer() {
243 ASSERT_TRUE(test_server_.Start()); 248 ASSERT_TRUE(test_server_.Start());
244 249
245 started_local_test_server_ = true; 250 started_local_test_server_ = true;
246 251
247 CommandLine* cl = CommandLine::ForCurrentProcess(); 252 CommandLine* cl = CommandLine::ForCurrentProcess();
248 cl->AppendSwitchASCII(switches::kSyncServiceURL, 253 cl->AppendSwitchASCII(switches::kSyncServiceURL,
249 StringPrintf("http://%s:%d/chromiumsync", 254 StringPrintf("http://%s:%d/chromiumsync",
250 test_server_.host_port_pair().host().c_str(), 255 test_server_.host_port_pair().host().c_str(),
251 test_server_.host_port_pair().port())); 256 test_server_.host_port_pair().port()));
252 } 257 }
253 258
254 void LiveSyncTest::TearDownLocalTestServer() { 259 void LiveSyncTest::TearDownLocalTestServer() {
255 ASSERT_TRUE(test_server_.Stop()); 260 ASSERT_TRUE(test_server_.Stop());
256 } 261 }
257 262
258
259 void LiveSyncTest::EnableNetwork(Profile* profile) { 263 void LiveSyncTest::EnableNetwork(Profile* profile) {
260 SetProxyConfig(profile->GetRequestContext(), 264 SetProxyConfig(profile->GetRequestContext(),
261 net::ProxyConfig::CreateDirect()); 265 net::ProxyConfig::CreateDirect());
266 // Bugs: http://crbug.com/53857
267 // http://crbug.com/53858
268 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
262 } 269 }
263 270
264 void LiveSyncTest::DisableNetwork(Profile* profile) { 271 void LiveSyncTest::DisableNetwork(Profile* profile) {
265 // Set the current proxy configuration to a nonexistent proxy to 272 // Set the current proxy configuration to a nonexistent proxy to
266 // effectively disable networking. 273 // effectively disable networking.
267 net::ProxyConfig config; 274 net::ProxyConfig config;
268 config.proxy_rules().ParseFromString("http=127.0.0.1:0"); 275 config.proxy_rules().ParseFromString("http=127.0.0.1:0");
269 SetProxyConfig(profile->GetRequestContext(), config); 276 SetProxyConfig(profile->GetRequestContext(), config);
277 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
270 } 278 }
271 279
272 bool LiveSyncTest::EnsureSyncServerConfiguration() { 280 bool LiveSyncTest::EnsureSyncServerConfiguration() {
273 const CommandLine* cl = CommandLine::ForCurrentProcess(); 281 const CommandLine* cl = CommandLine::ForCurrentProcess();
274 if (!cl->HasSwitch(switches::kSyncServiceURL)) 282 if (!cl->HasSwitch(switches::kSyncServiceURL))
275 return true; 283 return true;
276 284
277 return ConfigureSyncServer("user_email", username_); 285 return ConfigureSyncServer("user_email", username_);
278 } 286 }
279 287
(...skipping 17 matching lines...) Expand all
297 std::string data = EscapePath(name) + "=" + EscapePath(value); 305 std::string data = EscapePath(name) + "=" + EscapePath(value);
298 ConfigureURLFectcherDelegate delegate; 306 ConfigureURLFectcherDelegate delegate;
299 scoped_ptr<URLFetcher> fetcher( 307 scoped_ptr<URLFetcher> fetcher(
300 URLFetcher::Create(0, GURL(url), URLFetcher::POST, &delegate)); 308 URLFetcher::Create(0, GURL(url), URLFetcher::POST, &delegate));
301 fetcher->set_request_context(Profile::GetDefaultRequestContext()); 309 fetcher->set_request_context(Profile::GetDefaultRequestContext());
302 fetcher->set_upload_data("application/x-www-form-urlencoded", data); 310 fetcher->set_upload_data("application/x-www-form-urlencoded", data);
303 fetcher->Start(); 311 fetcher->Start();
304 MessageLoop::current()->Run(); 312 MessageLoop::current()->Run();
305 return delegate.success(); 313 return delegate.success();
306 } 314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698