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

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

Issue 7088017: Split incognito extension content settings in session-only and persistent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 6 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) 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 "chrome/browser/content_settings/content_settings_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_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 "chrome/browser/content_settings/stub_settings_observer.h" 9 #include "chrome/browser/content_settings/mock_settings_observer.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/testing_browser_process_test.h" 14 #include "chrome/test/testing_browser_process_test.h"
15 #include "chrome/test/testing_pref_service.h" 15 #include "chrome/test/testing_pref_service.h"
16 #include "chrome/test/testing_profile.h" 16 #include "chrome/test/testing_profile.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 20
21 using ::testing::_;
22
21 namespace content_settings { 23 namespace content_settings {
22 24
23 class PolicyDefaultProviderTest : public TestingBrowserProcessTest { 25 class PolicyDefaultProviderTest : public TestingBrowserProcessTest {
24 public: 26 public:
25 PolicyDefaultProviderTest() 27 PolicyDefaultProviderTest()
26 : ui_thread_(BrowserThread::UI, &message_loop_) { 28 : ui_thread_(BrowserThread::UI, &message_loop_) {
27 } 29 }
28 30
29 protected: 31 protected:
30 MessageLoop message_loop_; 32 MessageLoop message_loop_;
(...skipping 21 matching lines...) Expand all
52 prefs->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting); 54 prefs->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting);
53 ASSERT_FALSE( 55 ASSERT_FALSE(
54 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_COOKIES)); 56 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_COOKIES));
55 } 57 }
56 58
57 // When a default-content-setting is set to a managed setting a 59 // When a default-content-setting is set to a managed setting a
58 // CONTENT_SETTINGS_CHANGED notification should be fired. The same should happen 60 // CONTENT_SETTINGS_CHANGED notification should be fired. The same should happen
59 // if the managed setting is removed. 61 // if the managed setting is removed.
60 TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) { 62 TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) {
61 TestingProfile profile; 63 TestingProfile profile;
62 StubSettingsObserver observer; 64 MockSettingsObserver observer;
63 // Make sure the content settings map exists. 65 // Make sure the content settings map exists.
64 profile.GetHostContentSettingsMap(); 66 profile.GetHostContentSettingsMap();
65 TestingPrefService* prefs = profile.GetTestingPrefService(); 67 TestingPrefService* prefs = profile.GetTestingPrefService();
66 68
67 // Set the managed default-content-setting. 69 // Set the managed default-content-setting.
70 EXPECT_CALL(observer,
71 OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
72 CONTENT_SETTINGS_TYPE_DEFAULT, true,
73 _, true));
68 prefs->SetManagedPref(prefs::kManagedDefaultImagesSetting, 74 prefs->SetManagedPref(prefs::kManagedDefaultImagesSetting,
69 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 75 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
70 EXPECT_EQ(profile.GetHostContentSettingsMap(), observer.last_notifier); 76 ::testing::Mock::VerifyAndClearExpectations(&observer);
71 EXPECT_EQ(CONTENT_SETTINGS_TYPE_DEFAULT, observer.last_type);
72 EXPECT_TRUE(observer.last_update_all);
73 EXPECT_TRUE(observer.last_update_all_types);
74 EXPECT_EQ(1, observer.counter);
75 77
78 EXPECT_CALL(observer,
79 OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
80 CONTENT_SETTINGS_TYPE_DEFAULT, true,
81 _, true));
76 // Remove the managed default-content-setting. 82 // Remove the managed default-content-setting.
77 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); 83 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting);
78 EXPECT_EQ(profile.GetHostContentSettingsMap(), observer.last_notifier);
79 EXPECT_EQ(CONTENT_SETTINGS_TYPE_DEFAULT, observer.last_type);
80 EXPECT_TRUE(observer.last_update_all);
81 EXPECT_TRUE(observer.last_update_all_types);
82 EXPECT_EQ(2, observer.counter);
83 } 84 }
84 85
85 class PolicyProviderTest : public testing::Test { 86 class PolicyProviderTest : public testing::Test {
86 public: 87 public:
87 PolicyProviderTest() 88 PolicyProviderTest()
88 : ui_thread_(BrowserThread::UI, &message_loop_) { 89 : ui_thread_(BrowserThread::UI, &message_loop_) {
89 } 90 }
90 91
91 protected: 92 protected:
92 // TODO(markusheintz): Check if it's possible to derive the provider class 93 // TODO(markusheintz): Check if it's possible to derive the provider class
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 EXPECT_EQ(CONTENT_SETTING_ALLOW, 177 EXPECT_EQ(CONTENT_SETTING_ALLOW,
177 provider.GetContentSetting( 178 provider.GetContentSetting(
178 google_url, 179 google_url,
179 google_url, 180 google_url,
180 CONTENT_SETTINGS_TYPE_PLUGINS, 181 CONTENT_SETTINGS_TYPE_PLUGINS,
181 "anotherplugin")); 182 "anotherplugin"));
182 } 183 }
183 184
184 } // namespace content_settings 185 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698