| 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/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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 TEST_F(UploadFileElementReaderTest, WrongPath) { | 224 TEST_F(UploadFileElementReaderTest, WrongPath) { |
| 225 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); | 225 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); |
| 226 reader_.reset( | 226 reader_.reset( |
| 227 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 227 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 228 wrong_path, | 228 wrong_path, |
| 229 0, | 229 0, |
| 230 kuint64max, | 230 kuint64max, |
| 231 base::Time())); | 231 base::Time())); |
| 232 TestCompletionCallback init_callback; | 232 TestCompletionCallback init_callback; |
| 233 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); | 233 ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); |
| 234 EXPECT_EQ(OK, init_callback.WaitForResult()); | 234 EXPECT_EQ(ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); |
| 235 EXPECT_EQ(0U, reader_->GetContentLength()); | 235 EXPECT_EQ(0U, reader_->GetContentLength()); |
| 236 EXPECT_EQ(0U, reader_->BytesRemaining()); | 236 EXPECT_EQ(0U, reader_->BytesRemaining()); |
| 237 } | 237 } |
| 238 | 238 |
| 239 | 239 |
| 240 class UploadFileElementReaderSyncTest : public PlatformTest { | 240 class UploadFileElementReaderSyncTest : public PlatformTest { |
| 241 protected: | 241 protected: |
| 242 virtual void SetUp() OVERRIDE { | 242 virtual void SetUp() OVERRIDE { |
| 243 // Some tests (*.ReadPartially) rely on bytes_.size() being even. | 243 // Some tests (*.ReadPartially) rely on bytes_.size() being even. |
| 244 const char kData[] = "123456789abcdefghi"; | 244 const char kData[] = "123456789abcdefghi"; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 info.last_modified - base::TimeDelta::FromSeconds(1); | 359 info.last_modified - base::TimeDelta::FromSeconds(1); |
| 360 reader_.reset(new UploadFileElementReaderSync( | 360 reader_.reset(new UploadFileElementReaderSync( |
| 361 temp_file_path_, 0, kuint64max, expected_modification_time)); | 361 temp_file_path_, 0, kuint64max, expected_modification_time)); |
| 362 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, reader_->Init(CompletionCallback())); | 362 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, reader_->Init(CompletionCallback())); |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(UploadFileElementReaderSyncTest, WrongPath) { | 365 TEST_F(UploadFileElementReaderSyncTest, WrongPath) { |
| 366 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); | 366 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); |
| 367 reader_.reset(new UploadFileElementReaderSync( | 367 reader_.reset(new UploadFileElementReaderSync( |
| 368 wrong_path, 0, kuint64max, base::Time())); | 368 wrong_path, 0, kuint64max, base::Time())); |
| 369 ASSERT_EQ(OK, reader_->Init(CompletionCallback())); | 369 ASSERT_EQ(ERR_FILE_NOT_FOUND, reader_->Init(CompletionCallback())); |
| 370 EXPECT_EQ(0U, reader_->GetContentLength()); | 370 EXPECT_EQ(0U, reader_->GetContentLength()); |
| 371 EXPECT_EQ(0U, reader_->BytesRemaining()); | 371 EXPECT_EQ(0U, reader_->BytesRemaining()); |
| 372 } | 372 } |
| 373 | 373 |
| 374 } // namespace net | 374 } // namespace net |
| OLD | NEW |