OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "remoting/jingle_glue/iq_sender.h" | 9 #include "remoting/jingle_glue/iq_sender.h" |
10 #include "remoting/jingle_glue/mock_objects.h" | 10 #include "remoting/jingle_glue/mock_objects.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 "<cli:iq type=\"%s\" to=\"%s\" id=\"%s\" " | 71 "<cli:iq type=\"%s\" to=\"%s\" id=\"%s\" " |
72 "xmlns:cli=\"jabber:client\">" | 72 "xmlns:cli=\"jabber:client\">" |
73 "<%s:%s xmlns:%s=\"%s\"/>" | 73 "<%s:%s xmlns:%s=\"%s\"/>" |
74 "</cli:iq>", | 74 "</cli:iq>", |
75 kType, kTo, kStanzaId, kNamespacePrefix, kBodyTag, | 75 kType, kTo, kStanzaId, kNamespacePrefix, kBodyTag, |
76 kNamespacePrefix, kNamespace); | 76 kNamespacePrefix, kNamespace); |
77 EXPECT_EQ(expected_xml_string, sent_stanza->Str()); | 77 EXPECT_EQ(expected_xml_string, sent_stanza->Str()); |
78 delete sent_stanza; | 78 delete sent_stanza; |
79 } | 79 } |
80 | 80 |
81 MessageLoop message_loop_; | 81 base::MessageLoop message_loop_; |
82 MockSignalStrategy signal_strategy_; | 82 MockSignalStrategy signal_strategy_; |
83 scoped_ptr<IqSender> sender_; | 83 scoped_ptr<IqSender> sender_; |
84 MockCallback callback_; | 84 MockCallback callback_; |
85 scoped_ptr<IqRequest> request_; | 85 scoped_ptr<IqRequest> request_; |
86 }; | 86 }; |
87 | 87 |
88 TEST_F(IqSenderTest, SendIq) { | 88 TEST_F(IqSenderTest, SendIq) { |
89 ASSERT_NO_FATAL_FAILURE({ | 89 ASSERT_NO_FATAL_FAILURE({ |
90 SendTestMessage(); | 90 SendTestMessage(); |
91 }); | 91 }); |
(...skipping 14 matching lines...) Expand all Loading... |
106 } | 106 } |
107 | 107 |
108 TEST_F(IqSenderTest, Timeout) { | 108 TEST_F(IqSenderTest, Timeout) { |
109 ASSERT_NO_FATAL_FAILURE({ | 109 ASSERT_NO_FATAL_FAILURE({ |
110 SendTestMessage(); | 110 SendTestMessage(); |
111 }); | 111 }); |
112 | 112 |
113 request_->SetTimeout(base::TimeDelta::FromMilliseconds(2)); | 113 request_->SetTimeout(base::TimeDelta::FromMilliseconds(2)); |
114 | 114 |
115 EXPECT_CALL(callback_, OnReply(request_.get(), NULL)) | 115 EXPECT_CALL(callback_, OnReply(request_.get(), NULL)) |
116 .WillOnce(InvokeWithoutArgs(&message_loop_, &MessageLoop::Quit)); | 116 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::Quit)); |
117 message_loop_.Run(); | 117 message_loop_.Run(); |
118 } | 118 } |
119 | 119 |
120 TEST_F(IqSenderTest, InvalidFrom) { | 120 TEST_F(IqSenderTest, InvalidFrom) { |
121 ASSERT_NO_FATAL_FAILURE({ | 121 ASSERT_NO_FATAL_FAILURE({ |
122 SendTestMessage(); | 122 SendTestMessage(); |
123 }); | 123 }); |
124 | 124 |
125 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); | 125 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); |
126 response->AddAttr(QName(std::string(), "type"), "result"); | 126 response->AddAttr(QName(std::string(), "type"), "result"); |
(...skipping 24 matching lines...) Expand all Loading... |
151 QName("test:namespace", "response-body")); | 151 QName("test:namespace", "response-body")); |
152 response->AddElement(result); | 152 response->AddElement(result); |
153 | 153 |
154 EXPECT_TRUE(sender_->OnSignalStrategyIncomingStanza(response.get())); | 154 EXPECT_TRUE(sender_->OnSignalStrategyIncomingStanza(response.get())); |
155 | 155 |
156 EXPECT_CALL(callback_, OnReply(request_.get(), XmlEq(response.get()))); | 156 EXPECT_CALL(callback_, OnReply(request_.get(), XmlEq(response.get()))); |
157 message_loop_.RunUntilIdle(); | 157 message_loop_.RunUntilIdle(); |
158 } | 158 } |
159 | 159 |
160 } // namespace remoting | 160 } // namespace remoting |
OLD | NEW |