OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> |
| 6 |
5 #include <string> | 7 #include <string> |
6 #include <vector> | 8 #include <vector> |
7 | 9 |
| 10 #include "base/macros.h" |
8 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
11 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
12 #include "chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_st
ream_reader.h" | 15 #include "chrome/browser/chromeos/file_system_provider/fileapi/buffering_file_st
ream_reader.h" |
13 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 16 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
14 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
16 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 59 } |
57 | 60 |
58 const std::string fake_data('X', buf_len); | 61 const std::string fake_data('X', buf_len); |
59 memcpy(buf->data(), fake_data.c_str(), buf_len); | 62 memcpy(buf->data(), fake_data.c_str(), buf_len); |
60 | 63 |
61 base::ThreadTaskRunnerHandle::Get()->PostTask( | 64 base::ThreadTaskRunnerHandle::Get()->PostTask( |
62 FROM_HERE, base::Bind(callback, buf_len)); | 65 FROM_HERE, base::Bind(callback, buf_len)); |
63 return net::ERR_IO_PENDING; | 66 return net::ERR_IO_PENDING; |
64 } | 67 } |
65 | 68 |
66 int64 GetLength(const net::Int64CompletionCallback& callback) override { | 69 int64_t GetLength(const net::Int64CompletionCallback& callback) override { |
67 DCHECK_EQ(net::OK, return_error_); | 70 DCHECK_EQ(net::OK, return_error_); |
68 base::ThreadTaskRunnerHandle::Get()->PostTask( | 71 base::ThreadTaskRunnerHandle::Get()->PostTask( |
69 FROM_HERE, base::Bind(callback, kFileSize)); | 72 FROM_HERE, base::Bind(callback, kFileSize)); |
70 return net::ERR_IO_PENDING; | 73 return net::ERR_IO_PENDING; |
71 } | 74 } |
72 | 75 |
73 private: | 76 private: |
74 std::vector<int>* log_; // Not owned. | 77 std::vector<int>* log_; // Not owned. |
75 net::Error return_error_; | 78 net::Error return_error_; |
76 DISALLOW_COPY_AND_ASSIGN(FakeFileStreamReader); | 79 DISALLOW_COPY_AND_ASSIGN(FakeFileStreamReader); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 ASSERT_EQ(1u, read_log.size()); | 341 ASSERT_EQ(1u, read_log.size()); |
339 EXPECT_EQ(net::ERR_ACCESS_DENIED, read_log[0]); | 342 EXPECT_EQ(net::ERR_ACCESS_DENIED, read_log[0]); |
340 } | 343 } |
341 | 344 |
342 TEST_F(FileSystemProviderBufferingFileStreamReaderTest, GetLength) { | 345 TEST_F(FileSystemProviderBufferingFileStreamReaderTest, GetLength) { |
343 BufferingFileStreamReader reader(scoped_ptr<storage::FileStreamReader>( | 346 BufferingFileStreamReader reader(scoped_ptr<storage::FileStreamReader>( |
344 new FakeFileStreamReader(NULL, net::OK)), | 347 new FakeFileStreamReader(NULL, net::OK)), |
345 kPreloadingBufferLength, | 348 kPreloadingBufferLength, |
346 kFileSize); | 349 kFileSize); |
347 | 350 |
348 std::vector<int64> get_length_log; | 351 std::vector<int64_t> get_length_log; |
349 const int64 result = | 352 const int64_t result = |
350 reader.GetLength(base::Bind(&LogValue<int64>, &get_length_log)); | 353 reader.GetLength(base::Bind(&LogValue<int64_t>, &get_length_log)); |
351 base::RunLoop().RunUntilIdle(); | 354 base::RunLoop().RunUntilIdle(); |
352 | 355 |
353 EXPECT_EQ(net::ERR_IO_PENDING, result); | 356 EXPECT_EQ(net::ERR_IO_PENDING, result); |
354 ASSERT_EQ(1u, get_length_log.size()); | 357 ASSERT_EQ(1u, get_length_log.size()); |
355 EXPECT_EQ(kFileSize, get_length_log[0]); | 358 EXPECT_EQ(kFileSize, get_length_log[0]); |
356 } | 359 } |
357 | 360 |
358 } // namespace file_system_provider | 361 } // namespace file_system_provider |
359 } // namespace chromeos | 362 } // namespace chromeos |
OLD | NEW |