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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 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
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/host/remoting_me2me_host.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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 MockSignalStrategy signal_strategy_; 76 MockSignalStrategy signal_strategy_;
77 base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_; 77 base::ObserverList<SignalStrategy::Listener, true> signal_strategy_listeners_;
78 scoped_refptr<RsaKeyPair> key_pair_; 78 scoped_refptr<RsaKeyPair> key_pair_;
79 MockCallback callback_; 79 MockCallback callback_;
80 }; 80 };
81 81
82 TEST_F(RegisterSupportHostRequestTest, Send) { 82 TEST_F(RegisterSupportHostRequestTest, Send) {
83 // |iq_request| is freed by RegisterSupportHostRequest. 83 // |iq_request| is freed by RegisterSupportHostRequest.
84 int64_t start_time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); 84 int64_t start_time = static_cast<int64_t>(base::Time::Now().ToDoubleT());
85 85
86 scoped_ptr<RegisterSupportHostRequest> request( 86 std::unique_ptr<RegisterSupportHostRequest> request(
87 new RegisterSupportHostRequest(&signal_strategy_, key_pair_, 87 new RegisterSupportHostRequest(
88 kTestBotJid, 88 &signal_strategy_, key_pair_, kTestBotJid,
89 base::Bind(&MockCallback::OnResponse, 89 base::Bind(&MockCallback::OnResponse, base::Unretained(&callback_))));
90 base::Unretained(&callback_))));
91 90
92 XmlElement* sent_iq = nullptr; 91 XmlElement* sent_iq = nullptr;
93 EXPECT_CALL(signal_strategy_, GetNextId()) 92 EXPECT_CALL(signal_strategy_, GetNextId())
94 .WillOnce(Return(kStanzaId)); 93 .WillOnce(Return(kStanzaId));
95 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull())) 94 EXPECT_CALL(signal_strategy_, SendStanzaPtr(NotNull()))
96 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true))); 95 .WillOnce(DoAll(SaveArg<0>(&sent_iq), Return(true)));
97 96
98 request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED); 97 request->OnSignalStrategyStateChange(SignalStrategy::CONNECTED);
99 base::RunLoop().RunUntilIdle(); 98 base::RunLoop().RunUntilIdle();
100 99
101 // Verify format of the query. 100 // Verify format of the query.
102 scoped_ptr<XmlElement> stanza(sent_iq); 101 std::unique_ptr<XmlElement> stanza(sent_iq);
103 ASSERT_TRUE(stanza != nullptr); 102 ASSERT_TRUE(stanza != nullptr);
104 103
105 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "to")), 104 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "to")),
106 std::string(kTestBotJid)); 105 std::string(kTestBotJid));
107 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "type")), "set"); 106 EXPECT_EQ(stanza->Attr(buzz::QName(std::string(), "type")), "set");
108 107
109 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"), 108 EXPECT_EQ(QName(kChromotingXmlNamespace, "register-support-host"),
110 stanza->FirstElement()->Name()); 109 stanza->FirstElement()->Name());
111 110
112 QName signature_tag(kChromotingXmlNamespace, "signature"); 111 QName signature_tag(kChromotingXmlNamespace, "signature");
(...skipping 14 matching lines...) Expand all
127 126
128 std::string expected_signature = 127 std::string expected_signature =
129 key_pair->SignMessage(std::string(kTestJidNormalized) + ' ' + time_str); 128 key_pair->SignMessage(std::string(kTestJidNormalized) + ' ' + time_str);
130 EXPECT_EQ(expected_signature, signature->BodyText()); 129 EXPECT_EQ(expected_signature, signature->BodyText());
131 130
132 // Generate response and verify that callback is called. 131 // Generate response and verify that callback is called.
133 EXPECT_CALL(callback_, OnResponse(kSupportId, 132 EXPECT_CALL(callback_, OnResponse(kSupportId,
134 base::TimeDelta::FromSeconds(300), 133 base::TimeDelta::FromSeconds(300),
135 "")); 134 ""));
136 135
137 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); 136 std::unique_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ));
138 response->AddAttr(QName(std::string(), "from"), kTestBotJid); 137 response->AddAttr(QName(std::string(), "from"), kTestBotJid);
139 response->AddAttr(QName(std::string(), "type"), "result"); 138 response->AddAttr(QName(std::string(), "type"), "result");
140 response->AddAttr(QName(std::string(), "id"), kStanzaId); 139 response->AddAttr(QName(std::string(), "id"), kStanzaId);
141 140
142 XmlElement* result = new XmlElement( 141 XmlElement* result = new XmlElement(
143 QName(kChromotingXmlNamespace, "register-support-host-result")); 142 QName(kChromotingXmlNamespace, "register-support-host-result"));
144 response->AddElement(result); 143 response->AddElement(result);
145 144
146 XmlElement* support_id = new XmlElement( 145 XmlElement* support_id = new XmlElement(
147 QName(kChromotingXmlNamespace, "support-id")); 146 QName(kChromotingXmlNamespace, "support-id"));
(...skipping 12 matching lines...) Expand all
160 while ((listener = it.GetNext()) != nullptr) { 159 while ((listener = it.GetNext()) != nullptr) {
161 if (listener->OnSignalStrategyIncomingStanza(response.get())) 160 if (listener->OnSignalStrategyIncomingStanza(response.get()))
162 consumed++; 161 consumed++;
163 } 162 }
164 EXPECT_EQ(1, consumed); 163 EXPECT_EQ(1, consumed);
165 164
166 base::RunLoop().RunUntilIdle(); 165 base::RunLoop().RunUntilIdle();
167 } 166 }
168 167
169 } // namespace remoting 168 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698