diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 11:23:51 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 11:23:51 +0000 |
commit | 86999474ab7a6f6a07f4c868e8be52414457c02f (patch) | |
tree | 1be5fe0eb7039695f57a99eecbc0151647a9252f /net/ftp/ftp_network_transaction_unittest.cc | |
parent | cd02b22af5e2cb7eeb5c977a3787c4d3d740a7e4 (diff) | |
download | chromium_src-86999474ab7a6f6a07f4c868e8be52414457c02f.zip chromium_src-86999474ab7a6f6a07f4c868e8be52414457c02f.tar.gz chromium_src-86999474ab7a6f6a07f4c868e8be52414457c02f.tar.bz2 |
Initialize IOBuffers in new FTP unit tests (issue detected by valgrind).
TEST=none
BUG=http://crbug.com/12409
Review URL: http://codereview.chromium.org/126120
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_network_transaction_unittest.cc')
-rw-r--r-- | net/ftp/ftp_network_transaction_unittest.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc index 77b8c6a..2044b1d 100644 --- a/net/ftp/ftp_network_transaction_unittest.cc +++ b/net/ftp/ftp_network_transaction_unittest.cc @@ -15,6 +15,13 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +namespace { + +// Size we use for IOBuffers used to receive data from the test data socket. +const int kBufferSize = 128; + +} // namespace + namespace net { class FtpMockControlSocket : public DynamicMockSocket { @@ -278,9 +285,10 @@ TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) { ASSERT_EQ(ERR_IO_PENDING, transaction_.Start(&request_info, &callback_)); EXPECT_EQ(OK, callback_.WaitForResult()); EXPECT_EQ(FtpMockControlSocket::QUIT, ctrl_socket.state()); - scoped_refptr<IOBuffer> io_buffer(new IOBuffer(128)); + scoped_refptr<IOBuffer> io_buffer(new IOBuffer(kBufferSize)); + memset(io_buffer->data(), 0, kBufferSize); EXPECT_EQ(ERR_IO_PENDING, - transaction_.Read(io_buffer.get(), 128, &callback_)); + transaction_.Read(io_buffer.get(), kBufferSize, &callback_)); EXPECT_EQ(static_cast<int>(test_string.length()), callback_.WaitForResult()); EXPECT_EQ(test_string, std::string(io_buffer->data(), test_string.length())); } @@ -298,9 +306,10 @@ TEST_F(FtpNetworkTransactionTest, DownloadTransaction) { ASSERT_EQ(ERR_IO_PENDING, transaction_.Start(&request_info, &callback_)); EXPECT_EQ(OK, callback_.WaitForResult()); EXPECT_EQ(FtpMockControlSocket::QUIT, ctrl_socket.state()); - scoped_refptr<IOBuffer> io_buffer(new IOBuffer(128)); + scoped_refptr<IOBuffer> io_buffer(new IOBuffer(kBufferSize)); + memset(io_buffer->data(), 0, kBufferSize); EXPECT_EQ(ERR_IO_PENDING, - transaction_.Read(io_buffer.get(), 128, &callback_)); + transaction_.Read(io_buffer.get(), kBufferSize, &callback_)); EXPECT_EQ(static_cast<int>(test_string.length()), callback_.WaitForResult()); EXPECT_EQ(test_string, std::string(io_buffer->data(), test_string.length())); } |