Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / notifications / notification_test_util.cc
blob8abc379376e24312ddb5182ab1b4db2a21a9ce64
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::WebContents* MockNotificationDelegate::GetWebContents() const {
15 return NULL;
18 StubNotificationUIManager::StubNotificationUIManager(const GURL& welcome_origin)
19 : notification_(GURL(),
20 GURL(),
21 base::string16(),
22 base::string16(),
23 blink::WebTextDirectionDefault,
24 base::string16(),
25 base::string16(),
26 new MockNotificationDelegate("stub")),
27 welcome_origin_(welcome_origin),
28 welcomed_(false),
29 added_notifications_(0U) {}
31 StubNotificationUIManager::~StubNotificationUIManager() {}
33 void StubNotificationUIManager::Add(const Notification& notification,
34 Profile* profile) {
35 // Make a deep copy of the notification that we can inspect.
36 notification_ = notification;
37 profile_ = profile;
38 ++added_notifications_;
40 if (notification.origin_url() == welcome_origin_)
41 welcomed_ = true;
44 bool StubNotificationUIManager::Update(const Notification& notification,
45 Profile* profile) {
46 // Make a deep copy of the notification that we can inspect.
47 notification_ = notification;
48 profile_ = profile;
49 return true;
52 const Notification* StubNotificationUIManager::FindById(const std::string& id)
53 const {
54 return (notification_.id() == id) ? &notification_ : NULL;
57 bool StubNotificationUIManager::CancelById(const std::string& notification_id) {
58 dismissed_id_ = notification_id;
59 return true;
62 std::set<std::string>
63 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
64 Profile* profile,
65 const GURL& source) {
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) {
74 return false;
77 bool StubNotificationUIManager::CancelAllByProfile(Profile* profile) {
78 return false;
81 void StubNotificationUIManager::CancelAll() {}