Componentize AccountReconcilor.
[chromium-blink-merge.git] / chrome / browser / notifications / notification_test_util.cc
blob83c3922bb50146ba54cdacbdc2d3aabdcd03bb53
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/notifications/notification_test_util.h"
7 MockNotificationDelegate::MockNotificationDelegate(const std::string& id)
8 : id_(id) {}
10 MockNotificationDelegate::~MockNotificationDelegate() {}
12 std::string MockNotificationDelegate::id() const { return id_; }
14 content::RenderViewHost* MockNotificationDelegate::GetRenderViewHost() const {
15 return NULL;
18 StubNotificationUIManager::StubNotificationUIManager(const GURL& welcome_origin)
19 : notification_(GURL(),
20 GURL(),
21 base::string16(),
22 base::string16(),
23 new MockNotificationDelegate("stub")),
24 welcome_origin_(welcome_origin),
25 welcomed_(false),
26 added_notifications_(0U) {}
28 StubNotificationUIManager::~StubNotificationUIManager() {}
30 void StubNotificationUIManager::Add(const Notification& notification,
31 Profile* profile) {
32 // Make a deep copy of the notification that we can inspect.
33 notification_ = notification;
34 profile_ = profile;
35 ++added_notifications_;
37 if (notification.origin_url() == welcome_origin_)
38 welcomed_ = true;
41 bool StubNotificationUIManager::Update(const Notification& notification,
42 Profile* profile) {
43 // Make a deep copy of the notification that we can inspect.
44 notification_ = notification;
45 profile_ = profile;
46 return true;
49 const Notification* StubNotificationUIManager::FindById(const std::string& id)
50 const {
51 return (notification_.id() == id) ? &notification_ : NULL;
54 bool StubNotificationUIManager::CancelById(const std::string& notification_id) {
55 dismissed_id_ = notification_id;
56 return true;
59 std::set<std::string>
60 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
61 Profile* profile,
62 const GURL& source) {
63 std::set<std::string> notification_ids;
64 if (source == notification_.origin_url() && profile->IsSameProfile(profile_))
65 notification_ids.insert(notification_.notification_id());
66 return notification_ids;
69 bool StubNotificationUIManager::CancelAllBySourceOrigin(
70 const GURL& source_origin) {
71 return false;
74 bool StubNotificationUIManager::CancelAllByProfile(Profile* profile) {
75 return false;
78 void StubNotificationUIManager::CancelAll() {}