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

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

Issue 24364005: Update webrtc to r4819. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 16 matching lines...) Expand all
27 const int kTestError = -32123; 27 const int kTestError = -32123;
28 } // namespace 28 } // namespace
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_METHOD3(SendPacket, int(const char* data, size_t len, int flags)); 37 MOCK_METHOD4(SendPacket, int(const char* data,
38 size_t len,
39 talk_base::DiffServCodePoint dscp,
40 int flags));
38 MOCK_METHOD2(SetOption, int(talk_base::Socket::Option opt, int value)); 41 MOCK_METHOD2(SetOption, int(talk_base::Socket::Option opt, int value));
39 MOCK_METHOD0(GetError, int()); 42 MOCK_METHOD0(GetError, int());
40 MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole()); 43 MOCK_CONST_METHOD0(GetIceRole, cricket::IceRole());
41 MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos)); 44 MOCK_METHOD1(GetStats, bool(cricket::ConnectionInfos* infos));
42 MOCK_CONST_METHOD0(IsDtlsActive, bool()); 45 MOCK_CONST_METHOD0(IsDtlsActive, bool());
43 MOCK_CONST_METHOD1(GetSslRole, bool(talk_base::SSLRole* role)); 46 MOCK_CONST_METHOD1(GetSslRole, bool(talk_base::SSLRole* role));
44 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers)); 47 MOCK_METHOD1(SetSrtpCiphers, bool(const std::vector<std::string>& ciphers));
45 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher)); 48 MOCK_METHOD1(GetSrtpCipher, bool(std::string* cipher));
46 MOCK_METHOD6(ExportKeyingMaterial, bool(const std::string& label, 49 MOCK_METHOD6(ExportKeyingMaterial, bool(const std::string& label,
47 const uint8* context, 50 const uint8* context,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 EXPECT_EQ(kTestError, callback_result_); 100 EXPECT_EQ(kTestError, callback_result_);
98 101
99 // All Read() calls after Close() should return the error. 102 // All Read() calls after Close() should return the error.
100 EXPECT_EQ(kTestError, target_->Read(buffer.get(), kBufferSize, callback_)); 103 EXPECT_EQ(kTestError, target_->Read(buffer.get(), kBufferSize, callback_));
101 } 104 }
102 105
103 // Verify that Write sends the packet and returns correct result. 106 // Verify that Write sends the packet and returns correct result.
104 TEST_F(TransportChannelSocketAdapterTest, Write) { 107 TEST_F(TransportChannelSocketAdapterTest, Write) {
105 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize)); 108 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize));
106 109
107 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize, 0)) 110 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize,
111 talk_base::DSCP_NO_CHANGE, 0))
108 .WillOnce(Return(kTestDataSize)); 112 .WillOnce(Return(kTestDataSize));
109 113
110 int result = target_->Write(buffer.get(), kTestDataSize, callback_); 114 int result = target_->Write(buffer.get(), kTestDataSize, callback_);
111 EXPECT_EQ(kTestDataSize, result); 115 EXPECT_EQ(kTestDataSize, result);
112 } 116 }
113 117
114 // Verify that the message is still sent if Write() is called while 118 // Verify that the message is still sent if Write() is called while
115 // socket is not open yet. The result is the packet is lost. 119 // socket is not open yet. The result is the packet is lost.
116 TEST_F(TransportChannelSocketAdapterTest, WritePending) { 120 TEST_F(TransportChannelSocketAdapterTest, WritePending) {
117 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize)); 121 scoped_refptr<IOBuffer> buffer(new IOBuffer(kTestDataSize));
118 122
119 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize, 0)) 123 EXPECT_CALL(channel_, SendPacket(buffer->data(), kTestDataSize,
124 talk_base::DSCP_NO_CHANGE, 0))
120 .Times(1) 125 .Times(1)
121 .WillOnce(Return(SOCKET_ERROR)); 126 .WillOnce(Return(SOCKET_ERROR));
122 127
123 EXPECT_CALL(channel_, GetError()) 128 EXPECT_CALL(channel_, GetError())
124 .WillOnce(Return(EWOULDBLOCK)); 129 .WillOnce(Return(EWOULDBLOCK));
125 130
126 int result = target_->Write(buffer.get(), kTestDataSize, callback_); 131 int result = target_->Write(buffer.get(), kTestDataSize, callback_);
127 ASSERT_EQ(net::OK, result); 132 ASSERT_EQ(net::OK, result);
128 } 133 }
129 134
130 } // namespace jingle_glue 135 } // 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