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 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
13 #include "base/callback.h"
14 #include "chrome/browser/notifications/notification.h"
15 #include "chrome/browser/notifications/notification_ui_manager.h"
19 // NotificationDelegate which does nothing, useful for testing when
20 // the notification events are not important.
21 class MockNotificationDelegate
: public NotificationDelegate
{
23 explicit MockNotificationDelegate(const std::string
& id
);
25 // NotificationDelegate interface.
26 std::string
id() const override
;
29 ~MockNotificationDelegate() override
;
33 DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate
);
36 class StubNotificationUIManager
: public NotificationUIManager
{
38 StubNotificationUIManager();
39 ~StubNotificationUIManager() override
;
41 // Returns the number of currently active notifications.
42 unsigned int GetNotificationCount() const;
44 // Returns a reference to the notification at index |index|.
45 const Notification
& GetNotificationAt(unsigned int index
) const;
47 // Sets a one-shot callback that will be invoked when a notification has been
48 // added to the Notification UI manager. Will be invoked on the UI thread.
49 void SetNotificationAddedCallback(const base::Closure
& callback
);
51 // NotificationUIManager implementation.
52 void Add(const Notification
& notification
, Profile
* profile
) override
;
53 bool Update(const Notification
& notification
, Profile
* profile
) override
;
54 const Notification
* FindById(const std::string
& delegate_id
,
55 ProfileID profile_id
) const override
;
56 bool CancelById(const std::string
& delegate_id
,
57 ProfileID profile_id
) override
;
58 std::set
<std::string
> GetAllIdsByProfileAndSourceOrigin(
60 const GURL
& source
) override
;
61 std::set
<std::string
> GetAllIdsByProfile(ProfileID profile_id
) override
;
62 bool CancelAllBySourceOrigin(const GURL
& source_origin
) override
;
63 bool CancelAllByProfile(ProfileID profile_id
) override
;
64 void CancelAll() override
;
67 using NotificationPair
= std::pair
<Notification
, ProfileID
>;
68 std::vector
<NotificationPair
> notifications_
;
70 base::Closure notification_added_callback_
;
72 DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager
);
75 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_