| 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" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 ASSERT_TRUE(fake_auto_add_dir_.Delete()); | 89 ASSERT_TRUE(fake_auto_add_dir_.Delete()); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 base::ScopedTempDir fake_auto_add_dir_; | 94 base::ScopedTempDir fake_auto_add_dir_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class TestITunesFileUtil : public ITunesFileUtil { | 97 class TestITunesFileUtil : public ITunesFileUtil { |
| 98 public: | 98 public: |
| 99 explicit TestITunesFileUtil(chrome::MediaPathFilter* media_path_filter, | 99 explicit TestITunesFileUtil(MediaPathFilter* media_path_filter, |
| 100 ITunesDataProvider* data_provider) | 100 ITunesDataProvider* data_provider) |
| 101 : ITunesFileUtil(media_path_filter), | 101 : ITunesFileUtil(media_path_filter), |
| 102 data_provider_(data_provider) { | 102 data_provider_(data_provider) { |
| 103 } | 103 } |
| 104 virtual ~TestITunesFileUtil() {} | 104 virtual ~TestITunesFileUtil() {} |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 virtual ITunesDataProvider* GetDataProvider() OVERRIDE { | 107 virtual ITunesDataProvider* GetDataProvider() OVERRIDE { |
| 108 return data_provider_; | 108 return data_provider_; |
| 109 } | 109 } |
| 110 | 110 |
| 111 ITunesDataProvider* data_provider_; | 111 ITunesDataProvider* data_provider_; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class TestMediaFileSystemBackend | 114 class TestMediaFileSystemBackend : public MediaFileSystemBackend { |
| 115 : public chrome::MediaFileSystemBackend { | |
| 116 public: | 115 public: |
| 117 TestMediaFileSystemBackend(const base::FilePath& profile_path, | 116 TestMediaFileSystemBackend(const base::FilePath& profile_path, |
| 118 ITunesFileUtil* itunes_file_util) | 117 ITunesFileUtil* itunes_file_util) |
| 119 : chrome::MediaFileSystemBackend( | 118 : MediaFileSystemBackend( |
| 120 profile_path, | 119 profile_path, |
| 121 chrome::MediaFileSystemBackend::MediaTaskRunner().get()), | 120 MediaFileSystemBackend::MediaTaskRunner().get()), |
| 122 test_file_util_(itunes_file_util) {} | 121 test_file_util_(itunes_file_util) {} |
| 123 | 122 |
| 124 virtual fileapi::AsyncFileUtil* | 123 virtual fileapi::AsyncFileUtil* |
| 125 GetAsyncFileUtil(fileapi::FileSystemType type) OVERRIDE { | 124 GetAsyncFileUtil(fileapi::FileSystemType type) OVERRIDE { |
| 126 if (type != fileapi::kFileSystemTypeItunes) | 125 if (type != fileapi::kFileSystemTypeItunes) |
| 127 return NULL; | 126 return NULL; |
| 128 | 127 |
| 129 return test_file_util_.get(); | 128 return test_file_util_.get(); |
| 130 } | 129 } |
| 131 | 130 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 153 new TestITunesDataProvider(fake_library_dir_.path())); | 152 new TestITunesDataProvider(fake_library_dir_.path())); |
| 154 } | 153 } |
| 155 | 154 |
| 156 virtual void SetUp() OVERRIDE { | 155 virtual void SetUp() OVERRIDE { |
| 157 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 156 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
| 158 | 157 |
| 159 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 158 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
| 160 new quota::MockSpecialStoragePolicy(); | 159 new quota::MockSpecialStoragePolicy(); |
| 161 | 160 |
| 162 // Initialize fake ItunesDataProvider on media task runner thread. | 161 // Initialize fake ItunesDataProvider on media task runner thread. |
| 163 chrome::MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 162 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
| 164 FROM_HERE, | 163 FROM_HERE, |
| 165 base::Bind(&ItunesFileUtilTest::SetUpDataProvider, | 164 base::Bind(&ItunesFileUtilTest::SetUpDataProvider, |
| 166 base::Unretained(this))); | 165 base::Unretained(this))); |
| 167 base::WaitableEvent event(true, false /* initially_signalled */); | 166 base::WaitableEvent event(true, false /* initially_signalled */); |
| 168 chrome::MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 167 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
| 169 FROM_HERE, | 168 FROM_HERE, |
| 170 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); | 169 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event))); |
| 171 event.Wait(); | 170 event.Wait(); |
| 172 | 171 |
| 173 media_path_filter_.reset(new chrome::MediaPathFilter()); | 172 media_path_filter_.reset(new MediaPathFilter()); |
| 174 ScopedVector<fileapi::FileSystemBackend> additional_providers; | 173 ScopedVector<fileapi::FileSystemBackend> additional_providers; |
| 175 additional_providers.push_back(new TestMediaFileSystemBackend( | 174 additional_providers.push_back(new TestMediaFileSystemBackend( |
| 176 profile_dir_.path(), | 175 profile_dir_.path(), |
| 177 new TestITunesFileUtil(media_path_filter_.get(), | 176 new TestITunesFileUtil(media_path_filter_.get(), |
| 178 itunes_data_provider_.get()))); | 177 itunes_data_provider_.get()))); |
| 179 | 178 |
| 180 file_system_context_ = new fileapi::FileSystemContext( | 179 file_system_context_ = new fileapi::FileSystemContext( |
| 181 base::MessageLoopProxy::current().get(), | 180 base::MessageLoopProxy::current().get(), |
| 182 base::MessageLoopProxy::current().get(), | 181 base::MessageLoopProxy::current().get(), |
| 183 fileapi::ExternalMountPoints::CreateRefCounted().get(), | 182 fileapi::ExternalMountPoints::CreateRefCounted().get(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 216 } |
| 218 | 217 |
| 219 private: | 218 private: |
| 220 base::MessageLoop message_loop_; | 219 base::MessageLoop message_loop_; |
| 221 content::TestBrowserThread io_thread_; | 220 content::TestBrowserThread io_thread_; |
| 222 | 221 |
| 223 base::ScopedTempDir profile_dir_; | 222 base::ScopedTempDir profile_dir_; |
| 224 base::ScopedTempDir fake_library_dir_; | 223 base::ScopedTempDir fake_library_dir_; |
| 225 | 224 |
| 226 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 225 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
| 227 scoped_ptr<chrome::MediaPathFilter> media_path_filter_; | 226 scoped_ptr<MediaPathFilter> media_path_filter_; |
| 228 scoped_ptr<TestITunesDataProvider> itunes_data_provider_; | 227 scoped_ptr<TestITunesDataProvider> itunes_data_provider_; |
| 229 | 228 |
| 230 DISALLOW_COPY_AND_ASSIGN(ItunesFileUtilTest); | 229 DISALLOW_COPY_AND_ASSIGN(ItunesFileUtilTest); |
| 231 }; | 230 }; |
| 232 | 231 |
| 233 TEST_F(ItunesFileUtilTest, RootContents) { | 232 TEST_F(ItunesFileUtilTest, RootContents) { |
| 234 FileSystemOperation::FileEntryList contents; | 233 FileSystemOperation::FileEntryList contents; |
| 235 FileSystemURL url = CreateURL(""); | 234 FileSystemURL url = CreateURL(""); |
| 236 bool completed = false; | 235 bool completed = false; |
| 237 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 236 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 completed = false; | 336 completed = false; |
| 338 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 337 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 339 ASSERT_TRUE(completed); | 338 ASSERT_TRUE(completed); |
| 340 ASSERT_EQ(1u, contents.size()); | 339 ASSERT_EQ(1u, contents.size()); |
| 341 EXPECT_FALSE(contents.front().is_directory); | 340 EXPECT_FALSE(contents.front().is_directory); |
| 342 EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), | 341 EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), |
| 343 contents.front().name); | 342 contents.front().name); |
| 344 } | 343 } |
| 345 | 344 |
| 346 } // namespace itunes | 345 } // namespace itunes |
| OLD | NEW |