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 // TODO(peter): |notification_| should be initialized with the correct origin.
15 StubNotificationUIManager::StubNotificationUIManager(const GURL
& welcome_origin
)
16 : notification_(GURL(),
22 new MockNotificationDelegate("stub")),
24 welcome_origin_(welcome_origin
),
26 added_notifications_(0U) {
29 StubNotificationUIManager::~StubNotificationUIManager() {}
31 void StubNotificationUIManager::Add(const Notification
& notification
,
33 // Make a deep copy of the notification that we can inspect.
34 notification_
= notification
;
36 ++added_notifications_
;
38 if (notification
.origin_url() == welcome_origin_
)
42 bool StubNotificationUIManager::Update(const Notification
& notification
,
44 // Make a deep copy of the notification that we can inspect.
45 notification_
= notification
;
50 const Notification
* StubNotificationUIManager::FindById(
51 const std::string
& delegate_id
,
52 ProfileID profile_id
) const {
53 if (notification_
.delegate_id() == delegate_id
&& profile_
== profile_id
)
54 return ¬ification_
;
59 bool StubNotificationUIManager::CancelById(const std::string
& delegate_id
,
60 ProfileID profile_id
) {
61 dismissed_id_
= delegate_id
;
66 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
69 std::set
<std::string
> delegate_ids
;
70 if (source
== notification_
.origin_url() && profile
->IsSameProfile(profile_
))
71 delegate_ids
.insert(notification_
.delegate_id());
75 bool StubNotificationUIManager::CancelAllBySourceOrigin(
76 const GURL
& source_origin
) {
80 bool StubNotificationUIManager::CancelAllByProfile(ProfileID profile_id
) {
84 void StubNotificationUIManager::CancelAll() {}