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

Side by Side Diff: webkit/browser/blob/local_file_stream_reader_unittest.cc

Issue 167403002: Remove some PlatformFile uses from WebKit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « no previous file | webkit/browser/database/database_tracker.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 "webkit/browser/blob/local_file_stream_reader.h" 5 #include "webkit/browser/blob/local_file_stream_reader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/platform_file.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/test_completion_callback.h" 18 #include "net/base/test_completion_callback.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace webkit_blob { 21 namespace webkit_blob {
22 22
23 namespace { 23 namespace {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 CreateFileReader(nonexistent_path, 0, base::Time())); 128 CreateFileReader(nonexistent_path, 0, base::Time()));
129 int result = 0; 129 int result = 0;
130 std::string data; 130 std::string data;
131 ReadFromReader(reader.get(), &data, 10, &result); 131 ReadFromReader(reader.get(), &data, 10, &result);
132 ASSERT_EQ(net::ERR_FILE_NOT_FOUND, result); 132 ASSERT_EQ(net::ERR_FILE_NOT_FOUND, result);
133 ASSERT_EQ(0U, data.size()); 133 ASSERT_EQ(0U, data.size());
134 } 134 }
135 135
136 TEST_F(LocalFileStreamReaderTest, Empty) { 136 TEST_F(LocalFileStreamReaderTest, Empty) {
137 base::FilePath empty_path = test_dir().AppendASCII("empty"); 137 base::FilePath empty_path = test_dir().AppendASCII("empty");
138 base::PlatformFileError error = base::PLATFORM_FILE_OK; 138 base::File file(empty_path, base::File::FLAG_CREATE | base::File::FLAG_READ);
139 base::PlatformFile file = base::CreatePlatformFile( 139 ASSERT_TRUE(file.IsValid());
140 empty_path, 140 file.Close();
141 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ,
142 NULL, &error);
143 ASSERT_EQ(base::PLATFORM_FILE_OK, error);
144 ASSERT_NE(base::kInvalidPlatformFileValue, file);
145 base::ClosePlatformFile(file);
146 141
147 scoped_ptr<LocalFileStreamReader> reader( 142 scoped_ptr<LocalFileStreamReader> reader(
148 CreateFileReader(empty_path, 0, base::Time())); 143 CreateFileReader(empty_path, 0, base::Time()));
149 int result = 0; 144 int result = 0;
150 std::string data; 145 std::string data;
151 ReadFromReader(reader.get(), &data, 10, &result); 146 ReadFromReader(reader.get(), &data, 10, &result);
152 ASSERT_EQ(net::OK, result); 147 ASSERT_EQ(net::OK, result);
153 ASSERT_EQ(0U, data.size()); 148 ASSERT_EQ(0U, data.size());
154 149
155 net::TestInt64CompletionCallback callback; 150 net::TestInt64CompletionCallback callback;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); 247 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled));
253 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); 248 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0);
254 249
255 // Delete immediately. 250 // Delete immediately.
256 // Should not crash; nor should NeverCalled be callback. 251 // Should not crash; nor should NeverCalled be callback.
257 reader.reset(); 252 reader.reset();
258 EnsureFileTaskFinished(); 253 EnsureFileTaskFinished();
259 } 254 }
260 255
261 } // namespace webkit_blob 256 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « no previous file | webkit/browser/database/database_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698