OLD | NEW |
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 "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" | 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" |
| 17 #include "components/proxy_config/proxy_prefs.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 using testing::_; | 20 using testing::_; |
20 using testing::Return; | 21 using testing::Return; |
21 | 22 |
22 class DataReductionProxyChromeSettingsTest : public testing::Test { | 23 class DataReductionProxyChromeSettingsTest : public testing::Test { |
23 public: | 24 public: |
24 void SetUp() override { | 25 void SetUp() override { |
25 drp_chrome_settings_ = | 26 drp_chrome_settings_ = |
26 make_scoped_ptr(new DataReductionProxyChromeSettings()); | 27 make_scoped_ptr(new DataReductionProxyChromeSettings()); |
27 test_context_ = | 28 test_context_ = |
28 data_reduction_proxy::DataReductionProxyTestContext::Builder() | 29 data_reduction_proxy::DataReductionProxyTestContext::Builder() |
29 .WithMockConfig() | 30 .WithMockConfig() |
30 .SkipSettingsInitialization() | 31 .SkipSettingsInitialization() |
31 .Build(); | 32 .Build(); |
32 config_ = test_context_->mock_config(); | 33 config_ = test_context_->mock_config(); |
33 drp_chrome_settings_->ResetConfigForTest(config_); | 34 drp_chrome_settings_->ResetConfigForTest(config_); |
34 dict_ = make_scoped_ptr(new base::DictionaryValue()); | 35 dict_ = make_scoped_ptr(new base::DictionaryValue()); |
35 | 36 |
36 PrefRegistrySimple* registry = test_context_->pref_service()->registry(); | 37 PrefRegistrySimple* registry = test_context_->pref_service()->registry(); |
37 registry->RegisterDictionaryPref(prefs::kProxy); | 38 registry->RegisterDictionaryPref(ProxyPrefs::kProxy); |
38 } | 39 } |
39 | 40 |
40 base::MessageLoopForIO message_loop_; | 41 base::MessageLoopForIO message_loop_; |
41 scoped_ptr<DataReductionProxyChromeSettings> drp_chrome_settings_; | 42 scoped_ptr<DataReductionProxyChromeSettings> drp_chrome_settings_; |
42 scoped_ptr<base::DictionaryValue> dict_; | 43 scoped_ptr<base::DictionaryValue> dict_; |
43 scoped_ptr<data_reduction_proxy::DataReductionProxyTestContext> test_context_; | 44 scoped_ptr<data_reduction_proxy::DataReductionProxyTestContext> test_context_; |
44 data_reduction_proxy::MockDataReductionProxyConfig* config_; | 45 data_reduction_proxy::MockDataReductionProxyConfig* config_; |
45 }; | 46 }; |
46 | 47 |
47 TEST_F(DataReductionProxyChromeSettingsTest, MigrateNonexistentProxyPref) { | 48 TEST_F(DataReductionProxyChromeSettingsTest, MigrateNonexistentProxyPref) { |
48 base::HistogramTester histogram_tester; | 49 base::HistogramTester histogram_tester; |
49 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); | 50 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); |
50 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 51 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
51 test_context_->pref_service()); | 52 test_context_->pref_service()); |
52 | 53 |
53 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 54 EXPECT_EQ(NULL, |
| 55 test_context_->pref_service()->GetUserPref(ProxyPrefs::kProxy)); |
54 histogram_tester.ExpectUniqueSample( | 56 histogram_tester.ExpectUniqueSample( |
55 "DataReductionProxy.ProxyPrefMigrationResult", | 57 "DataReductionProxy.ProxyPrefMigrationResult", |
56 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); | 58 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); |
57 } | 59 } |
58 | 60 |
59 TEST_F(DataReductionProxyChromeSettingsTest, MigrateBadlyFormedProxyPref) { | 61 TEST_F(DataReductionProxyChromeSettingsTest, MigrateBadlyFormedProxyPref) { |
60 const struct { | 62 const struct { |
61 // NULL indicates that mode is unset. | 63 // NULL indicates that mode is unset. |
62 const char* proxy_mode_string; | 64 const char* proxy_mode_string; |
63 // NULL indicates that server is unset. | 65 // NULL indicates that server is unset. |
64 const char* proxy_server_string; | 66 const char* proxy_server_string; |
65 } test_cases[] = { | 67 } test_cases[] = { |
66 // The pref should not be cleared if mode is unset. | 68 // The pref should not be cleared if mode is unset. |
67 {nullptr, "http=compress.googlezip.net"}, | 69 {nullptr, "http=compress.googlezip.net"}, |
68 // The pref should not be cleared for modes other than "fixed_servers" and | 70 // The pref should not be cleared for modes other than "fixed_servers" and |
69 // "pac_script". | 71 // "pac_script". |
70 {"auto_detect", "http=compress.googlezip.net"}, | 72 {"auto_detect", "http=compress.googlezip.net"}, |
71 // The pref should not be cleared when the server field is unset. | 73 // The pref should not be cleared when the server field is unset. |
72 {"fixed_servers", nullptr}, | 74 {"fixed_servers", nullptr}, |
73 }; | 75 }; |
74 | 76 |
75 for (const auto& test : test_cases) { | 77 for (const auto& test : test_cases) { |
76 base::HistogramTester histogram_tester; | 78 base::HistogramTester histogram_tester; |
77 dict_.reset(new base::DictionaryValue()); | 79 dict_.reset(new base::DictionaryValue()); |
78 if (test.proxy_mode_string) | 80 if (test.proxy_mode_string) |
79 dict_->SetString("mode", test.proxy_mode_string); | 81 dict_->SetString("mode", test.proxy_mode_string); |
80 if (test.proxy_server_string) | 82 if (test.proxy_server_string) |
81 dict_->SetString("server", test.proxy_server_string); | 83 dict_->SetString("server", test.proxy_server_string); |
82 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 84 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
83 | 85 |
84 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); | 86 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); |
85 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 87 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
86 test_context_->pref_service()); | 88 test_context_->pref_service()); |
87 | 89 |
88 const base::DictionaryValue* final_value; | 90 const base::DictionaryValue* final_value; |
89 test_context_->pref_service() | 91 test_context_->pref_service() |
90 ->GetUserPref(prefs::kProxy) | 92 ->GetUserPref(ProxyPrefs::kProxy) |
91 ->GetAsDictionary(&final_value); | 93 ->GetAsDictionary(&final_value); |
92 EXPECT_NE(nullptr, final_value); | 94 EXPECT_NE(nullptr, final_value); |
93 EXPECT_TRUE(dict_->Equals(final_value)); | 95 EXPECT_TRUE(dict_->Equals(final_value)); |
94 | 96 |
95 histogram_tester.ExpectUniqueSample( | 97 histogram_tester.ExpectUniqueSample( |
96 "DataReductionProxy.ProxyPrefMigrationResult", | 98 "DataReductionProxy.ProxyPrefMigrationResult", |
97 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); | 99 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
101 TEST_F(DataReductionProxyChromeSettingsTest, MigrateEmptyProxy) { | 103 TEST_F(DataReductionProxyChromeSettingsTest, MigrateEmptyProxy) { |
102 base::HistogramTester histogram_tester; | 104 base::HistogramTester histogram_tester; |
103 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 105 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
104 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); | 106 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); |
105 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 107 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
106 test_context_->pref_service()); | 108 test_context_->pref_service()); |
107 | 109 |
108 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 110 EXPECT_EQ(NULL, |
| 111 test_context_->pref_service()->GetUserPref(ProxyPrefs::kProxy)); |
109 histogram_tester.ExpectUniqueSample( | 112 histogram_tester.ExpectUniqueSample( |
110 "DataReductionProxy.ProxyPrefMigrationResult", | 113 "DataReductionProxy.ProxyPrefMigrationResult", |
111 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_EMPTY, 1); | 114 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_EMPTY, 1); |
112 } | 115 } |
113 | 116 |
114 TEST_F(DataReductionProxyChromeSettingsTest, MigrateSystemProxy) { | 117 TEST_F(DataReductionProxyChromeSettingsTest, MigrateSystemProxy) { |
115 base::HistogramTester histogram_tester; | 118 base::HistogramTester histogram_tester; |
116 dict_->SetString("mode", "system"); | 119 dict_->SetString("mode", "system"); |
117 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 120 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
118 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); | 121 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); |
119 | 122 |
120 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 123 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
121 test_context_->pref_service()); | 124 test_context_->pref_service()); |
122 | 125 |
123 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 126 EXPECT_EQ(NULL, |
| 127 test_context_->pref_service()->GetUserPref(ProxyPrefs::kProxy)); |
124 histogram_tester.ExpectUniqueSample( | 128 histogram_tester.ExpectUniqueSample( |
125 "DataReductionProxy.ProxyPrefMigrationResult", | 129 "DataReductionProxy.ProxyPrefMigrationResult", |
126 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_MODE_SYSTEM, 1); | 130 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_MODE_SYSTEM, 1); |
127 } | 131 } |
128 | 132 |
129 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) { | 133 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) { |
130 const std::string kTestServers[] = {"http=http://proxy.googlezip.net", | 134 const std::string kTestServers[] = {"http=http://proxy.googlezip.net", |
131 "http=https://my-drp.org", | 135 "http=https://my-drp.org", |
132 "https=https://tunneldrp.com"}; | 136 "https=https://tunneldrp.com"}; |
133 | 137 |
134 for (const std::string& test_server : kTestServers) { | 138 for (const std::string& test_server : kTestServers) { |
135 base::HistogramTester histogram_tester; | 139 base::HistogramTester histogram_tester; |
136 dict_.reset(new base::DictionaryValue()); | 140 dict_.reset(new base::DictionaryValue()); |
137 dict_->SetString("mode", "fixed_servers"); | 141 dict_->SetString("mode", "fixed_servers"); |
138 dict_->SetString("server", test_server); | 142 dict_->SetString("server", test_server); |
139 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 143 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
140 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) | 144 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) |
141 .Times(1) | 145 .Times(1) |
142 .WillOnce(Return(true)); | 146 .WillOnce(Return(true)); |
143 | 147 |
144 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 148 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
145 test_context_->pref_service()); | 149 test_context_->pref_service()); |
146 | 150 |
147 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 151 EXPECT_EQ(NULL, |
| 152 test_context_->pref_service()->GetUserPref(ProxyPrefs::kProxy)); |
148 histogram_tester.ExpectUniqueSample( | 153 histogram_tester.ExpectUniqueSample( |
149 "DataReductionProxy.ProxyPrefMigrationResult", | 154 "DataReductionProxy.ProxyPrefMigrationResult", |
150 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_DRP, 1); | 155 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_DRP, 1); |
151 } | 156 } |
152 } | 157 } |
153 | 158 |
154 TEST_F(DataReductionProxyChromeSettingsTest, | 159 TEST_F(DataReductionProxyChromeSettingsTest, |
155 MigrateGooglezipDataReductionProxy) { | 160 MigrateGooglezipDataReductionProxy) { |
156 const std::string kTestServers[] = { | 161 const std::string kTestServers[] = { |
157 "http=http://proxy-dev.googlezip.net", | 162 "http=http://proxy-dev.googlezip.net", |
158 "http=https://arbitraryprefix.googlezip.net", | 163 "http=https://arbitraryprefix.googlezip.net", |
159 "https=https://tunnel.googlezip.net"}; | 164 "https=https://tunnel.googlezip.net"}; |
160 | 165 |
161 for (const std::string& test_server : kTestServers) { | 166 for (const std::string& test_server : kTestServers) { |
162 base::HistogramTester histogram_tester; | 167 base::HistogramTester histogram_tester; |
163 dict_.reset(new base::DictionaryValue()); | 168 dict_.reset(new base::DictionaryValue()); |
164 // The proxy pref is set to a Data Reduction Proxy that doesn't match the | 169 // The proxy pref is set to a Data Reduction Proxy that doesn't match the |
165 // currently configured DRP, but the pref should still be cleared. | 170 // currently configured DRP, but the pref should still be cleared. |
166 dict_->SetString("mode", "fixed_servers"); | 171 dict_->SetString("mode", "fixed_servers"); |
167 dict_->SetString("server", test_server); | 172 dict_->SetString("server", test_server); |
168 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 173 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
169 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) | 174 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) |
170 .Times(1) | 175 .Times(1) |
171 .WillOnce(Return(false)); | 176 .WillOnce(Return(false)); |
172 | 177 |
173 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 178 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
174 test_context_->pref_service()); | 179 test_context_->pref_service()); |
175 | 180 |
176 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 181 EXPECT_EQ(NULL, |
| 182 test_context_->pref_service()->GetUserPref(ProxyPrefs::kProxy)); |
177 histogram_tester.ExpectUniqueSample( | 183 histogram_tester.ExpectUniqueSample( |
178 "DataReductionProxy.ProxyPrefMigrationResult", | 184 "DataReductionProxy.ProxyPrefMigrationResult", |
179 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_GOOGLEZIP, 1); | 185 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_GOOGLEZIP, 1); |
180 } | 186 } |
181 } | 187 } |
182 | 188 |
183 TEST_F(DataReductionProxyChromeSettingsTest, | 189 TEST_F(DataReductionProxyChromeSettingsTest, |
184 MigratePacGooglezipDataReductionProxy) { | 190 MigratePacGooglezipDataReductionProxy) { |
185 const struct { | 191 const struct { |
186 const char* pac_url; | 192 const char* pac_url; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 false}, | 256 false}, |
251 // PAC URL that doesn't embed a script. | 257 // PAC URL that doesn't embed a script. |
252 {"http://compress.googlezip.net/pac", false}, | 258 {"http://compress.googlezip.net/pac", false}, |
253 }; | 259 }; |
254 | 260 |
255 for (const auto& test : test_cases) { | 261 for (const auto& test : test_cases) { |
256 base::HistogramTester histogram_tester; | 262 base::HistogramTester histogram_tester; |
257 dict_.reset(new base::DictionaryValue()); | 263 dict_.reset(new base::DictionaryValue()); |
258 dict_->SetString("mode", "pac_script"); | 264 dict_->SetString("mode", "pac_script"); |
259 dict_->SetString("pac_url", test.pac_url); | 265 dict_->SetString("pac_url", test.pac_url); |
260 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 266 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
261 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); | 267 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); |
262 | 268 |
263 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 269 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
264 test_context_->pref_service()); | 270 test_context_->pref_service()); |
265 | 271 |
266 if (test.expect_pref_cleared) { | 272 if (test.expect_pref_cleared) { |
267 EXPECT_EQ(NULL, | 273 EXPECT_EQ(NULL, |
268 test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 274 test_context_->pref_service()->GetUserPref(ProxyPrefs::kProxy)); |
269 histogram_tester.ExpectUniqueSample( | 275 histogram_tester.ExpectUniqueSample( |
270 "DataReductionProxy.ProxyPrefMigrationResult", | 276 "DataReductionProxy.ProxyPrefMigrationResult", |
271 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_PAC_GOOGLEZIP, | 277 DataReductionProxyChromeSettings::PROXY_PREF_CLEARED_PAC_GOOGLEZIP, |
272 1); | 278 1); |
273 } else { | 279 } else { |
274 const base::DictionaryValue* value; | 280 const base::DictionaryValue* value; |
275 EXPECT_TRUE(test_context_->pref_service() | 281 EXPECT_TRUE(test_context_->pref_service() |
276 ->GetUserPref(prefs::kProxy) | 282 ->GetUserPref(ProxyPrefs::kProxy) |
277 ->GetAsDictionary(&value)); | 283 ->GetAsDictionary(&value)); |
278 std::string mode; | 284 std::string mode; |
279 EXPECT_TRUE(value->GetString("mode", &mode)); | 285 EXPECT_TRUE(value->GetString("mode", &mode)); |
280 EXPECT_EQ("pac_script", mode); | 286 EXPECT_EQ("pac_script", mode); |
281 std::string pac_url; | 287 std::string pac_url; |
282 EXPECT_TRUE(value->GetString("pac_url", &pac_url)); | 288 EXPECT_TRUE(value->GetString("pac_url", &pac_url)); |
283 EXPECT_EQ(test.pac_url, pac_url); | 289 EXPECT_EQ(test.pac_url, pac_url); |
284 | 290 |
285 histogram_tester.ExpectUniqueSample( | 291 histogram_tester.ExpectUniqueSample( |
286 "DataReductionProxy.ProxyPrefMigrationResult", | 292 "DataReductionProxy.ProxyPrefMigrationResult", |
287 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); | 293 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); |
288 } | 294 } |
289 } | 295 } |
290 } | 296 } |
291 | 297 |
292 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { | 298 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { |
293 const std::string kTestServers[] = { | 299 const std::string kTestServers[] = { |
294 "http=https://youtube.com", | 300 "http=https://youtube.com", |
295 "http=http://googlezip.net", | 301 "http=http://googlezip.net", |
296 "http=http://thisismyproxynotgooglezip.net", | 302 "http=http://thisismyproxynotgooglezip.net", |
297 "https=http://arbitraryprefixgooglezip.net"}; | 303 "https=http://arbitraryprefixgooglezip.net"}; |
298 | 304 |
299 for (const std::string& test_server : kTestServers) { | 305 for (const std::string& test_server : kTestServers) { |
300 base::HistogramTester histogram_tester; | 306 base::HistogramTester histogram_tester; |
301 dict_.reset(new base::DictionaryValue()); | 307 dict_.reset(new base::DictionaryValue()); |
302 dict_->SetString("mode", "fixed_servers"); | 308 dict_->SetString("mode", "fixed_servers"); |
303 dict_->SetString("server", test_server); | 309 dict_->SetString("server", test_server); |
304 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 310 test_context_->pref_service()->Set(ProxyPrefs::kProxy, *dict_.get()); |
305 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) | 311 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) |
306 .Times(1) | 312 .Times(1) |
307 .WillOnce(Return(false)); | 313 .WillOnce(Return(false)); |
308 | 314 |
309 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 315 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
310 test_context_->pref_service()); | 316 test_context_->pref_service()); |
311 | 317 |
312 base::DictionaryValue* value = | 318 base::DictionaryValue* value = |
313 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref( | 319 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref( |
314 prefs::kProxy); | 320 ProxyPrefs::kProxy); |
315 std::string mode; | 321 std::string mode; |
316 EXPECT_TRUE(value->GetString("mode", &mode)); | 322 EXPECT_TRUE(value->GetString("mode", &mode)); |
317 EXPECT_EQ("fixed_servers", mode); | 323 EXPECT_EQ("fixed_servers", mode); |
318 std::string server; | 324 std::string server; |
319 EXPECT_TRUE(value->GetString("server", &server)); | 325 EXPECT_TRUE(value->GetString("server", &server)); |
320 EXPECT_EQ(test_server, server); | 326 EXPECT_EQ(test_server, server); |
321 | 327 |
322 histogram_tester.ExpectUniqueSample( | 328 histogram_tester.ExpectUniqueSample( |
323 "DataReductionProxy.ProxyPrefMigrationResult", | 329 "DataReductionProxy.ProxyPrefMigrationResult", |
324 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); | 330 DataReductionProxyChromeSettings::PROXY_PREF_NOT_CLEARED, 1); |
325 } | 331 } |
326 } | 332 } |
OLD | NEW |