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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc

Issue 48713008: [sync] Allow FakeURLFetcher to return arbitrary HTTP response codes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/prefs/scoped_user_pref_update.h" 12 #include "base/prefs/scoped_user_pref_update.h"
13 #include "base/prefs/testing_pref_service.h" 13 #include "base/prefs/testing_pref_service.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h" 16 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h"
17 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h" 17 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h"
18 #include "chrome/browser/prefs/proxy_prefs.h" 18 #include "chrome/browser/prefs/proxy_prefs.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/metrics/variations/variations_util.h" 20 #include "chrome/common/metrics/variations/variations_util.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "components/variations/entropy_provider.h" 22 #include "components/variations/entropy_provider.h"
23 #include "net/base/auth.h" 23 #include "net/base/auth.h"
24 #include "net/base/host_port_pair.h" 24 #include "net/base/host_port_pair.h"
25 #include "net/http/http_auth.h" 25 #include "net/http/http_auth.h"
26 #include "net/http/http_auth_cache.h" 26 #include "net/http/http_auth_cache.h"
27 #include "net/http/http_status_code.h"
27 #include "net/url_request/test_url_fetcher_factory.h" 28 #include "net/url_request/test_url_fetcher_factory.h"
28 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 #include "url/gurl.h" 31 #include "url/gurl.h"
31 32
32 using testing::_; 33 using testing::_;
33 using testing::AnyNumber; 34 using testing::AnyNumber;
34 using testing::Return; 35 using testing::Return;
35 36
36 const char kDataReductionProxyOrigin[] = "https://foo.com:443/"; 37 const char kDataReductionProxyOrigin[] = "https://foo.com:443/";
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const std::string& response, 112 const std::string& response,
112 bool success, 113 bool success,
113 int expected_calls) { 114 int expected_calls) {
114 MockDataReductionProxySettings<C>* settings = 115 MockDataReductionProxySettings<C>* settings =
115 static_cast<MockDataReductionProxySettings<C>*>(settings_.get()); 116 static_cast<MockDataReductionProxySettings<C>*>(settings_.get());
116 if (0 == expected_calls) { 117 if (0 == expected_calls) {
117 EXPECT_CALL(*settings, GetURLFetcher()).Times(0); 118 EXPECT_CALL(*settings, GetURLFetcher()).Times(0);
118 } else { 119 } else {
119 EXPECT_CALL(*settings, GetURLFetcher()) 120 EXPECT_CALL(*settings, GetURLFetcher())
120 .Times(expected_calls) 121 .Times(expected_calls)
121 .WillRepeatedly(Return(new net::FakeURLFetcher(GURL(test_url), 122 .WillRepeatedly(Return(new net::FakeURLFetcher(
122 settings, 123 GURL(test_url),
123 response, 124 settings,
124 success))); 125 response,
126 success ? net::HTTP_OK : net::HTTP_INTERNAL_SERVER_ERROR)));
125 } 127 }
126 } 128 }
127 129
128 // Explicitly generate required instantiations. 130 // Explicitly generate required instantiations.
129 template void 131 template void
130 DataReductionProxySettingsTestBase::SetProbeResult<DataReductionProxySettings>( 132 DataReductionProxySettingsTestBase::SetProbeResult<DataReductionProxySettings>(
131 const std::string& test_url, 133 const std::string& test_url,
132 const std::string& response, 134 const std::string& response,
133 bool success, 135 bool success,
134 int expected_calls); 136 int expected_calls);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 "http://*bat.com" 551 "http://*bat.com"
550 }; 552 };
551 553
552 ASSERT_EQ(settings_->bypass_rules_.size(), 6u); 554 ASSERT_EQ(settings_->bypass_rules_.size(), 6u);
553 int i = 0; 555 int i = 0;
554 for (std::vector<std::string>::iterator it = settings_->bypass_rules_.begin(); 556 for (std::vector<std::string>::iterator it = settings_->bypass_rules_.begin();
555 it != settings_->bypass_rules_.end(); ++it) { 557 it != settings_->bypass_rules_.end(); ++it) {
556 EXPECT_EQ(expected[i++], *it); 558 EXPECT_EQ(expected[i++], *it);
557 } 559 }
558 } 560 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698