1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
class Profile;
// NotificationDelegate which does nothing, useful for testing when
// the notification events are not important.
class MockNotificationDelegate : public NotificationDelegate {
public:
explicit MockNotificationDelegate(const std::string& id);
// NotificationDelegate interface.
std::string id() const override;
private:
~MockNotificationDelegate() override;
std::string id_;
DISALLOW_COPY_AND_ASSIGN(MockNotificationDelegate);
};
class StubNotificationUIManager : public NotificationUIManager {
public:
StubNotificationUIManager();
~StubNotificationUIManager() override;
// Returns the number of currently active notifications.
unsigned int GetNotificationCount() const;
// Returns a reference to the notification at index |index|.
const Notification& GetNotificationAt(unsigned int index) const;
// NotificationUIManager implementation.
void Add(const Notification& notification, Profile* profile) override;
bool Update(const Notification& notification, Profile* profile) override;
const Notification* FindById(const std::string& delegate_id,
ProfileID profile_id) const override;
bool CancelById(const std::string& delegate_id,
ProfileID profile_id) override;
std::set<std::string> GetAllIdsByProfileAndSourceOrigin(
Profile* profile,
const GURL& source) override;
bool CancelAllBySourceOrigin(const GURL& source_origin) override;
bool CancelAllByProfile(ProfileID profile_id) override;
void CancelAll() override;
private:
using NotificationPair = std::pair<Notification, ProfileID>;
std::vector<NotificationPair> notifications_;
DISALLOW_COPY_AND_ASSIGN(StubNotificationUIManager);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
|