| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.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_context.h" | 12 #include "webkit/fileapi/file_system_context.h" |
| 13 #include "webkit/fileapi/file_system_operation_interface.h" | 13 #include "webkit/fileapi/file_system_operation.h" |
| 14 #include "webkit/fileapi/file_system_task_runners.h" | 14 #include "webkit/fileapi/file_system_task_runners.h" |
| 15 #include "webkit/fileapi/isolated_context.h" | 15 #include "webkit/fileapi/isolated_context.h" |
| 16 #include "webkit/fileapi/media/native_media_file_util.h" | 16 #include "webkit/fileapi/media/native_media_file_util.h" |
| 17 #include "webkit/fileapi/mock_file_system_options.h" | 17 #include "webkit/fileapi/mock_file_system_options.h" |
| 18 #include "webkit/fileapi/native_file_util.h" | 18 #include "webkit/fileapi/native_file_util.h" |
| 19 #include "webkit/quota/mock_special_storage_policy.h" | 19 #include "webkit/quota/mock_special_storage_policy.h" |
| 20 | 20 |
| 21 #define FPL(x) FILE_PATH_LITERAL(x) | 21 #define FPL(x) FILE_PATH_LITERAL(x) |
| 22 | 22 |
| 23 using namespace fileapi; | 23 using namespace fileapi; |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 typedef FileSystemOperationInterface::FileEntryList FileEntryList; | 27 typedef FileSystemOperation::FileEntryList FileEntryList; |
| 28 | 28 |
| 29 struct FilteringTestCase { | 29 struct FilteringTestCase { |
| 30 const FilePath::CharType* path; | 30 const FilePath::CharType* path; |
| 31 bool is_directory; | 31 bool is_directory; |
| 32 bool visible; | 32 bool visible; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 const FilteringTestCase kFilteringTestCases[] = { | 35 const FilteringTestCase kFilteringTestCases[] = { |
| 36 // Directory should always be visible. | 36 // Directory should always be visible. |
| 37 { FPL("hoge"), true, true }, | 37 { FPL("hoge"), true, true }, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 GURL origin() { | 134 GURL origin() { |
| 135 return GURL("http://example.com"); | 135 return GURL("http://example.com"); |
| 136 } | 136 } |
| 137 | 137 |
| 138 fileapi::FileSystemType type() { | 138 fileapi::FileSystemType type() { |
| 139 return kFileSystemTypeNativeMedia; | 139 return kFileSystemTypeNativeMedia; |
| 140 } | 140 } |
| 141 | 141 |
| 142 FileSystemOperationInterface* NewOperation(const FileSystemURL& url) { | 142 FileSystemOperation* NewOperation(const FileSystemURL& url) { |
| 143 return file_system_context_->CreateFileSystemOperation(url); | 143 return file_system_context_->CreateFileSystemOperation(url); |
| 144 } | 144 } |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 MessageLoop message_loop_; | 147 MessageLoop message_loop_; |
| 148 | 148 |
| 149 ScopedTempDir data_dir_; | 149 ScopedTempDir data_dir_; |
| 150 scoped_refptr<FileSystemContext> file_system_context_; | 150 scoped_refptr<FileSystemContext> file_system_context_; |
| 151 | 151 |
| 152 FileSystemFileUtil* file_util_; | 152 FileSystemFileUtil* file_util_; |
| 153 std::string filesystem_id_; | 153 std::string filesystem_id_; |
| 154 | 154 |
| 155 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtilTest); | 155 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtilTest); |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 TEST_F(NativeMediaFileUtilTest, DirectoryExistsAndFileExistsFiltering) { | 158 TEST_F(NativeMediaFileUtilTest, DirectoryExistsAndFileExistsFiltering) { |
| 159 PopulateDirectoryWithTestCases(root_path(), | 159 PopulateDirectoryWithTestCases(root_path(), |
| 160 kFilteringTestCases, | 160 kFilteringTestCases, |
| 161 arraysize(kFilteringTestCases)); | 161 arraysize(kFilteringTestCases)); |
| 162 | 162 |
| 163 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { | 163 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
| 164 FilePath path = root_path().Append(kFilteringTestCases[i].path); | 164 FilePath path = root_path().Append(kFilteringTestCases[i].path); |
| 165 FileSystemURL url(origin(), type(), path); | 165 FileSystemURL url(origin(), type(), path); |
| 166 FileSystemOperationInterface* operation = NewOperation(url); | 166 FileSystemOperation* operation = NewOperation(url); |
| 167 | 167 |
| 168 base::PlatformFileError expectation = | 168 base::PlatformFileError expectation = |
| 169 kFilteringTestCases[i].visible ? | 169 kFilteringTestCases[i].visible ? |
| 170 base::PLATFORM_FILE_OK : | 170 base::PLATFORM_FILE_OK : |
| 171 base::PLATFORM_FILE_ERROR_NOT_FOUND; | 171 base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 172 | 172 |
| 173 if (kFilteringTestCases[i].is_directory) | 173 if (kFilteringTestCases[i].is_directory) |
| 174 operation->DirectoryExists(url, base::Bind(&ExpectEqHelper, expectation)); | 174 operation->DirectoryExists(url, base::Bind(&ExpectEqHelper, expectation)); |
| 175 else | 175 else |
| 176 operation->FileExists(url, base::Bind(&ExpectEqHelper, expectation)); | 176 operation->FileExists(url, base::Bind(&ExpectEqHelper, expectation)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 192 EXPECT_TRUE(completed); | 192 EXPECT_TRUE(completed); |
| 193 EXPECT_EQ(5u, content.size()); | 193 EXPECT_EQ(5u, content.size()); |
| 194 | 194 |
| 195 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { | 195 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
| 196 FilePath::StringType name = | 196 FilePath::StringType name = |
| 197 FilePath(kFilteringTestCases[i].path).BaseName().value(); | 197 FilePath(kFilteringTestCases[i].path).BaseName().value(); |
| 198 std::set<FilePath::StringType>::const_iterator found = content.find(name); | 198 std::set<FilePath::StringType>::const_iterator found = content.find(name); |
| 199 EXPECT_EQ(kFilteringTestCases[i].visible, found != content.end()); | 199 EXPECT_EQ(kFilteringTestCases[i].visible, found != content.end()); |
| 200 } | 200 } |
| 201 } | 201 } |
| OLD | NEW |