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

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

Issue 503253002: Fixing Windows build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 void CaptureStatus(CopresenceStatus status) { 103 void CaptureStatus(CopresenceStatus status) {
104 status_ = status; 104 status_ = status;
105 } 105 }
106 106
107 inline const ReportRequest* GetReportSent() { 107 inline const ReportRequest* GetReportSent() {
108 return static_cast<ReportRequest*>(request_proto_.get()); 108 return static_cast<ReportRequest*>(request_proto_.get());
109 } 109 }
110 110
111 // TODO(ckehoe): Fix this on Windows. See rpc_handler.cc.
112 #ifndef OS_WIN
113 const TokenTechnology& GetTokenTechnologyFromReport() { 111 const TokenTechnology& GetTokenTechnologyFromReport() {
114 return GetReportSent()->update_signals_request().state().capabilities() 112 return GetReportSent()->update_signals_request().state().capabilities()
115 .token_technology(0); 113 .token_technology(0);
116 } 114 }
117 #endif
118 115
119 const RepeatedPtrField<PublishedMessage>& GetMessagesPublished() { 116 const RepeatedPtrField<PublishedMessage>& GetMessagesPublished() {
120 return GetReportSent()->manage_messages_request().message_to_publish(); 117 return GetReportSent()->manage_messages_request().message_to_publish();
121 } 118 }
122 119
123 const RepeatedPtrField<Subscription>& GetSubscriptionsSent() { 120 const RepeatedPtrField<Subscription>& GetSubscriptionsSent() {
124 return GetReportSent()->manage_subscriptions_request().subscription(); 121 return GetReportSent()->manage_subscriptions_request().subscription();
125 } 122 }
126 123
127 void SetDeviceId(const std::string& device_id) { 124 void SetDeviceId(const std::string& device_id) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 TEST_F(RpcHandlerTest, Initialize) { 194 TEST_F(RpcHandlerTest, Initialize) {
198 SetDeviceId(""); 195 SetDeviceId("");
199 rpc_handler_.Initialize(RpcHandler::SuccessCallback()); 196 rpc_handler_.Initialize(RpcHandler::SuccessCallback());
200 RegisterDeviceRequest* registration = 197 RegisterDeviceRequest* registration =
201 static_cast<RegisterDeviceRequest*>(request_proto_.get()); 198 static_cast<RegisterDeviceRequest*>(request_proto_.get());
202 Identity identity = registration->device_identifiers().registrant(); 199 Identity identity = registration->device_identifiers().registrant();
203 EXPECT_EQ(CHROME, identity.type()); 200 EXPECT_EQ(CHROME, identity.type());
204 EXPECT_FALSE(identity.chrome_id().empty()); 201 EXPECT_FALSE(identity.chrome_id().empty());
205 } 202 }
206 203
207 // TODO(ckehoe): Fix this on Windows. See rpc_handler.cc.
208 #ifndef OS_WIN
209
210 TEST_F(RpcHandlerTest, GetDeviceCapabilities) { 204 TEST_F(RpcHandlerTest, GetDeviceCapabilities) {
211 // Empty request. 205 // Empty request.
212 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest)); 206 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest));
213 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); 207 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_);
214 const TokenTechnology* token_technology = &GetTokenTechnologyFromReport(); 208 const TokenTechnology* token_technology = &GetTokenTechnologyFromReport();
215 EXPECT_EQ(AUDIO_ULTRASOUND_PASSBAND, token_technology->medium()); 209 EXPECT_EQ(AUDIO_ULTRASOUND_PASSBAND, token_technology->medium());
216 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0)); 210 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0));
217 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1)); 211 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1));
218 212
219 // Request with broadcast only. 213 // Request with broadcast only.
(...skipping 27 matching lines...) Expand all
247 241
248 // Request with broadcast and scan. 242 // Request with broadcast and scan.
249 report.reset(new ReportRequest); 243 report.reset(new ReportRequest);
250 AddMessageWithStrategy(report.get(), SCAN_ONLY); 244 AddMessageWithStrategy(report.get(), SCAN_ONLY);
251 AddSubscriptionWithStrategy(report.get(), BROADCAST_AND_SCAN); 245 AddSubscriptionWithStrategy(report.get(), BROADCAST_AND_SCAN);
252 rpc_handler_.SendReportRequest(report.Pass()); 246 rpc_handler_.SendReportRequest(report.Pass());
253 token_technology = &GetTokenTechnologyFromReport(); 247 token_technology = &GetTokenTechnologyFromReport();
254 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0)); 248 EXPECT_EQ(TRANSMIT, token_technology->instruction_type(0));
255 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1)); 249 EXPECT_EQ(RECEIVE, token_technology->instruction_type(1));
256 } 250 }
257 #endif
258 251
259 TEST_F(RpcHandlerTest, CreateRequestHeader) { 252 TEST_F(RpcHandlerTest, CreateRequestHeader) {
260 SetDeviceId("CreateRequestHeader Device ID"); 253 SetDeviceId("CreateRequestHeader Device ID");
261 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest), 254 rpc_handler_.SendReportRequest(make_scoped_ptr(new ReportRequest),
262 "CreateRequestHeader App ID", 255 "CreateRequestHeader App ID",
263 StatusCallback()); 256 StatusCallback());
264 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); 257 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_);
265 ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get()); 258 ReportRequest* report = static_cast<ReportRequest*>(request_proto_.get());
266 EXPECT_EQ(kChromeVersion, 259 EXPECT_EQ(kChromeVersion,
267 report->header().framework_version().version_name()); 260 report->header().framework_version().version_name());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 messages_by_subscription_["Subscription 2"][1].payload()); 338 messages_by_subscription_["Subscription 2"][1].payload());
346 339
347 ASSERT_EQ(2U, directive_handler->added_directives().size()); 340 ASSERT_EQ(2U, directive_handler->added_directives().size());
348 EXPECT_EQ("Subscription 1", 341 EXPECT_EQ("Subscription 1",
349 directive_handler->added_directives()[0].subscription_id()); 342 directive_handler->added_directives()[0].subscription_id());
350 EXPECT_EQ("Subscription 2", 343 EXPECT_EQ("Subscription 2",
351 directive_handler->added_directives()[1].subscription_id()); 344 directive_handler->added_directives()[1].subscription_id());
352 } 345 }
353 346
354 } // namespace copresence 347 } // namespace copresence
OLDNEW
« components/copresence/rpc/rpc_handler.cc ('K') | « components/copresence/rpc/rpc_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698