OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/string_util.h" | 6 #include "base/stringprintf.h" |
7 #include "remoting/jingle_glue/iq_request.h" | 7 #include "remoting/jingle_glue/iq_request.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" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 | 13 |
14 TEST(IqRequestTest, MakeIqStanza) { | 14 TEST(IqRequestTest, MakeIqStanza) { |
15 const char* kMessageId = "0"; | 15 const char* kMessageId = "0"; |
16 const char* kNamespace = "chromium:testns"; | 16 const char* kNamespace = "chromium:testns"; |
17 const char* kNamespacePrefix = "tes"; | 17 const char* kNamespacePrefix = "tes"; |
18 const char* kBodyTag = "test"; | 18 const char* kBodyTag = "test"; |
19 const char* kType = "get"; | 19 const char* kType = "get"; |
20 const char* kTo = "user@domain.com"; | 20 const char* kTo = "user@domain.com"; |
21 | 21 |
22 std::string expected_xml_string = | 22 std::string expected_xml_string = |
23 StringPrintf( | 23 base::StringPrintf( |
24 "<cli:iq type=\"%s\" to=\"%s\" id=\"%s\" " | 24 "<cli:iq type=\"%s\" to=\"%s\" id=\"%s\" " |
25 "xmlns:cli=\"jabber:client\">" | 25 "xmlns:cli=\"jabber:client\">" |
26 "<%s:%s xmlns:%s=\"%s\"/>" | 26 "<%s:%s xmlns:%s=\"%s\"/>" |
27 "</cli:iq>", | 27 "</cli:iq>", |
28 kType, kTo, kMessageId, kNamespacePrefix, kBodyTag, | 28 kType, kTo, kMessageId, kNamespacePrefix, kBodyTag, |
29 kNamespacePrefix, kNamespace); | 29 kNamespacePrefix, kNamespace); |
30 | 30 |
31 buzz::XmlElement* iq_body = | 31 buzz::XmlElement* iq_body = |
32 new buzz::XmlElement(buzz::QName(kNamespace, kBodyTag)); | 32 new buzz::XmlElement(buzz::QName(kNamespace, kBodyTag)); |
33 scoped_ptr<buzz::XmlElement> stanza( | 33 scoped_ptr<buzz::XmlElement> stanza( |
34 IqRequest::MakeIqStanza(kType, kTo, iq_body, kMessageId)); | 34 IqRequest::MakeIqStanza(kType, kTo, iq_body, kMessageId)); |
35 | 35 |
36 EXPECT_EQ(expected_xml_string, stanza->Str()); | 36 EXPECT_EQ(expected_xml_string, stanza->Str()); |
37 } | 37 } |
38 | 38 |
39 } // namespace remoting | 39 } // namespace remoting |
OLD | NEW |