1 // Copyright 2014 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.
5 #include "remoting/jingle_glue/server_log_entry_unittest.h"
9 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
12 using buzz::XmlElement
;
17 const std::map
<std::string
, std::string
>& key_value_pairs
,
18 const std::set
<std::string
> keys
,
19 const XmlElement
* elem
,
22 for (const XmlAttr
* attr
= elem
->FirstAttr(); attr
!= NULL
;
23 attr
= attr
->NextAttr(), attrCount
++) {
24 if (attr
->Name().Namespace().length() != 0) {
25 *error
= "attribute has non-empty namespace " +
26 attr
->Name().Namespace();
29 const std::string
& key
= attr
->Name().LocalPart();
30 const std::string
& value
= attr
->Value();
31 std::map
<std::string
, std::string
>::const_iterator iter
=
32 key_value_pairs
.find(key
);
33 if (iter
== key_value_pairs
.end()) {
34 if (keys
.find(key
) == keys
.end()) {
35 *error
= "unexpected attribute " + key
;
39 if (iter
->second
!= value
) {
40 *error
= "attribute " + key
+ " has value " + iter
->second
+
41 ": expected " + value
;
46 int attr_count_expected
= key_value_pairs
.size() + keys
.size();
47 if (attrCount
!= attr_count_expected
) {
49 s
<< "stanza has " << attrCount
<< " keys: expected "
50 << attr_count_expected
;
57 } // namespace remoting