| 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/local_file_reader.h" | 5 #include "chrome/browser/chromeos/drive/local_file_reader.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 LocalFileReader* reader_; | 40 LocalFileReader* reader_; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 class LocalFileReaderTest : public ::testing::Test { | 45 class LocalFileReaderTest : public ::testing::Test { |
| 46 protected: | 46 protected: |
| 47 LocalFileReaderTest() { | |
| 48 } | |
| 49 | |
| 50 virtual void SetUp() OVERRIDE { | 47 virtual void SetUp() OVERRIDE { |
| 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 48 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 52 worker_thread_.reset(new base::Thread("LocalFileReaderTest")); | 49 worker_thread_.reset(new base::Thread("LocalFileReaderTest")); |
| 53 ASSERT_TRUE(worker_thread_->Start()); | 50 ASSERT_TRUE(worker_thread_->Start()); |
| 54 file_reader_.reset( | 51 file_reader_.reset( |
| 55 new LocalFileReader(worker_thread_->message_loop_proxy())); | 52 new LocalFileReader(worker_thread_->message_loop_proxy())); |
| 56 } | 53 } |
| 57 | 54 |
| 58 virtual void TearDown() OVERRIDE { | |
| 59 file_reader_.reset(); | |
| 60 worker_thread_.reset(); | |
| 61 } | |
| 62 | |
| 63 base::MessageLoop message_loop_; | 55 base::MessageLoop message_loop_; |
| 64 base::ScopedTempDir temp_dir_; | 56 base::ScopedTempDir temp_dir_; |
| 65 scoped_ptr<base::Thread> worker_thread_; | 57 scoped_ptr<base::Thread> worker_thread_; |
| 66 scoped_ptr<LocalFileReader> file_reader_; | 58 scoped_ptr<LocalFileReader> file_reader_; |
| 67 }; | 59 }; |
| 68 | 60 |
| 69 TEST_F(LocalFileReaderTest, NonExistingFile) { | 61 TEST_F(LocalFileReaderTest, NonExistingFile) { |
| 70 const base::FilePath kTestFile = | 62 const base::FilePath kTestFile = |
| 71 temp_dir_.path().AppendASCII("non-existing"); | 63 temp_dir_.path().AppendASCII("non-existing"); |
| 72 | 64 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ASSERT_EQ(net::OK, callback.WaitForResult()); | 98 ASSERT_EQ(net::OK, callback.WaitForResult()); |
| 107 | 99 |
| 108 LocalFileReaderAdapter adapter(file_reader_.get()); | 100 LocalFileReaderAdapter adapter(file_reader_.get()); |
| 109 std::string content; | 101 std::string content; |
| 110 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content)); | 102 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content)); |
| 111 EXPECT_EQ(expected_content, content); | 103 EXPECT_EQ(expected_content, content); |
| 112 } | 104 } |
| 113 | 105 |
| 114 } // namespace util | 106 } // namespace util |
| 115 } // namespace drive | 107 } // namespace drive |
| OLD | NEW |