Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc

Issue 14314026: remoting: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/message_reader_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ssl_hmac_channel_authenticator.h" 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 25 matching lines...) Expand all
36 36
37 class MockChannelDoneCallback { 37 class MockChannelDoneCallback {
38 public: 38 public:
39 MOCK_METHOD2(OnDone, void(net::Error error, net::StreamSocket* socket)); 39 MOCK_METHOD2(OnDone, void(net::Error error, net::StreamSocket* socket));
40 }; 40 };
41 41
42 ACTION_P(QuitThreadOnCounter, counter) { 42 ACTION_P(QuitThreadOnCounter, counter) {
43 --(*counter); 43 --(*counter);
44 EXPECT_GE(*counter, 0); 44 EXPECT_GE(*counter, 0);
45 if (*counter == 0) 45 if (*counter == 0)
46 MessageLoop::current()->Quit(); 46 base::MessageLoop::current()->Quit();
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 class SslHmacChannelAuthenticatorTest : public testing::Test { 51 class SslHmacChannelAuthenticatorTest : public testing::Test {
52 public: 52 public:
53 SslHmacChannelAuthenticatorTest() {} 53 SslHmacChannelAuthenticatorTest() {}
54 virtual ~SslHmacChannelAuthenticatorTest() {} 54 virtual ~SslHmacChannelAuthenticatorTest() {}
55 55
56 protected: 56 protected:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } else { 96 } else {
97 EXPECT_CALL(client_callback_, OnDone(net::OK, NotNull())) 97 EXPECT_CALL(client_callback_, OnDone(net::OK, NotNull()))
98 .WillOnce(QuitThreadOnCounter(&callback_counter)); 98 .WillOnce(QuitThreadOnCounter(&callback_counter));
99 EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull())) 99 EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull()))
100 .WillOnce(QuitThreadOnCounter(&callback_counter)); 100 .WillOnce(QuitThreadOnCounter(&callback_counter));
101 } 101 }
102 102
103 // Ensure that .Run() does not run unbounded if the callbacks are never 103 // Ensure that .Run() does not run unbounded if the callbacks are never
104 // called. 104 // called.
105 base::Timer shutdown_timer(false, false); 105 base::Timer shutdown_timer(false, false);
106 shutdown_timer.Start(FROM_HERE, TestTimeouts::action_timeout(), 106 shutdown_timer.Start(FROM_HERE,
107 MessageLoop::QuitClosure()); 107 TestTimeouts::action_timeout(),
108 base::MessageLoop::QuitClosure());
108 message_loop_.Run(); 109 message_loop_.Run();
109 } 110 }
110 111
111 void OnHostConnected(net::Error error, 112 void OnHostConnected(net::Error error,
112 scoped_ptr<net::StreamSocket> socket) { 113 scoped_ptr<net::StreamSocket> socket) {
113 host_callback_.OnDone(error, socket.get()); 114 host_callback_.OnDone(error, socket.get());
114 host_socket_ = socket.Pass(); 115 host_socket_ = socket.Pass();
115 } 116 }
116 117
117 void OnClientConnected(net::Error error, 118 void OnClientConnected(net::Error error,
118 scoped_ptr<net::StreamSocket> socket) { 119 scoped_ptr<net::StreamSocket> socket) {
119 client_callback_.OnDone(error, socket.get()); 120 client_callback_.OnDone(error, socket.get());
120 client_socket_ = socket.Pass(); 121 client_socket_ = socket.Pass();
121 } 122 }
122 123
123 MessageLoop message_loop_; 124 base::MessageLoop message_loop_;
124 125
125 scoped_refptr<RsaKeyPair> key_pair_; 126 scoped_refptr<RsaKeyPair> key_pair_;
126 std::string host_cert_; 127 std::string host_cert_;
127 scoped_ptr<FakeSocket> client_fake_socket_; 128 scoped_ptr<FakeSocket> client_fake_socket_;
128 scoped_ptr<FakeSocket> host_fake_socket_; 129 scoped_ptr<FakeSocket> host_fake_socket_;
129 scoped_ptr<ChannelAuthenticator> client_auth_; 130 scoped_ptr<ChannelAuthenticator> client_auth_;
130 scoped_ptr<ChannelAuthenticator> host_auth_; 131 scoped_ptr<ChannelAuthenticator> host_auth_;
131 MockChannelDoneCallback client_callback_; 132 MockChannelDoneCallback client_callback_;
132 MockChannelDoneCallback host_callback_; 133 MockChannelDoneCallback host_callback_;
133 scoped_ptr<net::StreamSocket> client_socket_; 134 scoped_ptr<net::StreamSocket> client_socket_;
(...skipping 29 matching lines...) Expand all
163 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( 164 host_auth_ = SslHmacChannelAuthenticator::CreateForHost(
164 host_cert_, key_pair_, kTestSharedSecret); 165 host_cert_, key_pair_, kTestSharedSecret);
165 166
166 RunChannelAuth(true); 167 RunChannelAuth(true);
167 168
168 ASSERT_TRUE(host_socket_.get() == NULL); 169 ASSERT_TRUE(host_socket_.get() == NULL);
169 } 170 }
170 171
171 } // namespace protocol 172 } // namespace protocol
172 } // namespace remoting 173 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/message_reader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698