| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 std::vector<Directive> added_directives_; | 79 std::vector<Directive> added_directives_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(FakeDirectiveHandler); | 81 DISALLOW_COPY_AND_ASSIGN(FakeDirectiveHandler); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 class RpcHandlerTest : public testing::Test, public CopresenceClientDelegate { | 86 class RpcHandlerTest : public testing::Test, public CopresenceDelegate { |
| 87 public: | 87 public: |
| 88 RpcHandlerTest() : rpc_handler_(this), status_(SUCCESS), api_key_("API key") { | 88 RpcHandlerTest() : rpc_handler_(this), status_(SUCCESS), api_key_("API key") { |
| 89 rpc_handler_.server_post_callback_ = | 89 rpc_handler_.server_post_callback_ = |
| 90 base::Bind(&RpcHandlerTest::CaptureHttpPost, base::Unretained(this)); | 90 base::Bind(&RpcHandlerTest::CaptureHttpPost, base::Unretained(this)); |
| 91 rpc_handler_.device_id_ = "Device ID"; | 91 rpc_handler_.device_id_ = "Device ID"; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void CaptureHttpPost( | 94 void CaptureHttpPost( |
| 95 net::URLRequestContextGetter* url_context_getter, | 95 net::URLRequestContextGetter* url_context_getter, |
| 96 const std::string& rpc_name, | 96 const std::string& rpc_name, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 void InvokeReportResponseHandler(int status_code, | 149 void InvokeReportResponseHandler(int status_code, |
| 150 const std::string& response) { | 150 const std::string& response) { |
| 151 rpc_handler_.ReportResponseHandler( | 151 rpc_handler_.ReportResponseHandler( |
| 152 base::Bind(&RpcHandlerTest::CaptureStatus, base::Unretained(this)), | 152 base::Bind(&RpcHandlerTest::CaptureStatus, base::Unretained(this)), |
| 153 NULL, | 153 NULL, |
| 154 status_code, | 154 status_code, |
| 155 response); | 155 response); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // CopresenceClientDelegate implementation | 158 // CopresenceDelegate implementation |
| 159 | 159 |
| 160 virtual void HandleMessages( | 160 virtual void HandleMessages( |
| 161 const std::string& app_id, | 161 const std::string& app_id, |
| 162 const std::string& subscription_id, | 162 const std::string& subscription_id, |
| 163 const std::vector<Message>& messages) OVERRIDE { | 163 const std::vector<Message>& messages) OVERRIDE { |
| 164 // app_id is unused for now, pending a server fix. | 164 // app_id is unused for now, pending a server fix. |
| 165 messages_by_subscription_[subscription_id] = messages; | 165 messages_by_subscription_[subscription_id] = messages; |
| 166 } | 166 } |
| 167 | 167 |
| 168 virtual net::URLRequestContextGetter* GetRequestContext() const OVERRIDE { | 168 virtual net::URLRequestContextGetter* GetRequestContext() const OVERRIDE { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 messages_by_subscription_["Subscription 2"][1].payload()); | 378 messages_by_subscription_["Subscription 2"][1].payload()); |
| 379 | 379 |
| 380 ASSERT_EQ(2U, directive_handler->added_directives().size()); | 380 ASSERT_EQ(2U, directive_handler->added_directives().size()); |
| 381 EXPECT_EQ("Subscription 1", | 381 EXPECT_EQ("Subscription 1", |
| 382 directive_handler->added_directives()[0].subscription_id()); | 382 directive_handler->added_directives()[0].subscription_id()); |
| 383 EXPECT_EQ("Subscription 2", | 383 EXPECT_EQ("Subscription 2", |
| 384 directive_handler->added_directives()[1].subscription_id()); | 384 directive_handler->added_directives()[1].subscription_id()); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace copresence | 387 } // namespace copresence |
| OLD | NEW |