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

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

Issue 6803012: Profile shouldn't own DesktopNotificationService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 8 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
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/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
10 #include "chrome/browser/notifications/notifications_prefs_cache.h" 11 #include "chrome/browser/notifications/notifications_prefs_cache.h"
11 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" 13 #include "chrome/browser/prefs/scoped_user_pref_update.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "chrome/test/testing_profile.h" 15 #include "chrome/test/testing_profile.h"
15 #include "content/browser/browser_thread.h" 16 #include "content/browser/browser_thread.h"
16 #include "content/browser/renderer_host/test_render_view_host.h" 17 #include "content/browser/renderer_host/test_render_view_host.h"
17 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DesktopNotificationServiceTest() { 96 DesktopNotificationServiceTest() {
96 } 97 }
97 98
98 virtual void SetUp() { 99 virtual void SetUp() {
99 RenderViewHostTestHarness::SetUp(); 100 RenderViewHostTestHarness::SetUp();
100 proxy_ = new ThreadProxy; 101 proxy_ = new ThreadProxy;
101 proxy_->PauseIOThread(); 102 proxy_->PauseIOThread();
102 103
103 // Creates the service, calls InitPrefs() on it which loads data from the 104 // Creates the service, calls InitPrefs() on it which loads data from the
104 // profile into the cache and then puts the cache in io thread mode. 105 // profile into the cache and then puts the cache in io thread mode.
105 service_ = profile()->GetDesktopNotificationService(); 106 service_ = DesktopNotificationServiceFactory::GetForProfile(profile());
106 cache_ = service_->prefs_cache(); 107 cache_ = service_->prefs_cache();
107 } 108 }
108 109
109 virtual void TearDown() { 110 virtual void TearDown() {
110 // The io thread's waiting on the io_event_ might hold a ref to |proxy_|, 111 // The io thread's waiting on the io_event_ might hold a ref to |proxy_|,
111 // preventing its destruction. Clear that ref. 112 // preventing its destruction. Clear that ref.
112 proxy_->DrainIOThread(); 113 proxy_->DrainIOThread();
113 RenderViewHostTestHarness::TearDown(); 114 RenderViewHostTestHarness::TearDown();
114 } 115 }
115 116
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionDenied, 275 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionDenied,
275 proxy_->CacheHasPermission(cache_, denied_url)); 276 proxy_->CacheHasPermission(cache_, denied_url));
276 277
277 service_->ResetBlockedOrigin(denied_url); 278 service_->ResetBlockedOrigin(denied_url);
278 279
279 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionNotAllowed, 280 EXPECT_EQ(WebKit::WebNotificationPresenter::PermissionNotAllowed,
280 proxy_->CacheHasPermission(cache_, denied_url)); 281 proxy_->CacheHasPermission(cache_, denied_url));
281 } 282 }
282 283
283 } // namespace 284 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698