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 "net/proxy/dhcp_proxy_script_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // do something a bit more clever to track worker threads even when the | 105 // do something a bit more clever to track worker threads even when the |
106 // DhcpProxyScriptFetcherWin state machine has finished. | 106 // DhcpProxyScriptFetcherWin state machine has finished. |
107 void FinishTestAllowCleanup() { | 107 void FinishTestAllowCleanup() { |
108 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30)); | 108 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30)); |
109 } | 109 } |
110 | 110 |
111 scoped_ptr<URLRequestContext> context_; | 111 scoped_ptr<URLRequestContext> context_; |
112 scoped_ptr<DhcpProxyScriptFetcherWin> fetcher_; | 112 scoped_ptr<DhcpProxyScriptFetcherWin> fetcher_; |
113 bool finished_; | 113 bool finished_; |
114 base::string16 pac_text_; | 114 base::string16 pac_text_; |
115 base::OneShotTimer<RealFetchTester> timeout_; | 115 base::OneShotTimer timeout_; |
116 base::OneShotTimer<RealFetchTester> cancel_timer_; | 116 base::OneShotTimer cancel_timer_; |
117 bool on_completion_is_error_; | 117 bool on_completion_is_error_; |
118 }; | 118 }; |
119 | 119 |
120 TEST(DhcpProxyScriptFetcherWin, RealFetch) { | 120 TEST(DhcpProxyScriptFetcherWin, RealFetch) { |
121 // This tests a call to Fetch() with no stubbing out of dependencies. | 121 // This tests a call to Fetch() with no stubbing out of dependencies. |
122 // | 122 // |
123 // We don't make assumptions about the environment this unit test is | 123 // We don't make assumptions about the environment this unit test is |
124 // running in, so it just exercises the code to make sure there | 124 // running in, so it just exercises the code to make sure there |
125 // is no crash and no unexpected error returned, but does not assert on | 125 // is no crash and no unexpected error returned, but does not assert on |
126 // results beyond that. | 126 // results beyond that. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 pac_script_ = pac_script; | 253 pac_script_ = pac_script; |
254 fetch_delay_ms_ = fetch_delay_ms; | 254 fetch_delay_ms_ = fetch_delay_ms; |
255 } | 255 } |
256 | 256 |
257 private: | 257 private: |
258 bool did_finish_; | 258 bool did_finish_; |
259 int result_; | 259 int result_; |
260 base::string16 pac_script_; | 260 base::string16 pac_script_; |
261 int fetch_delay_ms_; | 261 int fetch_delay_ms_; |
262 CompletionCallback callback_; | 262 CompletionCallback callback_; |
263 base::OneShotTimer<DummyDhcpProxyScriptAdapterFetcher> timer_; | 263 base::OneShotTimer timer_; |
264 }; | 264 }; |
265 | 265 |
266 class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin { | 266 class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin { |
267 public: | 267 public: |
268 class MockAdapterQuery : public AdapterQuery { | 268 class MockAdapterQuery : public AdapterQuery { |
269 public: | 269 public: |
270 MockAdapterQuery() { | 270 MockAdapterQuery() { |
271 } | 271 } |
272 | 272 |
273 bool ImplGetCandidateAdapterNames( | 273 bool ImplGetCandidateAdapterNames( |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } | 639 } |
640 | 640 |
641 // Re-do the first test to make sure the last test that was run did | 641 // Re-do the first test to make sure the last test that was run did |
642 // not leave things in a bad state. | 642 // not leave things in a bad state. |
643 (*test_functions.begin())(&client); | 643 (*test_functions.begin())(&client); |
644 } | 644 } |
645 | 645 |
646 } // namespace | 646 } // namespace |
647 | 647 |
648 } // namespace net | 648 } // namespace net |
OLD | NEW |