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()); | |
236 EXPECT_EQ(0U, reader_->BytesRemaining()); | |
237 } | 235 } |
238 | 236 |
239 | 237 |
240 class UploadFileElementReaderSyncTest : public PlatformTest { | 238 class UploadFileElementReaderSyncTest : public PlatformTest { |
241 protected: | 239 protected: |
242 virtual void SetUp() OVERRIDE { | 240 virtual void SetUp() OVERRIDE { |
243 // Some tests (*.ReadPartially) rely on bytes_.size() being even. | 241 // Some tests (*.ReadPartially) rely on bytes_.size() being even. |
244 const char kData[] = "123456789abcdefghi"; | 242 const char kData[] = "123456789abcdefghi"; |
245 bytes_.assign(kData, kData + arraysize(kData) - 1); | 243 bytes_.assign(kData, kData + arraysize(kData) - 1); |
246 | 244 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 info.last_modified - base::TimeDelta::FromSeconds(1); | 357 info.last_modified - base::TimeDelta::FromSeconds(1); |
360 reader_.reset(new UploadFileElementReaderSync( | 358 reader_.reset(new UploadFileElementReaderSync( |
361 temp_file_path_, 0, kuint64max, expected_modification_time)); | 359 temp_file_path_, 0, kuint64max, expected_modification_time)); |
362 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, reader_->Init(CompletionCallback())); | 360 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, reader_->Init(CompletionCallback())); |
363 } | 361 } |
364 | 362 |
365 TEST_F(UploadFileElementReaderSyncTest, WrongPath) { | 363 TEST_F(UploadFileElementReaderSyncTest, WrongPath) { |
366 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); | 364 const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); |
367 reader_.reset(new UploadFileElementReaderSync( | 365 reader_.reset(new UploadFileElementReaderSync( |
368 wrong_path, 0, kuint64max, base::Time())); | 366 wrong_path, 0, kuint64max, base::Time())); |
369 ASSERT_EQ(OK, reader_->Init(CompletionCallback())); | 367 ASSERT_EQ(ERR_FILE_NOT_FOUND, reader_->Init(CompletionCallback())); |
370 EXPECT_EQ(0U, reader_->GetContentLength()); | |
371 EXPECT_EQ(0U, reader_->BytesRemaining()); | |
372 } | 368 } |
373 | 369 |
374 } // namespace net | 370 } // namespace net |
OLD | NEW |