• 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 #include "jingle/notifier/listener/fake_push_client.h"
6 
7 #include "jingle/notifier/listener/push_client_observer.h"
8 
9 namespace notifier {
10 
FakePushClient()11 FakePushClient::FakePushClient() : sent_pings_(0) {}
12 
~FakePushClient()13 FakePushClient::~FakePushClient() {}
14 
AddObserver(PushClientObserver * observer)15 void FakePushClient::AddObserver(PushClientObserver* observer) {
16   observers_.AddObserver(observer);
17 }
18 
RemoveObserver(PushClientObserver * observer)19 void FakePushClient::RemoveObserver(PushClientObserver* observer) {
20   observers_.RemoveObserver(observer);
21 }
22 
UpdateSubscriptions(const SubscriptionList & subscriptions)23 void FakePushClient::UpdateSubscriptions(
24     const SubscriptionList& subscriptions) {
25   subscriptions_ = subscriptions;
26 }
27 
UpdateCredentials(const std::string & email,const std::string & token)28 void FakePushClient::UpdateCredentials(
29     const std::string& email, const std::string& token) {
30   email_ = email;
31   token_ = token;
32 }
33 
SendNotification(const Notification & notification)34 void FakePushClient::SendNotification(const Notification& notification) {
35   sent_notifications_.push_back(notification);
36 }
37 
SendPing()38 void FakePushClient::SendPing() {
39   sent_pings_++;
40 }
41 
EnableNotifications()42 void FakePushClient::EnableNotifications() {
43   FOR_EACH_OBSERVER(PushClientObserver, observers_,
44                     OnNotificationsEnabled());
45 }
46 
DisableNotifications(NotificationsDisabledReason reason)47 void FakePushClient::DisableNotifications(
48     NotificationsDisabledReason reason) {
49   FOR_EACH_OBSERVER(PushClientObserver, observers_,
50                     OnNotificationsDisabled(reason));
51 }
52 
SimulateIncomingNotification(const Notification & notification)53 void FakePushClient::SimulateIncomingNotification(
54     const Notification& notification) {
55   FOR_EACH_OBSERVER(PushClientObserver, observers_,
56                     OnIncomingNotification(notification));
57 }
58 
subscriptions() const59 const SubscriptionList& FakePushClient::subscriptions() const {
60   return subscriptions_;
61 }
62 
email() const63 const std::string& FakePushClient::email() const {
64   return email_;
65 }
66 
token() const67 const std::string& FakePushClient::token() const {
68   return token_;
69 }
70 
sent_notifications() const71 const std::vector<Notification>& FakePushClient::sent_notifications() const {
72   return sent_notifications_;
73 }
74 
sent_pings() const75 int FakePushClient::sent_pings() const {
76   return sent_pings_;
77 }
78 
79 }  // namespace notifier
80 
81