Index: webkit/fileapi/media/native_media_file_util_unittest.cc |
diff --git a/webkit/fileapi/media/native_media_file_util_unittest.cc b/webkit/fileapi/media/native_media_file_util_unittest.cc |
index 071922c8384d7dd48087df0803dfb85924835749..1eddd5ba9dc354b7731a8f4c6d4ebcde0544c6e3 100644 |
--- a/webkit/fileapi/media/native_media_file_util_unittest.cc |
+++ b/webkit/fileapi/media/native_media_file_util_unittest.cc |
@@ -135,6 +135,13 @@ class NativeMediaFileUtilTest : public testing::Test { |
return file_system_context_.get(); |
} |
+ FileSystemURL CreateURL(const FilePath::CharType* test_case_path) { |
+ return file_system_context_->CreateCrackedFileSystemURL( |
+ origin(), |
+ fileapi::kFileSystemTypeIsolated, |
+ GetVirtualPath(test_case_path)); |
+ } |
+ |
IsolatedContext* isolated_context() { |
return IsolatedContext::GetInstance(); |
} |
@@ -143,6 +150,12 @@ class NativeMediaFileUtilTest : public testing::Test { |
return data_dir_.path().Append(FPL("Media Directory")); |
} |
+ FilePath GetVirtualPath(const FilePath::CharType* test_case_path) { |
+ return FilePath::FromUTF8Unsafe(filesystem_id_). |
+ Append(FPL("Media Directory")). |
+ Append(FilePath(test_case_path)); |
+ } |
+ |
FileSystemFileUtil* file_util() { |
return file_util_; |
} |
@@ -177,8 +190,7 @@ TEST_F(NativeMediaFileUtilTest, DirectoryExistsAndFileExistsFiltering) { |
arraysize(kFilteringTestCases)); |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
FileSystemOperation* operation = NewOperation(url); |
base::PlatformFileError expectation = |
@@ -205,7 +217,7 @@ TEST_F(NativeMediaFileUtilTest, ReadDirectoryFiltering) { |
arraysize(kFilteringTestCases)); |
std::set<FilePath::StringType> content; |
- FileSystemURL url(origin(), type(), root_path()); |
+ FileSystemURL url = CreateURL(FPL("")); |
bool completed = false; |
NewOperation(url)->ReadDirectory( |
url, base::Bind(&DidReadDirectory, &content, &completed)); |
@@ -226,11 +238,10 @@ TEST_F(NativeMediaFileUtilTest, CreateFileAndCreateDirectoryFiltering) { |
// pre-existing. Though the result should be the same. |
for (int loop_count = 0; loop_count < 2; ++loop_count) { |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"CreateFileAndCreateDirectoryFiltering run %d, test %" PRIuS, |
@@ -254,7 +265,7 @@ TEST_F(NativeMediaFileUtilTest, CreateFileAndCreateDirectoryFiltering) { |
TEST_F(NativeMediaFileUtilTest, CopySourceFiltering) { |
FilePath dest_path = root_path().AppendASCII("dest"); |
- FileSystemURL dest_url(origin(), type(), dest_path); |
+ FileSystemURL dest_url = CreateURL(FPL("dest")); |
// Run the loop twice. The first run has no source files. The second run does. |
for (int loop_count = 0; loop_count < 2; ++loop_count) { |
@@ -269,11 +280,10 @@ TEST_F(NativeMediaFileUtilTest, CopySourceFiltering) { |
ASSERT_TRUE(file_util::Delete(dest_path, true)); |
ASSERT_TRUE(file_util::CreateDirectory(dest_path)); |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"CopySourceFiltering run %d test %" PRIuS, loop_count, i); |
@@ -308,16 +318,15 @@ TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { |
// Always create a dummy source data file. |
FilePath src_path = root_path().AppendASCII("foo.jpg"); |
- FileSystemURL src_url(origin(), type(), src_path); |
+ FileSystemURL src_url = CreateURL(FPL("foo.jpg")); |
static const char kDummyData[] = "dummy"; |
ASSERT_TRUE(file_util::WriteFile(src_path, kDummyData, strlen(kDummyData))); |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"CopyDestFiltering run %d test %" PRIuS, loop_count, i); |
@@ -356,7 +365,7 @@ TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { |
TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { |
FilePath dest_path = root_path().AppendASCII("dest"); |
- FileSystemURL dest_url(origin(), type(), dest_path); |
+ FileSystemURL dest_url = CreateURL(FPL("dest")); |
// Run the loop twice. The first run has no source files. The second run does. |
for (int loop_count = 0; loop_count < 2; ++loop_count) { |
@@ -371,11 +380,10 @@ TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { |
ASSERT_TRUE(file_util::Delete(dest_path, true)); |
ASSERT_TRUE(file_util::CreateDirectory(dest_path)); |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"MoveSourceFiltering run %d test %" PRIuS, loop_count, i); |
@@ -411,16 +419,15 @@ TEST_F(NativeMediaFileUtilTest, MoveDestFiltering) { |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
// Create the source file for every test case because it might get moved. |
FilePath src_path = root_path().AppendASCII("foo.jpg"); |
- FileSystemURL src_url(origin(), type(), src_path); |
+ FileSystemURL src_url = CreateURL(FPL("foo.jpg")); |
static const char kDummyData[] = "dummy"; |
ASSERT_TRUE( |
file_util::WriteFile(src_path, kDummyData, strlen(kDummyData))); |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"MoveDestFiltering run %d test %" PRIuS, loop_count, i); |
@@ -466,11 +473,10 @@ TEST_F(NativeMediaFileUtilTest, GetMetadataFiltering) { |
arraysize(kFilteringTestCases)); |
} |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"GetMetadataFiltering run %d test %" PRIuS, loop_count, i); |
@@ -498,11 +504,10 @@ TEST_F(NativeMediaFileUtilTest, RemoveFiltering) { |
arraysize(kFilteringTestCases)); |
} |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"RemoveFiltering run %d test %" PRIuS, loop_count, i); |
@@ -527,11 +532,10 @@ TEST_F(NativeMediaFileUtilTest, TruncateFiltering) { |
arraysize(kFilteringTestCases)); |
} |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"TruncateFiltering run %d test %" PRIuS, loop_count, i); |
@@ -561,11 +565,10 @@ TEST_F(NativeMediaFileUtilTest, TouchFileFiltering) { |
arraysize(kFilteringTestCases)); |
} |
for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { |
- FileSystemURL root_url(origin(), type(), root_path()); |
+ FileSystemURL root_url = CreateURL(FPL("")); |
FileSystemOperation* operation = NewOperation(root_url); |
- FilePath path = root_path().Append(kFilteringTestCases[i].path); |
- FileSystemURL url(origin(), type(), path); |
+ FileSystemURL url = CreateURL(kFilteringTestCases[i].path); |
std::string test_name = base::StringPrintf( |
"TouchFileFiltering run %d test %" PRIuS, loop_count, i); |