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

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

Issue 385263004: Get rid of some uses of CreateIntegerValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/content_settings/content_settings_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 CONTENT_SETTINGS_TYPE_IMAGES, 116 CONTENT_SETTINGS_TYPE_IMAGES,
117 "")); 117 ""));
118 118
119 pref_content_settings_provider.AddObserver(&mock_observer); 119 pref_content_settings_provider.AddObserver(&mock_observer);
120 120
121 pref_content_settings_provider.SetWebsiteSetting( 121 pref_content_settings_provider.SetWebsiteSetting(
122 pattern, 122 pattern,
123 ContentSettingsPattern::Wildcard(), 123 ContentSettingsPattern::Wildcard(),
124 CONTENT_SETTINGS_TYPE_IMAGES, 124 CONTENT_SETTINGS_TYPE_IMAGES,
125 std::string(), 125 std::string(),
126 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); 126 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
127 127
128 pref_content_settings_provider.ShutdownOnUIThread(); 128 pref_content_settings_provider.ShutdownOnUIThread();
129 } 129 }
130 130
131 // Test for regression in which the PrefProvider modified the user pref store 131 // Test for regression in which the PrefProvider modified the user pref store
132 // of the OTR unintentionally: http://crbug.com/74466. 132 // of the OTR unintentionally: http://crbug.com/74466.
133 TEST_F(PrefProviderTest, Incognito) { 133 TEST_F(PrefProviderTest, Incognito) {
134 PersistentPrefStore* user_prefs = new TestingPrefStore(); 134 PersistentPrefStore* user_prefs = new TestingPrefStore();
135 OverlayUserPrefStore* otr_user_prefs = 135 OverlayUserPrefStore* otr_user_prefs =
136 new OverlayUserPrefStore(user_prefs); 136 new OverlayUserPrefStore(user_prefs);
(...skipping 28 matching lines...) Expand all
165 165
166 PrefProvider pref_content_settings_provider(regular_prefs, false); 166 PrefProvider pref_content_settings_provider(regular_prefs, false);
167 PrefProvider pref_content_settings_provider_incognito(otr_prefs, true); 167 PrefProvider pref_content_settings_provider_incognito(otr_prefs, true);
168 ContentSettingsPattern pattern = 168 ContentSettingsPattern pattern =
169 ContentSettingsPattern::FromString("[*.]example.com"); 169 ContentSettingsPattern::FromString("[*.]example.com");
170 pref_content_settings_provider.SetWebsiteSetting( 170 pref_content_settings_provider.SetWebsiteSetting(
171 pattern, 171 pattern,
172 pattern, 172 pattern,
173 CONTENT_SETTINGS_TYPE_IMAGES, 173 CONTENT_SETTINGS_TYPE_IMAGES,
174 std::string(), 174 std::string(),
175 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); 175 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
176 176
177 GURL host("http://example.com/"); 177 GURL host("http://example.com/");
178 // The value should of course be visible in the regular PrefProvider. 178 // The value should of course be visible in the regular PrefProvider.
179 EXPECT_EQ(CONTENT_SETTING_ALLOW, 179 EXPECT_EQ(CONTENT_SETTING_ALLOW,
180 GetContentSetting(&pref_content_settings_provider, 180 GetContentSetting(&pref_content_settings_provider,
181 host, 181 host,
182 host, 182 host,
183 CONTENT_SETTINGS_TYPE_IMAGES, 183 CONTENT_SETTINGS_TYPE_IMAGES,
184 std::string(), 184 std::string(),
185 false)); 185 false));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 primary_url, 220 primary_url,
221 primary_url, 221 primary_url,
222 CONTENT_SETTINGS_TYPE_IMAGES, 222 CONTENT_SETTINGS_TYPE_IMAGES,
223 std::string(), 223 std::string(),
224 false)); 224 false));
225 225
226 provider.SetWebsiteSetting(primary_pattern, 226 provider.SetWebsiteSetting(primary_pattern,
227 primary_pattern, 227 primary_pattern,
228 CONTENT_SETTINGS_TYPE_IMAGES, 228 CONTENT_SETTINGS_TYPE_IMAGES,
229 std::string(), 229 std::string(),
230 base::Value::CreateIntegerValue( 230 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
231 CONTENT_SETTING_BLOCK));
232 EXPECT_EQ(CONTENT_SETTING_BLOCK, 231 EXPECT_EQ(CONTENT_SETTING_BLOCK,
233 GetContentSetting(&provider, 232 GetContentSetting(&provider,
234 primary_url, 233 primary_url,
235 primary_url, 234 primary_url,
236 CONTENT_SETTINGS_TYPE_IMAGES, 235 CONTENT_SETTINGS_TYPE_IMAGES,
237 std::string(), 236 std::string(),
238 false)); 237 false));
239 scoped_ptr<base::Value> value_ptr( 238 scoped_ptr<base::Value> value_ptr(
240 GetContentSettingValue(&provider, 239 GetContentSettingValue(&provider,
241 primary_url, 240 primary_url,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 host1, 282 host1,
284 host1, 283 host1,
285 CONTENT_SETTINGS_TYPE_IMAGES, 284 CONTENT_SETTINGS_TYPE_IMAGES,
286 std::string(), 285 std::string(),
287 false)); 286 false));
288 pref_content_settings_provider.SetWebsiteSetting( 287 pref_content_settings_provider.SetWebsiteSetting(
289 pattern1, 288 pattern1,
290 pattern1, 289 pattern1,
291 CONTENT_SETTINGS_TYPE_IMAGES, 290 CONTENT_SETTINGS_TYPE_IMAGES,
292 std::string(), 291 std::string(),
293 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 292 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
294 EXPECT_EQ(CONTENT_SETTING_BLOCK, 293 EXPECT_EQ(CONTENT_SETTING_BLOCK,
295 GetContentSetting(&pref_content_settings_provider, 294 GetContentSetting(&pref_content_settings_provider,
296 host1, 295 host1,
297 host1, 296 host1,
298 CONTENT_SETTINGS_TYPE_IMAGES, 297 CONTENT_SETTINGS_TYPE_IMAGES,
299 std::string(), 298 std::string(),
300 false)); 299 false));
301 EXPECT_EQ(CONTENT_SETTING_BLOCK, 300 EXPECT_EQ(CONTENT_SETTING_BLOCK,
302 GetContentSetting(&pref_content_settings_provider, 301 GetContentSetting(&pref_content_settings_provider,
303 host2, 302 host2,
304 host2, 303 host2,
305 CONTENT_SETTINGS_TYPE_IMAGES, 304 CONTENT_SETTINGS_TYPE_IMAGES,
306 std::string(), 305 std::string(),
307 false)); 306 false));
308 307
309 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 308 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
310 GetContentSetting(&pref_content_settings_provider, 309 GetContentSetting(&pref_content_settings_provider,
311 host3, 310 host3,
312 host3, 311 host3,
313 CONTENT_SETTINGS_TYPE_IMAGES, 312 CONTENT_SETTINGS_TYPE_IMAGES,
314 std::string(), 313 std::string(),
315 false)); 314 false));
316 pref_content_settings_provider.SetWebsiteSetting( 315 pref_content_settings_provider.SetWebsiteSetting(
317 pattern2, 316 pattern2,
318 pattern2, 317 pattern2,
319 CONTENT_SETTINGS_TYPE_IMAGES, 318 CONTENT_SETTINGS_TYPE_IMAGES,
320 std::string(), 319 std::string(),
321 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 320 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
322 EXPECT_EQ(CONTENT_SETTING_BLOCK, 321 EXPECT_EQ(CONTENT_SETTING_BLOCK,
323 GetContentSetting(&pref_content_settings_provider, 322 GetContentSetting(&pref_content_settings_provider,
324 host3, 323 host3,
325 host3, 324 host3,
326 CONTENT_SETTINGS_TYPE_IMAGES, 325 CONTENT_SETTINGS_TYPE_IMAGES,
327 std::string(), 326 std::string(),
328 false)); 327 false));
329 328
330 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 329 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
331 GetContentSetting(&pref_content_settings_provider, 330 GetContentSetting(&pref_content_settings_provider,
332 host4, 331 host4,
333 host4, 332 host4,
334 CONTENT_SETTINGS_TYPE_IMAGES, 333 CONTENT_SETTINGS_TYPE_IMAGES,
335 std::string(), 334 std::string(),
336 false)); 335 false));
337 pref_content_settings_provider.SetWebsiteSetting( 336 pref_content_settings_provider.SetWebsiteSetting(
338 pattern3, 337 pattern3,
339 pattern3, 338 pattern3,
340 CONTENT_SETTINGS_TYPE_IMAGES, 339 CONTENT_SETTINGS_TYPE_IMAGES,
341 std::string(), 340 std::string(),
342 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 341 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
343 EXPECT_EQ(CONTENT_SETTING_BLOCK, 342 EXPECT_EQ(CONTENT_SETTING_BLOCK,
344 GetContentSetting(&pref_content_settings_provider, 343 GetContentSetting(&pref_content_settings_provider,
345 host4, 344 host4,
346 host4, 345 host4,
347 CONTENT_SETTINGS_TYPE_IMAGES, 346 CONTENT_SETTINGS_TYPE_IMAGES,
348 std::string(), 347 std::string(),
349 false)); 348 false));
350 349
351 pref_content_settings_provider.ShutdownOnUIThread(); 350 pref_content_settings_provider.ShutdownOnUIThread();
352 } 351 }
(...skipping 12 matching lines...) Expand all
365 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 364 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
366 GetContentSetting( 365 GetContentSetting(
367 &pref_content_settings_provider, 366 &pref_content_settings_provider,
368 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, 367 host, host, CONTENT_SETTINGS_TYPE_PLUGINS,
369 resource1, false)); 368 resource1, false));
370 pref_content_settings_provider.SetWebsiteSetting( 369 pref_content_settings_provider.SetWebsiteSetting(
371 pattern, 370 pattern,
372 pattern, 371 pattern,
373 CONTENT_SETTINGS_TYPE_PLUGINS, 372 CONTENT_SETTINGS_TYPE_PLUGINS,
374 resource1, 373 resource1,
375 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 374 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
376 EXPECT_EQ(CONTENT_SETTING_BLOCK, 375 EXPECT_EQ(CONTENT_SETTING_BLOCK,
377 GetContentSetting( 376 GetContentSetting(
378 &pref_content_settings_provider, 377 &pref_content_settings_provider,
379 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, 378 host, host, CONTENT_SETTINGS_TYPE_PLUGINS,
380 resource1, false)); 379 resource1, false));
381 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 380 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
382 GetContentSetting( 381 GetContentSetting(
383 &pref_content_settings_provider, 382 &pref_content_settings_provider,
384 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, 383 host, host, CONTENT_SETTINGS_TYPE_PLUGINS,
385 resource2, false)); 384 resource2, false));
(...skipping 11 matching lines...) Expand all
397 396
398 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 397 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
399 GetContentSetting( 398 GetContentSetting(
400 &provider, 399 &provider,
401 primary_url, 400 primary_url,
402 primary_url, 401 primary_url,
403 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 402 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
404 std::string(), 403 std::string(),
405 false)); 404 false));
406 405
407 provider.SetWebsiteSetting( 406 provider.SetWebsiteSetting(ContentSettingsPattern::FromURL(primary_url),
408 ContentSettingsPattern::FromURL(primary_url), 407 ContentSettingsPattern::Wildcard(),
409 ContentSettingsPattern::Wildcard(), 408 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
410 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 409 std::string(),
411 std::string(), 410 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
412 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
413 EXPECT_EQ(CONTENT_SETTING_ALLOW, 411 EXPECT_EQ(CONTENT_SETTING_ALLOW,
414 GetContentSetting( 412 GetContentSetting(
415 &provider, 413 &provider,
416 primary_url, 414 primary_url,
417 secondary_url, 415 secondary_url,
418 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 416 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
419 std::string(), 417 std::string(),
420 false)); 418 false));
421 provider.ShutdownOnUIThread(); 419 provider.ShutdownOnUIThread();
422 } 420 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 base::Time second = pref_content_settings_provider.GetLastUsage( 472 base::Time second = pref_content_settings_provider.GetLastUsage(
475 pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); 473 pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION);
476 474
477 base::TimeDelta delta = second - first; 475 base::TimeDelta delta = second - first;
478 EXPECT_EQ(delta.InSeconds(), 10); 476 EXPECT_EQ(delta.InSeconds(), 10);
479 477
480 pref_content_settings_provider.ShutdownOnUIThread(); 478 pref_content_settings_provider.ShutdownOnUIThread();
481 } 479 }
482 480
483 } // namespace content_settings 481 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698