Implement self-contained gpu data collection on Android
[chromium-blink-merge.git] / remoting / signaling / push_notification_subscriber_unittest.cc
blob6536f9c6c3d459b6ff5f3ca353eff4a8c5b2ba4c
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.
5 #include "remoting/signaling/push_notification_subscriber.h"
7 #include "remoting/signaling/mock_signal_strategy.h"
8 #include "testing/gmock/include/gmock/gmock.h"
10 using testing::_;
11 using testing::AtLeast;
12 using testing::DoAll;
13 using testing::Return;
14 using testing::SaveArg;
16 namespace remoting {
18 TEST(PushNotificationSubscriberTest, Create) {
19 MockSignalStrategy signal_strategy;
20 EXPECT_CALL(signal_strategy, AddListener(_));
21 EXPECT_CALL(signal_strategy, RemoveListener(_));
23 PushNotificationSubscriber::SubscriptionList subscriptions;
24 PushNotificationSubscriber subscriber(&signal_strategy, subscriptions);
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)));
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);
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());
56 delete sent_stanza;
59 } // namespace remoting