#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
#include <set>
#include <string>
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_object_proxy.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
#include "chrome/browser/profiles/profile.h"
#include "ui/gfx/size.h"
class MockNotificationDelegate : public NotificationDelegate {
public:
explicit MockNotificationDelegate(const std::string& id);
virtual void Display() OVERRIDE {}
virtual void Error() OVERRIDE {}
virtual void Close(bool by_user) OVERRIDE {}
virtual void Click() OVERRIDE {}
virtual std::string id() const OVERRIDE;
virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
private:
virtual ~MockNotificationDelegate();
std::string id_;
DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate);
};
template<class Logger>
class LoggingNotificationDelegate : public NotificationDelegate {
public:
explicit LoggingNotificationDelegate(std::string id)
: notification_id_(id) {
}
virtual void Display() OVERRIDE {
Logger::log("notification displayed\n");
}
virtual void Error() OVERRIDE {
Logger::log("notification error\n");
}
virtual void Click() OVERRIDE {
Logger::log("notification clicked\n");
}
virtual void ButtonClick(int index) OVERRIDE {
Logger::log("notification button clicked\n");
}
virtual void Close(bool by_user) OVERRIDE {
if (by_user)
Logger::log("notification closed by user\n");
else
Logger::log("notification closed by script\n");
}
virtual std::string id() const OVERRIDE {
return notification_id_;
}
virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE {
return NULL;
}
private:
std::string notification_id_;
DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate);
};
class StubNotificationUIManager : public NotificationUIManager {
public:
explicit StubNotificationUIManager(const GURL& welcome_origin);
virtual ~StubNotificationUIManager();
virtual void Add(const Notification& notification, Profile* profile) OVERRIDE;
virtual bool Update(const Notification& notification,
Profile* profile) OVERRIDE;
virtual const Notification* FindById(const std::string& id) const OVERRIDE;
virtual bool CancelById(const std::string& notification_id) OVERRIDE;
virtual std::set<std::string> GetAllIdsByProfileAndSourceOrigin(
Profile* profile,
const GURL& source) OVERRIDE;
virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE;
virtual bool CancelAllByProfile(Profile* profile) OVERRIDE;
virtual void CancelAll() OVERRIDE;
const Notification& notification() const { return notification_; }
std::string& dismissed_id() { return dismissed_id_; }
size_t added_notifications() const { return added_notifications_; }
bool welcomed() const { return welcomed_; }
private:
DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager);
Notification notification_;
Profile* profile_;
std::string dismissed_id_;
GURL welcome_origin_;
bool welcomed_;
size_t added_notifications_;
};
#endif