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

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 196413016: Move CommandLine to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
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/sync/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 case MULTIPLE_CLIENT: { 130 case MULTIPLE_CLIENT: {
131 num_clients_ = 3; 131 num_clients_ = 3;
132 break; 132 break;
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 SyncTest::~SyncTest() {} 137 SyncTest::~SyncTest() {}
138 138
139 void SyncTest::SetUp() { 139 void SyncTest::SetUp() {
140 CommandLine* cl = CommandLine::ForCurrentProcess(); 140 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
141 if (cl->HasSwitch(switches::kPasswordFileForTest)) { 141 if (cl->HasSwitch(switches::kPasswordFileForTest)) {
142 ReadPasswordFile(); 142 ReadPasswordFile();
143 } else if (cl->HasSwitch(switches::kSyncUserForTest) && 143 } else if (cl->HasSwitch(switches::kSyncUserForTest) &&
144 cl->HasSwitch(switches::kSyncPasswordForTest)) { 144 cl->HasSwitch(switches::kSyncPasswordForTest)) {
145 username_ = cl->GetSwitchValueASCII(switches::kSyncUserForTest); 145 username_ = cl->GetSwitchValueASCII(switches::kSyncUserForTest);
146 password_ = cl->GetSwitchValueASCII(switches::kSyncPasswordForTest); 146 password_ = cl->GetSwitchValueASCII(switches::kSyncPasswordForTest);
147 } else { 147 } else {
148 username_ = "user@gmail.com"; 148 username_ = "user@gmail.com";
149 password_ = "password"; 149 password_ = "password";
150 } 150 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Allow the InProcessBrowserTest framework to perform its tear down. 203 // Allow the InProcessBrowserTest framework to perform its tear down.
204 InProcessBrowserTest::TearDown(); 204 InProcessBrowserTest::TearDown();
205 205
206 // Stop the local python test server. This is a no-op if one wasn't started. 206 // Stop the local python test server. This is a no-op if one wasn't started.
207 TearDownLocalPythonTestServer(); 207 TearDownLocalPythonTestServer();
208 208
209 // Stop the local sync test server. This is a no-op if one wasn't started. 209 // Stop the local sync test server. This is a no-op if one wasn't started.
210 TearDownLocalTestServer(); 210 TearDownLocalTestServer();
211 } 211 }
212 212
213 void SyncTest::SetUpCommandLine(CommandLine* cl) { 213 void SyncTest::SetUpCommandLine(base::CommandLine* cl) {
214 AddTestSwitches(cl); 214 AddTestSwitches(cl);
215 AddOptionalTypesToCommandLine(cl); 215 AddOptionalTypesToCommandLine(cl);
216 } 216 }
217 217
218 void SyncTest::AddTestSwitches(CommandLine* cl) { 218 void SyncTest::AddTestSwitches(base::CommandLine* cl) {
219 // Disable non-essential access of external network resources. 219 // Disable non-essential access of external network resources.
220 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking)) 220 if (!cl->HasSwitch(switches::kDisableBackgroundNetworking))
221 cl->AppendSwitch(switches::kDisableBackgroundNetworking); 221 cl->AppendSwitch(switches::kDisableBackgroundNetworking);
222 222
223 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) 223 if (!cl->HasSwitch(switches::kSyncShortInitialRetryOverride))
224 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride); 224 cl->AppendSwitch(switches::kSyncShortInitialRetryOverride);
225 225
226 // TODO(sync): Fix enable_disable_test.cc to play nice with priority 226 // TODO(sync): Fix enable_disable_test.cc to play nice with priority
227 // preferences. 227 // preferences.
228 if (!cl->HasSwitch(switches::kDisableSyncPriorityPreferences)) 228 if (!cl->HasSwitch(switches::kDisableSyncPriorityPreferences))
229 cl->AppendSwitch(switches::kDisableSyncPriorityPreferences); 229 cl->AppendSwitch(switches::kDisableSyncPriorityPreferences);
230 } 230 }
231 231
232 void SyncTest::AddOptionalTypesToCommandLine(CommandLine* cl) {} 232 void SyncTest::AddOptionalTypesToCommandLine(base::CommandLine* cl) {}
233 233
234 // static 234 // static
235 Profile* SyncTest::MakeProfile(const base::FilePath::StringType name) { 235 Profile* SyncTest::MakeProfile(const base::FilePath::StringType name) {
236 base::FilePath path; 236 base::FilePath path;
237 PathService::Get(chrome::DIR_USER_DATA, &path); 237 PathService::Get(chrome::DIR_USER_DATA, &path);
238 path = path.Append(name); 238 path = path.Append(name);
239 239
240 if (!base::PathExists(path)) 240 if (!base::PathExists(path))
241 CHECK(base::CreateDirectory(path)); 241 CHECK(base::CreateDirectory(path));
242 242
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 resolver->AllowDirectLookup("*.gstatic.com"); 407 resolver->AllowDirectLookup("*.gstatic.com");
408 mock_host_resolver_override_.reset( 408 mock_host_resolver_override_.reset(
409 new net::ScopedDefaultHostResolverProc(resolver)); 409 new net::ScopedDefaultHostResolverProc(resolver));
410 } 410 }
411 411
412 void SyncTest::TearDownInProcessBrowserTestFixture() { 412 void SyncTest::TearDownInProcessBrowserTestFixture() {
413 mock_host_resolver_override_.reset(); 413 mock_host_resolver_override_.reset();
414 } 414 }
415 415
416 void SyncTest::ReadPasswordFile() { 416 void SyncTest::ReadPasswordFile() {
417 CommandLine* cl = CommandLine::ForCurrentProcess(); 417 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
418 password_file_ = cl->GetSwitchValuePath(switches::kPasswordFileForTest); 418 password_file_ = cl->GetSwitchValuePath(switches::kPasswordFileForTest);
419 if (password_file_.empty()) 419 if (password_file_.empty())
420 LOG(FATAL) << "Can't run live server test without specifying --" 420 LOG(FATAL) << "Can't run live server test without specifying --"
421 << switches::kPasswordFileForTest << "=<filename>"; 421 << switches::kPasswordFileForTest << "=<filename>";
422 std::string file_contents; 422 std::string file_contents;
423 base::ReadFileToString(password_file_, &file_contents); 423 base::ReadFileToString(password_file_, &file_contents);
424 ASSERT_NE(file_contents, "") << "Password file \"" 424 ASSERT_NE(file_contents, "") << "Password file \""
425 << password_file_.value() << "\" does not exist."; 425 << password_file_.value() << "\" does not exist.";
426 std::vector<std::string> tokens; 426 std::vector<std::string> tokens;
427 std::string delimiters = "\r\n"; 427 std::string delimiters = "\r\n";
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // Nothing to do; we'll just talk to the URL we were given. 528 // Nothing to do; we'll just talk to the URL we were given.
529 } else { 529 } else {
530 LOG(FATAL) << "Don't know which server environment to run test in."; 530 LOG(FATAL) << "Don't know which server environment to run test in.";
531 } 531 }
532 } 532 }
533 533
534 bool SyncTest::SetUpLocalPythonTestServer() { 534 bool SyncTest::SetUpLocalPythonTestServer() {
535 EXPECT_TRUE(sync_server_.Start()) 535 EXPECT_TRUE(sync_server_.Start())
536 << "Could not launch local python test server."; 536 << "Could not launch local python test server.";
537 537
538 CommandLine* cl = CommandLine::ForCurrentProcess(); 538 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
539 if (server_type_ == LOCAL_PYTHON_SERVER) { 539 if (server_type_ == LOCAL_PYTHON_SERVER) {
540 std::string sync_service_url = sync_server_.GetURL("chromiumsync").spec(); 540 std::string sync_service_url = sync_server_.GetURL("chromiumsync").spec();
541 cl->AppendSwitchASCII(switches::kSyncServiceURL, sync_service_url); 541 cl->AppendSwitchASCII(switches::kSyncServiceURL, sync_service_url);
542 DVLOG(1) << "Started local python sync server at " << sync_service_url; 542 DVLOG(1) << "Started local python sync server at " << sync_service_url;
543 } 543 }
544 544
545 int xmpp_port = 0; 545 int xmpp_port = 0;
546 if (!sync_server_.server_data().GetInteger("xmpp_port", &xmpp_port)) { 546 if (!sync_server_.server_data().GetInteger("xmpp_port", &xmpp_port)) {
547 LOG(ERROR) << "Could not find valid xmpp_port value"; 547 LOG(ERROR) << "Could not find valid xmpp_port value";
548 return false; 548 return false;
(...skipping 13 matching lines...) Expand all
562 // The local XMPP server only supports insecure connections. 562 // The local XMPP server only supports insecure connections.
563 cl->AppendSwitch(switches::kSyncAllowInsecureXmppConnection); 563 cl->AppendSwitch(switches::kSyncAllowInsecureXmppConnection);
564 } 564 }
565 DVLOG(1) << "Started local python XMPP server at " 565 DVLOG(1) << "Started local python XMPP server at "
566 << xmpp_host_port_pair.ToString(); 566 << xmpp_host_port_pair.ToString();
567 567
568 return true; 568 return true;
569 } 569 }
570 570
571 bool SyncTest::SetUpLocalTestServer() { 571 bool SyncTest::SetUpLocalTestServer() {
572 CommandLine* cl = CommandLine::ForCurrentProcess(); 572 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
573 CommandLine::StringType server_cmdline_string = cl->GetSwitchValueNative( 573 base::CommandLine::StringType server_cmdline_string =
574 switches::kSyncServerCommandLine); 574 cl->GetSwitchValueNative(switches::kSyncServerCommandLine);
575 CommandLine::StringVector server_cmdline_vector; 575 base::CommandLine::StringVector server_cmdline_vector;
576 CommandLine::StringType delimiters(FILE_PATH_LITERAL(" ")); 576 base::CommandLine::StringType delimiters(FILE_PATH_LITERAL(" "));
577 Tokenize(server_cmdline_string, delimiters, &server_cmdline_vector); 577 Tokenize(server_cmdline_string, delimiters, &server_cmdline_vector);
578 CommandLine server_cmdline(server_cmdline_vector); 578 base::CommandLine server_cmdline(server_cmdline_vector);
579 base::LaunchOptions options; 579 base::LaunchOptions options;
580 #if defined(OS_WIN) 580 #if defined(OS_WIN)
581 options.start_hidden = true; 581 options.start_hidden = true;
582 #endif 582 #endif
583 if (!base::LaunchProcess(server_cmdline, options, &test_server_handle_)) 583 if (!base::LaunchProcess(server_cmdline, options, &test_server_handle_))
584 LOG(ERROR) << "Could not launch local test server."; 584 LOG(ERROR) << "Could not launch local test server.";
585 585
586 const base::TimeDelta kMaxWaitTime = TestTimeouts::action_max_timeout(); 586 const base::TimeDelta kMaxWaitTime = TestTimeouts::action_max_timeout();
587 const int kNumIntervals = 15; 587 const int kNumIntervals = 15;
588 if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) { 588 if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) {
(...skipping 29 matching lines...) Expand all
618 bool SyncTest::WaitForTestServerToStart(base::TimeDelta wait, int intervals) { 618 bool SyncTest::WaitForTestServerToStart(base::TimeDelta wait, int intervals) {
619 for (int i = 0; i < intervals; ++i) { 619 for (int i = 0; i < intervals; ++i) {
620 if (IsTestServerRunning()) 620 if (IsTestServerRunning())
621 return true; 621 return true;
622 base::PlatformThread::Sleep(wait / intervals); 622 base::PlatformThread::Sleep(wait / intervals);
623 } 623 }
624 return false; 624 return false;
625 } 625 }
626 626
627 bool SyncTest::IsTestServerRunning() { 627 bool SyncTest::IsTestServerRunning() {
628 CommandLine* cl = CommandLine::ForCurrentProcess(); 628 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
629 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL); 629 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL);
630 GURL sync_url_status(sync_url.append("/healthz")); 630 GURL sync_url_status(sync_url.append("/healthz"));
631 SyncServerStatusChecker delegate; 631 SyncServerStatusChecker delegate;
632 scoped_ptr<net::URLFetcher> fetcher(net::URLFetcher::Create( 632 scoped_ptr<net::URLFetcher> fetcher(net::URLFetcher::Create(
633 sync_url_status, net::URLFetcher::GET, &delegate)); 633 sync_url_status, net::URLFetcher::GET, &delegate));
634 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | 634 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE |
635 net::LOAD_DO_NOT_SEND_COOKIES | 635 net::LOAD_DO_NOT_SEND_COOKIES |
636 net::LOAD_DO_NOT_SAVE_COOKIES); 636 net::LOAD_DO_NOT_SAVE_COOKIES);
637 fetcher->SetRequestContext(g_browser_process->system_request_context()); 637 fetcher->SetRequestContext(g_browser_process->system_request_context());
638 fetcher->Start(); 638 fetcher->Start();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 BrowserThread::IO, FROM_HERE, 878 BrowserThread::IO, FROM_HERE,
879 base::Bind(&SetProxyConfigCallback, &done, 879 base::Bind(&SetProxyConfigCallback, &done,
880 make_scoped_refptr(context_getter), proxy_config)); 880 make_scoped_refptr(context_getter), proxy_config));
881 done.Wait(); 881 done.Wait();
882 } 882 }
883 883
884 void SyncTest::UseFakeServer() { 884 void SyncTest::UseFakeServer() {
885 DCHECK_EQ(SERVER_TYPE_UNDECIDED, server_type_); 885 DCHECK_EQ(SERVER_TYPE_UNDECIDED, server_type_);
886 server_type_ = IN_PROCESS_FAKE_SERVER; 886 server_type_ = IN_PROCESS_FAKE_SERVER;
887 } 887 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.h ('k') | chrome/browser/ui/app_list/app_list_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698