Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2126)

Side by Side Diff: remoting/jingle_glue/server_log_entry_unittest.cc

Issue 282063005: Pull out common code from client and host versions of ServerLogEntry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move ServerLogEntry to jingle_glue Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/jingle_glue/server_log_entry_unittest.h ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "remoting/jingle_glue/server_log_entry_unittest.h"
6
7 #include <sstream>
8
9 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
10
11 using buzz::XmlAttr;
12 using buzz::XmlElement;
13
14 namespace remoting {
15
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;
28 }
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;
37 }
38 } else {
39 if (iter->second != value) {
40 *error = "attribute " + key + " has value " + iter->second +
41 ": expected " + value;
42 return false;
43 }
44 }
45 }
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;
53 }
54 return true;
55 }
56
57 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/jingle_glue/server_log_entry_unittest.h ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698