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

Side by Side Diff: chrome/browser/content_settings/content_settings_default_provider_unittest.cc

Issue 2428433002: Delete fullscreen/mouselock pref data. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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 | « no previous file | chrome/browser/content_settings/content_settings_pref_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <memory> 5 #include <memory>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 8 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
9 #include "chrome/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 CONTENT_SETTINGS_TYPE_COOKIES, 145 CONTENT_SETTINGS_TYPE_COOKIES,
146 std::string(), false)); 146 std::string(), false));
147 // Reseting the pref to its previous value should update the cache. 147 // Reseting the pref to its previous value should update the cache.
148 prefs->SetInteger(info->default_value_pref_name(), CONTENT_SETTING_BLOCK); 148 prefs->SetInteger(info->default_value_pref_name(), CONTENT_SETTING_BLOCK);
149 EXPECT_EQ(CONTENT_SETTING_BLOCK, 149 EXPECT_EQ(CONTENT_SETTING_BLOCK,
150 TestUtils::GetContentSetting(&provider_, GURL(), GURL(), 150 TestUtils::GetContentSetting(&provider_, GURL(), GURL(),
151 CONTENT_SETTINGS_TYPE_COOKIES, 151 CONTENT_SETTINGS_TYPE_COOKIES,
152 std::string(), false)); 152 std::string(), false));
153 } 153 }
154 154
155 // Tests that fullscreen and mouselock content settings are cleared.
156 TEST_F(DefaultProviderTest, DiscardObsoletePreferences) {
157 static const char kFullscreenPrefPath[] =
158 "profile.default_content_setting_values.fullscreen";
159 #if !defined(OS_ANDROID)
160 static const char kMouselockPrefPath[] =
161 "profile.default_content_setting_values.mouselock";
162 #endif
163 static const char kGeolocationPrefPath[] =
164 "profile.default_content_setting_values.geolocation";
165
166 PrefService* prefs = profile_.GetPrefs();
167 // Set some pref data.
168 prefs->SetInteger(kFullscreenPrefPath, CONTENT_SETTING_BLOCK);
169 #if !defined(OS_ANDROID)
170 prefs->SetInteger(kMouselockPrefPath, CONTENT_SETTING_ALLOW);
171 #endif
172 prefs->SetInteger(kGeolocationPrefPath, CONTENT_SETTING_BLOCK);
173
174 // Instantiate a new DefaultProvider; can't use |provider_| because we want to
175 // test the constructor's behavior after setting the above.
176 DefaultProvider provider(prefs, false);
177
178 // Check that fullscreen and mouselock have been deleted.
179 EXPECT_FALSE(prefs->HasPrefPath(kFullscreenPrefPath));
180 #if !defined(OS_ANDROID)
181 EXPECT_FALSE(prefs->HasPrefPath(kMouselockPrefPath));
182 #endif
183 EXPECT_TRUE(prefs->HasPrefPath(kGeolocationPrefPath));
184 EXPECT_EQ(CONTENT_SETTING_BLOCK, prefs->GetInteger(kGeolocationPrefPath));
185 }
186
155 TEST_F(DefaultProviderTest, OffTheRecord) { 187 TEST_F(DefaultProviderTest, OffTheRecord) {
156 DefaultProvider otr_provider(profile_.GetPrefs(), true /* incognito */); 188 DefaultProvider otr_provider(profile_.GetPrefs(), true /* incognito */);
157 189
158 EXPECT_EQ(CONTENT_SETTING_ALLOW, 190 EXPECT_EQ(CONTENT_SETTING_ALLOW,
159 TestUtils::GetContentSetting( 191 TestUtils::GetContentSetting(
160 &provider_, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES, 192 &provider_, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES,
161 std::string(), false /* include_incognito */)); 193 std::string(), false /* include_incognito */));
162 EXPECT_EQ(CONTENT_SETTING_ALLOW, 194 EXPECT_EQ(CONTENT_SETTING_ALLOW,
163 TestUtils::GetContentSetting( 195 TestUtils::GetContentSetting(
164 &otr_provider, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES, 196 &otr_provider, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 EXPECT_EQ(CONTENT_SETTING_BLOCK, 239 EXPECT_EQ(CONTENT_SETTING_BLOCK,
208 TestUtils::GetContentSetting( 240 TestUtils::GetContentSetting(
209 &otr_provider2, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES, 241 &otr_provider2, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES,
210 std::string(), true /* include_incognito */)); 242 std::string(), true /* include_incognito */));
211 243
212 otr_provider.ShutdownOnUIThread(); 244 otr_provider.ShutdownOnUIThread();
213 otr_provider2.ShutdownOnUIThread(); 245 otr_provider2.ShutdownOnUIThread();
214 } 246 }
215 247
216 } // namespace content_settings 248 } // namespace content_settings
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_pref_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698