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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: remoting/signaling/gcd_notification_subscriber_unittest.cc
diff --git a/remoting/signaling/gcd_notification_subscriber_unittest.cc b/remoting/signaling/gcd_notification_subscriber_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8effcb43126dd16573456dde1012e6eea6f5a896
--- /dev/null
+++ b/remoting/signaling/gcd_notification_subscriber_unittest.cc
@@ -0,0 +1,53 @@
+// Copyright 2015 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 "remoting/signaling/gcd_notification_subscriber.h"
+
+#include "remoting/signaling/mock_signal_strategy.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using testing::_;
+using testing::AtLeast;
+using testing::DoAll;
+using testing::Return;
+using testing::SaveArg;
+
+namespace remoting {
+
+TEST(GcdNotificationSubscriberTest, Create) {
+ MockSignalStrategy signal_strategy;
+ EXPECT_CALL(signal_strategy, AddListener(_));
+ EXPECT_CALL(signal_strategy, RemoveListener(_));
+
+ GcdNotificationSubscriber subscriber(&signal_strategy);
+}
+
+TEST(GcdNotificationSubscriberTest, Subscribe) {
+ MockSignalStrategy signal_strategy;
+ EXPECT_CALL(signal_strategy, GetLocalJid())
+ .WillRepeatedly(Return("user@domain/resource"));
+ EXPECT_CALL(signal_strategy, GetNextId()).WillOnce(Return("next_id"));
+ EXPECT_CALL(signal_strategy, AddListener(_)).Times(AtLeast(1));
+ EXPECT_CALL(signal_strategy, RemoveListener(_)).Times(AtLeast(1));
+ buzz::XmlElement* sent_stanza;
+ EXPECT_CALL(signal_strategy, SendStanzaPtr(_))
+ .WillOnce(DoAll(SaveArg<0>(&sent_stanza), Return(true)));
+
+ GcdNotificationSubscriber subscriber(&signal_strategy);
+ SignalStrategy::Listener* listener = &subscriber;
+ listener->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
+
+ EXPECT_EQ(
+ "<cli:iq type=\"set\" to=\"user@domain\" id=\"next_id\""
+ " xmlns:cli=\"jabber:client\">"
+ "<push:subscribe xmlns:push=\"google:push\">"
+ "<push:item channel=\"cloud_devices\" from=\"\"/>"
+ "</push:subscribe>"
+ "</cli:iq>",
+ sent_stanza->Str());
+
+ delete sent_stanza;
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698