OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/memory/ref_counted.h" | |
6 #include "base/stringprintf.h" | |
7 #include "remoting/jingle_glue/iq_request.h" | |
8 #include "testing/gmock/include/gmock/gmock.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | |
11 | |
12 namespace remoting { | |
13 | |
14 TEST(IqRequestTest, MakeIqStanza) { | |
15 const char* kMessageId = "0"; | |
16 const char* kNamespace = "chromium:testns"; | |
17 const char* kNamespacePrefix = "tes"; | |
18 const char* kBodyTag = "test"; | |
19 const char* kType = "get"; | |
20 const char* kTo = "user@domain.com"; | |
21 | |
22 std::string expected_xml_string = | |
23 base::StringPrintf( | |
24 "<cli:iq type=\"%s\" to=\"%s\" id=\"%s\" " | |
25 "xmlns:cli=\"jabber:client\">" | |
26 "<%s:%s xmlns:%s=\"%s\"/>" | |
27 "</cli:iq>", | |
28 kType, kTo, kMessageId, kNamespacePrefix, kBodyTag, | |
29 kNamespacePrefix, kNamespace); | |
30 | |
31 buzz::XmlElement* iq_body = | |
32 new buzz::XmlElement(buzz::QName(kNamespace, kBodyTag)); | |
33 scoped_ptr<buzz::XmlElement> stanza( | |
34 IqRequest::MakeIqStanza(kType, kTo, iq_body)); | |
35 stanza->AddAttr(buzz::QName("", "id"), kMessageId); | |
36 | |
37 EXPECT_EQ(expected_xml_string, stanza->Str()); | |
38 } | |
39 | |
40 } // namespace remoting | |
OLD | NEW |