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_
10 #include "chrome/browser/notifications/notification_object_proxy.h"
11 #include "chrome/browser/notifications/balloon.h"
12 #include "ui/gfx/size.h"
14 // NotificationDelegate which does nothing, useful for testing when
15 // the notification events are not important.
16 class MockNotificationDelegate
: public NotificationDelegate
{
18 explicit MockNotificationDelegate(const std::string
& id
);
20 // NotificationDelegate interface.
21 virtual void Display() OVERRIDE
{}
22 virtual void Error() OVERRIDE
{}
23 virtual void Close(bool by_user
) OVERRIDE
{}
24 virtual void Click() OVERRIDE
{}
25 virtual std::string
id() const OVERRIDE
;
26 virtual content::RenderViewHost
* GetRenderViewHost() const OVERRIDE
;
29 virtual ~MockNotificationDelegate();
33 DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate
);
36 // Mock implementation of Javascript object proxy which logs events that
37 // would have been fired on it. Useful for tests where the sequence of
38 // notification events needs to be verified.
40 // |Logger| class provided in template must implement method
41 // static void log(string);
42 template<class Logger
>
43 class LoggingNotificationDelegate
: public NotificationDelegate
{
45 explicit LoggingNotificationDelegate(std::string id
)
46 : notification_id_(id
) {
49 // NotificationObjectProxy override
50 virtual void Display() OVERRIDE
{
51 Logger::log("notification displayed\n");
53 virtual void Error() OVERRIDE
{
54 Logger::log("notification error\n");
56 virtual void Click() OVERRIDE
{
57 Logger::log("notification clicked\n");
59 virtual void ButtonClick(int index
) OVERRIDE
{
60 Logger::log("notification button clicked\n");
62 virtual void Close(bool by_user
) OVERRIDE
{
64 Logger::log("notification closed by user\n");
66 Logger::log("notification closed by script\n");
68 virtual std::string
id() const OVERRIDE
{
69 return notification_id_
;
71 virtual content::RenderViewHost
* GetRenderViewHost() const OVERRIDE
{
76 std::string notification_id_
;
78 DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate
);
81 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_