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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 class TestITunesDataProvider : public ITunesDataProvider { | 67 class TestITunesDataProvider : public ITunesDataProvider { |
68 public: | 68 public: |
69 explicit TestITunesDataProvider(const base::FilePath& fake_library_path) | 69 explicit TestITunesDataProvider(const base::FilePath& fake_library_path) |
70 : ITunesDataProvider(fake_library_path) { | 70 : ITunesDataProvider(fake_library_path) { |
71 EXPECT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); | 71 EXPECT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); |
72 } | 72 } |
73 | 73 |
74 virtual ~TestITunesDataProvider() {} | 74 virtual ~TestITunesDataProvider() {} |
75 | 75 |
76 virtual void RefreshData(const ReadyCallback& ready_callback) OVERRIDE { | 76 virtual void RefreshData(const ReadyCallback& ready_callback) override { |
77 ready_callback.Run(true /* success */); | 77 ready_callback.Run(true /* success */); |
78 } | 78 } |
79 | 79 |
80 virtual const base::FilePath& auto_add_path() const OVERRIDE { | 80 virtual const base::FilePath& auto_add_path() const override { |
81 return fake_auto_add_dir_.path(); | 81 return fake_auto_add_dir_.path(); |
82 } | 82 } |
83 | 83 |
84 void SetProvideAutoAddDir(bool provide_auto_add_dir) { | 84 void SetProvideAutoAddDir(bool provide_auto_add_dir) { |
85 if (provide_auto_add_dir) { | 85 if (provide_auto_add_dir) { |
86 if (!fake_auto_add_dir_.IsValid()) | 86 if (!fake_auto_add_dir_.IsValid()) |
87 ASSERT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); | 87 ASSERT_TRUE(fake_auto_add_dir_.CreateUniqueTempDir()); |
88 } else { | 88 } else { |
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(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 : public MediaFileSystemBackend { | 114 class TestMediaFileSystemBackend : public MediaFileSystemBackend { |
115 public: | 115 public: |
116 TestMediaFileSystemBackend(const base::FilePath& profile_path, | 116 TestMediaFileSystemBackend(const base::FilePath& profile_path, |
117 ITunesFileUtil* itunes_file_util) | 117 ITunesFileUtil* itunes_file_util) |
118 : MediaFileSystemBackend( | 118 : MediaFileSystemBackend( |
119 profile_path, | 119 profile_path, |
120 MediaFileSystemBackend::MediaTaskRunner().get()), | 120 MediaFileSystemBackend::MediaTaskRunner().get()), |
121 test_file_util_(itunes_file_util) {} | 121 test_file_util_(itunes_file_util) {} |
122 | 122 |
123 virtual storage::AsyncFileUtil* GetAsyncFileUtil( | 123 virtual storage::AsyncFileUtil* GetAsyncFileUtil( |
124 storage::FileSystemType type) OVERRIDE { | 124 storage::FileSystemType type) override { |
125 if (type != storage::kFileSystemTypeItunes) | 125 if (type != storage::kFileSystemTypeItunes) |
126 return NULL; | 126 return NULL; |
127 | 127 |
128 return test_file_util_.get(); | 128 return test_file_util_.get(); |
129 } | 129 } |
130 | 130 |
131 private: | 131 private: |
132 scoped_ptr<storage::AsyncFileUtil> test_file_util_; | 132 scoped_ptr<storage::AsyncFileUtil> test_file_util_; |
133 }; | 133 }; |
134 | 134 |
(...skipping 10 matching lines...) Expand all Loading... |
145 0, | 145 0, |
146 base::WriteFile( | 146 base::WriteFile( |
147 fake_library_dir_.path().AppendASCII(kITunesLibraryXML), | 147 fake_library_dir_.path().AppendASCII(kITunesLibraryXML), |
148 NULL, | 148 NULL, |
149 0)); | 149 0)); |
150 | 150 |
151 itunes_data_provider_.reset( | 151 itunes_data_provider_.reset( |
152 new TestITunesDataProvider(fake_library_dir_.path())); | 152 new TestITunesDataProvider(fake_library_dir_.path())); |
153 } | 153 } |
154 | 154 |
155 virtual void SetUp() OVERRIDE { | 155 virtual void SetUp() override { |
156 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 156 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
157 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); | 157 ImportedMediaGalleryRegistry::GetInstance()->Initialize(); |
158 | 158 |
159 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = | 159 scoped_refptr<storage::SpecialStoragePolicy> storage_policy = |
160 new content::MockSpecialStoragePolicy(); | 160 new content::MockSpecialStoragePolicy(); |
161 | 161 |
162 // Initialize fake ItunesDataProvider on media task runner thread. | 162 // Initialize fake ItunesDataProvider on media task runner thread. |
163 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 163 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
164 FROM_HERE, | 164 FROM_HERE, |
165 base::Bind(&ItunesFileUtilTest::SetUpDataProvider, | 165 base::Bind(&ItunesFileUtilTest::SetUpDataProvider, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 completed = false; | 343 completed = false; |
344 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 344 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
345 ASSERT_TRUE(completed); | 345 ASSERT_TRUE(completed); |
346 ASSERT_EQ(1u, contents.size()); | 346 ASSERT_EQ(1u, contents.size()); |
347 EXPECT_FALSE(contents.front().is_directory); | 347 EXPECT_FALSE(contents.front().is_directory); |
348 EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), | 348 EXPECT_EQ(base::FilePath().AppendASCII("baz.ogg").value(), |
349 contents.front().name); | 349 contents.front().name); |
350 } | 350 } |
351 | 351 |
352 } // namespace itunes | 352 } // namespace itunes |
OLD | NEW |