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 "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 80 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); |
81 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) | 81 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) |
82 .WillOnce(Return(true)); | 82 .WillOnce(Return(true)); |
83 | 83 |
84 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 84 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
85 test_context_->pref_service()); | 85 test_context_->pref_service()); |
86 | 86 |
87 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | 87 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); |
88 } | 88 } |
89 | 89 |
90 TEST_F(DataReductionProxyChromeSettingsTest, MigrateCustomDataReductionProxy) { | |
91 dict_->SetString("mode", "fixed_servers"); | |
92 dict_->SetString("server", "http=https://my-drp.net"); | |
93 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | |
94 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) | |
95 .Times(1) | |
96 .WillOnce(Return(true)); | |
97 | |
98 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | |
99 test_context_->pref_service()); | |
100 | |
101 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | |
102 } | |
103 | |
104 TEST_F(DataReductionProxyChromeSettingsTest, MigrateDevDataReductionProxy) { | |
105 // The proxy pref is set to a Data Reduction Proxy that doesn't match the | |
106 // currently configured DRP, but the pref should still be cleared. | |
107 dict_->SetString("mode", "fixed_servers"); | |
108 dict_->SetString("server", "http=http://proxy-dev.googlezip.net"); | |
bengr
2015/04/28 16:52:27
Add a few more strings to test. E.g "http://google
sclittle
2015/04/28 18:27:57
Sure, added some more.
"http://googlezip.net" doe
bengr
2015/04/28 18:31:53
I understand the intention, but please also test h
sclittle
2015/04/28 19:25:20
Done.
| |
109 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | |
110 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)) | |
111 .Times(1) | |
112 .WillOnce(Return(false)); | |
113 | |
114 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | |
115 test_context_->pref_service()); | |
116 | |
117 EXPECT_EQ(NULL, test_context_->pref_service()->GetUserPref(prefs::kProxy)); | |
118 } | |
119 | |
90 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { | 120 TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { |
91 dict_->SetString("mode", "fixed_servers"); | 121 dict_->SetString("mode", "fixed_servers"); |
92 dict_->SetString("server", "http=https://youtube.com"); | 122 dict_->SetString("server", "http=https://youtube.com"); |
93 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); | 123 test_context_->pref_service()->Set(prefs::kProxy, *dict_.get()); |
94 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) | 124 EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) |
95 .WillOnce(Return(false)); | 125 .WillOnce(Return(false)); |
96 | 126 |
97 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( | 127 drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( |
98 test_context_->pref_service()); | 128 test_context_->pref_service()); |
99 | 129 |
100 base::DictionaryValue* value = | 130 base::DictionaryValue* value = |
101 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref( | 131 (base::DictionaryValue*)test_context_->pref_service()->GetUserPref( |
102 prefs::kProxy); | 132 prefs::kProxy); |
103 std::string mode; | 133 std::string mode; |
104 EXPECT_TRUE(value->GetString("mode", &mode)); | 134 EXPECT_TRUE(value->GetString("mode", &mode)); |
105 EXPECT_EQ("fixed_servers", mode); | 135 EXPECT_EQ("fixed_servers", mode); |
106 std::string server; | 136 std::string server; |
107 EXPECT_TRUE(value->GetString("server", &server)); | 137 EXPECT_TRUE(value->GetString("server", &server)); |
108 EXPECT_EQ("http=https://youtube.com", server); | 138 EXPECT_EQ("http=https://youtube.com", server); |
109 } | 139 } |
OLD | NEW |