OLD | NEW |
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 CommandLine::StringType delimiters(FILE_PATH_LITERAL(" ")); | 508 CommandLine::StringType delimiters(FILE_PATH_LITERAL(" ")); |
509 Tokenize(server_cmdline_string, delimiters, &server_cmdline_vector); | 509 Tokenize(server_cmdline_string, delimiters, &server_cmdline_vector); |
510 CommandLine server_cmdline(server_cmdline_vector); | 510 CommandLine server_cmdline(server_cmdline_vector); |
511 base::LaunchOptions options; | 511 base::LaunchOptions options; |
512 #if defined(OS_WIN) | 512 #if defined(OS_WIN) |
513 options.start_hidden = true; | 513 options.start_hidden = true; |
514 #endif | 514 #endif |
515 if (!base::LaunchProcess(server_cmdline, options, &test_server_handle_)) | 515 if (!base::LaunchProcess(server_cmdline, options, &test_server_handle_)) |
516 LOG(ERROR) << "Could not launch local test server."; | 516 LOG(ERROR) << "Could not launch local test server."; |
517 | 517 |
518 const int kMaxWaitTime = TestTimeouts::action_max_timeout_ms(); | 518 const base::TimeDelta kMaxWaitTime = TestTimeouts::action_max_timeout(); |
519 const int kNumIntervals = 15; | 519 const int kNumIntervals = 15; |
520 if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) { | 520 if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) { |
521 DVLOG(1) << "Started local test server at " | 521 DVLOG(1) << "Started local test server at " |
522 << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << "."; | 522 << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << "."; |
523 return true; | 523 return true; |
524 } else { | 524 } else { |
525 LOG(ERROR) << "Could not start local test server at " | 525 LOG(ERROR) << "Could not start local test server at " |
526 << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << "."; | 526 << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << "."; |
527 return false; | 527 return false; |
528 } | 528 } |
(...skipping 11 matching lines...) Expand all Loading... |
540 bool SyncTest::TearDownLocalTestServer() { | 540 bool SyncTest::TearDownLocalTestServer() { |
541 if (test_server_handle_ != base::kNullProcessHandle) { | 541 if (test_server_handle_ != base::kNullProcessHandle) { |
542 EXPECT_TRUE(base::KillProcess(test_server_handle_, 0, false)) | 542 EXPECT_TRUE(base::KillProcess(test_server_handle_, 0, false)) |
543 << "Could not stop local test server."; | 543 << "Could not stop local test server."; |
544 base::CloseProcessHandle(test_server_handle_); | 544 base::CloseProcessHandle(test_server_handle_); |
545 test_server_handle_ = base::kNullProcessHandle; | 545 test_server_handle_ = base::kNullProcessHandle; |
546 } | 546 } |
547 return true; | 547 return true; |
548 } | 548 } |
549 | 549 |
550 bool SyncTest::WaitForTestServerToStart(int time_ms, int intervals) { | 550 bool SyncTest::WaitForTestServerToStart(base::TimeDelta wait, int intervals) { |
551 for (int i = 0; i < intervals; ++i) { | 551 for (int i = 0; i < intervals; ++i) { |
552 if (IsTestServerRunning()) | 552 if (IsTestServerRunning()) |
553 return true; | 553 return true; |
554 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( | 554 base::PlatformThread::Sleep(wait / intervals); |
555 time_ms / intervals)); | |
556 } | 555 } |
557 return false; | 556 return false; |
558 } | 557 } |
559 | 558 |
560 bool SyncTest::IsTestServerRunning() { | 559 bool SyncTest::IsTestServerRunning() { |
561 CommandLine* cl = CommandLine::ForCurrentProcess(); | 560 CommandLine* cl = CommandLine::ForCurrentProcess(); |
562 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL); | 561 std::string sync_url = cl->GetSwitchValueASCII(switches::kSyncServiceURL); |
563 GURL sync_url_status(sync_url.append("/healthz")); | 562 GURL sync_url_status(sync_url.append("/healthz")); |
564 SyncServerStatusChecker delegate; | 563 SyncServerStatusChecker delegate; |
565 scoped_ptr<net::URLFetcher> fetcher(net::URLFetcher::Create( | 564 scoped_ptr<net::URLFetcher> fetcher(net::URLFetcher::Create( |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 785 |
787 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, | 786 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, |
788 const net::ProxyConfig& proxy_config) { | 787 const net::ProxyConfig& proxy_config) { |
789 base::WaitableEvent done(false, false); | 788 base::WaitableEvent done(false, false); |
790 BrowserThread::PostTask( | 789 BrowserThread::PostTask( |
791 BrowserThread::IO, FROM_HERE, | 790 BrowserThread::IO, FROM_HERE, |
792 base::Bind(&SetProxyConfigCallback, &done, | 791 base::Bind(&SetProxyConfigCallback, &done, |
793 make_scoped_refptr(context_getter), proxy_config)); | 792 make_scoped_refptr(context_getter), proxy_config)); |
794 done.Wait(); | 793 done.Wait(); |
795 } | 794 } |
OLD | NEW |