Gallery.app: Remove an unwanted space at the bottom of the window.
[chromium-blink-merge.git] / remoting / jingle_glue / server_log_entry_unittest.cc
blobb92feb2053049515f23866ceb6aa9a9ff3eb1f08
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"
7 #include <sstream>
9 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
11 using buzz::XmlAttr;
12 using buzz::XmlElement;
14 namespace remoting {
16 bool VerifyStanza(
17 const std::map<std::string, std::string>& key_value_pairs,
18 const std::set<std::string> keys,
19 const XmlElement* elem,
20 std::string* error) {
21 int attrCount = 0;
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();
27 return false;
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;
36 return false;
38 } else {
39 if (iter->second != value) {
40 *error = "attribute " + key + " has value " + iter->second +
41 ": expected " + value;
42 return false;
46 int attr_count_expected = key_value_pairs.size() + keys.size();
47 if (attrCount != attr_count_expected) {
48 std::stringstream s;
49 s << "stanza has " << attrCount << " keys: expected "
50 << attr_count_expected;
51 *error = s.str();
52 return false;
54 return true;
57 } // namespace remoting