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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 12 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
13 #include "webkit/fileapi/file_system_operation.h" | 13 #include "webkit/fileapi/file_system_operation.h" |
14 | 14 |
15 namespace fileapi { | 15 namespace fileapi { |
16 | 16 |
17 const int kFileOperationStatusNotSet = 1; | 17 const int kFileOperationStatusNotSet = 1; |
18 const int kFileOperationSucceeded = 0; | 18 const int kFileOperationSucceeded = 0; |
19 | 19 |
20 static bool FileExists(FilePath path) { | 20 static bool FileExists(FilePath path) { |
21 return file_util::PathExists(path) && !file_util::DirectoryExists(path); | 21 return file_util::PathExists(path) && !file_util::DirectoryExists(path); |
22 } | 22 } |
23 | 23 |
24 class MockDispatcher; | 24 class MockDispatcher; |
25 | 25 |
26 class FileSystemOperationTest : public testing::Test { | 26 class FileSystemOperationTest : public testing::Test { |
27 public: | 27 public: |
28 FileSystemOperationTest() | 28 FileSystemOperationTest() |
29 : status_(kFileOperationStatusNotSet) { | 29 : status_(kFileOperationStatusNotSet) { |
30 base_.CreateUniqueTempDir(); | 30 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
31 EXPECT_TRUE(base_.IsValid()); | |
32 } | 31 } |
33 | 32 |
34 FileSystemOperation* operation(); | 33 FileSystemOperation* operation(); |
35 | 34 |
36 void set_status(int status) { status_ = status; } | 35 void set_status(int status) { status_ = status; } |
37 int status() const { return status_; } | 36 int status() const { return status_; } |
38 void set_info(const base::PlatformFileInfo& info) { info_ = info; } | 37 void set_info(const base::PlatformFileInfo& info) { info_ = info; } |
39 const base::PlatformFileInfo& info() const { return info_; } | 38 const base::PlatformFileInfo& info() const { return info_; } |
40 void set_entries(const std::vector<base::FileUtilProxy::Entry>& entries) { | 39 void set_entries(const std::vector<base::FileUtilProxy::Entry>& entries) { |
41 entries_ = entries; | 40 entries_ = entries; |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 720 |
722 // Check that its length is now 3 and that it contains only bits of test data. | 721 // Check that its length is now 3 and that it contains only bits of test data. |
723 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 722 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
724 EXPECT_EQ(length, info.size); | 723 EXPECT_EQ(length, info.size); |
725 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 724 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
726 for (int i = 0; i < length; ++i) | 725 for (int i = 0; i < length; ++i) |
727 EXPECT_EQ(test_data[i], data[i]); | 726 EXPECT_EQ(test_data[i], data[i]); |
728 } | 727 } |
729 | 728 |
730 } // namespace fileapi | 729 } // namespace fileapi |
OLD | NEW |