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

Side by Side Diff: chrome/browser/host_content_settings_map_unittest.cc

Issue 3068005: Flesh out the content settings exceptions lists a bit more. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: reduce instance vars Created 10 years, 4 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
« no previous file with comments | « chrome/browser/host_content_settings_map.cc ('k') | chrome/browser/resources/options.html » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/host_content_settings_map.h" 5 #include "chrome/browser/host_content_settings_map.h"
6 6
7 #include "chrome/browser/pref_service.h" 7 #include "chrome/browser/pref_service.h"
8 #include "chrome/common/notification_registrar.h" 8 #include "chrome/common/notification_registrar.h"
9 #include "chrome/common/notification_service.h" 9 #include "chrome/common/notification_service.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 24 matching lines...) Expand all
35 virtual void Observe(NotificationType type, 35 virtual void Observe(NotificationType type,
36 const NotificationSource& source, 36 const NotificationSource& source,
37 const NotificationDetails& details) { 37 const NotificationDetails& details) {
38 ++counter; 38 ++counter;
39 Source<HostContentSettingsMap> content_settings(source); 39 Source<HostContentSettingsMap> content_settings(source);
40 Details<HostContentSettingsMap::ContentSettingsDetails> 40 Details<HostContentSettingsMap::ContentSettingsDetails>
41 settings_details(details); 41 settings_details(details);
42 last_notifier = content_settings.ptr(); 42 last_notifier = content_settings.ptr();
43 last_pattern = settings_details.ptr()->pattern(); 43 last_pattern = settings_details.ptr()->pattern();
44 last_update_all = settings_details.ptr()->update_all(); 44 last_update_all = settings_details.ptr()->update_all();
45 last_update_all_types = settings_details.ptr()->update_all_types();
45 // This checks that calling a Get function from an observer doesn't 46 // This checks that calling a Get function from an observer doesn't
46 // deadlock. 47 // deadlock.
47 last_notifier->GetContentSettings(GURL("http://random-hostname.com/")); 48 last_notifier->GetContentSettings(GURL("http://random-hostname.com/"));
48 } 49 }
49 50
50 HostContentSettingsMap* last_notifier; 51 HostContentSettingsMap* last_notifier;
51 HostContentSettingsMap::Pattern last_pattern; 52 HostContentSettingsMap::Pattern last_pattern;
52 bool last_update_all; 53 bool last_update_all;
54 bool last_update_all_types;
53 int counter; 55 int counter;
54 56
55 private: 57 private:
56 NotificationRegistrar registrar_; 58 NotificationRegistrar registrar_;
57 }; 59 };
58 60
59 class HostContentSettingsMapTest : public testing::Test { 61 class HostContentSettingsMapTest : public testing::Test {
60 public: 62 public:
61 HostContentSettingsMapTest() : ui_thread_(ChromeThread::UI, &message_loop_) {} 63 HostContentSettingsMapTest() : ui_thread_(ChromeThread::UI, &message_loop_) {}
62 64
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 HostContentSettingsMap* host_content_settings_map = 245 HostContentSettingsMap* host_content_settings_map =
244 profile.GetHostContentSettingsMap(); 246 profile.GetHostContentSettingsMap();
245 StubSettingsObserver observer; 247 StubSettingsObserver observer;
246 248
247 HostContentSettingsMap::Pattern pattern("[*.]example.com"); 249 HostContentSettingsMap::Pattern pattern("[*.]example.com");
248 host_content_settings_map->SetContentSetting(pattern, 250 host_content_settings_map->SetContentSetting(pattern,
249 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_ALLOW); 251 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_ALLOW);
250 EXPECT_EQ(host_content_settings_map, observer.last_notifier); 252 EXPECT_EQ(host_content_settings_map, observer.last_notifier);
251 EXPECT_EQ(pattern, observer.last_pattern); 253 EXPECT_EQ(pattern, observer.last_pattern);
252 EXPECT_FALSE(observer.last_update_all); 254 EXPECT_FALSE(observer.last_update_all);
255 EXPECT_FALSE(observer.last_update_all_types);
253 EXPECT_EQ(1, observer.counter); 256 EXPECT_EQ(1, observer.counter);
254 257
255 host_content_settings_map->ClearSettingsForOneType( 258 host_content_settings_map->ClearSettingsForOneType(
256 CONTENT_SETTINGS_TYPE_IMAGES); 259 CONTENT_SETTINGS_TYPE_IMAGES);
257 EXPECT_EQ(host_content_settings_map, observer.last_notifier); 260 EXPECT_EQ(host_content_settings_map, observer.last_notifier);
258 EXPECT_TRUE(observer.last_update_all); 261 EXPECT_TRUE(observer.last_update_all);
262 EXPECT_FALSE(observer.last_update_all_types);
259 EXPECT_EQ(2, observer.counter); 263 EXPECT_EQ(2, observer.counter);
260 264
261 host_content_settings_map->ResetToDefaults(); 265 host_content_settings_map->ResetToDefaults();
262 EXPECT_EQ(host_content_settings_map, observer.last_notifier); 266 EXPECT_EQ(host_content_settings_map, observer.last_notifier);
263 EXPECT_TRUE(observer.last_update_all); 267 EXPECT_TRUE(observer.last_update_all);
268 EXPECT_TRUE(observer.last_update_all_types);
264 EXPECT_EQ(3, observer.counter); 269 EXPECT_EQ(3, observer.counter);
265 270
266 host_content_settings_map->SetDefaultContentSetting( 271 host_content_settings_map->SetDefaultContentSetting(
267 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); 272 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
268 EXPECT_EQ(host_content_settings_map, observer.last_notifier); 273 EXPECT_EQ(host_content_settings_map, observer.last_notifier);
269 EXPECT_TRUE(observer.last_update_all); 274 EXPECT_TRUE(observer.last_update_all);
275 EXPECT_FALSE(observer.last_update_all_types);
270 EXPECT_EQ(4, observer.counter); 276 EXPECT_EQ(4, observer.counter);
271 } 277 }
272 278
273 TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { 279 TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) {
274 TestingProfile profile; 280 TestingProfile profile;
275 HostContentSettingsMap* host_content_settings_map = 281 HostContentSettingsMap* host_content_settings_map =
276 profile.GetHostContentSettingsMap(); 282 profile.GetHostContentSettingsMap();
277 283
278 PrefService* prefs = profile.GetPrefs(); 284 PrefService* prefs = profile.GetPrefs();
279 285
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_ALLOW); 515 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_ALLOW);
510 EXPECT_EQ(CONTENT_SETTING_BLOCK, 516 EXPECT_EQ(CONTENT_SETTING_BLOCK,
511 host_content_settings_map->GetContentSetting( 517 host_content_settings_map->GetContentSetting(
512 host, CONTENT_SETTINGS_TYPE_IMAGES)); 518 host, CONTENT_SETTINGS_TYPE_IMAGES));
513 EXPECT_EQ(CONTENT_SETTING_ALLOW, 519 EXPECT_EQ(CONTENT_SETTING_ALLOW,
514 otr_map->GetContentSetting( 520 otr_map->GetContentSetting(
515 host, CONTENT_SETTINGS_TYPE_IMAGES)); 521 host, CONTENT_SETTINGS_TYPE_IMAGES));
516 } 522 }
517 523
518 } // namespace 524 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/host_content_settings_map.cc ('k') | chrome/browser/resources/options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698