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

Side by Side Diff: components/copresence/rpc/rpc_handler_unittest.cc

Issue 453203002: Fixing memory leak in TimedMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging to HEAD Created 6 years, 4 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 "components/copresence/rpc/rpc_handler.h" 5 #include "components/copresence/rpc/rpc_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 base::MessageLoop message_loop_; 168 base::MessageLoop message_loop_;
169 169
170 RpcHandler rpc_handler_; 170 RpcHandler rpc_handler_;
171 171
172 std::string rpc_name_; 172 std::string rpc_name_;
173 scoped_ptr<MessageLite> request_proto_; 173 scoped_ptr<MessageLite> request_proto_;
174 CopresenceStatus status_; 174 CopresenceStatus status_;
175 std::map<std::string, std::vector<Message> > messages_by_subscription_; 175 std::map<std::string, std::vector<Message> > messages_by_subscription_;
176 }; 176 };
177 177
178 // TODO(ckehoe): Renable these after https://codereview.chromium.org/453203002/ 178 TEST_F(RpcHandlerTest, Initialize) {
179 // lands.
180 #define MAYBE_Initialize DISABLED_Initialize
181
182 TEST_F(RpcHandlerTest, MAYBE_Initialize) {
183 SetDeviceId(""); 179 SetDeviceId("");
184 rpc_handler_.Initialize(RpcHandler::SuccessCallback()); 180 rpc_handler_.Initialize(RpcHandler::SuccessCallback());
185 RegisterDeviceRequest* registration = 181 RegisterDeviceRequest* registration =
186 static_cast<RegisterDeviceRequest*>(request_proto_.get()); 182 static_cast<RegisterDeviceRequest*>(request_proto_.get());
187 Identity identity = registration->device_identifiers().registrant(); 183 Identity identity = registration->device_identifiers().registrant();
188 EXPECT_EQ(CHROME, identity.type()); 184 EXPECT_EQ(CHROME, identity.type());
189 EXPECT_FALSE(identity.chrome_id().empty()); 185 EXPECT_FALSE(identity.chrome_id().empty());
190 } 186 }
191 187
192 // TODO(ckehoe): Fix this on Windows. See rpc_handler.cc. 188 // TODO(ckehoe): Fix this on Windows. See rpc_handler.cc.
193 #ifndef OS_WIN 189 #ifndef OS_WIN
194 190
195 // TODO(ckehoe): Renable these after https://codereview.chromium.org/453203002/ 191 TEST_F(RpcHandlerTest, GetDeviceCapabilities) {
196 // lands.
197 #define MAYBE_GetDeviceCapabilities DISABLED_GetDeviceCapabilities
198
199 TEST_F(RpcHandlerTest, MAYBE_GetDeviceCapabilities) {
200 // Empty request. 192 // Empty request.
201 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest)); 193 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest));
202 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); 194 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_);
203 const TokenTechnology* token_technology = &GetTokenTechnologyFromReport(); 195 const TokenTechnology* token_technology = &GetTokenTechnologyFromReport();
204 EXPECT_EQ(AUDIO_ULTRASOUND_PASSBAND, token_technology->medium()); 196 EXPECT_EQ(AUDIO_ULTRASOUND_PASSBAND, token_technology->medium());
205 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0)); 197 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0));
206 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1)); 198 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1));
207 199
208 // Request with broadcast only. 200 // Request with broadcast only.
209 scoped_ptr<ReportRequest> report(new ReportRequest); 201 scoped_ptr<ReportRequest> report(new ReportRequest);
(...skipping 26 matching lines...) Expand all
236 report.reset(new ReportRequest); 228 report.reset(new ReportRequest);
237 AddMessageWithStrategy(report.get(), SCAN_ONLY); 229 AddMessageWithStrategy(report.get(), SCAN_ONLY);
238 AddSubscriptionWithStrategy(report.get(), BROADCAST_AND_SCAN); 230 AddSubscriptionWithStrategy(report.get(), BROADCAST_AND_SCAN);
239 rpc_handler_.SendReportRequest(report.Pass()); 231 rpc_handler_.SendReportRequest(report.Pass());
240 token_technology = &GetTokenTechnologyFromReport(); 232 token_technology = &GetTokenTechnologyFromReport();
241 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0)); 233 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0));
242 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1)); 234 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1));
243 } 235 }
244 #endif 236 #endif
245 237
246 // TODO(ckehoe): Renable these after https://codereview.chromium.org/453203002/ 238 TEST_F(RpcHandlerTest, CreateRequestHeader) {
247 // lands.
248 #define MAYBE_CreateRequestHeader DISABLED_CreateRequestHeader
249
250 TEST_F(RpcHandlerTest, MAYBE_CreateRequestHeader) {
251 SetDeviceId("CreateRequestHeader Device ID"); 239 SetDeviceId("CreateRequestHeader Device ID");
252 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest), 240 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest),
253 "CreateRequestHeader App ID", 241 "CreateRequestHeader App ID",
254 StatusCallback()); 242 StatusCallback());
255 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); 243 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_);
256 ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get()); 244 ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get());
257 EXPECT_TRUE(report->header().has_framework_version()); 245 EXPECT_TRUE(report->header().has_framework_version());
258 EXPECT_EQ("CreateRequestHeader App ID", 246 EXPECT_EQ("CreateRequestHeader App ID",
259 report->header().client_version().client()); 247 report->header().client_version().client());
260 EXPECT_EQ("CreateRequestHeader Device ID", 248 EXPECT_EQ("CreateRequestHeader Device ID",
261 report->header().registered_device_id()); 249 report->header().registered_device_id());
262 } 250 }
263 251
264 // TODO(ckehoe): Renable these after https://codereview.chromium.org/453203002/ 252 TEST_F(RpcHandlerTest, ReportTokens) {
265 // lands.
266 #define MAYBE_ReportTokens DISABLED_ReportTokens
267
268 TEST_F(RpcHandlerTest, MAYBE_ReportTokens) {
269 std::vector<FullToken> test_tokens; 253 std::vector<FullToken> test_tokens;
270 test_tokens.push_back(FullToken("token 1", false)); 254 test_tokens.push_back(FullToken("token 1", false));
271 test_tokens.push_back(FullToken("token 2", true)); 255 test_tokens.push_back(FullToken("token 2", true));
272 test_tokens.push_back(FullToken("token 3", false)); 256 test_tokens.push_back(FullToken("token 3", false));
273 AddInvalidToken("token 2"); 257 AddInvalidToken("token 2");
274 258
275 rpc_handler_.ReportTokens(test_tokens); 259 rpc_handler_.ReportTokens(test_tokens);
276 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); 260 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_);
277 ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get()); 261 ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get());
278 google::protobuf::RepeatedPtrField<TokenObservation> tokens_sent = 262 google::protobuf::RepeatedPtrField<TokenObservation> tokens_sent =
279 report->update_signals_request().token_observation(); 263 report->update_signals_request().token_observation();
280 ASSERT_EQ(2, tokens_sent.size()); 264 ASSERT_EQ(2, tokens_sent.size());
281 EXPECT_EQ("token 1", tokens_sent.Get(0).token_id()); 265 EXPECT_EQ("token 1", tokens_sent.Get(0).token_id());
282 EXPECT_EQ("token 3", tokens_sent.Get(1).token_id()); 266 EXPECT_EQ("token 3", tokens_sent.Get(1).token_id());
283 } 267 }
284 268
285 // TODO(ckehoe): Renable these after https://codereview.chromium.org/453203002/ 269 TEST_F(RpcHandlerTest, ReportResponseHandler) {
286 // lands.
287 #define MAYBE_ReportResponseHandler DISABLED_ReportResponseHandler
288
289 TEST_F(RpcHandlerTest, MAYBE_ReportResponseHandler) {
290 // Fail on HTTP status != 200. 270 // Fail on HTTP status != 200.
291 ReportResponse empty_response; 271 ReportResponse empty_response;
292 empty_response.mutable_header()->mutable_status()->set_code(OK); 272 empty_response.mutable_header()->mutable_status()->set_code(OK);
293 std::string serialized_empty_response; 273 std::string serialized_empty_response;
294 ASSERT_TRUE(empty_response.SerializeToString(&serialized_empty_response)); 274 ASSERT_TRUE(empty_response.SerializeToString(&serialized_empty_response));
295 status_ = SUCCESS; 275 status_ = SUCCESS;
296 InvokeReportResponseHandler(net::HTTP_BAD_REQUEST, serialized_empty_response); 276 InvokeReportResponseHandler(net::HTTP_BAD_REQUEST, serialized_empty_response);
297 EXPECT_EQ(FAIL, status_); 277 EXPECT_EQ(FAIL, status_);
298 278
299 std::vector<std::string> subscription_1(1, "Subscription 1"); 279 std::vector<std::string> subscription_1(1, "Subscription 1");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 messages_by_subscription_["Subscription 2"][1].payload()); 321 messages_by_subscription_["Subscription 2"][1].payload());
342 322
343 ASSERT_EQ(2U, directive_handler->added_directives().size()); 323 ASSERT_EQ(2U, directive_handler->added_directives().size());
344 EXPECT_EQ("Subscription 1", 324 EXPECT_EQ("Subscription 1",
345 directive_handler->added_directives()[0].subscription_id()); 325 directive_handler->added_directives()[0].subscription_id());
346 EXPECT_EQ("Subscription 2", 326 EXPECT_EQ("Subscription 2",
347 directive_handler->added_directives()[1].subscription_id()); 327 directive_handler->added_directives()[1].subscription_id());
348 } 328 }
349 329
350 } // namespace copresence 330 } // namespace copresence
OLDNEW
« no previous file with comments | « components/copresence/mediums/audio/audio_recorder_unittest.cc ('k') | components/copresence/timed_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698