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

Side by Side Diff: chrome/browser/notifications/desktop_notification_profile_util_unittest.cc

Issue 2938163002: Store base::Value in ContentSettingPatternSource instead of an enum (Closed)
Patch Set: ps Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/desktop_notification_profile_util.h"
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "components/content_settings/core/common/content_settings_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
10 12
11 class DesktopNotificationServiceTest : public ChromeRenderViewHostTestHarness { 13 class DesktopNotificationServiceTest : public ChromeRenderViewHostTestHarness {
12 protected: 14 protected:
13 void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); } 15 void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); }
14 }; 16 };
15 17
16 18
17 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) { 19 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) {
18 DesktopNotificationProfileUtil::GrantPermission(profile(), 20 DesktopNotificationProfileUtil::GrantPermission(profile(),
19 GURL("http://allowed2.com")); 21 GURL("http://allowed2.com"));
20 DesktopNotificationProfileUtil::GrantPermission(profile(), 22 DesktopNotificationProfileUtil::GrantPermission(profile(),
21 GURL("http://allowed.com")); 23 GURL("http://allowed.com"));
22 DesktopNotificationProfileUtil::DenyPermission(profile(), 24 DesktopNotificationProfileUtil::DenyPermission(profile(),
23 GURL("http://denied2.com")); 25 GURL("http://denied2.com"));
24 DesktopNotificationProfileUtil::DenyPermission(profile(), 26 DesktopNotificationProfileUtil::DenyPermission(profile(),
25 GURL("http://denied.com")); 27 GURL("http://denied.com"));
26 28
27 ContentSettingsForOneType settings; 29 ContentSettingsForOneType settings;
28 DesktopNotificationProfileUtil::GetNotificationsSettings( 30 DesktopNotificationProfileUtil::GetNotificationsSettings(
29 profile(), &settings); 31 profile(), &settings);
30 // |settings| contains the default setting and 4 exceptions. 32 // |settings| contains the default setting and 4 exceptions.
31 ASSERT_EQ(5u, settings.size()); 33 ASSERT_EQ(5u, settings.size());
32 34
33 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( 35 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
34 GURL("http://allowed.com")), 36 GURL("http://allowed.com")),
35 settings[0].primary_pattern); 37 settings[0].primary_pattern);
36 EXPECT_EQ(CONTENT_SETTING_ALLOW, 38 EXPECT_EQ(CONTENT_SETTING_ALLOW, content_settings::ValueToContentSetting(
37 settings[0].setting); 39 settings[0].setting_value.get()));
38 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( 40 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
39 GURL("http://allowed2.com")), 41 GURL("http://allowed2.com")),
40 settings[1].primary_pattern); 42 settings[1].primary_pattern);
41 EXPECT_EQ(CONTENT_SETTING_ALLOW, 43 EXPECT_EQ(CONTENT_SETTING_ALLOW, content_settings::ValueToContentSetting(
42 settings[1].setting); 44 settings[1].setting_value.get()));
43 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( 45 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
44 GURL("http://denied.com")), 46 GURL("http://denied.com")),
45 settings[2].primary_pattern); 47 settings[2].primary_pattern);
46 EXPECT_EQ(CONTENT_SETTING_BLOCK, 48 EXPECT_EQ(CONTENT_SETTING_BLOCK, content_settings::ValueToContentSetting(
47 settings[2].setting); 49 settings[2].setting_value.get()));
48 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( 50 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
49 GURL("http://denied2.com")), 51 GURL("http://denied2.com")),
50 settings[3].primary_pattern); 52 settings[3].primary_pattern);
51 EXPECT_EQ(CONTENT_SETTING_BLOCK, 53 EXPECT_EQ(CONTENT_SETTING_BLOCK, content_settings::ValueToContentSetting(
52 settings[3].setting); 54 settings[3].setting_value.get()));
53 EXPECT_EQ(ContentSettingsPattern::Wildcard(), 55 EXPECT_EQ(ContentSettingsPattern::Wildcard(),
54 settings[4].primary_pattern); 56 settings[4].primary_pattern);
55 EXPECT_EQ(CONTENT_SETTING_ASK, 57 EXPECT_EQ(CONTENT_SETTING_ASK, content_settings::ValueToContentSetting(
56 settings[4].setting); 58 settings[4].setting_value.get()));
57 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698