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

Side by Side Diff: net/socket/deterministic_socket_data_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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
OLDNEW
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 "net/socket/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include "testing/platform_test.h" 7 #include "testing/platform_test.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 //----------------------------------------------------------------------------- 10 //-----------------------------------------------------------------------------
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ASSERT_EQ(rv, sock_->Read(read_buf_, len, &read_callback_)); 124 ASSERT_EQ(rv, sock_->Read(read_buf_, len, &read_callback_));
125 } 125 }
126 126
127 void DeterministicSocketDataTest::AssertReadBufferEquals(const char* data, 127 void DeterministicSocketDataTest::AssertReadBufferEquals(const char* data,
128 int len) { 128 int len) {
129 ASSERT_EQ(std::string(data, len), std::string(read_buf_->data(), len)); 129 ASSERT_EQ(std::string(data, len), std::string(read_buf_->data(), len));
130 } 130 }
131 131
132 void DeterministicSocketDataTest::AssertSyncWriteEquals(const char* data, 132 void DeterministicSocketDataTest::AssertSyncWriteEquals(const char* data,
133 int len) { 133 int len) {
134 scoped_refptr<IOBuffer> buf = new IOBuffer(len); 134 scoped_refptr<IOBuffer> buf(new IOBuffer(len));
135 memcpy(buf->data(), data, len); 135 memcpy(buf->data(), data, len);
136 136
137 // Issue the write, which will complete immediately 137 // Issue the write, which will complete immediately
138 ASSERT_EQ(len, sock_->Write(buf, len, &write_callback_)); 138 ASSERT_EQ(len, sock_->Write(buf, len, &write_callback_));
139 } 139 }
140 140
141 void DeterministicSocketDataTest::AssertAsyncWriteEquals(const char* data, 141 void DeterministicSocketDataTest::AssertAsyncWriteEquals(const char* data,
142 int len) { 142 int len) {
143 // Issue the read, which will be completed asynchronously 143 // Issue the read, which will be completed asynchronously
144 AssertWriteReturns(data, len, ERR_IO_PENDING); 144 AssertWriteReturns(data, len, ERR_IO_PENDING);
145 145
146 EXPECT_FALSE(read_callback_.have_result()); 146 EXPECT_FALSE(read_callback_.have_result());
147 EXPECT_TRUE(sock_->IsConnected()); 147 EXPECT_TRUE(sock_->IsConnected());
148 data_->RunFor(1); // Runs 1 step, to cause the callbacks to be invoked 148 data_->RunFor(1); // Runs 1 step, to cause the callbacks to be invoked
149 149
150 ASSERT_EQ(len, write_callback_.WaitForResult()); 150 ASSERT_EQ(len, write_callback_.WaitForResult());
151 } 151 }
152 152
153 void DeterministicSocketDataTest::AssertWriteReturns(const char* data, 153 void DeterministicSocketDataTest::AssertWriteReturns(const char* data,
154 int len, int rv) { 154 int len, int rv) {
155 scoped_refptr<IOBuffer> buf = new IOBuffer(len); 155 scoped_refptr<IOBuffer> buf(new IOBuffer(len));
156 memcpy(buf->data(), data, len); 156 memcpy(buf->data(), data, len);
157 157
158 // Issue the read, which will complete asynchronously 158 // Issue the read, which will complete asynchronously
159 ASSERT_EQ(rv, sock_->Write(buf, len, &write_callback_)); 159 ASSERT_EQ(rv, sock_->Write(buf, len, &write_callback_));
160 } 160 }
161 161
162 // ----------- Read 162 // ----------- Read
163 163
164 TEST_F(DeterministicSocketDataTest, SingleSyncReadWhileStopped) { 164 TEST_F(DeterministicSocketDataTest, SingleSyncReadWhileStopped) {
165 MockRead reads[] = { 165 MockRead reads[] = {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // Issue the writes which will complete immediately 521 // Issue the writes which will complete immediately
522 data_->StopAfter(1); 522 data_->StopAfter(1);
523 AssertSyncWriteEquals(kMsg3, kLen3); 523 AssertSyncWriteEquals(kMsg3, kLen3);
524 524
525 data_->RunFor(1); 525 data_->RunFor(1);
526 ASSERT_EQ(kLen2, read_callback_.WaitForResult()); 526 ASSERT_EQ(kLen2, read_callback_.WaitForResult());
527 AssertReadBufferEquals(kMsg2, kLen2); 527 AssertReadBufferEquals(kMsg2, kLen2);
528 } 528 }
529 529
530 } // namespace net 530 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base_unittest.cc ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698