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 "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/webrtc/libjingle/xmllite/xmlelement.h" | 10 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 return false; | 34 return false; |
35 } | 35 } |
36 if (exp->BodyText() != val->BodyText()) { | 36 if (exp->BodyText() != val->BodyText()) { |
37 *error = "<" + exp->Name().LocalPart() + ">" + exp->BodyText() + | 37 *error = "<" + exp->Name().LocalPart() + ">" + exp->BodyText() + |
38 "</" + exp->Name().LocalPart() + ">" " is expected, but found " + | 38 "</" + exp->Name().LocalPart() + ">" " is expected, but found " + |
39 "<" + exp->Name().LocalPart() + ">" + val->BodyText() + | 39 "<" + exp->Name().LocalPart() + ">" + val->BodyText() + |
40 "</" + exp->Name().LocalPart() + ">"; | 40 "</" + exp->Name().LocalPart() + ">"; |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 for (const XmlAttr* exp_attr = exp->FirstAttr(); exp_attr != NULL; | 44 for (const XmlAttr* exp_attr = exp->FirstAttr(); exp_attr != nullptr; |
45 exp_attr = exp_attr->NextAttr()) { | 45 exp_attr = exp_attr->NextAttr()) { |
46 if (exp_attr->Name().Namespace() == kXmlNsNs || | 46 if (exp_attr->Name().Namespace() == kXmlNsNs || |
47 exp_attr->Name() == QName(kXmlNs)) { | 47 exp_attr->Name() == QName(kXmlNs)) { |
48 continue; // Skip NS attributes. | 48 continue; // Skip NS attributes. |
49 } | 49 } |
50 if (val->Attr(exp_attr->Name()) != exp_attr->Value()) { | 50 if (val->Attr(exp_attr->Name()) != exp_attr->Value()) { |
51 *error = "In <" + exp->Name().LocalPart() + "> attribute " + | 51 *error = "In <" + exp->Name().LocalPart() + "> attribute " + |
52 exp_attr->Name().LocalPart() + " is expected to be set to " + | 52 exp_attr->Name().LocalPart() + " is expected to be set to " + |
53 exp_attr->Value(); | 53 exp_attr->Value(); |
54 return false; | 54 return false; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 XmlElement::ForStr(kTestSessionTerminateMessage)); | 249 XmlElement::ForStr(kTestSessionTerminateMessage)); |
250 ASSERT_TRUE(source_message.get()); | 250 ASSERT_TRUE(source_message.get()); |
251 | 251 |
252 EXPECT_TRUE(JingleMessage::IsJingleMessage(source_message.get())); | 252 EXPECT_TRUE(JingleMessage::IsJingleMessage(source_message.get())); |
253 | 253 |
254 JingleMessage message; | 254 JingleMessage message; |
255 std::string error; | 255 std::string error; |
256 EXPECT_TRUE(message.ParseXml(source_message.get(), &error)) << error; | 256 EXPECT_TRUE(message.ParseXml(source_message.get(), &error)) << error; |
257 | 257 |
258 EXPECT_EQ(message.action, JingleMessage::SESSION_INFO); | 258 EXPECT_EQ(message.action, JingleMessage::SESSION_INFO); |
259 ASSERT_TRUE(message.info.get() != NULL); | 259 ASSERT_TRUE(message.info.get() != nullptr); |
260 EXPECT_TRUE(message.info->Name() == | 260 EXPECT_TRUE(message.info->Name() == |
261 buzz::QName("urn:xmpp:jingle:1", "test-info")); | 261 buzz::QName("urn:xmpp:jingle:1", "test-info")); |
262 | 262 |
263 scoped_ptr<XmlElement> formatted_message(message.ToXml()); | 263 scoped_ptr<XmlElement> formatted_message(message.ToXml()); |
264 ASSERT_TRUE(formatted_message.get()); | 264 ASSERT_TRUE(formatted_message.get()); |
265 EXPECT_TRUE(VerifyXml(source_message.get(), formatted_message.get(), &error)) | 265 EXPECT_TRUE(VerifyXml(source_message.get(), formatted_message.get(), &error)) |
266 << error; | 266 << error; |
267 } | 267 } |
268 | 268 |
269 TEST(JingleMessageReplyTest, ToXml) { | 269 TEST(JingleMessageReplyTest, ToXml) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get())); | 365 EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get())); |
366 | 366 |
367 JingleMessage message; | 367 JingleMessage message; |
368 std::string error; | 368 std::string error; |
369 EXPECT_FALSE(message.ParseXml(source_message.get(), &error)); | 369 EXPECT_FALSE(message.ParseXml(source_message.get(), &error)); |
370 EXPECT_FALSE(error.empty()); | 370 EXPECT_FALSE(error.empty()); |
371 } | 371 } |
372 | 372 |
373 } // namespace protocol | 373 } // namespace protocol |
374 } // namespace remoting | 374 } // namespace remoting |
OLD | NEW |