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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "components/audio_modem/public/modem.h" |
| 16 #include "components/audio_modem/test/stub_whispernet_client.h" |
15 #include "components/copresence/copresence_state_impl.h" | 17 #include "components/copresence/copresence_state_impl.h" |
16 #include "components/copresence/handlers/directive_handler.h" | 18 #include "components/copresence/handlers/directive_handler.h" |
17 #include "components/copresence/mediums/audio/audio_manager.h" | |
18 #include "components/copresence/proto/data.pb.h" | 19 #include "components/copresence/proto/data.pb.h" |
19 #include "components/copresence/proto/enums.pb.h" | 20 #include "components/copresence/proto/enums.pb.h" |
20 #include "components/copresence/proto/rpcs.pb.h" | 21 #include "components/copresence/proto/rpcs.pb.h" |
21 #include "components/copresence/test/fake_directive_handler.h" | 22 #include "components/copresence/test/fake_directive_handler.h" |
22 #include "components/copresence/test/stub_whispernet_client.h" | |
23 #include "net/http/http_status_code.h" | 23 #include "net/http/http_status_code.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
25 | 25 |
26 using google::protobuf::MessageLite; | 26 using google::protobuf::MessageLite; |
27 using google::protobuf::RepeatedPtrField; | 27 using google::protobuf::RepeatedPtrField; |
28 | 28 |
29 using testing::ElementsAre; | 29 using testing::ElementsAre; |
30 using testing::Property; | 30 using testing::Property; |
31 using testing::SizeIs; | 31 using testing::SizeIs; |
32 | 32 |
| 33 using audio_modem::AudioToken; |
| 34 using audio_modem::WhispernetClient; |
| 35 |
33 namespace copresence { | 36 namespace copresence { |
34 | 37 |
35 namespace { | 38 namespace { |
36 | 39 |
37 const char kChromeVersion[] = "Chrome Version String"; | 40 const char kChromeVersion[] = "Chrome Version String"; |
38 | 41 |
39 void IgnoreMessages( | 42 void IgnoreMessages( |
40 const RepeatedPtrField<SubscribedMessage>& /* messages */) {} | 43 const RepeatedPtrField<SubscribedMessage>& /* messages */) {} |
41 | 44 |
42 } // namespace | 45 } // namespace |
43 | 46 |
44 class RpcHandlerTest : public testing::Test, public CopresenceDelegate { | 47 class RpcHandlerTest : public testing::Test, public CopresenceDelegate { |
45 public: | 48 public: |
46 RpcHandlerTest() | 49 RpcHandlerTest() |
47 : whispernet_client_(new StubWhispernetClient), | 50 : whispernet_client_(new audio_modem::StubWhispernetClient), |
48 // TODO(ckehoe): Use a FakeCopresenceState here | 51 // TODO(ckehoe): Use a FakeCopresenceState here |
49 // and test that it gets called correctly. | 52 // and test that it gets called correctly. |
50 state_(new CopresenceStateImpl), | 53 state_(new CopresenceStateImpl), |
51 rpc_handler_(this, | 54 rpc_handler_(this, |
52 state_.get(), | 55 state_.get(), |
53 &directive_handler_, | 56 &directive_handler_, |
54 nullptr, | 57 nullptr, |
55 base::Bind(&IgnoreMessages), | 58 base::Bind(&IgnoreMessages), |
56 base::Bind(&RpcHandlerTest::CaptureHttpPost, | 59 base::Bind(&RpcHandlerTest::CaptureHttpPost, |
57 base::Unretained(this))), | 60 base::Unretained(this))), |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // Check processing. | 340 // Check processing. |
338 status_ = FAIL; | 341 status_ = FAIL; |
339 SendReportResponse(net::HTTP_OK, response.Pass()); | 342 SendReportResponse(net::HTTP_OK, response.Pass()); |
340 EXPECT_EQ(SUCCESS, status_); | 343 EXPECT_EQ(SUCCESS, status_); |
341 EXPECT_TRUE(TokenIsInvalid("bad token")); | 344 EXPECT_TRUE(TokenIsInvalid("bad token")); |
342 EXPECT_THAT(directive_handler_.added_directives(), | 345 EXPECT_THAT(directive_handler_.added_directives(), |
343 ElementsAre("Subscription 1", "Subscription 2")); | 346 ElementsAre("Subscription 1", "Subscription 2")); |
344 } | 347 } |
345 | 348 |
346 } // namespace copresence | 349 } // namespace copresence |
OLD | NEW |