Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: net/proxy/proxy_script_decider_unittest.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_script_decider.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 public: 37 public:
38 struct Rule { 38 struct Rule {
39 Rule(const GURL& url, int fetch_error, bool is_valid_script) 39 Rule(const GURL& url, int fetch_error, bool is_valid_script)
40 : url(url), 40 : url(url),
41 fetch_error(fetch_error), 41 fetch_error(fetch_error),
42 is_valid_script(is_valid_script) { 42 is_valid_script(is_valid_script) {
43 } 43 }
44 44
45 base::string16 text() const { 45 base::string16 text() const {
46 if (is_valid_script) 46 if (is_valid_script)
47 return UTF8ToUTF16(url.spec() + "!FindProxyForURL"); 47 return base::UTF8ToUTF16(url.spec() + "!FindProxyForURL");
48 if (fetch_error == OK) 48 if (fetch_error == OK)
49 return UTF8ToUTF16(url.spec() + "!invalid-script"); 49 return base::UTF8ToUTF16(url.spec() + "!invalid-script");
50 return base::string16(); 50 return base::string16();
51 } 51 }
52 52
53 GURL url; 53 GURL url;
54 int fetch_error; 54 int fetch_error;
55 bool is_valid_script; 55 bool is_valid_script;
56 }; 56 };
57 57
58 Rule AddSuccessRule(const char* url) { 58 Rule AddSuccessRule(const char* url) {
59 Rule rule(GURL(url), OK /*fetch_error*/, true); 59 Rule rule(GURL(url), OK /*fetch_error*/, true);
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 668
669 // All of the tests above that use ProxyScriptDecider have tested 669 // All of the tests above that use ProxyScriptDecider have tested
670 // failure to fetch a PAC file via DHCP configuration, so we now test 670 // failure to fetch a PAC file via DHCP configuration, so we now test
671 // success at downloading and parsing, and then success at downloading, 671 // success at downloading and parsing, and then success at downloading,
672 // failure at parsing. 672 // failure at parsing.
673 673
674 TEST(ProxyScriptDeciderTest, AutodetectDhcpSuccess) { 674 TEST(ProxyScriptDeciderTest, AutodetectDhcpSuccess) {
675 Rules rules; 675 Rules rules;
676 RuleBasedProxyScriptFetcher fetcher(&rules); 676 RuleBasedProxyScriptFetcher fetcher(&rules);
677 SynchronousSuccessDhcpFetcher dhcp_fetcher( 677 SynchronousSuccessDhcpFetcher dhcp_fetcher(
678 WideToUTF16(L"http://bingo/!FindProxyForURL")); 678 base::WideToUTF16(L"http://bingo/!FindProxyForURL"));
679 679
680 ProxyConfig config; 680 ProxyConfig config;
681 config.set_auto_detect(true); 681 config.set_auto_detect(true);
682 682
683 rules.AddSuccessRule("http://bingo/"); 683 rules.AddSuccessRule("http://bingo/");
684 rules.AddFailDownloadRule("http://wpad/wpad.dat"); 684 rules.AddFailDownloadRule("http://wpad/wpad.dat");
685 685
686 TestCompletionCallback callback; 686 TestCompletionCallback callback;
687 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL); 687 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
688 EXPECT_EQ(OK, decider.Start( 688 EXPECT_EQ(OK, decider.Start(
689 config, base::TimeDelta(), true, callback.callback())); 689 config, base::TimeDelta(), true, callback.callback()));
690 EXPECT_EQ(dhcp_fetcher.expected_text(), 690 EXPECT_EQ(dhcp_fetcher.expected_text(),
691 decider.script_data()->utf16()); 691 decider.script_data()->utf16());
692 692
693 EXPECT_TRUE(decider.effective_config().has_pac_url()); 693 EXPECT_TRUE(decider.effective_config().has_pac_url());
694 EXPECT_EQ(GURL("http://dhcppac/"), decider.effective_config().pac_url()); 694 EXPECT_EQ(GURL("http://dhcppac/"), decider.effective_config().pac_url());
695 } 695 }
696 696
697 TEST(ProxyScriptDeciderTest, AutodetectDhcpFailParse) { 697 TEST(ProxyScriptDeciderTest, AutodetectDhcpFailParse) {
698 Rules rules; 698 Rules rules;
699 RuleBasedProxyScriptFetcher fetcher(&rules); 699 RuleBasedProxyScriptFetcher fetcher(&rules);
700 SynchronousSuccessDhcpFetcher dhcp_fetcher( 700 SynchronousSuccessDhcpFetcher dhcp_fetcher(
701 WideToUTF16(L"http://bingo/!invalid-script")); 701 base::WideToUTF16(L"http://bingo/!invalid-script"));
702 702
703 ProxyConfig config; 703 ProxyConfig config;
704 config.set_auto_detect(true); 704 config.set_auto_detect(true);
705 705
706 rules.AddFailParsingRule("http://bingo/"); 706 rules.AddFailParsingRule("http://bingo/");
707 rules.AddFailDownloadRule("http://wpad/wpad.dat"); 707 rules.AddFailDownloadRule("http://wpad/wpad.dat");
708 708
709 TestCompletionCallback callback; 709 TestCompletionCallback callback;
710 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL); 710 ProxyScriptDecider decider(&fetcher, &dhcp_fetcher, NULL);
711 // Since there is fallback to DNS-based WPAD, the final error will be that 711 // Since there is fallback to DNS-based WPAD, the final error will be that
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 775
776 // Run the message loop to let the DHCP fetch complete and post the results 776 // Run the message loop to let the DHCP fetch complete and post the results
777 // back. Before the fix linked to above, this would try to invoke on 777 // back. Before the fix linked to above, this would try to invoke on
778 // the callback object provided by ProxyScriptDecider after it was 778 // the callback object provided by ProxyScriptDecider after it was
779 // no longer valid. 779 // no longer valid.
780 base::MessageLoop::current()->RunUntilIdle(); 780 base::MessageLoop::current()->RunUntilIdle();
781 } 781 }
782 782
783 } // namespace 783 } // namespace
784 } // namespace net 784 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_decider.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698