summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/notifications_prefs_cache_unittest.cc
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-03 02:29:52 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-03 02:29:52 +0000
commit78dcb900b1ae1209d87cd746c1ff7d4c13f9f04e (patch)
tree716fc33ee1e0c300f6b56e5921c7b183258458d3 /chrome/browser/notifications/notifications_prefs_cache_unittest.cc
parent1350815259420160cfd2bdf8d94fbf9f80bc379b (diff)
downloadchromium_src-78dcb900b1ae1209d87cd746c1ff7d4c13f9f04e.zip
chromium_src-78dcb900b1ae1209d87cd746c1ff7d4c13f9f04e.tar.gz
chromium_src-78dcb900b1ae1209d87cd746c1ff7d4c13f9f04e.tar.bz2
Add a default content setting to the notifications service.
Not yet used anywhere, no behavior change. BUG=45547 TEST=none (unit tests) Review URL: http://codereview.chromium.org/2842043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications/notifications_prefs_cache_unittest.cc')
-rw-r--r--chrome/browser/notifications/notifications_prefs_cache_unittest.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/browser/notifications/notifications_prefs_cache_unittest.cc b/chrome/browser/notifications/notifications_prefs_cache_unittest.cc
new file mode 100644
index 0000000..0cbea9e
--- /dev/null
+++ b/chrome/browser/notifications/notifications_prefs_cache_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/notifications/notifications_prefs_cache.h"
+
+#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h"
+
+TEST(NotificationsPrefsCacheTest, CanCreate) {
+ scoped_refptr<NotificationsPrefsCache> cache(new NotificationsPrefsCache());
+ std::vector<GURL> allowed_origins;
+ allowed_origins.push_back(GURL("http://allowed.com"));
+ std::vector<GURL> denied_origins;
+ denied_origins.push_back(GURL("http://denied.com"));
+
+ {
+ MessageLoop loop;
+ ChromeThread ui_thread(ChromeThread::UI, &loop);
+
+ cache->SetCacheAllowedOrigins(allowed_origins);
+ cache->SetCacheDeniedOrigins(denied_origins);
+ cache->SetCacheDefaultContentSetting(CONTENT_SETTING_DEFAULT);
+ }
+
+ cache->set_is_initialized(true);
+
+ {
+ MessageLoop loop;
+ ChromeThread io_thread(ChromeThread::IO, &loop);
+
+ cache->CacheAllowedOrigin(GURL("http://allowed2.com"));
+ cache->CacheDeniedOrigin(GURL("http://denied2.com"));
+
+ EXPECT_EQ(cache->HasPermission(GURL("http://allowed.com")),
+ WebKit::WebNotificationPresenter::PermissionAllowed);
+ EXPECT_EQ(cache->HasPermission(GURL("http://allowed2.com")),
+ WebKit::WebNotificationPresenter::PermissionAllowed);
+
+ EXPECT_EQ(cache->HasPermission(GURL("http://denied.com")),
+ WebKit::WebNotificationPresenter::PermissionDenied);
+ EXPECT_EQ(cache->HasPermission(GURL("http://denied2.com")),
+ WebKit::WebNotificationPresenter::PermissionDenied);
+
+ EXPECT_EQ(cache->HasPermission(GURL("http://unkown.com")),
+ WebKit::WebNotificationPresenter::PermissionNotAllowed);
+
+ cache->SetCacheDefaultContentSetting(CONTENT_SETTING_ASK);
+ EXPECT_EQ(cache->HasPermission(GURL("http://unkown.com")),
+ WebKit::WebNotificationPresenter::PermissionNotAllowed);
+
+ cache->SetCacheDefaultContentSetting(CONTENT_SETTING_ALLOW);
+ EXPECT_EQ(cache->HasPermission(GURL("http://unkown.com")),
+ WebKit::WebNotificationPresenter::PermissionAllowed);
+
+ cache->SetCacheDefaultContentSetting(CONTENT_SETTING_BLOCK);
+ EXPECT_EQ(cache->HasPermission(GURL("http://unkown.com")),
+ WebKit::WebNotificationPresenter::PermissionDenied);
+ }
+}
+