OLD | NEW |
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.h" | 7 #include "base/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 void Callback(int result) { | 57 void Callback(int result) { |
58 callback_result_ = result; | 58 callback_result_ = result; |
59 } | 59 } |
60 | 60 |
61 MockTransportChannel channel_; | 61 MockTransportChannel channel_; |
62 scoped_ptr<TransportChannelSocketAdapter> target_; | 62 scoped_ptr<TransportChannelSocketAdapter> target_; |
63 net::CompletionCallback callback_; | 63 net::CompletionCallback callback_; |
64 int callback_result_; | 64 int callback_result_; |
65 MessageLoopForIO message_loop_; | 65 base::MessageLoopForIO message_loop_; |
66 }; | 66 }; |
67 | 67 |
68 // Verify that Read() returns net::ERR_IO_PENDING. | 68 // Verify that Read() returns net::ERR_IO_PENDING. |
69 TEST_F(TransportChannelSocketAdapterTest, Read) { | 69 TEST_F(TransportChannelSocketAdapterTest, Read) { |
70 scoped_refptr<IOBuffer> buffer(new IOBuffer(kBufferSize)); | 70 scoped_refptr<IOBuffer> buffer(new IOBuffer(kBufferSize)); |
71 | 71 |
72 int result = target_->Read(buffer, kBufferSize, callback_); | 72 int result = target_->Read(buffer, kBufferSize, callback_); |
73 ASSERT_EQ(net::ERR_IO_PENDING, result); | 73 ASSERT_EQ(net::ERR_IO_PENDING, result); |
74 | 74 |
75 channel_.SignalReadPacket(&channel_, kTestData, kTestDataSize, 0); | 75 channel_.SignalReadPacket(&channel_, kTestData, kTestDataSize, 0); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 .WillOnce(Return(SOCKET_ERROR)); | 111 .WillOnce(Return(SOCKET_ERROR)); |
112 | 112 |
113 EXPECT_CALL(channel_, GetError()) | 113 EXPECT_CALL(channel_, GetError()) |
114 .WillOnce(Return(EWOULDBLOCK)); | 114 .WillOnce(Return(EWOULDBLOCK)); |
115 | 115 |
116 int result = target_->Write(buffer, kTestDataSize, callback_); | 116 int result = target_->Write(buffer, kTestDataSize, callback_); |
117 ASSERT_EQ(net::OK, result); | 117 ASSERT_EQ(net::OK, result); |
118 } | 118 } |
119 | 119 |
120 } // namespace jingle_glue | 120 } // namespace jingle_glue |
OLD | NEW |