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

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

Issue 105833010: Added Dev host for data reduction proxy controlled by Finch experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments from bengr Created 7 years 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
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"
(...skipping 18 matching lines...) Expand all
29 #include "net/url_request/test_url_fetcher_factory.h" 29 #include "net/url_request/test_url_fetcher_factory.h"
30 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 #include "url/gurl.h" 32 #include "url/gurl.h"
33 33
34 using testing::_; 34 using testing::_;
35 using testing::AnyNumber; 35 using testing::AnyNumber;
36 using testing::Return; 36 using testing::Return;
37 37
38 const char kDataReductionProxyOrigin[] = "https://foo.com:443/"; 38 const char kDataReductionProxyOrigin[] = "https://foo.com:443/";
39 const char kDataReductionProxyDevHost[] = "http://foo-dev.com:80";
39 const char kDataReductionProxyFallback[] = "http://bar.com:80"; 40 const char kDataReductionProxyFallback[] = "http://bar.com:80";
40 const char kDataReductionProxyAuth[] = "12345"; 41 const char kDataReductionProxyAuth[] = "12345";
41 42
42 const char kProbeURLWithOKResponse[] = "http://ok.org/"; 43 const char kProbeURLWithOKResponse[] = "http://ok.org/";
43 const char kProbeURLWithBadResponse[] = "http://bad.org/"; 44 const char kProbeURLWithBadResponse[] = "http://bad.org/";
44 const char kProbeURLWithNoResponse[] = "http://no.org/"; 45 const char kProbeURLWithNoResponse[] = "http://no.org/";
45 46
46 // Transform "normal"-looking headers (\n-separated) to the appropriate 47 // Transform "normal"-looking headers (\n-separated) to the appropriate
47 // input format for ParseRawHeaders (\0-separated). 48 // input format for ParseRawHeaders (\0-separated).
48 void HeadersToRaw(std::string* headers) { 49 void HeadersToRaw(std::string* headers) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 262 }
262 263
263 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) { 264 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) {
264 AddProxyToCommandLine(); 265 AddProxyToCommandLine();
265 // SetUp() adds the origin to the command line, which should be returned here. 266 // SetUp() adds the origin to the command line, which should be returned here.
266 std::string result = 267 std::string result =
267 DataReductionProxySettings::GetDataReductionProxyOrigin(); 268 DataReductionProxySettings::GetDataReductionProxyOrigin();
268 EXPECT_EQ(kDataReductionProxyOrigin, result); 269 EXPECT_EQ(kDataReductionProxyOrigin, result);
269 } 270 }
270 271
272 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) {
273 AddProxyToCommandLine();
274 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
275 switches::kSpdyProxyDevAuthOrigin, kDataReductionProxyDevHost);
276 std::string result =
277 DataReductionProxySettings::GetDataReductionProxyOrigin();
278 EXPECT_EQ(kDataReductionProxyDevHost, result);
279 }
280
271 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxies) { 281 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxies) {
272 DataReductionProxySettings::DataReductionProxyList proxies = 282 DataReductionProxySettings::DataReductionProxyList proxies =
273 DataReductionProxySettings::GetDataReductionProxies(); 283 DataReductionProxySettings::GetDataReductionProxies();
274 284
275 unsigned int expected_proxy_size = 0u; 285 unsigned int expected_proxy_size = 0u;
276 #if defined(SPDY_PROXY_AUTH_ORIGIN) 286 #if defined(SPDY_PROXY_AUTH_ORIGIN)
277 ++expected_proxy_size; 287 ++expected_proxy_size;
278 #endif 288 #endif
279 #if defined(DATA_REDUCTION_FALLBACK_HOST) 289 #if defined(DATA_REDUCTION_FALLBACK_HOST)
280 ++expected_proxy_size; 290 ++expected_proxy_size;
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 616 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
607 std::string headers(tests[i].headers); 617 std::string headers(tests[i].headers);
608 HeadersToRaw(&headers); 618 HeadersToRaw(&headers);
609 scoped_refptr<net::HttpResponseHeaders> parsed( 619 scoped_refptr<net::HttpResponseHeaders> parsed(
610 new net::HttpResponseHeaders(headers)); 620 new net::HttpResponseHeaders(headers));
611 621
612 EXPECT_EQ(tests[i].expected_result, 622 EXPECT_EQ(tests[i].expected_result,
613 DataReductionProxySettings::WasFetchedViaProxy(parsed)); 623 DataReductionProxySettings::WasFetchedViaProxy(parsed));
614 } 624 }
615 } 625 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698