Chromium Code Reviews| Index: chrome/browser/notifications/message_center_settings_controller_unittest.cc |
| diff --git a/chrome/browser/notifications/message_center_settings_controller_unittest.cc b/chrome/browser/notifications/message_center_settings_controller_unittest.cc |
| index cd8e18b8656882e7d73ce10fbe188fce2bd271a4..40b9ef0e9003295f8f18d9c57798128e03c2d7ec 100644 |
| --- a/chrome/browser/notifications/message_center_settings_controller_unittest.cc |
| +++ b/chrome/browser/notifications/message_center_settings_controller_unittest.cc |
| @@ -8,11 +8,13 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/test_extension_system.h" |
| +#include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| #include "chrome/browser/notifications/message_center_settings_controller.h" |
| #include "chrome/browser/profiles/profile_info_cache.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/test/base/testing_browser_process.h" |
| #include "chrome/test/base/testing_profile_manager.h" |
| +#include "components/content_settings/core/browser/host_content_settings_map.h" |
| #include "content/public/test/test_browser_thread_bundle.h" |
| #include "extensions/common/extension.h" |
| #include "extensions/common/extension_builder.h" |
| @@ -28,7 +30,7 @@ |
| class MessageCenterSettingsControllerBaseTest : public testing::Test { |
| protected: |
| MessageCenterSettingsControllerBaseTest() |
| - : testing_profile_manager_(TestingBrowserProcess::GetGlobal()){}; |
| + : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
| ~MessageCenterSettingsControllerBaseTest() override{}; |
| @@ -257,3 +259,45 @@ TEST_F(MessageCenterSettingsControllerTest, NotifierSortOrder) { |
| STLDeleteElements(¬ifiers); |
| } |
| + |
| +TEST_F(MessageCenterSettingsControllerTest, SetWebPageNotifierEnabled) { |
| + Profile* profile = CreateProfile("MyProfile"); |
| + CreateController(); |
| + |
| + GURL origin("https://example.com/"); |
| + |
| + message_center::NotifierId notifier_id(origin); |
| + message_center::Notifier enabled_notifier( |
| + notifier_id, base::string16(), true); |
| + message_center::Notifier disabled_notifier( |
| + notifier_id, base::string16(), false); |
| + |
| + ContentSetting default_setting = |
| + profile->GetHostContentSettingsMap()->GetDefaultContentSetting( |
| + CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); |
| + ASSERT_EQ(CONTENT_SETTING_ASK, default_setting); |
| + |
| + // (1) Enable the permission when the default is to ask (expected to set). |
| + controller()->SetNotifierEnabled(disabled_notifier, true); |
| + EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| + DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); |
| + |
| + // (2) Disable the permission when the default is to ask (expected to clear). |
|
dewittj
2015/04/27 16:48:51
Is this true? I would expect an explicit disable b
Peter Beverloo
2015/04/28 12:14:45
I noticed this (default allowed -> disable does BL
|
| + controller()->SetNotifierEnabled(enabled_notifier, false); |
| + EXPECT_EQ(CONTENT_SETTING_ASK, |
| + DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); |
| + |
| + // Change the default content setting vaule for notifications to ALLOW. |
| + profile->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| + CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); |
| + |
| + // (3) Disable the permission when the default is allowed (expected to set). |
| + controller()->SetNotifierEnabled(enabled_notifier, false); |
| + EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| + DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); |
| + |
| + // (4) Enable the permission when the default is allowed (expected to clear). |
| + controller()->SetNotifierEnabled(disabled_notifier, true); |
| + EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| + DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); |
| +} |
|
dewittj
2015/04/27 16:48:51
what about default is block?
Peter Beverloo
2015/04/28 12:14:45
Done.
|