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

Side by Side Diff: remoting/host/register_support_host_request_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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/host/policy_hack/policy_watcher_unittest.cc ('k') | remoting/host/server_log_entry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/host/register_support_host_request.h" 5 #include "remoting/host/register_support_host_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) 92 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull()))
93 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); 93 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true)));
94 94
95 request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); 95 request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
96 message_loop_.RunUntilIdle(); 96 message_loop_.RunUntilIdle();
97 97
98 // Verify format of the query. 98 // Verify format of the query.
99 scoped_ptr<XmlElement> stanza(sent_iq); 99 scoped_ptr<XmlElement> stanza(sent_iq);
100 ASSERT_TRUE(stanza != NULL); 100 ASSERT_TRUE(stanza != NULL);
101 101
102 EXPECT_EQ(stanza->Attr(buzz::QName("", "to")), 102 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "to")),
103 std::string(kTestBotJid)); 103 std::string(kTestBotJid));
104 EXPECT_EQ(stanza->Attr(buzz::QName("", "type")), "set"); 104 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "type")), "set");
105 105
106 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"), 106 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"),
107 stanza->FirstElement()->Name()); 107 stanza->FirstElement()->Name());
108 108
109 QName signature_tag(kChromotingXmlNamespace, "signature"); 109 QName signature_tag(kChromotingXmlNamespace, "signature");
110 XmlElement* signature = stanza->FirstElement()->FirstNamed(signature_tag); 110 XmlElement* signature = stanza->FirstElement()->FirstNamed(signature_tag);
111 ASSERT_TRUE(signature != NULL); 111 ASSERT_TRUE(signature != NULL);
112 EXPECT_TRUE(stanza->NextNamed(signature_tag) == NULL); 112 EXPECT_TRUE(stanza->NextNamed(signature_tag) == NULL);
113 113
114 std::string time_str = 114 std::string time_str =
115 signature->Attr(QName(kChromotingXmlNamespace, "time")); 115 signature->Attr(QName(kChromotingXmlNamespace, "time"));
116 int64 time; 116 int64 time;
117 EXPECT_TRUE(base::StringToInt64(time_str, &time)); 117 EXPECT_TRUE(base::StringToInt64(time_str, &time));
118 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); 118 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT());
119 EXPECT_LE(start_time, time); 119 EXPECT_LE(start_time, time);
120 EXPECT_GE(now, time); 120 EXPECT_GE(now, time);
121 121
122 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); 122 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair);
123 ASSERT_TRUE(key_pair); 123 ASSERT_TRUE(key_pair);
124 124
125 std::string expected_signature = 125 std::string expected_signature =
126 key_pair->SignMessage(std::string(kTestJid) + ' ' + time_str); 126 key_pair->SignMessage(std::string(kTestJid) + ' ' + time_str);
127 EXPECT_EQ(expected_signature, signature->BodyText()); 127 EXPECT_EQ(expected_signature, signature->BodyText());
128 128
129 // Generate response and verify that callback is called. 129 // Generate response and verify that callback is called.
130 EXPECT_CALL(callback_, OnResponse(true, kSupportId, 130 EXPECT_CALL(callback_, OnResponse(true, kSupportId,
131 base::TimeDelta::FromSeconds(300))); 131 base::TimeDelta::FromSeconds(300)));
132 132
133 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); 133 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ));
134 response->AddAttr(QName("", "from"), kTestBotJid); 134 response->AddAttr(QName(std::string(), "from"), kTestBotJid);
135 response->AddAttr(QName("", "type"), "result"); 135 response->AddAttr(QName(std::string(), "type"), "result");
136 response->AddAttr(QName("", "id"), kStanzaId); 136 response->AddAttr(QName(std::string(), "id"), kStanzaId);
137 137
138 XmlElement* result = new XmlElement( 138 XmlElement* result = new XmlElement(
139 QName(kChromotingXmlNamespace, "register-support-host-result")); 139 QName(kChromotingXmlNamespace, "register-support-host-result"));
140 response->AddElement(result); 140 response->AddElement(result);
141 141
142 XmlElement* support_id = new XmlElement( 142 XmlElement* support_id = new XmlElement(
143 QName(kChromotingXmlNamespace, "support-id")); 143 QName(kChromotingXmlNamespace, "support-id"));
144 support_id->AddText(kSupportId); 144 support_id->AddText(kSupportId);
145 result->AddElement(support_id); 145 result->AddElement(support_id);
146 146
147 XmlElement* support_id_lifetime = new XmlElement( 147 XmlElement* support_id_lifetime = new XmlElement(
148 QName(kChromotingXmlNamespace, "support-id-lifetime")); 148 QName(kChromotingXmlNamespace, "support-id-lifetime"));
149 support_id_lifetime->AddText(kSupportIdLifetime); 149 support_id_lifetime->AddText(kSupportIdLifetime);
150 result->AddElement(support_id_lifetime); 150 result->AddElement(support_id_lifetime);
151 151
152 int consumed = 0; 152 int consumed = 0;
153 ObserverListBase<SignalStrategy::Listener>::Iterator it( 153 ObserverListBase<SignalStrategy::Listener>::Iterator it(
154 signal_strategy_listeners_); 154 signal_strategy_listeners_);
155 SignalStrategy::Listener* listener; 155 SignalStrategy::Listener* listener;
156 while ((listener = it.GetNext()) != NULL) { 156 while ((listener = it.GetNext()) != NULL) {
157 if (listener->OnSignalStrategyIncomingStanza(response.get())) 157 if (listener->OnSignalStrategyIncomingStanza(response.get()))
158 consumed++; 158 consumed++;
159 } 159 }
160 EXPECT_EQ(1, consumed); 160 EXPECT_EQ(1, consumed);
161 161
162 message_loop_.RunUntilIdle(); 162 message_loop_.RunUntilIdle();
163 } 163 }
164 164
165 } // namespace remoting 165 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_unittest.cc ('k') | remoting/host/server_log_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698