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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace remoting { | 25 namespace remoting { |
26 namespace protocol { | 26 namespace protocol { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 ACTION_P(QuitThreadOnCounter, counter) { | 30 ACTION_P(QuitThreadOnCounter, counter) { |
31 --(*counter); | 31 --(*counter); |
32 EXPECT_GE(*counter, 0); | 32 EXPECT_GE(*counter, 0); |
33 if (*counter == 0) | 33 if (*counter == 0) |
34 base::MessageLoop::current()->Quit(); | 34 base::MessageLoop::current()->QuitWhenIdle(); |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 AuthenticatorTestBase::MockChannelDoneCallback::MockChannelDoneCallback() {} | 39 AuthenticatorTestBase::MockChannelDoneCallback::MockChannelDoneCallback() {} |
40 | 40 |
41 AuthenticatorTestBase::MockChannelDoneCallback::~MockChannelDoneCallback() {} | 41 AuthenticatorTestBase::MockChannelDoneCallback::~MockChannelDoneCallback() {} |
42 | 42 |
43 AuthenticatorTestBase::AuthenticatorTestBase() {} | 43 AuthenticatorTestBase::AuthenticatorTestBase() {} |
44 | 44 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED)) | 135 EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED)) |
136 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 136 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
137 } else { | 137 } else { |
138 EXPECT_CALL(host_callback_, OnDone(net::OK)) | 138 EXPECT_CALL(host_callback_, OnDone(net::OK)) |
139 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 139 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
140 } | 140 } |
141 | 141 |
142 // Ensure that .Run() does not run unbounded if the callbacks are never | 142 // Ensure that .Run() does not run unbounded if the callbacks are never |
143 // called. | 143 // called. |
144 base::Timer shutdown_timer(false, false); | 144 base::Timer shutdown_timer(false, false); |
145 shutdown_timer.Start(FROM_HERE, | 145 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), |
146 TestTimeouts::action_timeout(), | 146 base::MessageLoop::QuitWhenIdleClosure()); |
147 base::MessageLoop::QuitClosure()); | |
148 message_loop_.Run(); | 147 message_loop_.Run(); |
149 shutdown_timer.Stop(); | 148 shutdown_timer.Stop(); |
150 | 149 |
151 testing::Mock::VerifyAndClearExpectations(&client_callback_); | 150 testing::Mock::VerifyAndClearExpectations(&client_callback_); |
152 testing::Mock::VerifyAndClearExpectations(&host_callback_); | 151 testing::Mock::VerifyAndClearExpectations(&host_callback_); |
153 | 152 |
154 if (!expected_fail) { | 153 if (!expected_fail) { |
155 ASSERT_TRUE(client_socket_.get() != nullptr); | 154 ASSERT_TRUE(client_socket_.get() != nullptr); |
156 ASSERT_TRUE(host_socket_.get() != nullptr); | 155 ASSERT_TRUE(host_socket_.get() != nullptr); |
157 } | 156 } |
158 } | 157 } |
159 | 158 |
160 void AuthenticatorTestBase::OnHostConnected( | 159 void AuthenticatorTestBase::OnHostConnected( |
161 int error, | 160 int error, |
162 scoped_ptr<P2PStreamSocket> socket) { | 161 scoped_ptr<P2PStreamSocket> socket) { |
163 host_callback_.OnDone(error); | 162 host_callback_.OnDone(error); |
164 host_socket_ = socket.Pass(); | 163 host_socket_ = socket.Pass(); |
165 } | 164 } |
166 | 165 |
167 void AuthenticatorTestBase::OnClientConnected( | 166 void AuthenticatorTestBase::OnClientConnected( |
168 int error, | 167 int error, |
169 scoped_ptr<P2PStreamSocket> socket) { | 168 scoped_ptr<P2PStreamSocket> socket) { |
170 client_callback_.OnDone(error); | 169 client_callback_.OnDone(error); |
171 client_socket_ = socket.Pass(); | 170 client_socket_ = socket.Pass(); |
172 } | 171 } |
173 | 172 |
174 } // namespace protocol | 173 } // namespace protocol |
175 } // namespace remoting | 174 } // namespace remoting |
OLD | NEW |