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

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

Issue 101143006: Convert base::file_util to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base:: Created 6 years, 11 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 | « net/base/upload_file_element_reader.cc ('k') | net/disk_cache/entry_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/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 ASSERT_EQ( 197 ASSERT_EQ(
198 ERR_IO_PENDING, 198 ERR_IO_PENDING,
199 reader_->Read(wrapped_buffer.get(), kLength, read_callback.callback())); 199 reader_->Read(wrapped_buffer.get(), kLength, read_callback.callback()));
200 EXPECT_EQ(static_cast<int>(kLength), read_callback.WaitForResult()); 200 EXPECT_EQ(static_cast<int>(kLength), read_callback.WaitForResult());
201 const std::vector<char> expected(bytes_.begin() + kOffset, 201 const std::vector<char> expected(bytes_.begin() + kOffset,
202 bytes_.begin() + kOffset + kLength); 202 bytes_.begin() + kOffset + kLength);
203 EXPECT_EQ(expected, buf); 203 EXPECT_EQ(expected, buf);
204 } 204 }
205 205
206 TEST_F(UploadFileElementReaderTest, FileChanged) { 206 TEST_F(UploadFileElementReaderTest, FileChanged) {
207 base::PlatformFileInfo info; 207 base::File::Info info;
208 ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); 208 ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info));
209 209
210 // Expect one second before the actual modification time to simulate change. 210 // Expect one second before the actual modification time to simulate change.
211 const base::Time expected_modification_time = 211 const base::Time expected_modification_time =
212 info.last_modified - base::TimeDelta::FromSeconds(1); 212 info.last_modified - base::TimeDelta::FromSeconds(1);
213 reader_.reset( 213 reader_.reset(
214 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 214 new UploadFileElementReader(base::MessageLoopProxy::current().get(),
215 temp_file_path_, 215 temp_file_path_,
216 0, 216 0,
217 kuint64max, 217 kuint64max,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 std::vector<char> buf(kLength); 342 std::vector<char> buf(kLength);
343 scoped_refptr<IOBuffer> wrapped_buffer = new WrappedIOBuffer(&buf[0]); 343 scoped_refptr<IOBuffer> wrapped_buffer = new WrappedIOBuffer(&buf[0]);
344 EXPECT_EQ(static_cast<int>(kLength), 344 EXPECT_EQ(static_cast<int>(kLength),
345 reader_->Read(wrapped_buffer.get(), kLength, CompletionCallback())); 345 reader_->Read(wrapped_buffer.get(), kLength, CompletionCallback()));
346 const std::vector<char> expected(bytes_.begin() + kOffset, 346 const std::vector<char> expected(bytes_.begin() + kOffset,
347 bytes_.begin() + kOffset + kLength); 347 bytes_.begin() + kOffset + kLength);
348 EXPECT_EQ(expected, buf); 348 EXPECT_EQ(expected, buf);
349 } 349 }
350 350
351 TEST_F(UploadFileElementReaderSyncTest, FileChanged) { 351 TEST_F(UploadFileElementReaderSyncTest, FileChanged) {
352 base::PlatformFileInfo info; 352 base::File::Info info;
353 ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); 353 ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info));
354 354
355 // Expect one second before the actual modification time to simulate change. 355 // Expect one second before the actual modification time to simulate change.
356 const base::Time expected_modification_time = 356 const base::Time expected_modification_time =
357 info.last_modified - base::TimeDelta::FromSeconds(1); 357 info.last_modified - base::TimeDelta::FromSeconds(1);
358 reader_.reset(new UploadFileElementReaderSync( 358 reader_.reset(new UploadFileElementReaderSync(
359 temp_file_path_, 0, kuint64max, expected_modification_time)); 359 temp_file_path_, 0, kuint64max, expected_modification_time));
360 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, reader_->Init(CompletionCallback())); 360 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, reader_->Init(CompletionCallback()));
361 } 361 }
362 362
363 TEST_F(UploadFileElementReaderSyncTest, WrongPath) { 363 TEST_F(UploadFileElementReaderSyncTest, WrongPath) {
364 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); 364 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path"));
365 reader_.reset(new UploadFileElementReaderSync( 365 reader_.reset(new UploadFileElementReaderSync(
366 wrong_path, 0, kuint64max, base::Time())); 366 wrong_path, 0, kuint64max, base::Time()));
367 ASSERT_EQ(ERR_FILE_NOT_FOUND, reader_->Init(CompletionCallback())); 367 ASSERT_EQ(ERR_FILE_NOT_FOUND, reader_->Init(CompletionCallback()));
368 } 368 }
369 369
370 } // namespace net 370 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_file_element_reader.cc ('k') | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698