OLD | NEW |
(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 |
OLD | NEW |