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