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

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

Issue 1104413003: Check for *.googlezip.net proxies when migrating proxy pref for DRP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test for http://googlezip.net Created 5 years, 7 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
« no previous file with comments | « chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <string> 5 #include <string>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); 68 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
69 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); 69 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0);
70 70
71 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( 71 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
72 test_context_->pref_service()); 72 test_context_->pref_service());
73 73
74 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); 74 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy));
75 } 75 }
76 76
77 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) { 77 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) {
78 dict_->SetString("mode", "fixed_servers"); 78 const std::string kTestServers[] = {"http=http://proxy.googlezip.net",
79 dict_->SetString("server", "http=https://proxy.googlezip.net"); 79 "http=https://my-drp.org",
80 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); 80 "https=https://tunneldrp.com"};
81 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1)
82 .WillOnce(Return(true));
83 81
84 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( 82 for (const std::string& test_server : kTestServers) {
85 test_context_->pref_service()); 83 dict_.reset(new base::DictionaryValue());
84 dict_->SetString("mode", "fixed_servers");
85 dict_->SetString("server", test_server);
86 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
87 EXPECT_CALL(*config_, ContainsDataReductionProxy(_))
88 .Times(1)
89 .WillOnce(Return(true));
86 90
87 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); 91 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
92 test_context_->pref_service());
93
94 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy));
95 }
96 }
97
98 TEST_F(DataReductionProxyChromeSettingsTest,
99 MigrateGooglezipDataReductionProxy) {
100 const std::string kTestServers[] = {
101 "http=http://proxy-dev.googlezip.net",
102 "http=https://arbitraryprefix.googlezip.net",
103 "https=https://tunnel.googlezip.net"};
104
105 for (const std::string& test_server : kTestServers) {
106 dict_.reset(new base::DictionaryValue());
107 // The proxy pref is set to a Data Reduction Proxy that doesn't match the
108 // currently configured DRP, but the pref should still be cleared.
109 dict_->SetString("mode", "fixed_servers");
110 dict_->SetString("server", test_server);
111 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
112 EXPECT_CALL(*config_, ContainsDataReductionProxy(_))
113 .Times(1)
114 .WillOnce(Return(false));
115
116 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
117 test_context_->pref_service());
118
119 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy));
120 }
88 } 121 }
89 122
90 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { 123 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) {
91 dict_->SetString("mode", "fixed_servers"); 124 const std::string kTestServers[] = {
92 dict_->SetString("server", "http=https://youtube.com"); 125 "http=https://youtube.com",
93 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); 126 "http=http://googlezip.net",
94 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) 127 "http=http://thisismyproxynotgooglezip.net",
95 .WillOnce(Return(false)); 128 "https=http://arbitraryprefixgooglezip.net"};
96 129
97 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( 130 for (const std::string& test_server : kTestServers) {
98 test_context_->pref_service()); 131 dict_.reset(new base::DictionaryValue());
132 dict_->SetString("mode", "fixed_servers");
133 dict_->SetString("server", test_server);
134 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
135 EXPECT_CALL(*config_, ContainsDataReductionProxy(_))
136 .Times(1)
137 .WillOnce(Return(false));
99 138
100 base::DictionaryValue* value = 139 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
101 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref( 140 test_context_->pref_service());
102 prefs::kProxy); 141
103 std::string mode; 142 base::DictionaryValue* value =
104 EXPECT_TRUE(value->GetString("mode", &mode)); 143 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref(
105 EXPECT_EQ("fixed_servers", mode); 144 prefs::kProxy);
106 std::string server; 145 std::string mode;
107 EXPECT_TRUE(value->GetString("server", &server)); 146 EXPECT_TRUE(value->GetString("mode", &mode));
108 EXPECT_EQ("http=https://youtube.com", server); 147 EXPECT_EQ("fixed_servers", mode);
148 std::string server;
149 EXPECT_TRUE(value->GetString("server", &server));
150 EXPECT_EQ(test_server, server);
151 }
109 } 152 }
OLDNEW
« no previous file with comments | « chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698