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

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

Issue 156373002: Support for new data reduction proxy via header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compilation error on unsupported platforms Created 6 years, 10 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
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/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 }; 633 };
634 634
635 ASSERT_EQ(settings_->bypass_rules_.size(), 6u); 635 ASSERT_EQ(settings_->bypass_rules_.size(), 6u);
636 int i = 0; 636 int i = 0;
637 for (std::vector<std::string>::iterator it = settings_->bypass_rules_.begin(); 637 for (std::vector<std::string>::iterator it = settings_->bypass_rules_.begin();
638 it != settings_->bypass_rules_.end(); ++it) { 638 it != settings_->bypass_rules_.end(); ++it) {
639 EXPECT_EQ(expected[i++], *it); 639 EXPECT_EQ(expected[i++], *it);
640 } 640 }
641 } 641 }
642 642
643 TEST_F(DataReductionProxySettingsTest, WasFetchedViaProxy) {
644 const struct {
645 const char* headers;
646 bool expected_result;
647 } tests[] = {
648 { "HTTP/1.1 200 OK\n"
649 "Via: 1.1 Chrome Proxy\n",
650 false,
651 },
652 { "HTTP/1.1 200 OK\n"
653 "Via: 1.1 Chrome Compression Proxy\n",
654 true,
655 },
656 { "HTTP/1.1 200 OK\n"
657 "Via: 1.1 Foo Bar, 1.1 Chrome Compression Proxy\n",
658 true,
659 },
660 { "HTTP/1.1 200 OK\n"
661 "Via: 1.1 Chrome Compression Proxy, 1.1 Bar Foo\n",
662 true,
663 },
664 { "HTTP/1.1 200 OK\n"
665 "Via: 1.1 chrome compression proxy\n",
666 false,
667 },
668 { "HTTP/1.1 200 OK\n"
669 "Via: 1.1 Foo Bar\n"
670 "Via: 1.1 Chrome Compression Proxy\n",
671 true,
672 },
673 };
674 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
675 std::string headers(tests[i].headers);
676 HeadersToRaw(&headers);
677 scoped_refptr<net::HttpResponseHeaders> parsed(
678 new net::HttpResponseHeaders(headers));
679
680 EXPECT_EQ(tests[i].expected_result,
681 DataReductionProxySettings::WasFetchedViaProxy(parsed));
682 }
683 }
684
685 TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) { 643 TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
686 // No call to |AddProxyToCommandLine()| was made, so the proxy feature 644 // No call to |AddProxyToCommandLine()| was made, so the proxy feature
687 // should be unavailable. 645 // should be unavailable.
688 EXPECT_FALSE(DataReductionProxySettings::IsDataReductionProxyAllowed()); 646 EXPECT_FALSE(DataReductionProxySettings::IsDataReductionProxyAllowed());
689 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); 647 MockSettings* settings = static_cast<MockSettings*>(settings_.get());
690 EXPECT_CALL(*settings, RecordStartupState(spdyproxy::PROXY_NOT_AVAILABLE)); 648 EXPECT_CALL(*settings, RecordStartupState(spdyproxy::PROXY_NOT_AVAILABLE));
691 settings_->InitDataReductionProxySettings(); 649 settings_->InitDataReductionProxySettings();
692 } 650 }
OLDNEW
« no previous file with comments | « chrome/browser/net/spdyproxy/data_reduction_proxy_settings.cc ('k') | chrome/browser/net/spdyproxy/data_saving_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698