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

Side by Side Diff: remoting/signaling/gcd_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: revised unit test 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
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/gcd_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(GcdNotificationSubscriberTest, Create) {
19 MockSignalStrategy signal_strategy;
20 EXPECT_CALL(signal_strategy, AddListener(_));
21 EXPECT_CALL(signal_strategy, RemoveListener(_));
22
23 GcdNotificationSubscriber subscriber(&signal_strategy);
24 }
25
26 TEST(GcdNotificationSubscriberTest, Subscribe) {
27 MockSignalStrategy signal_strategy;
28 EXPECT_CALL(signal_strategy, GetLocalJid())
29 .WillRepeatedly(Return("user@domain/resource"));
30 EXPECT_CALL(signal_strategy, GetNextId()).WillOnce(Return("next_id"));
31 EXPECT_CALL(signal_strategy, AddListener(_)).Times(AtLeast(1));
32 EXPECT_CALL(signal_strategy, RemoveListener(_)).Times(AtLeast(1));
33 buzz::XmlElement* sent_stanza;
34 EXPECT_CALL(signal_strategy, SendStanzaPtr(_))
35 .WillOnce(DoAll(SaveArg<0>(&sent_stanza), Return(true)));
36
37 GcdNotificationSubscriber subscriber(&signal_strategy);
38 SignalStrategy::Listener* listener = &subscriber;
39 listener->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
40
41 EXPECT_EQ(
42 "<cli:iq type=\"set\" to=\"user@domain\" id=\"next_id\""
43 " xmlns:cli=\"jabber:client\">"
44 "<push:subscribe xmlns:push=\"google:push\">"
45 "<push:item channel=\"cloud_devices\" from=\"\"/>"
46 "</push:subscribe>"
47 "</cli:iq>",
48 sent_stanza->Str());
49
50 delete sent_stanza;
51 }
52
53 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698