OLD | NEW |
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/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "net/url_request/test_url_fetcher_factory.h" | 31 #include "net/url_request/test_url_fetcher_factory.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
35 | 35 |
36 using testing::_; | 36 using testing::_; |
37 using testing::AnyNumber; | 37 using testing::AnyNumber; |
38 using testing::Return; | 38 using testing::Return; |
39 | 39 |
40 const char kDataReductionProxyOrigin[] = "https://foo.com:443/"; | 40 const char kDataReductionProxyOrigin[] = "https://foo.com:443/"; |
| 41 const char kDataReductionProxyDevHost[] = "http://foo-dev.com:80"; |
41 const char kDataReductionProxyFallback[] = "http://bar.com:80"; | 42 const char kDataReductionProxyFallback[] = "http://bar.com:80"; |
42 const char kDataReductionProxyAuth[] = "12345"; | 43 const char kDataReductionProxyAuth[] = "12345"; |
43 | 44 |
44 const char kProbeURLWithOKResponse[] = "http://ok.org/"; | 45 const char kProbeURLWithOKResponse[] = "http://ok.org/"; |
45 const char kProbeURLWithBadResponse[] = "http://bad.org/"; | 46 const char kProbeURLWithBadResponse[] = "http://bad.org/"; |
46 const char kProbeURLWithNoResponse[] = "http://no.org/"; | 47 const char kProbeURLWithNoResponse[] = "http://no.org/"; |
47 | 48 |
48 // Transform "normal"-looking headers (\n-separated) to the appropriate | 49 // Transform "normal"-looking headers (\n-separated) to the appropriate |
49 // input format for ParseRawHeaders (\0-separated). | 50 // input format for ParseRawHeaders (\0-separated). |
50 void HeadersToRaw(std::string* headers) { | 51 void HeadersToRaw(std::string* headers) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 303 } |
303 | 304 |
304 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) { | 305 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) { |
305 AddProxyToCommandLine(); | 306 AddProxyToCommandLine(); |
306 // SetUp() adds the origin to the command line, which should be returned here. | 307 // SetUp() adds the origin to the command line, which should be returned here. |
307 std::string result = | 308 std::string result = |
308 DataReductionProxySettings::GetDataReductionProxyOrigin(); | 309 DataReductionProxySettings::GetDataReductionProxyOrigin(); |
309 EXPECT_EQ(kDataReductionProxyOrigin, result); | 310 EXPECT_EQ(kDataReductionProxyOrigin, result); |
310 } | 311 } |
311 | 312 |
| 313 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) { |
| 314 AddProxyToCommandLine(); |
| 315 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 316 switches::kSpdyProxyDevAuthOrigin, kDataReductionProxyDevHost); |
| 317 std::string result = |
| 318 DataReductionProxySettings::GetDataReductionProxyOrigin(); |
| 319 EXPECT_EQ(kDataReductionProxyDevHost, result); |
| 320 } |
| 321 |
312 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxies) { | 322 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxies) { |
313 DataReductionProxySettings::DataReductionProxyList proxies = | 323 DataReductionProxySettings::DataReductionProxyList proxies = |
314 DataReductionProxySettings::GetDataReductionProxies(); | 324 DataReductionProxySettings::GetDataReductionProxies(); |
315 | 325 |
316 unsigned int expected_proxy_size = 0u; | 326 unsigned int expected_proxy_size = 0u; |
317 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 327 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
318 ++expected_proxy_size; | 328 ++expected_proxy_size; |
319 #endif | 329 #endif |
320 #if defined(DATA_REDUCTION_FALLBACK_HOST) | 330 #if defined(DATA_REDUCTION_FALLBACK_HOST) |
321 ++expected_proxy_size; | 331 ++expected_proxy_size; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 } | 673 } |
664 | 674 |
665 TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) { | 675 TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) { |
666 // No call to |AddProxyToCommandLine()| was made, so the proxy feature | 676 // No call to |AddProxyToCommandLine()| was made, so the proxy feature |
667 // should be unavailable. | 677 // should be unavailable. |
668 EXPECT_FALSE(DataReductionProxySettings::IsDataReductionProxyAllowed()); | 678 EXPECT_FALSE(DataReductionProxySettings::IsDataReductionProxyAllowed()); |
669 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); | 679 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); |
670 EXPECT_CALL(*settings, RecordStartupState(spdyproxy::PROXY_NOT_AVAILABLE)); | 680 EXPECT_CALL(*settings, RecordStartupState(spdyproxy::PROXY_NOT_AVAILABLE)); |
671 settings_->InitDataReductionProxySettings(); | 681 settings_->InitDataReductionProxySettings(); |
672 } | 682 } |
OLD | NEW |