OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/fileapi/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 27 matching lines...) Loading... |
38 virtual void DidSucceed() { | 38 virtual void DidSucceed() { |
39 status_ = kFileOperationSucceeded; | 39 status_ = kFileOperationSucceeded; |
40 } | 40 } |
41 | 41 |
42 virtual void DidReadMetadata(const base::PlatformFileInfo& info) { | 42 virtual void DidReadMetadata(const base::PlatformFileInfo& info) { |
43 info_ = info; | 43 info_ = info; |
44 status_ = kFileOperationSucceeded; | 44 status_ = kFileOperationSucceeded; |
45 } | 45 } |
46 | 46 |
47 virtual void DidReadDirectory( | 47 virtual void DidReadDirectory( |
48 const std::vector<base::file_util_proxy::Entry>& entries, | 48 const std::vector<base::FileUtilProxy::Entry>& entries, |
49 bool /* has_more */) { | 49 bool /* has_more */) { |
50 entries_ = entries; | 50 entries_ = entries; |
51 } | 51 } |
52 | 52 |
53 virtual void DidOpenFileSystem(const std::string&, const FilePath&) { | 53 virtual void DidOpenFileSystem(const std::string&, const FilePath&) { |
54 NOTREACHED(); | 54 NOTREACHED(); |
55 } | 55 } |
56 | 56 |
57 virtual void DidWrite(int64 bytes, bool complete) { | 57 virtual void DidWrite(int64 bytes, bool complete) { |
58 NOTREACHED(); | 58 NOTREACHED(); |
59 } | 59 } |
60 | 60 |
61 // Helpers for testing. | 61 // Helpers for testing. |
62 int status() const { return status_; } | 62 int status() const { return status_; } |
63 int request_id() const { return request_id_; } | 63 int request_id() const { return request_id_; } |
64 const base::PlatformFileInfo& info() const { return info_; } | 64 const base::PlatformFileInfo& info() const { return info_; } |
65 const std::vector<base::file_util_proxy::Entry>& entries() const { | 65 const std::vector<base::FileUtilProxy::Entry>& entries() const { |
66 return entries_; | 66 return entries_; |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 int status_; | 70 int status_; |
71 int request_id_; | 71 int request_id_; |
72 base::PlatformFileInfo info_; | 72 base::PlatformFileInfo info_; |
73 std::vector<base::file_util_proxy::Entry> entries_; | 73 std::vector<base::FileUtilProxy::Entry> entries_; |
74 }; | 74 }; |
75 | 75 |
76 class FileSystemOperationTest : public testing::Test { | 76 class FileSystemOperationTest : public testing::Test { |
77 public: | 77 public: |
78 FileSystemOperationTest() | 78 FileSystemOperationTest() |
79 : request_id_(kInvalidRequestId), | 79 : request_id_(kInvalidRequestId), |
80 operation_(NULL) { | 80 operation_(NULL) { |
81 base_.CreateUniqueTempDir(); | 81 base_.CreateUniqueTempDir(); |
82 EXPECT_TRUE(base_.IsValid()); | 82 EXPECT_TRUE(base_.IsValid()); |
83 } | 83 } |
(...skipping 697 matching lines...) Loading... |
781 | 781 |
782 // Check that its length is now 3 and that it contains only bits of test data. | 782 // Check that its length is now 3 and that it contains only bits of test data. |
783 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 783 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
784 EXPECT_EQ(length, info.size); | 784 EXPECT_EQ(length, info.size); |
785 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 785 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
786 for (int i = 0; i < length; ++i) | 786 for (int i = 0; i < length; ++i) |
787 EXPECT_EQ(test_data[i], data[i]); | 787 EXPECT_EQ(test_data[i], data[i]); |
788 } | 788 } |
789 | 789 |
790 } // namespace fileapi | 790 } // namespace fileapi |
OLD | NEW |