OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/channel_socket_adapter.h" | 5 #include "remoting/protocol/channel_socket_adapter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/socket/socket.h" | 16 #include "net/socket/socket.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/webrtc/p2p/base/transportchannel.h" | 19 #include "third_party/webrtc/p2p/base/transportchannel.h" |
19 | 20 |
20 using net::IOBuffer; | 21 using net::IOBuffer; |
21 | 22 |
(...skipping 29 matching lines...) Expand all Loading... |
51 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers)); | 52 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers)); |
52 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher)); | 53 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher)); |
53 MOCK_METHOD1(GetSslCipher, bool(std::string* cipher)); | 54 MOCK_METHOD1(GetSslCipher, bool(std::string* cipher)); |
54 MOCK_CONST_METHOD0(GetLocalCertificate, | 55 MOCK_CONST_METHOD0(GetLocalCertificate, |
55 rtc::scoped_refptr<rtc::RTCCertificate>()); | 56 rtc::scoped_refptr<rtc::RTCCertificate>()); |
56 MOCK_CONST_METHOD1(GetRemoteSSLCertificate, | 57 MOCK_CONST_METHOD1(GetRemoteSSLCertificate, |
57 bool(rtc::SSLCertificate** cert)); | 58 bool(rtc::SSLCertificate** cert)); |
58 | 59 |
59 // This can't be a real mock method because gmock doesn't support move-only | 60 // This can't be a real mock method because gmock doesn't support move-only |
60 // return values. | 61 // return values. |
61 virtual rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() const { | 62 virtual rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() |
| 63 const { |
62 EXPECT_TRUE(false); // Never called. | 64 EXPECT_TRUE(false); // Never called. |
63 return nullptr; | 65 return nullptr; |
64 } | 66 } |
65 | 67 |
66 MOCK_METHOD6(ExportKeyingMaterial, | 68 MOCK_METHOD6(ExportKeyingMaterial, |
67 bool(const std::string& label, | 69 bool(const std::string& label, |
68 const uint8_t* context, | 70 const uint8_t* context, |
69 size_t context_len, | 71 size_t context_len, |
70 bool use_context, | 72 bool use_context, |
71 uint8_t* result, | 73 uint8_t* result, |
(...skipping 11 matching lines...) Expand all Loading... |
83 protected: | 85 protected: |
84 void SetUp() override { | 86 void SetUp() override { |
85 target_.reset(new TransportChannelSocketAdapter(&channel_)); | 87 target_.reset(new TransportChannelSocketAdapter(&channel_)); |
86 } | 88 } |
87 | 89 |
88 void Callback(int result) { | 90 void Callback(int result) { |
89 callback_result_ = result; | 91 callback_result_ = result; |
90 } | 92 } |
91 | 93 |
92 MockTransportChannel channel_; | 94 MockTransportChannel channel_; |
93 scoped_ptr<TransportChannelSocketAdapter> target_; | 95 std::unique_ptr<TransportChannelSocketAdapter> target_; |
94 net::CompletionCallback callback_; | 96 net::CompletionCallback callback_; |
95 int callback_result_; | 97 int callback_result_; |
96 base::MessageLoopForIO message_loop_; | 98 base::MessageLoopForIO message_loop_; |
97 }; | 99 }; |
98 | 100 |
99 // Verify that Read() returns net::ERR_IO_PENDING. | 101 // Verify that Read() returns net::ERR_IO_PENDING. |
100 TEST_F(TransportChannelSocketAdapterTest, Read) { | 102 TEST_F(TransportChannelSocketAdapterTest, Read) { |
101 scoped_refptr<IOBuffer> buffer(new IOBuffer(kBufferSize)); | 103 scoped_refptr<IOBuffer> buffer(new IOBuffer(kBufferSize)); |
102 | 104 |
103 int result = target_->Recv(buffer.get(), kBufferSize, callback_); | 105 int result = target_->Recv(buffer.get(), kBufferSize, callback_); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 146 |
145 EXPECT_CALL(channel_, GetError()) | 147 EXPECT_CALL(channel_, GetError()) |
146 .WillOnce(Return(EWOULDBLOCK)); | 148 .WillOnce(Return(EWOULDBLOCK)); |
147 | 149 |
148 int result = target_->Send(buffer.get(), kTestDataSize, callback_); | 150 int result = target_->Send(buffer.get(), kTestDataSize, callback_); |
149 ASSERT_EQ(net::OK, result); | 151 ASSERT_EQ(net::OK, result); |
150 } | 152 } |
151 | 153 |
152 } // namespace protocol | 154 } // namespace protocol |
153 } // namespace remoting | 155 } // namespace remoting |
OLD | NEW |