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 #ifndef COMPONENTS_CAST_CHANNEL_CAST_TEST_UTIL_H_ | 5 #ifndef COMPONENTS_CAST_CHANNEL_CAST_TEST_UTIL_H_ |
6 #define COMPONENTS_CAST_CHANNEL_CAST_TEST_UTIL_H_ | 6 #define COMPONENTS_CAST_CHANNEL_CAST_TEST_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // Proxy for ConnectRawPtr. Unpacks scoped_ptr into a GMock-friendly bare | 68 // Proxy for ConnectRawPtr. Unpacks scoped_ptr into a GMock-friendly bare |
69 // ptr. | 69 // ptr. |
70 void Connect(std::unique_ptr<CastTransport::Delegate> delegate, | 70 void Connect(std::unique_ptr<CastTransport::Delegate> delegate, |
71 base::Callback<void(ChannelError)> callback) override { | 71 base::Callback<void(ChannelError)> callback) override { |
72 delegate_ = std::move(delegate); | 72 delegate_ = std::move(delegate); |
73 ConnectRawPtr(delegate_.get(), callback); | 73 ConnectRawPtr(delegate_.get(), callback); |
74 } | 74 } |
75 | 75 |
76 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback)); | 76 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback)); |
77 MOCK_CONST_METHOD0(ip_endpoint, const net::IPEndPoint&()); | |
78 MOCK_CONST_METHOD0(id, int()); | |
79 MOCK_METHOD1(set_id, void(int id)); | |
80 MOCK_CONST_METHOD0(channel_auth, ChannelAuthType()); | |
81 MOCK_CONST_METHOD0(ready_state, ReadyState()); | 77 MOCK_CONST_METHOD0(ready_state, ReadyState()); |
82 MOCK_CONST_METHOD0(error_state, ChannelError()); | 78 |
83 MOCK_CONST_METHOD0(keep_alive, bool(void)); | 79 const net::IPEndPoint& ip_endpoint() const override { return ip_endpoint_; } |
84 MOCK_CONST_METHOD0(audio_only, bool(void)); | 80 void SetIPEndpoint(const net::IPEndPoint& ip_endpoint) { |
85 MOCK_METHOD1(SetErrorState, void(ChannelError error_state)); | 81 ip_endpoint_ = ip_endpoint; |
| 82 } |
| 83 |
| 84 int id() const override { return channel_id_; } |
| 85 void set_id(int id) override { channel_id_ = id; } |
| 86 |
| 87 ChannelAuthType channel_auth() const override { return channel_auth_; } |
| 88 void SetChannelAuth(ChannelAuthType channel_auth) { |
| 89 channel_auth_ = channel_auth; |
| 90 } |
| 91 |
| 92 ChannelError error_state() const override { return error_state_; } |
| 93 void SetErrorState(ChannelError error_state) override { |
| 94 error_state_ = error_state; |
| 95 } |
| 96 |
| 97 bool keep_alive() const override { return keep_alive_; } |
| 98 void SetKeepAlive(bool keep_alive) { keep_alive_ = keep_alive; } |
| 99 |
| 100 bool audio_only() const override { return audio_only_; } |
| 101 void SetAudioOnly(bool audio_only) { audio_only_ = audio_only; } |
86 | 102 |
87 CastTransport* transport() const override { return mock_transport_.get(); } | 103 CastTransport* transport() const override { return mock_transport_.get(); } |
88 | |
89 MockCastTransport* mock_transport() const { return mock_transport_.get(); } | 104 MockCastTransport* mock_transport() const { return mock_transport_.get(); } |
90 | 105 |
91 private: | 106 private: |
| 107 net::IPEndPoint ip_endpoint_; |
| 108 int channel_id_; |
| 109 ChannelAuthType channel_auth_; |
| 110 ChannelError error_state_; |
| 111 bool keep_alive_; |
| 112 bool audio_only_; |
| 113 |
92 std::unique_ptr<MockCastTransport> mock_transport_; | 114 std::unique_ptr<MockCastTransport> mock_transport_; |
93 std::unique_ptr<CastTransport::Delegate> delegate_; | 115 std::unique_ptr<CastTransport::Delegate> delegate_; |
94 | 116 |
95 DISALLOW_COPY_AND_ASSIGN(MockCastSocket); | 117 DISALLOW_COPY_AND_ASSIGN(MockCastSocket); |
96 }; | 118 }; |
97 | 119 |
98 // Creates the IPEndpoint 192.168.1.1. | 120 // Creates the IPEndpoint 192.168.1.1. |
99 net::IPEndPoint CreateIPEndPointForTest(); | 121 net::IPEndPoint CreateIPEndPointForTest(); |
100 | 122 |
101 // Checks if two proto messages are the same. | 123 // Checks if two proto messages are the same. |
(...skipping 10 matching lines...) Expand all Loading... |
112 ACTION_TEMPLATE(PostCompletionCallbackTask, | 134 ACTION_TEMPLATE(PostCompletionCallbackTask, |
113 HAS_1_TEMPLATE_PARAMS(int, cb_idx), | 135 HAS_1_TEMPLATE_PARAMS(int, cb_idx), |
114 AND_1_VALUE_PARAMS(rv)) { | 136 AND_1_VALUE_PARAMS(rv)) { |
115 base::ThreadTaskRunnerHandle::Get()->PostTask( | 137 base::ThreadTaskRunnerHandle::Get()->PostTask( |
116 FROM_HERE, base::Bind(testing::get<cb_idx>(args), rv)); | 138 FROM_HERE, base::Bind(testing::get<cb_idx>(args), rv)); |
117 } | 139 } |
118 | 140 |
119 } // namespace cast_channel | 141 } // namespace cast_channel |
120 | 142 |
121 #endif // COMPONENTS_CAST_CHANNEL_CAST_TEST_UTIL_H_ | 143 #endif // COMPONENTS_CAST_CHANNEL_CAST_TEST_UTIL_H_ |
OLD | NEW |