Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/files/file_util.h" | 7 #include "base/files/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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, |
| 218 expected_modification_time)); | 218 expected_modification_time)); |
| 219 TestCompletionCallback init_callback; | 219 TestCompletionCallback init_callback; |
| 220 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); | 220 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); |
| 221 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, init_callback.WaitForResult()); | 221 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, init_callback.WaitForResult()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 TEST_F(UploadFileElementReaderTest, InexactExpectedTimeStamp) { | |
| 225 base::File::Info info; | |
| 226 ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); | |
| 227 | |
| 228 const base::Time expected_modification_time = | |
| 229 info.last_modified - base::TimeDelta::FromMilliseconds(900); | |
| 230 reader_.reset(new UploadFileElementReader( | |
| 231 base::MessageLoopProxy::current().get(), temp_file_path_, 0, kuint64max, | |
| 232 expected_modification_time)); | |
|
mmenke
2015/02/02 15:34:21
nit: While you're here, should format the identic
| |
| 233 TestCompletionCallback init_callback; | |
| 234 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); | |
| 235 EXPECT_EQ(OK, init_callback.WaitForResult()); | |
| 236 } | |
| 237 | |
| 224 TEST_F(UploadFileElementReaderTest, WrongPath) { | 238 TEST_F(UploadFileElementReaderTest, WrongPath) { |
| 225 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); | 239 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); |
| 226 reader_.reset( | 240 reader_.reset( |
| 227 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 241 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 228 wrong_path, | 242 wrong_path, |
| 229 0, | 243 0, |
| 230 kuint64max, | 244 kuint64max, |
| 231 base::Time())); | 245 base::Time())); |
| 232 TestCompletionCallback init_callback; | 246 TestCompletionCallback init_callback; |
| 233 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); | 247 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); |
| 234 EXPECT_EQ(ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); | 248 EXPECT_EQ(ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); |
| 235 } | 249 } |
| 236 | 250 |
| 237 } // namespace net | 251 } // namespace net |
| OLD | NEW |