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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 config_.set_pac_url(GURL(kCustomUrl)); | 421 config_.set_pac_url(GURL(kCustomUrl)); |
422 Rules::Rule rule = rules_.AddSuccessRule(kCustomUrl); | 422 Rules::Rule rule = rules_.AddSuccessRule(kCustomUrl); |
423 resolver_.rules()->AddSimulatedFailure("wpad"); | 423 resolver_.rules()->AddSimulatedFailure("wpad"); |
424 resolver_.rules()->AddRule("custom", "1.2.3.4"); | 424 resolver_.rules()->AddRule("custom", "1.2.3.4"); |
425 EXPECT_EQ(ERR_IO_PENDING, StartDecider()); | 425 EXPECT_EQ(ERR_IO_PENDING, StartDecider()); |
426 callback_.WaitForResult(); | 426 callback_.WaitForResult(); |
427 EXPECT_TRUE(decider_->effective_config().has_pac_url()); | 427 EXPECT_TRUE(decider_->effective_config().has_pac_url()); |
428 EXPECT_EQ(rule.url, decider_->effective_config().pac_url()); | 428 EXPECT_EQ(rule.url, decider_->effective_config().pac_url()); |
429 } | 429 } |
430 | 430 |
| 431 // Regression test for http://crbug.com/409698. |
| 432 // This test lets the state machine get into state QUICK_CHECK_COMPLETE, then |
| 433 // destroys the decider, causing a cancel. |
| 434 TEST_F(ProxyScriptDeciderQuickCheckTest, CancelPartway) { |
| 435 resolver_.set_synchronous_mode(false); |
| 436 resolver_.set_ondemand_mode(true); |
| 437 EXPECT_EQ(ERR_IO_PENDING, StartDecider()); |
| 438 decider_.reset(NULL); |
| 439 } |
| 440 |
431 // Fails at WPAD (downloading), but succeeds in choosing the custom PAC. | 441 // Fails at WPAD (downloading), but succeeds in choosing the custom PAC. |
432 TEST(ProxyScriptDeciderTest, AutodetectFailCustomSuccess1) { | 442 TEST(ProxyScriptDeciderTest, AutodetectFailCustomSuccess1) { |
433 Rules rules; | 443 Rules rules; |
434 RuleBasedProxyScriptFetcher fetcher(&rules); | 444 RuleBasedProxyScriptFetcher fetcher(&rules); |
435 DoNothingDhcpProxyScriptFetcher dhcp_fetcher; | 445 DoNothingDhcpProxyScriptFetcher dhcp_fetcher; |
436 | 446 |
437 ProxyConfig config; | 447 ProxyConfig config; |
438 config.set_auto_detect(true); | 448 config.set_auto_detect(true); |
439 config.set_pac_url(GURL("http://custom/proxy.pac")); | 449 config.set_pac_url(GURL("http://custom/proxy.pac")); |
440 | 450 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 | 778 |
769 // Run the message loop to let the DHCP fetch complete and post the results | 779 // Run the message loop to let the DHCP fetch complete and post the results |
770 // back. Before the fix linked to above, this would try to invoke on | 780 // back. Before the fix linked to above, this would try to invoke on |
771 // the callback object provided by ProxyScriptDecider after it was | 781 // the callback object provided by ProxyScriptDecider after it was |
772 // no longer valid. | 782 // no longer valid. |
773 base::MessageLoop::current()->RunUntilIdle(); | 783 base::MessageLoop::current()->RunUntilIdle(); |
774 } | 784 } |
775 | 785 |
776 } // namespace | 786 } // namespace |
777 } // namespace net | 787 } // namespace net |
OLD | NEW |