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

Side by Side Diff: net/base/upload_file_element_reader_unittest.cc

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « net/base/upload_data_stream_unittest.cc ('k') | net/disk_cache/backend_unittest.cc » ('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 "net/base/upload_file_element_reader.h" 5 #include "net/base/upload_file_element_reader.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.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"
11 #include "net/base/test_completion_callback.h" 11 #include "net/base/test_completion_callback.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 class UploadFileElementReaderTest : public PlatformTest { 17 class UploadFileElementReaderTest : public PlatformTest {
18 protected: 18 protected:
(...skipping 13 matching lines...) Expand all
32 reader_.reset(new UploadFileElementReader( 32 reader_.reset(new UploadFileElementReader(
33 temp_file_path_, 0, kuint64max, base::Time())); 33 temp_file_path_, 0, kuint64max, base::Time()));
34 ASSERT_EQ(OK, reader_->InitSync()); 34 ASSERT_EQ(OK, reader_->InitSync());
35 EXPECT_EQ(bytes_.size(), reader_->GetContentLength()); 35 EXPECT_EQ(bytes_.size(), reader_->GetContentLength());
36 EXPECT_EQ(bytes_.size(), reader_->BytesRemaining()); 36 EXPECT_EQ(bytes_.size(), reader_->BytesRemaining());
37 EXPECT_FALSE(reader_->IsInMemory()); 37 EXPECT_FALSE(reader_->IsInMemory());
38 } 38 }
39 39
40 std::vector<char> bytes_; 40 std::vector<char> bytes_;
41 scoped_ptr<UploadElementReader> reader_; 41 scoped_ptr<UploadElementReader> reader_;
42 ScopedTempDir temp_dir_; 42 base::ScopedTempDir temp_dir_;
43 FilePath temp_file_path_; 43 FilePath temp_file_path_;
44 }; 44 };
45 45
46 TEST_F(UploadFileElementReaderTest, ReadPartially) { 46 TEST_F(UploadFileElementReaderTest, ReadPartially) {
47 const size_t kHalfSize = bytes_.size() / 2; 47 const size_t kHalfSize = bytes_.size() / 2;
48 ASSERT_EQ(bytes_.size(), kHalfSize * 2); 48 ASSERT_EQ(bytes_.size(), kHalfSize * 2);
49 std::vector<char> buf(kHalfSize); 49 std::vector<char> buf(kHalfSize);
50 scoped_refptr<IOBuffer> wrapped_buffer = new WrappedIOBuffer(&buf[0]); 50 scoped_refptr<IOBuffer> wrapped_buffer = new WrappedIOBuffer(&buf[0]);
51 EXPECT_EQ(static_cast<int>(buf.size()), 51 EXPECT_EQ(static_cast<int>(buf.size()),
52 reader_->ReadSync(wrapped_buffer, buf.size())); 52 reader_->ReadSync(wrapped_buffer, buf.size()));
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 TEST_F(UploadFileElementReaderTest, WrongPath) { 251 TEST_F(UploadFileElementReaderTest, WrongPath) {
252 const FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); 252 const FilePath wrong_path(FILE_PATH_LITERAL("wrong_path"));
253 reader_.reset(new UploadFileElementReader( 253 reader_.reset(new UploadFileElementReader(
254 wrong_path, 0, kuint64max, base::Time())); 254 wrong_path, 0, kuint64max, base::Time()));
255 ASSERT_EQ(OK, reader_->InitSync()); 255 ASSERT_EQ(OK, reader_->InitSync());
256 EXPECT_EQ(0U, reader_->GetContentLength()); 256 EXPECT_EQ(0U, reader_->GetContentLength());
257 EXPECT_EQ(0U, reader_->BytesRemaining()); 257 EXPECT_EQ(0U, reader_->BytesRemaining());
258 } 258 }
259 259
260 } // namespace net 260 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_data_stream_unittest.cc ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698