• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef JINGLE_NOTIFIER_LISTENER_FAKE_PUSH_CLIENT_H_
6 #define JINGLE_NOTIFIER_LISTENER_FAKE_PUSH_CLIENT_H_
7 
8 #include <vector>
9 
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/observer_list.h"
13 #include "jingle/notifier/listener/push_client.h"
14 #include "jingle/notifier/listener/push_client_observer.h"
15 
16 namespace notifier {
17 
18 // PushClient implementation that can be used for testing.
19 class FakePushClient : public PushClient {
20  public:
21   FakePushClient();
22   virtual ~FakePushClient();
23 
24   // PushClient implementation.
25   virtual void AddObserver(PushClientObserver* observer) OVERRIDE;
26   virtual void RemoveObserver(PushClientObserver* observer) OVERRIDE;
27   virtual void UpdateSubscriptions(
28       const SubscriptionList& subscriptions) OVERRIDE;
29   virtual void UpdateCredentials(
30       const std::string& email, const std::string& token) OVERRIDE;
31   virtual void SendNotification(const Notification& notification) OVERRIDE;
32   virtual void SendPing() OVERRIDE;
33 
34   // Triggers OnNotificationsEnabled on all observers.
35   void EnableNotifications();
36 
37   // Triggers OnNotificationsDisabled on all observers.
38   void DisableNotifications(NotificationsDisabledReason reason);
39 
40   // Triggers OnIncomingNotification on all observers.
41   void SimulateIncomingNotification(const Notification& notification);
42 
43   const SubscriptionList& subscriptions() const;
44   const std::string& email() const;
45   const std::string& token() const;
46   const std::vector<Notification>& sent_notifications() const;
47   int sent_pings() const;
48 
49  private:
50   ObserverList<PushClientObserver> observers_;
51   SubscriptionList subscriptions_;
52   std::string email_;
53   std::string token_;
54   std::vector<Notification> sent_notifications_;
55   int sent_pings_;
56 
57   DISALLOW_COPY_AND_ASSIGN(FakePushClient);
58 };
59 
60 }  // namespace notifier
61 
62 #endif  // JINGLE_NOTIFIER_LISTENER_FAKE_PUSH_CLIENT_H_
63