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

Side by Side Diff: jingle/glue/channel_socket_adapter_unittest.cc

Issue 167893002: Roll webrtc to r5549. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 | « jingle/glue/channel_socket_adapter.cc ('k') | jingle/glue/fake_socket_factory.h » ('j') | 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "jingle/glue/channel_socket_adapter.h" 8 #include "jingle/glue/channel_socket_adapter.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 18 matching lines...) Expand all
29 29
30 class MockTransportChannel : public cricket::TransportChannel { 30 class MockTransportChannel : public cricket::TransportChannel {
31 public: 31 public:
32 MockTransportChannel() : cricket::TransportChannel(std::string(), 0) { 32 MockTransportChannel() : cricket::TransportChannel(std::string(), 0) {
33 set_writable(true); 33 set_writable(true);
34 set_readable(true); 34 set_readable(true);
35 } 35 }
36 36
37 MOCK_METHOD4(SendPacket, int(const char* data, 37 MOCK_METHOD4(SendPacket, int(const char* data,
38 size_t len, 38 size_t len,
39 talk_base::DiffServCodePoint dscp, 39 const talk_base::PacketOptions& options,
40 int flags)); 40 int flags));
41 MOCK_METHOD2(SetOption, int(talk_base::Socket::Option opt, int value)); 41 MOCK_METHOD2(SetOption, int(talk_base::Socket::Option opt, int value));
42 MOCK_METHOD0(GetError, int()); 42 MOCK_METHOD0(GetError, int());
43 MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole()); 43 MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole());
44 MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos)); 44 MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos));
45 MOCK_CONST_METHOD0(IsDtlsActive, bool()); 45 MOCK_CONST_METHOD0(IsDtlsActive, bool());
46 MOCK_CONST_METHOD1(GetSslRole, bool(talk_base::SSLRole* role)); 46 MOCK_CONST_METHOD1(GetSslRole, bool(talk_base::SSLRole* role));
47 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers)); 47 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers));
48 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher)); 48 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher));
49 MOCK_CONST_METHOD1(GetLocalIdentity, bool(talk_base::SSLIdentity** identity)); 49 MOCK_CONST_METHOD1(GetLocalIdentity, bool(talk_base::SSLIdentity** identity));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 EXPECT_EQ(kTestError, callback_result_); 104 EXPECT_EQ(kTestError, callback_result_);
105 105
106 // All Read() calls after Close() should return the error. 106 // All Read() calls after Close() should return the error.
107 EXPECT_EQ(kTestError, target_->Read(buffer.get(), kBufferSize, callback_)); 107 EXPECT_EQ(kTestError, target_->Read(buffer.get(), kBufferSize, callback_));
108 } 108 }
109 109
110 // Verify that Write sends the packet and returns correct result. 110 // Verify that Write sends the packet and returns correct result.
111 TEST_F(TransportChannelSocketAdapterTest, Write) { 111 TEST_F(TransportChannelSocketAdapterTest, Write) {
112 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize)); 112 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize));
113 113
114 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize, 114 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize, _, 0))
115 talk_base::DSCP_NO_CHANGE, 0))
116 .WillOnce(Return(kTestDataSize)); 115 .WillOnce(Return(kTestDataSize));
117 116
118 int result = target_->Write(buffer.get(), kTestDataSize, callback_); 117 int result = target_->Write(buffer.get(), kTestDataSize, callback_);
119 EXPECT_EQ(kTestDataSize, result); 118 EXPECT_EQ(kTestDataSize, result);
120 } 119 }
121 120
122 // Verify that the message is still sent if Write() is called while 121 // Verify that the message is still sent if Write() is called while
123 // socket is not open yet. The result is the packet is lost. 122 // socket is not open yet. The result is the packet is lost.
124 TEST_F(TransportChannelSocketAdapterTest, WritePending) { 123 TEST_F(TransportChannelSocketAdapterTest, WritePending) {
125 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize)); 124 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize));
126 125
127 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize, 126 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize, _, 0))
128 talk_base::DSCP_NO_CHANGE, 0))
129 .Times(1) 127 .Times(1)
130 .WillOnce(Return(SOCKET_ERROR)); 128 .WillOnce(Return(SOCKET_ERROR));
131 129
132 EXPECT_CALL(channel_, GetError()) 130 EXPECT_CALL(channel_, GetError())
133 .WillOnce(Return(EWOULDBLOCK)); 131 .WillOnce(Return(EWOULDBLOCK));
134 132
135 int result = target_->Write(buffer.get(), kTestDataSize, callback_); 133 int result = target_->Write(buffer.get(), kTestDataSize, callback_);
136 ASSERT_EQ(net::OK, result); 134 ASSERT_EQ(net::OK, result);
137 } 135 }
138 136
139 } // namespace jingle_glue 137 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « jingle/glue/channel_socket_adapter.cc ('k') | jingle/glue/fake_socket_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698