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

Side by Side Diff: remoting/protocol/jingle_messages_unittest.cc

Issue 10532211: Added piping for sending audio packets from host to client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unittests Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/content_description.cc ('k') | remoting/protocol/session_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/protocol/jingle_messages.h" 5 #include "remoting/protocol/jingle_messages.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 } // namespace 92 } // namespace
93 93
94 // Each of the tests below try to parse a message, format it again, 94 // Each of the tests below try to parse a message, format it again,
95 // and then verify that the formatted message is the same as the 95 // and then verify that the formatted message is the same as the
96 // original stanza. The sample messages were generated by libjingle. 96 // original stanza. The sample messages were generated by libjingle.
97 97
98 TEST(JingleMessageTest, SessionInitiate) { 98 TEST(JingleMessageTest, SessionInitiate) {
99 const char* kTestSessionInitiateMessage = 99 const char* kTestSessionInitiateMessage =
100 "<iq to='user@gmail.com/chromoting016DBB07' type='set' " 100 "<iq to='user@gmail.com/chromoting016DBB07' type='set' "
101 "from='user@gmail.com/chromiumsy5C6A652D' " 101 "from='user@gmail.com/chromiumsy5C6A652D' "
102 "xmlns='jabber:client'><jingle xmlns='urn:xmpp:jingle:1' " 102 "xmlns='jabber:client'>"
103 "action='session-initiate' sid='2227053353' " 103 "<jingle xmlns='urn:xmpp:jingle:1' "
104 "initiator='user@gmail.com/chromiumsy5C6A652D'><content " 104 "action='session-initiate' sid='2227053353' "
105 "name='chromoting' creator='initiator'><description " 105 "initiator='user@gmail.com/chromiumsy5C6A652D'>"
106 "xmlns='google:remoting'><control transport='stream' version='2'/><event " 106 "<content name='chromoting' creator='initiator'>"
107 "transport='stream' version='2'/><video transport='stream' version='2' " 107 "<description xmlns='google:remoting'>"
108 "codec='vp8'/><initial-resolution width='640' height='480'/>" 108 "<control transport='stream' version='2'/>"
109 "<authentication><auth-token>j7whCMii0Z0AAPwj7whCM/j7whCMii0Z0AAPw=" 109 "<event transport='stream' version='2'/>"
110 "</auth-token></authentication></description><transport " 110 "<video transport='stream' version='2' codec='vp8'/>"
111 "xmlns='http://www.google.com/transport/p2p'/></content></jingle>" 111 "<audio transport='stream' version='2' codec='verbatim'/>"
112 "<initial-resolution width='640' height='480'/>"
113 "<authentication><auth-token>"
114 "j7whCMii0Z0AAPwj7whCM/j7whCMii0Z0AAPw="
115 "</auth-token></authentication>"
116 "</description>"
117 "<transport xmlns='http://www.google.com/transport/p2p'/>"
118 "</content>"
119 "</jingle>"
112 "</iq>"; 120 "</iq>";
113 scoped_ptr<XmlElement> source_message( 121 scoped_ptr<XmlElement> source_message(
114 XmlElement::ForStr(kTestSessionInitiateMessage)); 122 XmlElement::ForStr(kTestSessionInitiateMessage));
115 ASSERT_TRUE(source_message.get()); 123 ASSERT_TRUE(source_message.get());
116 124
117 EXPECT_TRUE(JingleMessage::IsJingleMessage(source_message.get())); 125 EXPECT_TRUE(JingleMessage::IsJingleMessage(source_message.get()));
118 126
119 JingleMessage message; 127 JingleMessage message;
120 std::string error; 128 std::string error;
121 EXPECT_TRUE(message.ParseXml(source_message.get(), &error)) << error; 129 EXPECT_TRUE(message.ParseXml(source_message.get(), &error)) << error;
122 130
123 EXPECT_EQ(message.action, JingleMessage::SESSION_INITIATE); 131 EXPECT_EQ(message.action, JingleMessage::SESSION_INITIATE);
124 132
125 scoped_ptr<XmlElement> formatted_message(message.ToXml()); 133 scoped_ptr<XmlElement> formatted_message(message.ToXml());
126 ASSERT_TRUE(formatted_message.get()); 134 ASSERT_TRUE(formatted_message.get());
127 EXPECT_TRUE(VerifyXml(formatted_message.get(), source_message.get(), &error)) 135 EXPECT_TRUE(VerifyXml(formatted_message.get(), source_message.get(), &error))
128 << error; 136 << error;
129 } 137 }
130 138
131 TEST(JingleMessageTest, SessionAccept) { 139 TEST(JingleMessageTest, SessionAccept) {
132 const char* kTestSessionAcceptMessage = 140 const char* kTestSessionAcceptMessage =
133 "<cli:iq from='user@gmail.com/chromoting016DBB07' " 141 "<cli:iq from='user@gmail.com/chromoting016DBB07' "
134 "to='user@gmail.com/chromiumsy5C6A652D' type='set' " 142 "to='user@gmail.com/chromiumsy5C6A652D' type='set' "
135 "xmlns:cli='jabber:client'><jingle action='session-accept' " 143 "xmlns:cli='jabber:client'>"
136 "sid='2227053353' xmlns='urn:xmpp:jingle:1'><content creator='initiator' " 144 "<jingle action='session-accept' sid='2227053353' "
137 "name='chromoting'><description xmlns='google:remoting'><control " 145 "xmlns='urn:xmpp:jingle:1'>i"
138 "transport='stream' version='2'/><event transport='stream' version='2'/>" 146 "<content creator='initiator' name='chromoting'>"
139 "<video codec='vp8' transport='stream' version='2'/><initial-resolution " 147 "<description xmlns='google:remoting'>"
140 "height='480' width='640'/><authentication><certificate>" 148 "<control transport='stream' version='2'/>"
141 "MIICpjCCAY6gW0Cert0TANBgkqhkiG9w0BAQUFA=</certificate>" 149 "<event transport='stream' version='2'/>"
142 "</authentication></description><transport xmlns=" 150 "<video codec='vp8' transport='stream' version='2'/>"
143 "'http://www.google.com/transport/p2p'/></content></jingle></cli:iq>"; 151 "<audio transport='stream' version='2' codec='verbatim'/>"
152 "<initial-resolution height='480' width='640'/>"
153 "<authentication><certificate>"
154 "MIICpjCCAY6gW0Cert0TANBgkqhkiG9w0BAQUFA="
155 "</certificate></authentication>"
156 "</description>"
157 "<transport xmlns='http://www.google.com/transport/p2p'/>"
158 "</content>"
159 "</jingle>"
160 "</cli:iq>";
144 161
145 scoped_ptr<XmlElement> source_message( 162 scoped_ptr<XmlElement> source_message(
146 XmlElement::ForStr(kTestSessionAcceptMessage)); 163 XmlElement::ForStr(kTestSessionAcceptMessage));
147 ASSERT_TRUE(source_message.get()); 164 ASSERT_TRUE(source_message.get());
148 165
149 EXPECT_TRUE(JingleMessage::IsJingleMessage(source_message.get())); 166 EXPECT_TRUE(JingleMessage::IsJingleMessage(source_message.get()));
150 167
151 JingleMessage message; 168 JingleMessage message;
152 std::string error; 169 std::string error;
153 EXPECT_TRUE(message.ParseXml(source_message.get(), &error)) << error; 170 EXPECT_TRUE(message.ParseXml(source_message.get(), &error)) << error;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ASSERT_TRUE(expected.get()); 327 ASSERT_TRUE(expected.get());
311 328
312 std::string error; 329 std::string error;
313 EXPECT_TRUE(VerifyXml(expected.get(), reply.get(), &error)) << error; 330 EXPECT_TRUE(VerifyXml(expected.get(), reply.get(), &error)) << error;
314 } 331 }
315 } 332 }
316 333
317 TEST(JingleMessageTest, ErrorMessage) { 334 TEST(JingleMessageTest, ErrorMessage) {
318 const char* kTestSessionInitiateErrorMessage = 335 const char* kTestSessionInitiateErrorMessage =
319 "<iq to='user@gmail.com/chromoting016DBB07' type='error' " 336 "<iq to='user@gmail.com/chromoting016DBB07' type='error' "
320 "from='user@gmail.com/chromiumsy5C6A652D' " 337 "from='user@gmail.com/chromiumsy5C6A652D' "
321 "xmlns='jabber:client'><jingle xmlns='urn:xmpp:jingle:1' " 338 "xmlns='jabber:client'>"
322 "action='session-initiate' sid='2227053353' " 339 "<jingle xmlns='urn:xmpp:jingle:1' "
323 "initiator='user@gmail.com/chromiumsy5C6A652D'><content " 340 "action='session-initiate' sid='2227053353' "
324 "name='chromoting' creator='initiator'><description " 341 "initiator='user@gmail.com/chromiumsy5C6A652D'>"
325 "xmlns='google:remoting'><control transport='stream' version='2'/><event " 342 "<content name='chromoting' creator='initiator'>"
326 "transport='stream' version='2'/><video transport='stream' version='2' " 343 "<description xmlns='google:remoting'>"
327 "codec='vp8'/><initial-resolution width='800' height='600'/>" 344 "<control transport='stream' version='2'/>"
328 "<authentication><auth-token>j7whCMii0Z0AAPwj7whCM/j7whCMii0Z0AAPw=" 345 "<event transport='stream' version='2'/>"
329 "</auth-token></authentication></description><transport " 346 "<video transport='stream' version='2' codec='vp8'/>"
330 "xmlns='http://www.google.com/transport/p2p'/></content></jingle>" 347 "<audio transport='stream' version='2' codec='verbatim'/>"
331 "<error code='501' type='cancel'><feature-not-implemented " 348 "<initial-resolution width='800' height='600'/>"
332 "xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" 349 "<authentication><auth-token>"
350 "j7whCMii0Z0AAPwj7whCM/j7whCMii0Z0AAPw="
351 "</auth-token></authentication>"
352 "</description>"
353 "<transport xmlns='http://www.google.com/transport/p2p'/>"
354 "</content>"
355 "</jingle>"
356 "<error code='501' type='cancel'>"
357 "<feature-not-implemented "
358 "xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
359 "</error>"
333 "</iq>"; 360 "</iq>";
334 scoped_ptr<XmlElement> source_message( 361 scoped_ptr<XmlElement> source_message(
335 XmlElement::ForStr(kTestSessionInitiateErrorMessage)); 362 XmlElement::ForStr(kTestSessionInitiateErrorMessage));
336 ASSERT_TRUE(source_message.get()); 363 ASSERT_TRUE(source_message.get());
337 364
338 EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get())); 365 EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get()));
339 366
340 JingleMessage message; 367 JingleMessage message;
341 std::string error; 368 std::string error;
342 EXPECT_FALSE(message.ParseXml(source_message.get(), &error)); 369 EXPECT_FALSE(message.ParseXml(source_message.get(), &error));
343 EXPECT_FALSE(error.empty()); 370 EXPECT_FALSE(error.empty());
344 } 371 }
345 372
346 } // namespace protocol 373 } // namespace protocol
347 } // namespace remoting 374 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/content_description.cc ('k') | remoting/protocol/session_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698