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

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

Issue 2428433002: Delete fullscreen/mouselock pref data. (Closed)
Patch Set: Fix test by avoiding JS update calls. 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
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 static const char kMouselockPrefPath[] =
160 "profile.default_content_setting_values.mouselock";
161 static const char kGeolocationPrefPath[] =
162 "profile.default_content_setting_values.geolocation";
163
164 PrefService* prefs = profile_.GetPrefs();
165 // Set some pref data.
166 prefs->SetInteger(kFullscreenPrefPath, CONTENT_SETTING_BLOCK);
167 prefs->SetInteger(kMouselockPrefPath, CONTENT_SETTING_ALLOW);
168 prefs->SetInteger(kGeolocationPrefPath, CONTENT_SETTING_BLOCK);
169
170 // Instantiate a new DefaultProvider; can't use |provider_| because we want to
171 // test the constructor's behavior after setting the above.
172 DefaultProvider provider(prefs, false);
173
174 // Check that fullscreen and mouselock have been deleted.
175 EXPECT_FALSE(prefs->HasPrefPath(kFullscreenPrefPath));
176 EXPECT_FALSE(prefs->HasPrefPath(kMouselockPrefPath));
177 EXPECT_TRUE(prefs->HasPrefPath(kGeolocationPrefPath));
178 EXPECT_EQ(CONTENT_SETTING_BLOCK, prefs->GetInteger(kGeolocationPrefPath));
179 }
180
155 TEST_F(DefaultProviderTest, OffTheRecord) { 181 TEST_F(DefaultProviderTest, OffTheRecord) {
156 DefaultProvider otr_provider(profile_.GetPrefs(), true /* incognito */); 182 DefaultProvider otr_provider(profile_.GetPrefs(), true /* incognito */);
157 183
158 EXPECT_EQ(CONTENT_SETTING_ALLOW, 184 EXPECT_EQ(CONTENT_SETTING_ALLOW,
159 TestUtils::GetContentSetting( 185 TestUtils::GetContentSetting(
160 &provider_, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES, 186 &provider_, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES,
161 std::string(), false /* include_incognito */)); 187 std::string(), false /* include_incognito */));
162 EXPECT_EQ(CONTENT_SETTING_ALLOW, 188 EXPECT_EQ(CONTENT_SETTING_ALLOW,
163 TestUtils::GetContentSetting( 189 TestUtils::GetContentSetting(
164 &otr_provider, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES, 190 &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, 233 EXPECT_EQ(CONTENT_SETTING_BLOCK,
208 TestUtils::GetContentSetting( 234 TestUtils::GetContentSetting(
209 &otr_provider2, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES, 235 &otr_provider2, GURL(), GURL(), CONTENT_SETTINGS_TYPE_COOKIES,
210 std::string(), true /* include_incognito */)); 236 std::string(), true /* include_incognito */));
211 237
212 otr_provider.ShutdownOnUIThread(); 238 otr_provider.ShutdownOnUIThread();
213 otr_provider2.ShutdownOnUIThread(); 239 otr_provider2.ShutdownOnUIThread();
214 } 240 }
215 241
216 } // namespace content_settings 242 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698