| 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/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtilTest); | 171 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtilTest); |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 TEST_F(NativeMediaFileUtilTest, DirectoryExistsAndFileExistsFiltering) { | 174 TEST_F(NativeMediaFileUtilTest, DirectoryExistsAndFileExistsFiltering) { |
| 175 PopulateDirectoryWithTestCases(root_path(), | 175 PopulateDirectoryWithTestCases(root_path(), |
| 176 kFilteringTestCases, | 176 kFilteringTestCases, |
| 177 arraysize(kFilteringTestCases)); | 177 arraysize(kFilteringTestCases)); |
| 178 | 178 |
| 179 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { | 179 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
| 180 FilePath path = root_path().Append(kFilteringTestCases[i].path); | 180 FilePath path = root_path().Append(kFilteringTestCases[i].path); |
| 181 FileSystemURL url(origin(), type(), path); | 181 FileSystemURL url(origin(), kFileSystemTypeIsolated, path); |
| 182 url = FileSystemURL::CreateForCrackedURL(url, "", type(), path); |
| 182 FileSystemOperation* operation = NewOperation(url); | 183 FileSystemOperation* operation = NewOperation(url); |
| 183 | 184 |
| 184 base::PlatformFileError expectation = | 185 base::PlatformFileError expectation = |
| 185 kFilteringTestCases[i].visible ? | 186 kFilteringTestCases[i].visible ? |
| 186 base::PLATFORM_FILE_OK : | 187 base::PLATFORM_FILE_OK : |
| 187 base::PLATFORM_FILE_ERROR_NOT_FOUND; | 188 base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 188 | 189 |
| 189 std::string test_name = | 190 std::string test_name = |
| 190 base::StringPrintf("DirectoryExistsAndFileExistsFiltering %" PRIuS, i); | 191 base::StringPrintf("DirectoryExistsAndFileExistsFiltering %" PRIuS, i); |
| 191 if (kFilteringTestCases[i].is_directory) { | 192 if (kFilteringTestCases[i].is_directory) { |
| 192 operation->DirectoryExists( | 193 operation->DirectoryExists( |
| 193 url, base::Bind(&ExpectEqHelper, test_name, expectation)); | 194 url, base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 194 } else { | 195 } else { |
| 195 operation->FileExists( | 196 operation->FileExists( |
| 196 url, base::Bind(&ExpectEqHelper, test_name, expectation)); | 197 url, base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 197 } | 198 } |
| 198 MessageLoop::current()->RunUntilIdle(); | 199 MessageLoop::current()->RunUntilIdle(); |
| 199 } | 200 } |
| 200 } | 201 } |
| 201 | 202 |
| 202 TEST_F(NativeMediaFileUtilTest, ReadDirectoryFiltering) { | 203 TEST_F(NativeMediaFileUtilTest, ReadDirectoryFiltering) { |
| 203 PopulateDirectoryWithTestCases(root_path(), | 204 PopulateDirectoryWithTestCases(root_path(), |
| 204 kFilteringTestCases, | 205 kFilteringTestCases, |
| 205 arraysize(kFilteringTestCases)); | 206 arraysize(kFilteringTestCases)); |
| 206 | 207 |
| 207 std::set<FilePath::StringType> content; | 208 std::set<FilePath::StringType> content; |
| 208 FileSystemURL url(origin(), type(), root_path()); | 209 FileSystemURL url(origin(), type(), root_path()); |
| 210 url = FileSystemURL::CreateForCrackedURL(url, "", type(), root_path()); |
| 209 bool completed = false; | 211 bool completed = false; |
| 210 NewOperation(url)->ReadDirectory( | 212 NewOperation(url)->ReadDirectory( |
| 211 url, base::Bind(&DidReadDirectory, &content, &completed)); | 213 url, base::Bind(&DidReadDirectory, &content, &completed)); |
| 212 MessageLoop::current()->RunUntilIdle(); | 214 MessageLoop::current()->RunUntilIdle(); |
| 213 EXPECT_TRUE(completed); | 215 EXPECT_TRUE(completed); |
| 214 EXPECT_EQ(5u, content.size()); | 216 EXPECT_EQ(5u, content.size()); |
| 215 | 217 |
| 216 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { | 218 for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
| 217 FilePath::StringType name = | 219 FilePath::StringType name = |
| 218 FilePath(kFilteringTestCases[i].path).BaseName().value(); | 220 FilePath(kFilteringTestCases[i].path).BaseName().value(); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 if (loop_count == 0 || !kFilteringTestCases[i].visible) { | 575 if (loop_count == 0 || !kFilteringTestCases[i].visible) { |
| 574 // Files do not exists. Touch fails. | 576 // Files do not exists. Touch fails. |
| 575 expectation = base::PLATFORM_FILE_ERROR_FAILED; | 577 expectation = base::PLATFORM_FILE_ERROR_FAILED; |
| 576 } | 578 } |
| 577 operation->TouchFile( | 579 operation->TouchFile( |
| 578 url, time, time, base::Bind(&ExpectEqHelper, test_name, expectation)); | 580 url, time, time, base::Bind(&ExpectEqHelper, test_name, expectation)); |
| 579 MessageLoop::current()->RunUntilIdle(); | 581 MessageLoop::current()->RunUntilIdle(); |
| 580 } | 582 } |
| 581 } | 583 } |
| 582 } | 584 } |
| OLD | NEW |