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/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 3667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3678 EXPECT_EQ( | 3678 EXPECT_EQ( |
3679 GURL(test.sanitized_url_unstripped), | 3679 GURL(test.sanitized_url_unstripped), |
3680 helper.SanitizeUrl(raw_url, ProxyService::SanitizeUrlPolicy::UNSAFE)); | 3680 helper.SanitizeUrl(raw_url, ProxyService::SanitizeUrlPolicy::UNSAFE)); |
3681 | 3681 |
3682 EXPECT_EQ( | 3682 EXPECT_EQ( |
3683 GURL(test.sanitized_url), | 3683 GURL(test.sanitized_url), |
3684 helper.SanitizeUrl(raw_url, ProxyService::SanitizeUrlPolicy::SAFE)); | 3684 helper.SanitizeUrl(raw_url, ProxyService::SanitizeUrlPolicy::SAFE)); |
3685 } | 3685 } |
3686 } | 3686 } |
3687 | 3687 |
3688 TEST_F(ProxyServiceTest, OnShutdownWithLiveRequest) { | |
mmenke
2017/05/01 16:52:14
The tests don't test all paths - this one depends
| |
3689 MockProxyConfigService* config_service = | |
3690 new MockProxyConfigService("http://foopy/proxy.pac"); | |
3691 | |
3692 MockAsyncProxyResolver resolver; | |
3693 MockAsyncProxyResolverFactory* factory = | |
3694 new MockAsyncProxyResolverFactory(true); | |
3695 | |
3696 ProxyService service(base::WrapUnique(config_service), | |
3697 base::WrapUnique(factory), nullptr); | |
3698 | |
3699 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; | |
3700 service.SetProxyScriptFetchers( | |
3701 fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher())); | |
3702 | |
3703 ProxyInfo info; | |
3704 TestCompletionCallback callback; | |
3705 ProxyService::PacRequest* request; | |
3706 int rv = service.ResolveProxy(GURL("http://request/"), std::string(), &info, | |
3707 callback.callback(), &request, nullptr, | |
3708 NetLogWithSource()); | |
3709 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | |
3710 | |
3711 // The first request should have triggered download of PAC script. | |
3712 EXPECT_TRUE(fetcher->has_pending_request()); | |
3713 EXPECT_EQ(GURL("http://foopy/proxy.pac"), fetcher->pending_request_url()); | |
3714 | |
3715 service.OnShutdown(); | |
3716 EXPECT_THAT(callback.WaitForResult(), IsOk()); | |
3717 EXPECT_FALSE(fetcher->has_pending_request()); | |
3718 EXPECT_TRUE(info.is_direct()); | |
3719 } | |
3720 | |
3721 TEST_F(ProxyServiceTest, OnShutdownFollowedByRequest) { | |
3722 MockProxyConfigService* config_service = | |
3723 new MockProxyConfigService("http://foopy/proxy.pac"); | |
3724 | |
3725 MockAsyncProxyResolver resolver; | |
3726 MockAsyncProxyResolverFactory* factory = | |
3727 new MockAsyncProxyResolverFactory(true); | |
3728 | |
3729 ProxyService service(base::WrapUnique(config_service), | |
3730 base::WrapUnique(factory), nullptr); | |
3731 | |
3732 MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; | |
3733 service.SetProxyScriptFetchers( | |
3734 fetcher, base::WrapUnique(new DoNothingDhcpProxyScriptFetcher())); | |
3735 | |
3736 service.OnShutdown(); | |
3737 | |
3738 ProxyInfo info; | |
3739 TestCompletionCallback callback; | |
3740 ProxyService::PacRequest* request; | |
3741 int rv = service.ResolveProxy(GURL("http://request/"), std::string(), &info, | |
3742 callback.callback(), &request, nullptr, | |
3743 NetLogWithSource()); | |
3744 EXPECT_THAT(rv, IsOk()); | |
3745 EXPECT_FALSE(fetcher->has_pending_request()); | |
3746 EXPECT_TRUE(info.is_direct()); | |
3747 } | |
3748 | |
3688 } // namespace net | 3749 } // namespace net |
OLD | NEW |