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
)
10 MockNotificationDelegate::~MockNotificationDelegate() {}
12 std::string
MockNotificationDelegate::id() const { return id_
; }
14 content::RenderViewHost
* MockNotificationDelegate::GetRenderViewHost() const {
18 StubNotificationUIManager::StubNotificationUIManager(const GURL
& welcome_origin
)
19 : notification_(GURL(),
23 new MockNotificationDelegate("stub")),
24 welcome_origin_(welcome_origin
),
26 added_notifications_(0U) {}
28 StubNotificationUIManager::~StubNotificationUIManager() {}
30 void StubNotificationUIManager::Add(const Notification
& notification
,
32 // Make a deep copy of the notification that we can inspect.
33 notification_
= notification
;
35 ++added_notifications_
;
37 if (notification
.origin_url() == welcome_origin_
)
41 bool StubNotificationUIManager::Update(const Notification
& notification
,
43 // Make a deep copy of the notification that we can inspect.
44 notification_
= notification
;
49 const Notification
* StubNotificationUIManager::FindById(const std::string
& id
)
51 return (notification_
.id() == id
) ? ¬ification_
: NULL
;
54 bool StubNotificationUIManager::CancelById(const std::string
& notification_id
) {
55 dismissed_id_
= notification_id
;
60 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
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
) {
74 bool StubNotificationUIManager::CancelAllByProfile(Profile
* profile
) {
78 void StubNotificationUIManager::CancelAll() {}