OLD | NEW |
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/notifications/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
12 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 11 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
14 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
15 #include "content/browser/browser_thread.h" | 14 #include "content/browser/browser_thread.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 // The HasPermission method of the DesktopNotificationService wants to be called | 20 // The HasPermission method of the DesktopNotificationService wants to be called |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionAllowed, | 154 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionAllowed, |
156 proxy_->ServiceHasPermission(service_, https_url)); | 155 proxy_->ServiceHasPermission(service_, https_url)); |
157 } | 156 } |
158 | 157 |
159 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) { | 158 TEST_F(DesktopNotificationServiceTest, GetNotificationsSettings) { |
160 service_->GrantPermission(GURL("http://allowed2.com")); | 159 service_->GrantPermission(GURL("http://allowed2.com")); |
161 service_->GrantPermission(GURL("http://allowed.com")); | 160 service_->GrantPermission(GURL("http://allowed.com")); |
162 service_->DenyPermission(GURL("http://denied2.com")); | 161 service_->DenyPermission(GURL("http://denied2.com")); |
163 service_->DenyPermission(GURL("http://denied.com")); | 162 service_->DenyPermission(GURL("http://denied.com")); |
164 | 163 |
165 HostContentSettingsMap::SettingsForOneType settings; | 164 ContentSettingsForOneType settings; |
166 service_->GetNotificationsSettings(&settings); | 165 service_->GetNotificationsSettings(&settings); |
167 // |settings| contains the default setting and 4 exceptions. | 166 // |settings| contains the default setting and 4 exceptions. |
168 ASSERT_EQ(5u, settings.size()); | 167 ASSERT_EQ(5u, settings.size()); |
169 | 168 |
170 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 169 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
171 GURL("http://allowed.com")), | 170 GURL("http://allowed.com")), |
172 settings[0].a); | 171 settings[0].primary_pattern); |
173 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 172 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
174 settings[0].c); | 173 settings[0].setting); |
175 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 174 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
176 GURL("http://allowed2.com")), | 175 GURL("http://allowed2.com")), |
177 settings[1].a); | 176 settings[1].primary_pattern); |
178 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 177 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
179 settings[1].c); | 178 settings[1].setting); |
180 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 179 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
181 GURL("http://denied.com")), | 180 GURL("http://denied.com")), |
182 settings[2].a); | 181 settings[2].primary_pattern); |
183 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 182 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
184 settings[2].c); | 183 settings[2].setting); |
185 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( | 184 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( |
186 GURL("http://denied2.com")), | 185 GURL("http://denied2.com")), |
187 settings[3].a); | 186 settings[3].primary_pattern); |
188 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 187 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
189 settings[3].c); | 188 settings[3].setting); |
190 EXPECT_EQ(ContentSettingsPattern::Wildcard(), | 189 EXPECT_EQ(ContentSettingsPattern::Wildcard(), |
191 settings[4].a); | 190 settings[4].primary_pattern); |
192 EXPECT_EQ(CONTENT_SETTING_ASK, | 191 EXPECT_EQ(CONTENT_SETTING_ASK, |
193 settings[4].c); | 192 settings[4].setting); |
194 } | 193 } |
OLD | NEW |