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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace remoting { | 24 namespace remoting { |
25 namespace protocol { | 25 namespace protocol { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 ACTION_P(QuitThreadOnCounter, counter) { | 29 ACTION_P(QuitThreadOnCounter, counter) { |
30 --(*counter); | 30 --(*counter); |
31 EXPECT_GE(*counter, 0); | 31 EXPECT_GE(*counter, 0); |
32 if (*counter == 0) | 32 if (*counter == 0) |
33 MessageLoop::current()->Quit(); | 33 base::MessageLoop::current()->Quit(); |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 AuthenticatorTestBase::MockChannelDoneCallback::MockChannelDoneCallback() {} | 38 AuthenticatorTestBase::MockChannelDoneCallback::MockChannelDoneCallback() {} |
39 | 39 |
40 AuthenticatorTestBase::MockChannelDoneCallback::~MockChannelDoneCallback() {} | 40 AuthenticatorTestBase::MockChannelDoneCallback::~MockChannelDoneCallback() {} |
41 | 41 |
42 AuthenticatorTestBase::AuthenticatorTestBase() {} | 42 AuthenticatorTestBase::AuthenticatorTestBase() {} |
43 | 43 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED)) | 112 EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED)) |
113 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 113 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
114 } else { | 114 } else { |
115 EXPECT_CALL(host_callback_, OnDone(net::OK)) | 115 EXPECT_CALL(host_callback_, OnDone(net::OK)) |
116 .WillOnce(QuitThreadOnCounter(&callback_counter)); | 116 .WillOnce(QuitThreadOnCounter(&callback_counter)); |
117 } | 117 } |
118 | 118 |
119 // Ensure that .Run() does not run unbounded if the callbacks are never | 119 // Ensure that .Run() does not run unbounded if the callbacks are never |
120 // called. | 120 // called. |
121 base::Timer shutdown_timer(false, false); | 121 base::Timer shutdown_timer(false, false); |
122 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), | 122 shutdown_timer.Start(FROM_HERE, |
123 MessageLoop::QuitClosure()); | 123 TestTimeouts::action_timeout(), |
| 124 base::MessageLoop::QuitClosure()); |
124 message_loop_.Run(); | 125 message_loop_.Run(); |
125 shutdown_timer.Stop(); | 126 shutdown_timer.Stop(); |
126 | 127 |
127 testing::Mock::VerifyAndClearExpectations(&client_callback_); | 128 testing::Mock::VerifyAndClearExpectations(&client_callback_); |
128 testing::Mock::VerifyAndClearExpectations(&host_callback_); | 129 testing::Mock::VerifyAndClearExpectations(&host_callback_); |
129 | 130 |
130 if (!expected_fail) { | 131 if (!expected_fail) { |
131 ASSERT_TRUE(client_socket_.get() != NULL); | 132 ASSERT_TRUE(client_socket_.get() != NULL); |
132 ASSERT_TRUE(host_socket_.get() != NULL); | 133 ASSERT_TRUE(host_socket_.get() != NULL); |
133 } | 134 } |
134 } | 135 } |
135 | 136 |
136 void AuthenticatorTestBase::OnHostConnected( | 137 void AuthenticatorTestBase::OnHostConnected( |
137 net::Error error, | 138 net::Error error, |
138 scoped_ptr<net::StreamSocket> socket) { | 139 scoped_ptr<net::StreamSocket> socket) { |
139 host_callback_.OnDone(error); | 140 host_callback_.OnDone(error); |
140 host_socket_ = socket.Pass(); | 141 host_socket_ = socket.Pass(); |
141 } | 142 } |
142 | 143 |
143 void AuthenticatorTestBase::OnClientConnected( | 144 void AuthenticatorTestBase::OnClientConnected( |
144 net::Error error, | 145 net::Error error, |
145 scoped_ptr<net::StreamSocket> socket) { | 146 scoped_ptr<net::StreamSocket> socket) { |
146 client_callback_.OnDone(error); | 147 client_callback_.OnDone(error); |
147 client_socket_ = socket.Pass(); | 148 client_socket_ = socket.Pass(); |
148 } | 149 } |
149 | 150 |
150 } // namespace protocol | 151 } // namespace protocol |
151 } // namespace remoting | 152 } // namespace remoting |
OLD | NEW |