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::WebContents
* MockNotificationDelegate::GetWebContents() const {
18 StubNotificationUIManager::StubNotificationUIManager(const GURL
& welcome_origin
)
19 : notification_(GURL(),
23 blink::WebTextDirectionDefault
,
26 new MockNotificationDelegate("stub")),
27 welcome_origin_(welcome_origin
),
29 added_notifications_(0U) {}
31 StubNotificationUIManager::~StubNotificationUIManager() {}
33 void StubNotificationUIManager::Add(const Notification
& notification
,
35 // Make a deep copy of the notification that we can inspect.
36 notification_
= notification
;
38 ++added_notifications_
;
40 if (notification
.origin_url() == welcome_origin_
)
44 bool StubNotificationUIManager::Update(const Notification
& notification
,
46 // Make a deep copy of the notification that we can inspect.
47 notification_
= notification
;
52 const Notification
* StubNotificationUIManager::FindById(const std::string
& id
)
54 return (notification_
.id() == id
) ? ¬ification_
: NULL
;
57 bool StubNotificationUIManager::CancelById(const std::string
& notification_id
) {
58 dismissed_id_
= notification_id
;
63 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
66 std::set
<std::string
> notification_ids
;
67 if (source
== notification_
.origin_url() && profile
->IsSameProfile(profile_
))
68 notification_ids
.insert(notification_
.delegate_id());
69 return notification_ids
;
72 bool StubNotificationUIManager::CancelAllBySourceOrigin(
73 const GURL
& source_origin
) {
77 bool StubNotificationUIManager::CancelAllByProfile(Profile
* profile
) {
81 void StubNotificationUIManager::CancelAll() {}