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

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

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | « ipc/ipc_channel_posix_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/file_stream.h" 5 #include "net/base/file_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 26 matching lines...) Expand all
37 37
38 class FileStreamTest : public PlatformTest { 38 class FileStreamTest : public PlatformTest {
39 public: 39 public:
40 virtual void SetUp() { 40 virtual void SetUp() {
41 PlatformTest::SetUp(); 41 PlatformTest::SetUp();
42 42
43 file_util::CreateTemporaryFile(&temp_file_path_); 43 file_util::CreateTemporaryFile(&temp_file_path_);
44 file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize); 44 file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize);
45 } 45 }
46 virtual void TearDown() { 46 virtual void TearDown() {
47 EXPECT_TRUE(file_util::Delete(temp_file_path_, false)); 47 EXPECT_TRUE(base::Delete(temp_file_path_, false));
48 48
49 PlatformTest::TearDown(); 49 PlatformTest::TearDown();
50 } 50 }
51 51
52 const base::FilePath temp_file_path() const { return temp_file_path_; } 52 const base::FilePath temp_file_path() const { return temp_file_path_; }
53 53
54 private: 54 private:
55 base::FilePath temp_file_path_; 55 base::FilePath temp_file_path_;
56 }; 56 };
57 57
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ASSERT_EQ(0, read_stream->SeekSync(FROM_BEGIN, 0)); 109 ASSERT_EQ(0, read_stream->SeekSync(FROM_BEGIN, 0));
110 ASSERT_EQ(kTestDataSize, read_stream->Available()); 110 ASSERT_EQ(kTestDataSize, read_stream->Available());
111 // Read into buffer and compare. 111 // Read into buffer and compare.
112 char buffer[kTestDataSize]; 112 char buffer[kTestDataSize];
113 ASSERT_EQ(kTestDataSize, 113 ASSERT_EQ(kTestDataSize,
114 read_stream->ReadSync(buffer, kTestDataSize)); 114 read_stream->ReadSync(buffer, kTestDataSize));
115 ASSERT_EQ(0, memcmp(kTestData, buffer, kTestDataSize)); 115 ASSERT_EQ(0, memcmp(kTestData, buffer, kTestDataSize));
116 read_stream.reset(); 116 read_stream.reset();
117 117
118 // 2. Test writing with a file handle. 118 // 2. Test writing with a file handle.
119 file_util::Delete(temp_file_path(), false); 119 base::Delete(temp_file_path(), false);
120 flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE; 120 flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE;
121 file = base::CreatePlatformFile(temp_file_path(), flags, &created, NULL); 121 file = base::CreatePlatformFile(temp_file_path(), flags, &created, NULL);
122 122
123 scoped_ptr<FileStream> write_stream(new FileStream(file, flags, NULL)); 123 scoped_ptr<FileStream> write_stream(new FileStream(file, flags, NULL));
124 ASSERT_EQ(0, write_stream->SeekSync(FROM_BEGIN, 0)); 124 ASSERT_EQ(0, write_stream->SeekSync(FROM_BEGIN, 0));
125 ASSERT_EQ(kTestDataSize, 125 ASSERT_EQ(kTestDataSize,
126 write_stream->WriteSync(kTestData, kTestDataSize)); 126 write_stream->WriteSync(kTestData, kTestDataSize));
127 write_stream.reset(); 127 write_stream.reset();
128 128
129 // Read into buffer and compare to make sure the handle worked fine. 129 // Read into buffer and compare to make sure the handle worked fine.
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 scoped_refptr<IOBuffer> buf = new WrappedIOBuffer(NULL); 1073 scoped_refptr<IOBuffer> buf = new WrappedIOBuffer(NULL);
1074 rv = stream->Read(buf.get(), 1, callback.callback()); 1074 rv = stream->Read(buf.get(), 1, callback.callback());
1075 if (rv == ERR_IO_PENDING) 1075 if (rv == ERR_IO_PENDING)
1076 rv = callback.WaitForResult(); 1076 rv = callback.WaitForResult();
1077 EXPECT_LT(rv, 0); 1077 EXPECT_LT(rv, 0);
1078 } 1078 }
1079 1079
1080 } // namespace 1080 } // namespace
1081 1081
1082 } // namespace net 1082 } // namespace net
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix_unittest.cc ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698