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

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

Issue 376253005: Migrate the notification permission to the new common permission classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/desktop_notification_service.h"
6
7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/synchronization/waitable_event.h"
11 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/testing_profile.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/web/WebNotificationPresenter.h"
16
17 class DesktopNotificationServiceTest : public ChromeRenderViewHostTestHarness {
18 protected:
19 virtual void SetUp() {
20 ChromeRenderViewHostTestHarness::SetUp();
21
22 // Creates the destop notification service.
23 service_ = DesktopNotificationServiceFactory::GetForProfile(profile());
24 }
25
26 DesktopNotificationService* service_;
27 };
28
29
30 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) {
31 service_->GrantPermission(GURL("http://allowed2.com"));
32 service_->GrantPermission(GURL("http://allowed.com"));
33 service_->DenyPermission(GURL("http://denied2.com"));
34 service_->DenyPermission(GURL("http://denied.com"));
35
36 ContentSettingsForOneType settings;
37 service_->GetNotificationsSettings(&settings);
38 // |settings| contains the default setting and 4 exceptions.
39 ASSERT_EQ(5u, settings.size());
40
41 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
42 GURL("http://allowed.com")),
43 settings[0].primary_pattern);
44 EXPECT_EQ(CONTENT_SETTING_ALLOW,
45 settings[0].setting);
46 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
47 GURL("http://allowed2.com")),
48 settings[1].primary_pattern);
49 EXPECT_EQ(CONTENT_SETTING_ALLOW,
50 settings[1].setting);
51 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
52 GURL("http://denied.com")),
53 settings[2].primary_pattern);
54 EXPECT_EQ(CONTENT_SETTING_BLOCK,
55 settings[2].setting);
56 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(
57 GURL("http://denied2.com")),
58 settings[3].primary_pattern);
59 EXPECT_EQ(CONTENT_SETTING_BLOCK,
60 settings[3].setting);
61 EXPECT_EQ(ContentSettingsPattern::Wildcard(),
62 settings[4].primary_pattern);
63 EXPECT_EQ(CONTENT_SETTING_ASK,
64 settings[4].setting);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698