Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / jingle / notifier / listener / fake_push_client.h
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   ~FakePushClient() override;
23
24   // PushClient implementation.
25   void AddObserver(PushClientObserver* observer) override;
26   void RemoveObserver(PushClientObserver* observer) override;
27   void UpdateSubscriptions(const SubscriptionList& subscriptions) override;
28   void UpdateCredentials(const std::string& email,
29                          const std::string& token) override;
30   void SendNotification(const Notification& notification) override;
31   void SendPing() override;
32
33   // Triggers OnNotificationsEnabled on all observers.
34   void EnableNotifications();
35
36   // Triggers OnNotificationsDisabled on all observers.
37   void DisableNotifications(NotificationsDisabledReason reason);
38
39   // Triggers OnIncomingNotification on all observers.
40   void SimulateIncomingNotification(const Notification& notification);
41
42   const SubscriptionList& subscriptions() const;
43   const std::string& email() const;
44   const std::string& token() const;
45   const std::vector<Notification>& sent_notifications() const;
46   int sent_pings() const;
47
48  private:
49   ObserverList<PushClientObserver> observers_;
50   SubscriptionList subscriptions_;
51   std::string email_;
52   std::string token_;
53   std::vector<Notification> sent_notifications_;
54   int sent_pings_;
55
56   DISALLOW_COPY_AND_ASSIGN(FakePushClient);
57 };
58
59 }  // namespace notifier
60
61 #endif  // JINGLE_NOTIFIER_LISTENER_FAKE_PUSH_CLIENT_H_