| OLD | NEW |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 const std::string GetPlatformVersionString() const override { | 76 const std::string GetPlatformVersionString() const override { |
| 77 return kChromeVersion; | 77 return kChromeVersion; |
| 78 } | 78 } |
| 79 | 79 |
| 80 const std::string GetAPIKey(const std::string& app_id) const override { | 80 const std::string GetAPIKey(const std::string& app_id) const override { |
| 81 return app_id + " API Key"; | 81 return app_id + " API Key"; |
| 82 } | 82 } |
| 83 | 83 |
| 84 const std::string GetProjectId(const std::string& app_id) const override { | |
| 85 return app_id + " Project ID"; | |
| 86 } | |
| 87 | |
| 88 WhispernetClient* GetWhispernetClient() override { | 84 WhispernetClient* GetWhispernetClient() override { |
| 89 return whispernet_client_.get(); | 85 return whispernet_client_.get(); |
| 90 } | 86 } |
| 91 | 87 |
| 92 // TODO(ckehoe): Add GCM tests. | 88 // TODO(ckehoe): Add GCM tests. |
| 93 gcm::GCMDriver* GetGCMDriver() override { | 89 gcm::GCMDriver* GetGCMDriver() override { |
| 94 return nullptr; | 90 return nullptr; |
| 95 } | 91 } |
| 96 | 92 |
| 97 const std::string GetDeviceId(bool authenticated) override { | 93 const std::string GetDeviceId(bool authenticated) override { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 "CreateRequestHeader Auth Token"); | 279 "CreateRequestHeader Auth Token"); |
| 284 | 280 |
| 285 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); | 281 EXPECT_EQ(RpcHandler::kReportRequestRpcName, rpc_name_); |
| 286 EXPECT_EQ("CreateRequestHeader App API Key", api_key_); | 282 EXPECT_EQ("CreateRequestHeader App API Key", api_key_); |
| 287 EXPECT_EQ("CreateRequestHeader Auth Token", auth_token_); | 283 EXPECT_EQ("CreateRequestHeader Auth Token", auth_token_); |
| 288 const ReportRequest* report = static_cast<ReportRequest*>(request_protos_[0]); | 284 const ReportRequest* report = static_cast<ReportRequest*>(request_protos_[0]); |
| 289 EXPECT_EQ(kChromeVersion, | 285 EXPECT_EQ(kChromeVersion, |
| 290 report->header().framework_version().version_name()); | 286 report->header().framework_version().version_name()); |
| 291 EXPECT_EQ("CreateRequestHeader App", | 287 EXPECT_EQ("CreateRequestHeader App", |
| 292 report->header().client_version().client()); | 288 report->header().client_version().client()); |
| 293 EXPECT_EQ("CreateRequestHeader App Project ID", | |
| 294 report->header().client_version().project_id()); | |
| 295 EXPECT_EQ("CreateRequestHeader Device ID", | 289 EXPECT_EQ("CreateRequestHeader Device ID", |
| 296 report->header().registered_device_id()); | 290 report->header().registered_device_id()); |
| 297 EXPECT_EQ(CHROME_PLATFORM_TYPE, | 291 EXPECT_EQ(CHROME_PLATFORM_TYPE, |
| 298 report->header().device_fingerprint().type()); | 292 report->header().device_fingerprint().type()); |
| 299 } | 293 } |
| 300 | 294 |
| 301 TEST_F(RpcHandlerTest, ReportTokens) { | 295 TEST_F(RpcHandlerTest, ReportTokens) { |
| 302 std::vector<AudioToken> test_tokens; | 296 std::vector<AudioToken> test_tokens; |
| 303 test_tokens.push_back(AudioToken("token 1", false)); | 297 test_tokens.push_back(AudioToken("token 1", false)); |
| 304 test_tokens.push_back(AudioToken("token 2", false)); | 298 test_tokens.push_back(AudioToken("token 2", false)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // Check processing. | 339 // Check processing. |
| 346 status_ = FAIL; | 340 status_ = FAIL; |
| 347 SendReportResponse(net::HTTP_OK, response.Pass()); | 341 SendReportResponse(net::HTTP_OK, response.Pass()); |
| 348 EXPECT_EQ(SUCCESS, status_); | 342 EXPECT_EQ(SUCCESS, status_); |
| 349 EXPECT_TRUE(TokenIsInvalid("bad token")); | 343 EXPECT_TRUE(TokenIsInvalid("bad token")); |
| 350 EXPECT_THAT(directive_handler_.added_directives(), | 344 EXPECT_THAT(directive_handler_.added_directives(), |
| 351 ElementsAre("Subscription 1", "Subscription 2")); | 345 ElementsAre("Subscription 1", "Subscription 2")); |
| 352 } | 346 } |
| 353 | 347 |
| 354 } // namespace copresence | 348 } // namespace copresence |
| OLD | NEW |