Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: remoting/signaling/push_notification_subscriber_unittest.cc

Issue 1123153002: Added class to subscribe to GCD notifications over XMPP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-xmpp-connect2a
Patch Set: sync to head Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/signaling/push_notification_subscriber.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 "remoting/signaling/push_notification_subscriber.h"
6
7 #include "remoting/signaling/mock_signal_strategy.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9
10 using testing::_;
11 using testing::AtLeast;
12 using testing::DoAll;
13 using testing::Return;
14 using testing::SaveArg;
15
16 namespace remoting {
17
18 TEST(PushNotificationSubscriberTest, Create) {
19 MockSignalStrategy signal_strategy;
20 EXPECT_CALL(signal_strategy, AddListener(_));
21 EXPECT_CALL(signal_strategy, RemoveListener(_));
22
23 PushNotificationSubscriber::SubscriptionList subscriptions;
24 PushNotificationSubscriber subscriber(&signal_strategy, subscriptions);
25 }
26
27 TEST(PushNotificationSubscriberTest, Subscribe) {
28 MockSignalStrategy signal_strategy;
29 EXPECT_CALL(signal_strategy, GetLocalJid())
30 .WillRepeatedly(Return("user@domain/resource"));
31 EXPECT_CALL(signal_strategy, GetNextId()).WillOnce(Return("next_id"));
32 EXPECT_CALL(signal_strategy, AddListener(_)).Times(AtLeast(1));
33 EXPECT_CALL(signal_strategy, RemoveListener(_)).Times(AtLeast(1));
34 buzz::XmlElement* sent_stanza;
35 EXPECT_CALL(signal_strategy, SendStanzaPtr(_))
36 .WillOnce(DoAll(SaveArg<0>(&sent_stanza), Return(true)));
37
38 PushNotificationSubscriber::Subscription subscription;
39 subscription.channel = "sub_channel";
40 subscription.from = "sub_from";
41 PushNotificationSubscriber::SubscriptionList subscriptions;
42 subscriptions.push_back(subscription);
43 PushNotificationSubscriber subscriber(&signal_strategy, subscriptions);
44 SignalStrategy::Listener* listener = &subscriber;
45 listener->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
46
47 EXPECT_EQ(
48 "<cli:iq type=\"set\" to=\"user@domain\" id=\"next_id\""
49 " xmlns:cli=\"jabber:client\">"
50 "<push:subscribe xmlns:push=\"google:push\">"
51 "<push:item channel=\"sub_channel\" from=\"sub_from\"/>"
52 "</push:subscribe>"
53 "</cli:iq>",
54 sent_stanza->Str());
55
56 delete sent_stanza;
57 }
58
59 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/push_notification_subscriber.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698