| Index: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
|
| diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
|
| index 743fb263fdd07b2eb7d44f2d4367342624b66c52..5f421a33eb91449fe5acdb2fcf2796928b243c76 100644
|
| --- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
|
| +++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
|
| @@ -54,7 +54,9 @@ class RealFetchTester {
|
| on_completion_is_error_(false) {
|
| // Make sure the test ends.
|
| timeout_.Start(FROM_HERE,
|
| - base::TimeDelta::FromSeconds(5), this, &RealFetchTester::OnTimeout);
|
| + base::TimeDelta::FromSeconds(5),
|
| + this,
|
| + &RealFetchTester::OnTimeout);
|
| }
|
|
|
| void RunTest() {
|
| @@ -74,8 +76,10 @@ class RealFetchTester {
|
| // Put the cancellation into the queue before even running the
|
| // test to avoid the chance of one of the adapter fetcher worker
|
| // threads completing before cancellation. See http://crbug.com/86756.
|
| - cancel_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(0),
|
| - this, &RealFetchTester::OnCancelTimer);
|
| + cancel_timer_.Start(FROM_HERE,
|
| + base::TimeDelta::FromMilliseconds(0),
|
| + this,
|
| + &RealFetchTester::OnCancelTimer);
|
| RunTest();
|
| }
|
|
|
| @@ -135,7 +139,7 @@ TEST(DhcpProxyScriptFetcherWin, RealFetch) {
|
|
|
| fetcher.WaitUntilDone();
|
| printf("PAC URL was %s\n",
|
| - fetcher.fetcher_->GetPacURL().possibly_invalid_spec().c_str());
|
| + fetcher.fetcher_->GetPacURL().possibly_invalid_spec().c_str());
|
|
|
| fetcher.FinishTestAllowCleanup();
|
| }
|
| @@ -159,14 +163,11 @@ class DelayingDhcpProxyScriptAdapterFetcher
|
| DelayingDhcpProxyScriptAdapterFetcher(
|
| URLRequestContext* url_request_context,
|
| scoped_refptr<base::TaskRunner> task_runner)
|
| - : DhcpProxyScriptAdapterFetcher(url_request_context, task_runner) {
|
| - }
|
| + : DhcpProxyScriptAdapterFetcher(url_request_context, task_runner) {}
|
|
|
| class DelayingDhcpQuery : public DhcpQuery {
|
| public:
|
| - explicit DelayingDhcpQuery()
|
| - : DhcpQuery() {
|
| - }
|
| + explicit DelayingDhcpQuery() : DhcpQuery() {}
|
|
|
| std::string ImplGetPacURLFromDhcp(
|
| const std::string& adapter_name) OVERRIDE {
|
| @@ -175,19 +176,14 @@ class DelayingDhcpProxyScriptAdapterFetcher
|
| }
|
| };
|
|
|
| - DhcpQuery* ImplCreateDhcpQuery() OVERRIDE {
|
| - return new DelayingDhcpQuery();
|
| - }
|
| + DhcpQuery* ImplCreateDhcpQuery() OVERRIDE { return new DelayingDhcpQuery(); }
|
| };
|
|
|
| // For RealFetchWithDeferredCancel, below.
|
| -class DelayingDhcpProxyScriptFetcherWin
|
| - : public DhcpProxyScriptFetcherWin {
|
| +class DelayingDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
|
| public:
|
| - explicit DelayingDhcpProxyScriptFetcherWin(
|
| - URLRequestContext* context)
|
| - : DhcpProxyScriptFetcherWin(context) {
|
| - }
|
| + explicit DelayingDhcpProxyScriptFetcherWin(URLRequestContext* context)
|
| + : DhcpProxyScriptFetcherWin(context) {}
|
|
|
| DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher() OVERRIDE {
|
| return new DelayingDhcpProxyScriptAdapterFetcher(url_request_context(),
|
| @@ -220,35 +216,26 @@ class DummyDhcpProxyScriptAdapterFetcher
|
| did_finish_(false),
|
| result_(OK),
|
| pac_script_(L"bingo"),
|
| - fetch_delay_ms_(1) {
|
| - }
|
| + fetch_delay_ms_(1) {}
|
|
|
| void Fetch(const std::string& adapter_name,
|
| const CompletionCallback& callback) OVERRIDE {
|
| callback_ = callback;
|
| - timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(fetch_delay_ms_),
|
| - this, &DummyDhcpProxyScriptAdapterFetcher::OnTimer);
|
| + timer_.Start(FROM_HERE,
|
| + base::TimeDelta::FromMilliseconds(fetch_delay_ms_),
|
| + this,
|
| + &DummyDhcpProxyScriptAdapterFetcher::OnTimer);
|
| }
|
|
|
| - void Cancel() OVERRIDE {
|
| - timer_.Stop();
|
| - }
|
| + void Cancel() OVERRIDE { timer_.Stop(); }
|
|
|
| - bool DidFinish() const OVERRIDE {
|
| - return did_finish_;
|
| - }
|
| + bool DidFinish() const OVERRIDE { return did_finish_; }
|
|
|
| - int GetResult() const OVERRIDE {
|
| - return result_;
|
| - }
|
| + int GetResult() const OVERRIDE { return result_; }
|
|
|
| - base::string16 GetPacScript() const OVERRIDE {
|
| - return pac_script_;
|
| - }
|
| + base::string16 GetPacScript() const OVERRIDE { return pac_script_; }
|
|
|
| - void OnTimer() {
|
| - callback_.Run(result_);
|
| - }
|
| + void OnTimer() { callback_.Run(result_); }
|
|
|
| void Configure(bool did_finish,
|
| int result,
|
| @@ -273,16 +260,14 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
|
| public:
|
| class MockAdapterQuery : public AdapterQuery {
|
| public:
|
| - MockAdapterQuery() {
|
| - }
|
| + MockAdapterQuery() {}
|
|
|
| - virtual ~MockAdapterQuery() {
|
| - }
|
| + virtual ~MockAdapterQuery() {}
|
|
|
| virtual bool ImplGetCandidateAdapterNames(
|
| std::set<std::string>* adapter_names) OVERRIDE {
|
| - adapter_names->insert(
|
| - mock_adapter_names_.begin(), mock_adapter_names_.end());
|
| + adapter_names->insert(mock_adapter_names_.begin(),
|
| + mock_adapter_names_.end());
|
| return true;
|
| }
|
|
|
| @@ -296,9 +281,7 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
|
| ResetTestState();
|
| }
|
|
|
| - virtual ~MockDhcpProxyScriptFetcherWin() {
|
| - ResetTestState();
|
| - }
|
| + virtual ~MockDhcpProxyScriptFetcherWin() { ResetTestState(); }
|
|
|
| using DhcpProxyScriptFetcherWin::GetTaskRunner;
|
|
|
| @@ -334,9 +317,7 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
|
| return adapter_query_.get();
|
| }
|
|
|
| - base::TimeDelta ImplGetMaxWait() OVERRIDE {
|
| - return max_wait_;
|
| - }
|
| + base::TimeDelta ImplGetMaxWait() OVERRIDE { return max_wait_; }
|
|
|
| void ImplOnGetCandidateAdapterNamesDone() OVERRIDE {
|
| worker_finished_event_.Signal();
|
| @@ -344,8 +325,8 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
|
|
|
| void ResetTestState() {
|
| // Delete any adapter fetcher objects we didn't hand out.
|
| - std::vector<DhcpProxyScriptAdapterFetcher*>::const_iterator it
|
| - = adapter_fetchers_.begin();
|
| + std::vector<DhcpProxyScriptAdapterFetcher*>::const_iterator it =
|
| + adapter_fetchers_.begin();
|
| for (; it != adapter_fetchers_.end(); ++it) {
|
| if (num_fetchers_created_-- <= 0) {
|
| delete (*it);
|
| @@ -359,9 +340,7 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
|
| max_wait_ = TestTimeouts::tiny_timeout();
|
| }
|
|
|
| - bool HasPendingFetchers() {
|
| - return num_pending_fetchers() > 0;
|
| - }
|
| + bool HasPendingFetchers() { return num_pending_fetchers() > 0; }
|
|
|
| int next_adapter_fetcher_index_;
|
|
|
| @@ -383,8 +362,7 @@ class FetcherClient {
|
| : context_(new TestURLRequestContext),
|
| fetcher_(context_.get()),
|
| finished_(false),
|
| - result_(ERR_UNEXPECTED) {
|
| - }
|
| + result_(ERR_UNEXPECTED) {}
|
|
|
| void RunTest() {
|
| int result = fetcher_.Fetch(
|
| @@ -453,7 +431,10 @@ TEST(DhcpProxyScriptFetcherWin, NormalCaseURLConfiguredOneAdapter) {
|
|
|
| void TestNormalCaseURLConfiguredMultipleAdapters(FetcherClient* client) {
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
|
| + "most_preferred",
|
| + true,
|
| + ERR_PAC_NOT_IN_DHCP,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| "second", true, OK, L"bingo", base::TimeDelta::FromMilliseconds(50));
|
| @@ -473,12 +454,17 @@ TEST(DhcpProxyScriptFetcherWin, NormalCaseURLConfiguredMultipleAdapters) {
|
| void TestNormalCaseURLConfiguredMultipleAdaptersWithTimeout(
|
| FetcherClient* client) {
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
|
| + "most_preferred",
|
| + true,
|
| + ERR_PAC_NOT_IN_DHCP,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| // This will time out.
|
| - client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "second", false, ERR_IO_PENDING, L"bingo",
|
| - TestTimeouts::action_timeout());
|
| + client->fetcher_.ConfigureAndPushBackAdapter("second",
|
| + false,
|
| + ERR_IO_PENDING,
|
| + L"bingo",
|
| + TestTimeouts::action_timeout());
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| "third", true, OK, L"rocko", base::TimeDelta::FromMilliseconds(1));
|
| client->RunTest();
|
| @@ -496,19 +482,30 @@ TEST(DhcpProxyScriptFetcherWin,
|
| void TestFailureCaseURLConfiguredMultipleAdaptersWithTimeout(
|
| FetcherClient* client) {
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
|
| + "most_preferred",
|
| + true,
|
| + ERR_PAC_NOT_IN_DHCP,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| // This will time out.
|
| - client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "second", false, ERR_IO_PENDING, L"bingo",
|
| - TestTimeouts::action_timeout());
|
| + client->fetcher_.ConfigureAndPushBackAdapter("second",
|
| + false,
|
| + ERR_IO_PENDING,
|
| + L"bingo",
|
| + TestTimeouts::action_timeout());
|
| // This is the first non-ERR_PAC_NOT_IN_DHCP error and as such
|
| // should be chosen.
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "third", true, ERR_PAC_STATUS_NOT_OK, L"",
|
| + "third",
|
| + true,
|
| + ERR_PAC_STATUS_NOT_OK,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "fourth", true, ERR_NOT_IMPLEMENTED, L"",
|
| + "fourth",
|
| + true,
|
| + ERR_NOT_IMPLEMENTED,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| client->RunTest();
|
| client->RunMessageLoopUntilComplete();
|
| @@ -524,16 +521,24 @@ TEST(DhcpProxyScriptFetcherWin,
|
|
|
| void TestFailureCaseNoURLConfigured(FetcherClient* client) {
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
|
| + "most_preferred",
|
| + true,
|
| + ERR_PAC_NOT_IN_DHCP,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| // This will time out.
|
| - client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "second", false, ERR_IO_PENDING, L"bingo",
|
| - TestTimeouts::action_timeout());
|
| + client->fetcher_.ConfigureAndPushBackAdapter("second",
|
| + false,
|
| + ERR_IO_PENDING,
|
| + L"bingo",
|
| + TestTimeouts::action_timeout());
|
| // This is the first non-ERR_PAC_NOT_IN_DHCP error and as such
|
| // should be chosen.
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "third", true, ERR_PAC_NOT_IN_DHCP, L"",
|
| + "third",
|
| + true,
|
| + ERR_PAC_NOT_IN_DHCP,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| client->RunTest();
|
| client->RunMessageLoopUntilComplete();
|
| @@ -565,11 +570,13 @@ void TestShortCircuitLessPreferredAdapters(FetcherClient* client) {
|
| // time. Verify that we complete quickly and do not wait for the slow
|
| // adapters, i.e. we finish before timeout.
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "1", true, ERR_PAC_NOT_IN_DHCP, L"",
|
| + "1",
|
| + true,
|
| + ERR_PAC_NOT_IN_DHCP,
|
| + L"",
|
| base::TimeDelta::FromMilliseconds(1));
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| - "2", true, OK, L"bingo",
|
| - base::TimeDelta::FromMilliseconds(1));
|
| + "2", true, OK, L"bingo", base::TimeDelta::FromMilliseconds(1));
|
| client->fetcher_.ConfigureAndPushBackAdapter(
|
| "3", true, OK, L"wrongo", TestTimeouts::action_max_timeout());
|
|
|
| @@ -636,9 +643,8 @@ TEST(DhcpProxyScriptFetcherWin, ReuseFetcher) {
|
| test_functions.push_back(TestShortCircuitLessPreferredAdapters);
|
| test_functions.push_back(TestImmediateCancel);
|
|
|
| - std::random_shuffle(test_functions.begin(),
|
| - test_functions.end(),
|
| - base::RandGenerator);
|
| + std::random_shuffle(
|
| + test_functions.begin(), test_functions.end(), base::RandGenerator);
|
| for (TestVector::const_iterator it = test_functions.begin();
|
| it != test_functions.end();
|
| ++it) {
|
|
|