summaryrefslogtreecommitdiff
path: root/chromium/jingle/notifier/listener/fake_push_client.cc
blob: 1106c932b7f3016abccc539c4b226f7072b62598 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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.

#include "jingle/notifier/listener/fake_push_client.h"

#include "jingle/notifier/listener/push_client_observer.h"

namespace notifier {

FakePushClient::FakePushClient() : sent_pings_(0) {}

FakePushClient::~FakePushClient() {}

void FakePushClient::AddObserver(PushClientObserver* observer) {
  observers_.AddObserver(observer);
}

void FakePushClient::RemoveObserver(PushClientObserver* observer) {
  observers_.RemoveObserver(observer);
}

void FakePushClient::UpdateSubscriptions(
    const SubscriptionList& subscriptions) {
  subscriptions_ = subscriptions;
}

void FakePushClient::UpdateCredentials(
    const std::string& email, const std::string& token) {
  email_ = email;
  token_ = token;
}

void FakePushClient::SendNotification(const Notification& notification) {
  sent_notifications_.push_back(notification);
}

void FakePushClient::SendPing() {
  sent_pings_++;
}

void FakePushClient::EnableNotifications() {
  FOR_EACH_OBSERVER(PushClientObserver, observers_,
                    OnNotificationsEnabled());
}

void FakePushClient::DisableNotifications(
    NotificationsDisabledReason reason) {
  FOR_EACH_OBSERVER(PushClientObserver, observers_,
                    OnNotificationsDisabled(reason));
}

void FakePushClient::SimulateIncomingNotification(
    const Notification& notification) {
  FOR_EACH_OBSERVER(PushClientObserver, observers_,
                    OnIncomingNotification(notification));
}

const SubscriptionList& FakePushClient::subscriptions() const {
  return subscriptions_;
}

const std::string& FakePushClient::email() const {
  return email_;
}

const std::string& FakePushClient::token() const {
  return token_;
}

const std::vector<Notification>& FakePushClient::sent_notifications() const {
  return sent_notifications_;
}

int FakePushClient::sent_pings() const {
  return sent_pings_;
}

}  // namespace notifier