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

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

Issue 1108413003: Check for *.googlezip.net proxies when migrating proxy pref for DRP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); 67 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
68 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); 68 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0);
69 69
70 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( 70 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
71 test_context_->pref_service()); 71 test_context_->pref_service());
72 72
73 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); 73 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy));
74 } 74 }
75 75
76 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) { 76 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) {
77 dict_->SetString("mode", "fixed_servers"); 77 const std::string kTestServers[] = {"http=http://proxy.googlezip.net",
78 dict_->SetString("server", "http=https://proxy.googlezip.net"); 78 "http=https://my-drp.org",
79 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); 79 "https=https://tunneldrp.com"};
80 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1)
81 .WillOnce(Return(true));
82 80
83 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( 81 for (const std::string& test_server : kTestServers) {
84 test_context_->pref_service()); 82 dict_.reset(new base::DictionaryValue());
83 dict_->SetString("mode", "fixed_servers");
84 dict_->SetString("server", test_server);
85 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
86 EXPECT_CALL(*config_, ContainsDataReductionProxy(_))
87 .Times(1)
88 .WillOnce(Return(true));
85 89
86 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); 90 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
91 test_context_->pref_service());
92
93 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy));
94 }
95 }
96
97 TEST_F(DataReductionProxyChromeSettingsTest,
98 MigrateGooglezipDataReductionProxy) {
99 const std::string kTestServers[] = {
100 "http=http://proxy-dev.googlezip.net",
101 "http=https://arbitraryprefix.googlezip.net",
102 "https=https://tunnel.googlezip.net"};
103
104 for (const std::string& test_server : kTestServers) {
105 dict_.reset(new base::DictionaryValue());
106 // The proxy pref is set to a Data Reduction Proxy that doesn't match the
107 // currently configured DRP, but the pref should still be cleared.
108 dict_->SetString("mode", "fixed_servers");
109 dict_->SetString("server", test_server);
110 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
111 EXPECT_CALL(*config_, ContainsDataReductionProxy(_))
112 .Times(1)
113 .WillOnce(Return(false));
114
115 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
116 test_context_->pref_service());
117
118 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy));
119 }
87 } 120 }
88 121
89 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { 122 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) {
90 dict_->SetString("mode", "fixed_servers"); 123 const std::string kTestServers[] = {
91 dict_->SetString("server", "http=https://youtube.com"); 124 "http=https://youtube.com",
92 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); 125 "http=http://googlezip.net",
93 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) 126 "http=http://thisismyproxynotgooglezip.net",
94 .WillOnce(Return(false)); 127 "https=http://arbitraryprefixgooglezip.net"};
95 128
96 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( 129 for (const std::string& test_server : kTestServers) {
97 test_context_->pref_service()); 130 dict_.reset(new base::DictionaryValue());
131 dict_->SetString("mode", "fixed_servers");
132 dict_->SetString("server", test_server);
133 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get());
134 EXPECT_CALL(*config_, ContainsDataReductionProxy(_))
135 .Times(1)
136 .WillOnce(Return(false));
98 137
99 base::DictionaryValue* value = 138 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs(
100 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref( 139 test_context_->pref_service());
101 prefs::kProxy); 140
102 std::string mode; 141 base::DictionaryValue* value =
103 EXPECT_TRUE(value->GetString("mode", &mode)); 142 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref(
104 EXPECT_EQ("fixed_servers", mode); 143 prefs::kProxy);
105 std::string server; 144 std::string mode;
106 EXPECT_TRUE(value->GetString("server", &server)); 145 EXPECT_TRUE(value->GetString("mode", &mode));
107 EXPECT_EQ("http=https://youtube.com", server); 146 EXPECT_EQ("fixed_servers", mode);
147 std::string server;
148 EXPECT_TRUE(value->GetString("server", &server));
149 EXPECT_EQ(test_server, server);
150 }
108 } 151 }
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