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

Unified Diff: net/base/upload_file_element_reader_unittest.cc

Issue 868253012: [net] Subtract timestamps to determine if uploading file changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/upload_file_element_reader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_file_element_reader_unittest.cc
diff --git a/net/base/upload_file_element_reader_unittest.cc b/net/base/upload_file_element_reader_unittest.cc
index b0374acd966ba694ea832f5bba57bc116fff5195..719ce1e71c54cd103cc65d242ab961c0c08caa28 100644
--- a/net/base/upload_file_element_reader_unittest.cc
+++ b/net/base/upload_file_element_reader_unittest.cc
@@ -210,25 +210,33 @@ TEST_F(UploadFileElementReaderTest, FileChanged) {
// Expect one second before the actual modification time to simulate change.
const base::Time expected_modification_time =
info.last_modified - base::TimeDelta::FromSeconds(1);
- reader_.reset(
- new UploadFileElementReader(base::MessageLoopProxy::current().get(),
- temp_file_path_,
- 0,
- kuint64max,
- expected_modification_time));
+ reader_.reset(new UploadFileElementReader(
+ base::MessageLoopProxy::current().get(), temp_file_path_, 0, kuint64max,
+ expected_modification_time));
TestCompletionCallback init_callback;
ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback()));
EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, init_callback.WaitForResult());
}
+TEST_F(UploadFileElementReaderTest, InexactExpectedTimeStamp) {
+ base::File::Info info;
+ ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info));
+
+ const base::Time expected_modification_time =
+ info.last_modified - base::TimeDelta::FromMilliseconds(900);
+ reader_.reset(new UploadFileElementReader(
+ base::MessageLoopProxy::current().get(), temp_file_path_, 0, kuint64max,
+ expected_modification_time));
+ TestCompletionCallback init_callback;
+ ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback()));
+ EXPECT_EQ(OK, init_callback.WaitForResult());
+}
+
TEST_F(UploadFileElementReaderTest, WrongPath) {
const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path"));
reader_.reset(
new UploadFileElementReader(base::MessageLoopProxy::current().get(),
- wrong_path,
- 0,
- kuint64max,
- base::Time()));
+ wrong_path, 0, kuint64max, base::Time()));
TestCompletionCallback init_callback;
ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback()));
EXPECT_EQ(ERR_FILE_NOT_FOUND, init_callback.WaitForResult());
« no previous file with comments | « net/base/upload_file_element_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698