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 "components/drive/local_file_reader.h" | 5 #include "components/drive/local_file_reader.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <string> | 10 #include <string> |
8 | 11 |
9 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
14 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
15 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
16 #include "components/drive/drive_test_util.h" | 19 #include "components/drive/drive_test_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 TEST_F(LocalFileReaderTest, OpenWithOffset) { | 89 TEST_F(LocalFileReaderTest, OpenWithOffset) { |
87 base::FilePath test_file; | 90 base::FilePath test_file; |
88 std::string expected_content; | 91 std::string expected_content; |
89 ASSERT_TRUE(google_apis::test_util::CreateFileOfSpecifiedSize( | 92 ASSERT_TRUE(google_apis::test_util::CreateFileOfSpecifiedSize( |
90 temp_dir_.path(), 1024, &test_file, &expected_content)); | 93 temp_dir_.path(), 1024, &test_file, &expected_content)); |
91 | 94 |
92 size_t offset = expected_content.size() / 2; | 95 size_t offset = expected_content.size() / 2; |
93 expected_content.erase(0, offset); | 96 expected_content.erase(0, offset); |
94 | 97 |
95 net::TestCompletionCallback callback; | 98 net::TestCompletionCallback callback; |
96 file_reader_->Open( | 99 file_reader_->Open(test_file, static_cast<int64_t>(offset), |
97 test_file, static_cast<int64>(offset), callback.callback()); | 100 callback.callback()); |
98 ASSERT_EQ(net::OK, callback.WaitForResult()); | 101 ASSERT_EQ(net::OK, callback.WaitForResult()); |
99 | 102 |
100 LocalFileReaderAdapter adapter(file_reader_.get()); | 103 LocalFileReaderAdapter adapter(file_reader_.get()); |
101 std::string content; | 104 std::string content; |
102 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content)); | 105 ASSERT_EQ(net::OK, test_util::ReadAllData(&adapter, &content)); |
103 EXPECT_EQ(expected_content, content); | 106 EXPECT_EQ(expected_content, content); |
104 } | 107 } |
105 | 108 |
106 } // namespace util | 109 } // namespace util |
107 } // namespace drive | 110 } // namespace drive |
OLD | NEW |