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

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

Issue 6542048: Add content_settings::PolicyProvider and a set of new policies to managed content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 10 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) 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/content_settings/content_settings_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h"
6 6
7 #include "chrome/browser/browser_thread.h" 7 #include "chrome/browser/browser_thread.h"
8 #include "chrome/browser/content_settings/stub_settings_observer.h" 8 #include "chrome/browser/content_settings/stub_settings_observer.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "chrome/test/testing_pref_service.h" 12 #include "chrome/test/testing_pref_service.h"
13 #include "chrome/test/testing_profile.h" 13 #include "chrome/test/testing_profile.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15 #include "googleurl/src/gurl.h"
16 16
17 namespace content_settings { 17 namespace content_settings {
18 18
19 class PolicyDefaultProviderTest : public testing::Test { 19 class PolicyDefaultProviderTest : public testing::Test {
20 public: 20 public:
21 PolicyDefaultProviderTest() 21 PolicyDefaultProviderTest()
22 : ui_thread_(BrowserThread::UI, &message_loop_) { 22 : ui_thread_(BrowserThread::UI, &message_loop_) {
23 } 23 }
24 24
25 protected: 25 protected:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Remove the managed default-content-setting. 73 // Remove the managed default-content-setting.
74 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); 74 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting);
75 EXPECT_EQ(profile.GetHostContentSettingsMap(), observer.last_notifier); 75 EXPECT_EQ(profile.GetHostContentSettingsMap(), observer.last_notifier);
76 EXPECT_EQ(CONTENT_SETTINGS_TYPE_DEFAULT, observer.last_type); 76 EXPECT_EQ(CONTENT_SETTINGS_TYPE_DEFAULT, observer.last_type);
77 EXPECT_EQ(ContentSettingsPattern(), observer.last_pattern); 77 EXPECT_EQ(ContentSettingsPattern(), observer.last_pattern);
78 EXPECT_TRUE(observer.last_update_all); 78 EXPECT_TRUE(observer.last_update_all);
79 EXPECT_TRUE(observer.last_update_all_types); 79 EXPECT_TRUE(observer.last_update_all_types);
80 EXPECT_EQ(2, observer.counter); 80 EXPECT_EQ(2, observer.counter);
81 } 81 }
82 82
83 class PolicyProviderTest : public testing::Test {
84 public:
85 PolicyProviderTest()
86 : ui_thread_(BrowserThread::UI, &message_loop_) {
Bernhard Bauer 2011/02/23 13:18:53 Is this because of a |DCHECK(BrowserThread::Curren
Bernhard Bauer 2011/02/25 16:08:01 Did you see this comment?
markusheintz_ 2011/02/28 09:08:44 Sorry I forgot to add my reply. Yeah I agree. We s
87 }
88
89 protected:
90 MessageLoop message_loop_;
91 BrowserThread ui_thread_;
92 };
93
94 TEST_F(PolicyProviderTest, Default) {
95 TestingProfile profile;
96 TestingPrefService* prefs = profile.GetTestingPrefService();
97
98 ListValue* value = new ListValue();
99 value->Append(Value::CreateStringValue("[*.]google.com"));
100 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls,
101 value);
102
103 PolicyProvider provider(static_cast<Profile*>(&profile));
104
105 ContentSettingsPattern yt_url_pattern("www.youtube.com");
106 GURL youtube_url("http://www.youtube.com");
107 GURL google_url("http://mail.google.com");
108
109 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
110 provider.GetContentSetting(
111 youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, ""));
112 EXPECT_EQ(CONTENT_SETTING_BLOCK,
113 provider.GetContentSetting(
114 google_url, google_url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
115
116 provider.SetContentSetting(
117 yt_url_pattern,
118 yt_url_pattern,
119 CONTENT_SETTINGS_TYPE_COOKIES,
120 "",
121 CONTENT_SETTING_BLOCK);
122 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
123 provider.GetContentSetting(
124 youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, ""));
125 }
126
83 } // namespace content_settings 127 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698