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

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

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "remoting/signaling/server_log_entry_unittest.h" 5 #include "remoting/signaling/server_log_entry_unittest.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 10 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
11 11
12 using buzz::QName; 12 using buzz::QName;
13 using buzz::XmlAttr; 13 using buzz::XmlAttr;
14 using buzz::XmlElement; 14 using buzz::XmlElement;
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 const char kJabberClientNamespace[] = "jabber:client"; 18 const char kJabberClientNamespace[] = "jabber:client";
19 const char kChromotingNamespace[] = "google:remoting"; 19 const char kChromotingNamespace[] = "google:remoting";
20 20
21 XmlElement* GetLogElementFromStanza(XmlElement* stanza) { 21 XmlElement* GetLogElementFromStanza(XmlElement* stanza) {
22 if (stanza->Name() != QName(kJabberClientNamespace, "iq")) { 22 if (stanza->Name() != QName(kJabberClientNamespace, "iq")) {
23 ADD_FAILURE() << "Expected element 'iq'"; 23 ADD_FAILURE() << "Expected element 'iq'";
24 return NULL; 24 return nullptr;
25 } 25 }
26 XmlElement* log_element = stanza->FirstChild()->AsElement(); 26 XmlElement* log_element = stanza->FirstChild()->AsElement();
27 if (log_element->Name() != QName(kChromotingNamespace, "log")) { 27 if (log_element->Name() != QName(kChromotingNamespace, "log")) {
28 ADD_FAILURE() << "Expected element 'log'"; 28 ADD_FAILURE() << "Expected element 'log'";
29 return NULL; 29 return nullptr;
30 } 30 }
31 if (log_element->NextChild()) { 31 if (log_element->NextChild()) {
32 ADD_FAILURE() << "Expected only 1 child of 'iq'"; 32 ADD_FAILURE() << "Expected only 1 child of 'iq'";
33 return NULL; 33 return nullptr;
34 } 34 }
35 return log_element; 35 return log_element;
36 } 36 }
37 37
38 XmlElement* GetSingleLogEntryFromStanza(XmlElement* stanza) { 38 XmlElement* GetSingleLogEntryFromStanza(XmlElement* stanza) {
39 XmlElement* log_element = GetLogElementFromStanza(stanza); 39 XmlElement* log_element = GetLogElementFromStanza(stanza);
40 if (!log_element) { 40 if (!log_element) {
41 // Test failure already recorded, so just return NULL here. 41 // Test failure already recorded, so just return nullptr here.
42 return NULL; 42 return nullptr;
43 } 43 }
44 XmlElement* entry = log_element->FirstChild()->AsElement(); 44 XmlElement* entry = log_element->FirstChild()->AsElement();
45 if (entry->Name() != QName(kChromotingNamespace, "entry")) { 45 if (entry->Name() != QName(kChromotingNamespace, "entry")) {
46 ADD_FAILURE() << "Expected element 'entry'"; 46 ADD_FAILURE() << "Expected element 'entry'";
47 return NULL; 47 return nullptr;
48 } 48 }
49 if (entry->NextChild()) { 49 if (entry->NextChild()) {
50 ADD_FAILURE() << "Expected only 1 child of 'log'"; 50 ADD_FAILURE() << "Expected only 1 child of 'log'";
51 return NULL; 51 return nullptr;
52 } 52 }
53 return entry; 53 return entry;
54 } 54 }
55 55
56 bool VerifyStanza( 56 bool VerifyStanza(
57 const std::map<std::string, std::string>& key_value_pairs, 57 const std::map<std::string, std::string>& key_value_pairs,
58 const std::set<std::string> keys, 58 const std::set<std::string> keys,
59 const XmlElement* elem, 59 const XmlElement* elem,
60 std::string* error) { 60 std::string* error) {
61 int attrCount = 0; 61 int attrCount = 0;
62 for (const XmlAttr* attr = elem->FirstAttr(); attr != NULL; 62 for (const XmlAttr* attr = elem->FirstAttr(); attr != nullptr;
63 attr = attr->NextAttr(), attrCount++) { 63 attr = attr->NextAttr(), attrCount++) {
64 if (attr->Name().Namespace().length() != 0) { 64 if (attr->Name().Namespace().length() != 0) {
65 *error = "attribute has non-empty namespace " + 65 *error = "attribute has non-empty namespace " +
66 attr->Name().Namespace(); 66 attr->Name().Namespace();
67 return false; 67 return false;
68 } 68 }
69 const std::string& key = attr->Name().LocalPart(); 69 const std::string& key = attr->Name().LocalPart();
70 const std::string& value = attr->Value(); 70 const std::string& value = attr->Value();
71 std::map<std::string, std::string>::const_iterator iter = 71 std::map<std::string, std::string>::const_iterator iter =
72 key_value_pairs.find(key); 72 key_value_pairs.find(key);
(...skipping 15 matching lines...) Expand all
88 std::stringstream s; 88 std::stringstream s;
89 s << "stanza has " << attrCount << " keys: expected " 89 s << "stanza has " << attrCount << " keys: expected "
90 << attr_count_expected; 90 << attr_count_expected;
91 *error = s.str(); 91 *error = s.str();
92 return false; 92 return false;
93 } 93 }
94 return true; 94 return true;
95 } 95 }
96 96
97 } // namespace remoting 97 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/server_log_entry_unittest.h ('k') | remoting/signaling/xmpp_signal_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698