| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h" |
| 6 | 6 |
| 7 #include "base/perftimer.h" | 7 #include "base/perftimer.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 : url_request_context_(new TestURLRequestContext()), | 134 : url_request_context_(new TestURLRequestContext()), |
| 135 fetcher_( | 135 fetcher_( |
| 136 new MockDhcpProxyScriptAdapterFetcher(url_request_context_.get())) { | 136 new MockDhcpProxyScriptAdapterFetcher(url_request_context_.get())) { |
| 137 } | 137 } |
| 138 | 138 |
| 139 void WaitForResult(int expected_error) { | 139 void WaitForResult(int expected_error) { |
| 140 EXPECT_EQ(expected_error, callback_.WaitForResult()); | 140 EXPECT_EQ(expected_error, callback_.WaitForResult()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void RunTest() { | 143 void RunTest() { |
| 144 fetcher_->Fetch("adapter name", &callback_); | 144 fetcher_->Fetch("adapter name", callback_.callback()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void FinishTestAllowCleanup() { | 147 void FinishTestAllowCleanup() { |
| 148 fetcher_->FinishTest(); | 148 fetcher_->FinishTest(); |
| 149 MessageLoop::current()->RunAllPending(); | 149 MessageLoop::current()->RunAllPending(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TestOldCompletionCallback callback_; | 152 TestCompletionCallback callback_; |
| 153 scoped_refptr<URLRequestContext> url_request_context_; | 153 scoped_refptr<URLRequestContext> url_request_context_; |
| 154 scoped_ptr<MockDhcpProxyScriptAdapterFetcher> fetcher_; | 154 scoped_ptr<MockDhcpProxyScriptAdapterFetcher> fetcher_; |
| 155 string16 pac_text_; | 155 string16 pac_text_; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 TEST(DhcpProxyScriptAdapterFetcher, NormalCaseURLNotInDhcp) { | 158 TEST(DhcpProxyScriptAdapterFetcher, NormalCaseURLNotInDhcp) { |
| 159 FetcherClient client; | 159 FetcherClient client; |
| 160 client.fetcher_->configured_url_ = ""; | 160 client.fetcher_->configured_url_ = ""; |
| 161 client.RunTest(); | 161 client.RunTest(); |
| 162 client.WaitForResult(ERR_PAC_NOT_IN_DHCP); | 162 client.WaitForResult(ERR_PAC_NOT_IN_DHCP); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 ASSERT_TRUE(client.fetcher_->DidFinish()); | 288 ASSERT_TRUE(client.fetcher_->DidFinish()); |
| 289 EXPECT_EQ(OK, client.fetcher_->GetResult()); | 289 EXPECT_EQ(OK, client.fetcher_->GetResult()); |
| 290 EXPECT_EQ(string16(L"-downloadable.pac-\n"), client.fetcher_->GetPacScript()); | 290 EXPECT_EQ(string16(L"-downloadable.pac-\n"), client.fetcher_->GetPacScript()); |
| 291 EXPECT_EQ(configured_url, | 291 EXPECT_EQ(configured_url, |
| 292 client.fetcher_->GetPacURL()); | 292 client.fetcher_->GetPacURL()); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace | 295 } // namespace |
| 296 | 296 |
| 297 } // namespace net | 297 } // namespace net |
| OLD | NEW |