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

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

Issue 441103002: Tests for the Copresence API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api
Patch Set: Renaming to simply CopresenceDelegate 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
« no previous file with comments | « components/copresence/rpc/rpc_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW
« no previous file with comments | « components/copresence/rpc/rpc_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698