OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/protocol/authenticator_test_base.h" | 5 #include "remoting/protocol/authenticator_test_base.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/run_loop.h" |
12 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/test/test_data_directory.h" | 16 #include "net/test/test_data_directory.h" |
16 #include "remoting/base/rsa_key_pair.h" | 17 #include "remoting/base/rsa_key_pair.h" |
17 #include "remoting/protocol/authenticator.h" | 18 #include "remoting/protocol/authenticator.h" |
18 #include "remoting/protocol/channel_authenticator.h" | 19 #include "remoting/protocol/channel_authenticator.h" |
19 #include "remoting/protocol/fake_stream_socket.h" | 20 #include "remoting/protocol/fake_stream_socket.h" |
20 #include "remoting/protocol/p2p_stream_socket.h" | 21 #include "remoting/protocol/p2p_stream_socket.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } else { | 141 } else { |
141 EXPECT_CALL(host_callback_, OnDone(net::OK)) | 142 EXPECT_CALL(host_callback_, OnDone(net::OK)) |
142 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 143 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
143 } | 144 } |
144 | 145 |
145 // Ensure that .Run() does not run unbounded if the callbacks are never | 146 // Ensure that .Run() does not run unbounded if the callbacks are never |
146 // called. | 147 // called. |
147 base::Timer shutdown_timer(false, false); | 148 base::Timer shutdown_timer(false, false); |
148 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), | 149 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), |
149 base::MessageLoop::QuitWhenIdleClosure()); | 150 base::MessageLoop::QuitWhenIdleClosure()); |
150 message_loop_.Run(); | 151 base::RunLoop().Run(); |
151 shutdown_timer.Stop(); | 152 shutdown_timer.Stop(); |
152 | 153 |
153 testing::Mock::VerifyAndClearExpectations(&client_callback_); | 154 testing::Mock::VerifyAndClearExpectations(&client_callback_); |
154 testing::Mock::VerifyAndClearExpectations(&host_callback_); | 155 testing::Mock::VerifyAndClearExpectations(&host_callback_); |
155 | 156 |
156 if (!expected_fail) { | 157 if (!expected_fail) { |
157 ASSERT_TRUE(client_socket_.get() != nullptr); | 158 ASSERT_TRUE(client_socket_.get() != nullptr); |
158 ASSERT_TRUE(host_socket_.get() != nullptr); | 159 ASSERT_TRUE(host_socket_.get() != nullptr); |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 void AuthenticatorTestBase::OnHostConnected( | 163 void AuthenticatorTestBase::OnHostConnected( |
163 int error, | 164 int error, |
164 std::unique_ptr<P2PStreamSocket> socket) { | 165 std::unique_ptr<P2PStreamSocket> socket) { |
165 host_callback_.OnDone(error); | 166 host_callback_.OnDone(error); |
166 host_socket_ = std::move(socket); | 167 host_socket_ = std::move(socket); |
167 } | 168 } |
168 | 169 |
169 void AuthenticatorTestBase::OnClientConnected( | 170 void AuthenticatorTestBase::OnClientConnected( |
170 int error, | 171 int error, |
171 std::unique_ptr<P2PStreamSocket> socket) { | 172 std::unique_ptr<P2PStreamSocket> socket) { |
172 client_callback_.OnDone(error); | 173 client_callback_.OnDone(error); |
173 client_socket_ = std::move(socket); | 174 client_socket_ = std::move(socket); |
174 } | 175 } |
175 | 176 |
176 } // namespace protocol | 177 } // namespace protocol |
177 } // namespace remoting | 178 } // namespace remoting |
OLD | NEW |