OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" | 16 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" |
17 #include "chrome/browser/media_galleries/fileapi/itunes_file_util.h" | 17 #include "chrome/browser/media_galleries/fileapi/itunes_file_util.h" |
18 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 18 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
19 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 19 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 20 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
22 #include "content/public/test/test_file_system_options.h" | 23 #include "content/public/test/test_file_system_options.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "webkit/browser/fileapi/async_file_util.h" | 25 #include "webkit/browser/fileapi/async_file_util.h" |
25 #include "webkit/browser/fileapi/external_mount_points.h" | 26 #include "webkit/browser/fileapi/external_mount_points.h" |
26 #include "webkit/browser/fileapi/file_system_context.h" | 27 #include "webkit/browser/fileapi/file_system_context.h" |
27 #include "webkit/browser/fileapi/file_system_operation_context.h" | 28 #include "webkit/browser/fileapi/file_system_operation_context.h" |
28 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 29 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
29 #include "webkit/browser/quota/mock_special_storage_policy.h" | 30 #include "webkit/browser/quota/mock_special_storage_policy.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 fake_library_dir_.path().AppendASCII(kITunesLibraryXML), | 147 fake_library_dir_.path().AppendASCII(kITunesLibraryXML), |
147 NULL, | 148 NULL, |
148 0)); | 149 0)); |
149 | 150 |
150 itunes_data_provider_.reset( | 151 itunes_data_provider_.reset( |
151 new TestITunesDataProvider(fake_library_dir_.path())); | 152 new TestITunesDataProvider(fake_library_dir_.path())); |
152 } | 153 } |
153 | 154 |
154 virtual void SetUp() OVERRIDE { | 155 virtual void SetUp() OVERRIDE { |
155 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 156 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
| 157 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); |
156 | 158 |
157 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 159 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
158 new quota::MockSpecialStoragePolicy(); | 160 new quota::MockSpecialStoragePolicy(); |
159 | 161 |
160 // Initialize fake ItunesDataProvider on media task runner thread. | 162 // Initialize fake ItunesDataProvider on media task runner thread. |
161 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 163 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
162 FROM_HERE, | 164 FROM_HERE, |
163 base::Bind(&ItunesFileUtilTest::SetUpDataProvider, | 165 base::Bind(&ItunesFileUtilTest::SetUpDataProvider, |
164 base::Unretained(this))); | 166 base::Unretained(this))); |
165 base::WaitableEvent event(true, false /* initially_signalled */); | 167 base::WaitableEvent event(true, false /* initially_signalled */); |
(...skipping 24 matching lines...) Expand all Loading... |
190 protected: | 192 protected: |
191 void TestNonexistentFolder(const std::string& path_append) { | 193 void TestNonexistentFolder(const std::string& path_append) { |
192 FileSystemOperation::FileEntryList contents; | 194 FileSystemOperation::FileEntryList contents; |
193 FileSystemURL url = CreateURL(path_append); | 195 FileSystemURL url = CreateURL(path_append); |
194 bool completed = false; | 196 bool completed = false; |
195 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 197 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
196 | 198 |
197 ASSERT_FALSE(completed); | 199 ASSERT_FALSE(completed); |
198 } | 200 } |
199 | 201 |
200 FileSystemURL CreateURL(const std::string& virtual_path) const { | 202 FileSystemURL CreateURL(const std::string& path) const { |
| 203 base::FilePath virtual_path = |
| 204 ImportedMediaGalleryRegistry::GetInstance()->ImportedRoot(); |
| 205 virtual_path = virtual_path.AppendASCII("itunes"); |
| 206 virtual_path = virtual_path.AppendASCII(path); |
201 return file_system_context_->CreateCrackedFileSystemURL( | 207 return file_system_context_->CreateCrackedFileSystemURL( |
202 GURL("http://www.example.com"), fileapi::kFileSystemTypeItunes, | 208 GURL("http://www.example.com"), fileapi::kFileSystemTypeItunes, |
203 base::FilePath::FromUTF8Unsafe(virtual_path)); | 209 virtual_path); |
204 } | 210 } |
205 | 211 |
206 fileapi::FileSystemOperationRunner* operation_runner() const { | 212 fileapi::FileSystemOperationRunner* operation_runner() const { |
207 return file_system_context_->operation_runner(); | 213 return file_system_context_->operation_runner(); |
208 } | 214 } |
209 | 215 |
210 scoped_refptr<fileapi::FileSystemContext> file_system_context() const { | 216 scoped_refptr<fileapi::FileSystemContext> file_system_context() const { |
211 return file_system_context_; | 217 return file_system_context_; |
212 } | 218 } |
213 | 219 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 completed = false; | 342 completed = false; |
337 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 343 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
338 ASSERT_TRUE(completed); | 344 ASSERT_TRUE(completed); |
339 ASSERT_EQ(1u, contents.size()); | 345 ASSERT_EQ(1u, contents.size()); |
340 EXPECT_FALSE(contents.front().is_directory); | 346 EXPECT_FALSE(contents.front().is_directory); |
341 EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), | 347 EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), |
342 contents.front().name); | 348 contents.front().name); |
343 } | 349 } |
344 | 350 |
345 } // namespace itunes | 351 } // namespace itunes |
OLD | NEW |