| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/drive_file_stream_reader.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 temp_dir_.path(), 1024, &file_path_, &file_content_)); | 52 temp_dir_.path(), 1024, &file_path_, &file_content_)); |
| 53 | 53 |
| 54 worker_thread_.reset(new base::Thread("ReaderProxyTest")); | 54 worker_thread_.reset(new base::Thread("ReaderProxyTest")); |
| 55 ASSERT_TRUE(worker_thread_->Start()); | 55 ASSERT_TRUE(worker_thread_->Start()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual void TearDown() OVERRIDE { | 58 virtual void TearDown() OVERRIDE { |
| 59 worker_thread_.reset(); | 59 worker_thread_.reset(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 MessageLoopForIO message_loop_; | 62 base::MessageLoopForIO message_loop_; |
| 63 content::TestBrowserThread io_thread_; | 63 content::TestBrowserThread io_thread_; |
| 64 | 64 |
| 65 base::ScopedTempDir temp_dir_; | 65 base::ScopedTempDir temp_dir_; |
| 66 base::FilePath file_path_; | 66 base::FilePath file_path_; |
| 67 std::string file_content_; | 67 std::string file_content_; |
| 68 | 68 |
| 69 scoped_ptr<base::Thread> worker_thread_; | 69 scoped_ptr<base::Thread> worker_thread_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 TEST_F(LocalReaderProxyTest, Read) { | 72 TEST_F(LocalReaderProxyTest, Read) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 std::string content; | 105 std::string content; |
| 106 ASSERT_EQ(net::OK, test_util::ReadAllData(&proxy, &content)); | 106 ASSERT_EQ(net::OK, test_util::ReadAllData(&proxy, &content)); |
| 107 EXPECT_EQ(expected_content, content); | 107 EXPECT_EQ(expected_content, content); |
| 108 } | 108 } |
| 109 | 109 |
| 110 class NetworkReaderProxyTest : public ::testing::Test { | 110 class NetworkReaderProxyTest : public ::testing::Test { |
| 111 protected: | 111 protected: |
| 112 NetworkReaderProxyTest() : io_thread_(BrowserThread::IO, &message_loop_) { | 112 NetworkReaderProxyTest() : io_thread_(BrowserThread::IO, &message_loop_) { |
| 113 } | 113 } |
| 114 | 114 |
| 115 MessageLoopForIO message_loop_; | 115 base::MessageLoopForIO message_loop_; |
| 116 content::TestBrowserThread io_thread_; | 116 content::TestBrowserThread io_thread_; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 TEST_F(NetworkReaderProxyTest, EmptyFile) { | 119 TEST_F(NetworkReaderProxyTest, EmptyFile) { |
| 120 NetworkReaderProxy proxy(0, 0, base::Bind(&base::DoNothing)); | 120 NetworkReaderProxy proxy(0, 0, base::Bind(&base::DoNothing)); |
| 121 | 121 |
| 122 net::TestCompletionCallback callback; | 122 net::TestCompletionCallback callback; |
| 123 const int kBufferSize = 10; | 123 const int kBufferSize = 10; |
| 124 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kBufferSize)); | 124 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kBufferSize)); |
| 125 int result = proxy.Read(buffer.get(), kBufferSize, callback.callback()); | 125 int result = proxy.Read(buffer.get(), kBufferSize, callback.callback()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 FileSystemInterface* GetFileSystem() { | 342 FileSystemInterface* GetFileSystem() { |
| 343 return fake_file_system_.get(); | 343 return fake_file_system_.get(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 DriveFileStreamReader::FileSystemGetter GetFileSystemGetter() { | 346 DriveFileStreamReader::FileSystemGetter GetFileSystemGetter() { |
| 347 return base::Bind(&DriveFileStreamReaderTest::GetFileSystem, | 347 return base::Bind(&DriveFileStreamReaderTest::GetFileSystem, |
| 348 base::Unretained(this)); | 348 base::Unretained(this)); |
| 349 } | 349 } |
| 350 | 350 |
| 351 MessageLoopForIO message_loop_; | 351 base::MessageLoopForIO message_loop_; |
| 352 content::TestBrowserThread ui_thread_; | 352 content::TestBrowserThread ui_thread_; |
| 353 content::TestBrowserThread io_thread_; | 353 content::TestBrowserThread io_thread_; |
| 354 | 354 |
| 355 scoped_ptr<base::Thread> worker_thread_; | 355 scoped_ptr<base::Thread> worker_thread_; |
| 356 | 356 |
| 357 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; | 357 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; |
| 358 scoped_ptr<test_util::FakeFileSystem> fake_file_system_; | 358 scoped_ptr<test_util::FakeFileSystem> fake_file_system_; |
| 359 }; | 359 }; |
| 360 | 360 |
| 361 TEST_F(DriveFileStreamReaderTest, Read) { | 361 TEST_F(DriveFileStreamReaderTest, Read) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 google_apis::CreateComposedCallback( | 513 google_apis::CreateComposedCallback( |
| 514 base::Bind(&google_apis::test_util::RunAndQuit), | 514 base::Bind(&google_apis::test_util::RunAndQuit), |
| 515 google_apis::test_util::CreateCopyResultCallback( | 515 google_apis::test_util::CreateCopyResultCallback( |
| 516 &error, &entry))); | 516 &error, &entry))); |
| 517 message_loop_.Run(); | 517 message_loop_.Run(); |
| 518 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, error); | 518 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, error); |
| 519 EXPECT_FALSE(entry); | 519 EXPECT_FALSE(entry); |
| 520 } | 520 } |
| 521 | 521 |
| 522 } // namespace drive | 522 } // namespace drive |
| OLD | NEW |