OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/host_change_notification_listener.h" | 5 #include "remoting/host/host_change_notification_listener.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 }; | 89 }; |
90 | 90 |
91 TEST_F(HostChangeNotificationListenerTest, ReceiveValidNotification) { | 91 TEST_F(HostChangeNotificationListenerTest, ReceiveValidNotification) { |
92 EXPECT_CALL(mock_listener_, OnHostDeleted()) | 92 EXPECT_CALL(mock_listener_, OnHostDeleted()) |
93 .WillOnce(Return()); | 93 .WillOnce(Return()); |
94 scoped_ptr<XmlElement> stanza = GetNotificationStanza( | 94 scoped_ptr<XmlElement> stanza = GetNotificationStanza( |
95 "delete", kHostId, kTestBotJid); | 95 "delete", kHostId, kTestBotJid); |
96 host_change_notification_listener_->OnSignalStrategyIncomingStanza( | 96 host_change_notification_listener_->OnSignalStrategyIncomingStanza( |
97 stanza.get()); | 97 stanza.get()); |
98 message_loop_.PostTask(FROM_HERE, | 98 message_loop_.PostTask(FROM_HERE, |
99 base::Bind(base::MessageLoop::QuitClosure())); | 99 base::Bind(base::MessageLoop::QuitWhenIdleClosure())); |
100 message_loop_.Run(); | 100 message_loop_.Run(); |
101 } | 101 } |
102 | 102 |
103 TEST_F(HostChangeNotificationListenerTest, ReceiveNotificationBeforeDelete) { | 103 TEST_F(HostChangeNotificationListenerTest, ReceiveNotificationBeforeDelete) { |
104 EXPECT_CALL(mock_listener_, OnHostDeleted()) | 104 EXPECT_CALL(mock_listener_, OnHostDeleted()) |
105 .Times(0); | 105 .Times(0); |
106 scoped_ptr<XmlElement> stanza = GetNotificationStanza( | 106 scoped_ptr<XmlElement> stanza = GetNotificationStanza( |
107 "delete", kHostId, kTestBotJid); | 107 "delete", kHostId, kTestBotJid); |
108 host_change_notification_listener_->OnSignalStrategyIncomingStanza( | 108 host_change_notification_listener_->OnSignalStrategyIncomingStanza( |
109 stanza.get()); | 109 stanza.get()); |
110 host_change_notification_listener_.reset(); | 110 host_change_notification_listener_.reset(); |
111 message_loop_.PostTask(FROM_HERE, | 111 message_loop_.PostTask(FROM_HERE, |
112 base::Bind(base::MessageLoop::QuitClosure())); | 112 base::Bind(base::MessageLoop::QuitWhenIdleClosure())); |
113 message_loop_.Run(); | 113 message_loop_.Run(); |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 TEST_F(HostChangeNotificationListenerTest, ReceiveInvalidHostIdNotification) { | 117 TEST_F(HostChangeNotificationListenerTest, ReceiveInvalidHostIdNotification) { |
118 EXPECT_CALL(mock_listener_, OnHostDeleted()) | 118 EXPECT_CALL(mock_listener_, OnHostDeleted()) |
119 .Times(0); | 119 .Times(0); |
120 scoped_ptr<XmlElement> stanza = GetNotificationStanza( | 120 scoped_ptr<XmlElement> stanza = GetNotificationStanza( |
121 "delete", "1", kTestBotJid); | 121 "delete", "1", kTestBotJid); |
122 host_change_notification_listener_->OnSignalStrategyIncomingStanza( | 122 host_change_notification_listener_->OnSignalStrategyIncomingStanza( |
123 stanza.get()); | 123 stanza.get()); |
124 message_loop_.PostTask(FROM_HERE, | 124 message_loop_.PostTask(FROM_HERE, |
125 base::Bind(base::MessageLoop::QuitClosure())); | 125 base::Bind(base::MessageLoop::QuitWhenIdleClosure())); |
126 message_loop_.Run(); | 126 message_loop_.Run(); |
127 } | 127 } |
128 | 128 |
129 TEST_F(HostChangeNotificationListenerTest, ReceiveInvalidBotJidNotification) { | 129 TEST_F(HostChangeNotificationListenerTest, ReceiveInvalidBotJidNotification) { |
130 EXPECT_CALL(mock_listener_, OnHostDeleted()) | 130 EXPECT_CALL(mock_listener_, OnHostDeleted()) |
131 .Times(0); | 131 .Times(0); |
132 scoped_ptr<XmlElement> stanza = GetNotificationStanza( | 132 scoped_ptr<XmlElement> stanza = GetNotificationStanza( |
133 "delete", kHostId, "notremotingbot@bot.talk.google.com"); | 133 "delete", kHostId, "notremotingbot@bot.talk.google.com"); |
134 host_change_notification_listener_->OnSignalStrategyIncomingStanza( | 134 host_change_notification_listener_->OnSignalStrategyIncomingStanza( |
135 stanza.get()); | 135 stanza.get()); |
136 message_loop_.PostTask(FROM_HERE, | 136 message_loop_.PostTask(FROM_HERE, |
137 base::Bind(base::MessageLoop::QuitClosure())); | 137 base::Bind(base::MessageLoop::QuitWhenIdleClosure())); |
138 message_loop_.Run(); | 138 message_loop_.Run(); |
139 } | 139 } |
140 | 140 |
141 TEST_F(HostChangeNotificationListenerTest, ReceiveNonDeleteNotification) { | 141 TEST_F(HostChangeNotificationListenerTest, ReceiveNonDeleteNotification) { |
142 EXPECT_CALL(mock_listener_, OnHostDeleted()) | 142 EXPECT_CALL(mock_listener_, OnHostDeleted()) |
143 .Times(0); | 143 .Times(0); |
144 scoped_ptr<XmlElement> stanza = GetNotificationStanza( | 144 scoped_ptr<XmlElement> stanza = GetNotificationStanza( |
145 "update", kHostId, kTestBotJid); | 145 "update", kHostId, kTestBotJid); |
146 host_change_notification_listener_->OnSignalStrategyIncomingStanza( | 146 host_change_notification_listener_->OnSignalStrategyIncomingStanza( |
147 stanza.get()); | 147 stanza.get()); |
148 message_loop_.PostTask(FROM_HERE, | 148 message_loop_.PostTask(FROM_HERE, |
149 base::Bind(base::MessageLoop::QuitClosure())); | 149 base::Bind(base::MessageLoop::QuitWhenIdleClosure())); |
150 message_loop_.Run(); | 150 message_loop_.Run(); |
151 } | 151 } |
152 | 152 |
153 } // namespace remoting | 153 } // namespace remoting |
OLD | NEW |