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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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_resolver_v8_tracing_unittest.cc ('k') | net/quic/quic_http_stream_test.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 "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 callback2.callback(), &request2, BoundNetLog()); 1716 callback2.callback(), &request2, BoundNetLog());
1717 EXPECT_EQ(ERR_IO_PENDING, rv); 1717 EXPECT_EQ(ERR_IO_PENDING, rv);
1718 1718
1719 // Check that nothing has been sent to the proxy resolver yet. 1719 // Check that nothing has been sent to the proxy resolver yet.
1720 ASSERT_EQ(0u, resolver->pending_requests().size()); 1720 ASSERT_EQ(0u, resolver->pending_requests().size());
1721 1721
1722 // It should be trying to auto-detect first -- FAIL the autodetect during 1722 // It should be trying to auto-detect first -- FAIL the autodetect during
1723 // the script download. 1723 // the script download.
1724 EXPECT_TRUE(fetcher->has_pending_request()); 1724 EXPECT_TRUE(fetcher->has_pending_request());
1725 EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url()); 1725 EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url());
1726 fetcher->NotifyFetchCompletion(ERR_FAILED, ""); 1726 fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
1727 1727
1728 // Next it should be trying the custom PAC url. 1728 // Next it should be trying the custom PAC url.
1729 EXPECT_TRUE(fetcher->has_pending_request()); 1729 EXPECT_TRUE(fetcher->has_pending_request());
1730 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); 1730 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
1731 fetcher->NotifyFetchCompletion(OK, kValidPacScript1); 1731 fetcher->NotifyFetchCompletion(OK, kValidPacScript1);
1732 1732
1733 EXPECT_EQ(ASCIIToUTF16(kValidPacScript1), 1733 EXPECT_EQ(ASCIIToUTF16(kValidPacScript1),
1734 resolver->pending_set_pac_script_request()->script_data()->utf16()); 1734 resolver->pending_set_pac_script_request()->script_data()->utf16());
1735 resolver->pending_set_pac_script_request()->CompleteNow(OK); 1735 resolver->pending_set_pac_script_request()->CompleteNow(OK);
1736 1736
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 rv = service.ResolveProxy(GURL("http://request2"), &info2, 1865 rv = service.ResolveProxy(GURL("http://request2"), &info2,
1866 callback2.callback(), &request2, BoundNetLog()); 1866 callback2.callback(), &request2, BoundNetLog());
1867 EXPECT_EQ(ERR_IO_PENDING, rv); 1867 EXPECT_EQ(ERR_IO_PENDING, rv);
1868 1868
1869 // Check that nothing has been sent to the proxy resolver yet. 1869 // Check that nothing has been sent to the proxy resolver yet.
1870 ASSERT_EQ(0u, resolver->pending_requests().size()); 1870 ASSERT_EQ(0u, resolver->pending_requests().size());
1871 1871
1872 // It should be trying to auto-detect first -- fail the download. 1872 // It should be trying to auto-detect first -- fail the download.
1873 EXPECT_TRUE(fetcher->has_pending_request()); 1873 EXPECT_TRUE(fetcher->has_pending_request());
1874 EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url()); 1874 EXPECT_EQ(GURL("http://wpad/wpad.dat"), fetcher->pending_request_url());
1875 fetcher->NotifyFetchCompletion(ERR_FAILED, ""); 1875 fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
1876 1876
1877 // Next it should be trying the custom PAC url -- fail the download. 1877 // Next it should be trying the custom PAC url -- fail the download.
1878 EXPECT_TRUE(fetcher->has_pending_request()); 1878 EXPECT_TRUE(fetcher->has_pending_request());
1879 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); 1879 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
1880 fetcher->NotifyFetchCompletion(ERR_FAILED, ""); 1880 fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
1881 1881
1882 // Since we never managed to initialize a ProxyResolver, nothing should have 1882 // Since we never managed to initialize a ProxyResolver, nothing should have
1883 // been sent to it. 1883 // been sent to it.
1884 ASSERT_EQ(0u, resolver->pending_requests().size()); 1884 ASSERT_EQ(0u, resolver->pending_requests().size());
1885 1885
1886 // Verify that requests ran as expected -- they should have fallen back to 1886 // Verify that requests ran as expected -- they should have fallen back to
1887 // the manual proxy configuration for HTTP urls. 1887 // the manual proxy configuration for HTTP urls.
1888 EXPECT_EQ(OK, callback1.WaitForResult()); 1888 EXPECT_EQ(OK, callback1.WaitForResult());
1889 EXPECT_EQ("foopy:80", info1.proxy_server().ToURI()); 1889 EXPECT_EQ("foopy:80", info1.proxy_server().ToURI());
1890 1890
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 2244
2245 // Nothing has been sent to the resolver yet. 2245 // Nothing has been sent to the resolver yet.
2246 EXPECT_TRUE(resolver->pending_requests().empty()); 2246 EXPECT_TRUE(resolver->pending_requests().empty());
2247 2247
2248 // At this point the ProxyService should be waiting for the 2248 // At this point the ProxyService should be waiting for the
2249 // ProxyScriptFetcher to invoke its completion callback, notifying it of 2249 // ProxyScriptFetcher to invoke its completion callback, notifying it of
2250 // PAC script download completion. 2250 // PAC script download completion.
2251 // 2251 //
2252 // We simulate a failed download attempt, the proxy service should now 2252 // We simulate a failed download attempt, the proxy service should now
2253 // fall-back to DIRECT connections. 2253 // fall-back to DIRECT connections.
2254 fetcher->NotifyFetchCompletion(ERR_FAILED, ""); 2254 fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
2255 2255
2256 ASSERT_TRUE(resolver->pending_requests().empty()); 2256 ASSERT_TRUE(resolver->pending_requests().empty());
2257 2257
2258 // Wait for completion callback, and verify it used DIRECT. 2258 // Wait for completion callback, and verify it used DIRECT.
2259 EXPECT_EQ(OK, callback1.WaitForResult()); 2259 EXPECT_EQ(OK, callback1.WaitForResult());
2260 EXPECT_TRUE(info1.is_direct()); 2260 EXPECT_TRUE(info1.is_direct());
2261 2261
2262 // At this point we have initialized the proxy service using a PAC script, 2262 // At this point we have initialized the proxy service using a PAC script,
2263 // however it failed and fell-back to DIRECT. 2263 // however it failed and fell-back to DIRECT.
2264 // 2264 //
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 // special unit-test mode. 2597 // special unit-test mode.
2598 fetcher->WaitUntilFetch(); 2598 fetcher->WaitUntilFetch();
2599 2599
2600 ASSERT_TRUE(resolver->pending_requests().empty()); 2600 ASSERT_TRUE(resolver->pending_requests().empty());
2601 2601
2602 // Make sure that our background checker is trying to download the expected 2602 // Make sure that our background checker is trying to download the expected
2603 // PAC script (same one as before). This time we will simulate a failure 2603 // PAC script (same one as before). This time we will simulate a failure
2604 // to download the script. 2604 // to download the script.
2605 EXPECT_TRUE(fetcher->has_pending_request()); 2605 EXPECT_TRUE(fetcher->has_pending_request());
2606 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); 2606 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
2607 fetcher->NotifyFetchCompletion(ERR_FAILED, ""); 2607 fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
2608 2608
2609 MessageLoop::current()->RunUntilIdle(); 2609 MessageLoop::current()->RunUntilIdle();
2610 2610
2611 // At this point the ProxyService should have re-configured itself to use 2611 // At this point the ProxyService should have re-configured itself to use
2612 // DIRECT connections rather than the given proxy resolver. 2612 // DIRECT connections rather than the given proxy resolver.
2613 2613
2614 // Start a second request. 2614 // Start a second request.
2615 ProxyInfo info2; 2615 ProxyInfo info2;
2616 TestCompletionCallback callback2; 2616 TestCompletionCallback callback2;
2617 rv = service.ResolveProxy( 2617 rv = service.ResolveProxy(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 EXPECT_EQ(OK, callback2.WaitForResult()); 2764 EXPECT_EQ(OK, callback2.WaitForResult());
2765 EXPECT_EQ("request2:80", info2.proxy_server().ToURI()); 2765 EXPECT_EQ("request2:80", info2.proxy_server().ToURI());
2766 2766
2767 // In response to getting that resolve request, the poller should have 2767 // In response to getting that resolve request, the poller should have
2768 // started the next poll, and made it as far as to request the download. 2768 // started the next poll, and made it as far as to request the download.
2769 2769
2770 EXPECT_TRUE(fetcher->has_pending_request()); 2770 EXPECT_TRUE(fetcher->has_pending_request());
2771 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); 2771 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url());
2772 2772
2773 // This time we will fail the download, to simulate a PAC script change. 2773 // This time we will fail the download, to simulate a PAC script change.
2774 fetcher->NotifyFetchCompletion(ERR_FAILED, ""); 2774 fetcher->NotifyFetchCompletion(ERR_FAILED, std::string());
2775 2775
2776 // Drain the message loop, so ProxyService is notified of the change 2776 // Drain the message loop, so ProxyService is notified of the change
2777 // and has a chance to re-configure itself. 2777 // and has a chance to re-configure itself.
2778 MessageLoop::current()->RunUntilIdle(); 2778 MessageLoop::current()->RunUntilIdle();
2779 2779
2780 // Start a third request -- this time we expect to get a direct connection 2780 // Start a third request -- this time we expect to get a direct connection
2781 // since the PAC script poller experienced a failure. 2781 // since the PAC script poller experienced a failure.
2782 ProxyInfo info3; 2782 ProxyInfo info3;
2783 TestCompletionCallback callback3; 2783 TestCompletionCallback callback3;
2784 rv = service.ResolveProxy( 2784 rv = service.ResolveProxy(
2785 GURL("http://request3"), &info3, callback3.callback(), NULL, 2785 GURL("http://request3"), &info3, callback3.callback(), NULL,
2786 BoundNetLog()); 2786 BoundNetLog());
2787 EXPECT_EQ(OK, rv); 2787 EXPECT_EQ(OK, rv);
2788 EXPECT_TRUE(info3.is_direct()); 2788 EXPECT_TRUE(info3.is_direct());
2789 } 2789 }
2790 2790
2791 } // namespace net 2791 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8_tracing_unittest.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698