| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "jingle/notifier/base/chrome_async_socket.h" | 5 #include "jingle/notifier/base/chrome_async_socket.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "net/base/capturing_net_log.h" |
| 15 #include "net/base/cert_verifier.h" |
| 16 #include "net/base/net_errors.h" |
| 14 #include "net/base/ssl_config_service.h" | 17 #include "net/base/ssl_config_service.h" |
| 15 #include "net/base/capturing_net_log.h" | |
| 16 #include "net/base/net_errors.h" | |
| 17 #include "net/socket/socket_test_util.h" | 18 #include "net/socket/socket_test_util.h" |
| 18 #include "talk/base/sigslot.h" | 19 #include "talk/base/sigslot.h" |
| 19 #include "talk/base/socketaddress.h" | 20 #include "talk/base/socketaddress.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 namespace notifier { | 23 namespace notifier { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Data provider that handles reads/writes for ChromeAsyncSocket. | 27 // Data provider that handles reads/writes for ChromeAsyncSocket. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 virtual void SetUp() { | 109 virtual void SetUp() { |
| 109 scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory( | 110 scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory( |
| 110 new net::MockClientSocketFactory()); | 111 new net::MockClientSocketFactory()); |
| 111 mock_client_socket_factory->AddSocketDataProvider( | 112 mock_client_socket_factory->AddSocketDataProvider( |
| 112 &async_socket_data_provider_); | 113 &async_socket_data_provider_); |
| 113 mock_client_socket_factory->AddSSLSocketDataProvider( | 114 mock_client_socket_factory->AddSSLSocketDataProvider( |
| 114 &ssl_socket_data_provider_); | 115 &ssl_socket_data_provider_); |
| 115 | 116 |
| 116 chrome_async_socket_.reset( | 117 chrome_async_socket_.reset( |
| 117 new ChromeAsyncSocket(mock_client_socket_factory.release(), | 118 new ChromeAsyncSocket(mock_client_socket_factory.release(), |
| 118 ssl_config_, 14, 20, &capturing_net_log_)), | 119 ssl_config_, &cert_verifier_, 14, 20, |
| 120 &capturing_net_log_)), |
| 119 | 121 |
| 120 chrome_async_socket_->SignalConnected.connect( | 122 chrome_async_socket_->SignalConnected.connect( |
| 121 this, &ChromeAsyncSocketTest::OnConnect); | 123 this, &ChromeAsyncSocketTest::OnConnect); |
| 122 chrome_async_socket_->SignalSSLConnected.connect( | 124 chrome_async_socket_->SignalSSLConnected.connect( |
| 123 this, &ChromeAsyncSocketTest::OnSSLConnect); | 125 this, &ChromeAsyncSocketTest::OnSSLConnect); |
| 124 chrome_async_socket_->SignalClosed.connect( | 126 chrome_async_socket_->SignalClosed.connect( |
| 125 this, &ChromeAsyncSocketTest::OnClose); | 127 this, &ChromeAsyncSocketTest::OnClose); |
| 126 chrome_async_socket_->SignalRead.connect( | 128 chrome_async_socket_->SignalRead.connect( |
| 127 this, &ChromeAsyncSocketTest::OnRead); | 129 this, &ChromeAsyncSocketTest::OnRead); |
| 128 chrome_async_socket_->SignalError.connect( | 130 chrome_async_socket_->SignalError.connect( |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 366 } |
| 365 | 367 |
| 366 // ChromeAsyncSocket expects a message loop. | 368 // ChromeAsyncSocket expects a message loop. |
| 367 MessageLoop message_loop_; | 369 MessageLoop message_loop_; |
| 368 | 370 |
| 369 AsyncSocketDataProvider async_socket_data_provider_; | 371 AsyncSocketDataProvider async_socket_data_provider_; |
| 370 net::SSLSocketDataProvider ssl_socket_data_provider_; | 372 net::SSLSocketDataProvider ssl_socket_data_provider_; |
| 371 | 373 |
| 372 net::CapturingNetLog capturing_net_log_; | 374 net::CapturingNetLog capturing_net_log_; |
| 373 net::SSLConfig ssl_config_; | 375 net::SSLConfig ssl_config_; |
| 376 net::CertVerifier cert_verifier_; |
| 374 scoped_ptr<ChromeAsyncSocket> chrome_async_socket_; | 377 scoped_ptr<ChromeAsyncSocket> chrome_async_socket_; |
| 375 std::deque<SignalSocketState> signal_socket_states_; | 378 std::deque<SignalSocketState> signal_socket_states_; |
| 376 const talk_base::SocketAddress addr_; | 379 const talk_base::SocketAddress addr_; |
| 377 | 380 |
| 378 private: | 381 private: |
| 379 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocketTest); | 382 DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocketTest); |
| 380 }; | 383 }; |
| 381 | 384 |
| 382 TEST_F(ChromeAsyncSocketTest, InitialState) { | 385 TEST_F(ChromeAsyncSocketTest, InitialState) { |
| 383 ExpectClosed(); | 386 ExpectClosed(); |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 message_loop_.RunAllPending(); | 1014 message_loop_.RunAllPending(); |
| 1012 | 1015 |
| 1013 ExpectNoSignal(); | 1016 ExpectNoSignal(); |
| 1014 | 1017 |
| 1015 DoSSLCloseOpenedNoError(); | 1018 DoSSLCloseOpenedNoError(); |
| 1016 } | 1019 } |
| 1017 | 1020 |
| 1018 } // namespace | 1021 } // namespace |
| 1019 | 1022 |
| 1020 } // namespace notifier | 1023 } // namespace notifier |
| OLD | NEW |