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