OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 MockMediaFolderFinder( | 50 MockMediaFolderFinder( |
51 const FindFoldersStartedCallback& started_callback, | 51 const FindFoldersStartedCallback& started_callback, |
52 const base::Closure destruction_callback, | 52 const base::Closure destruction_callback, |
53 const MediaFolderFinderResultsCallback& callback) | 53 const MediaFolderFinderResultsCallback& callback) |
54 : MediaFolderFinder(callback), | 54 : MediaFolderFinder(callback), |
55 started_callback_(started_callback), | 55 started_callback_(started_callback), |
56 destruction_callback_(destruction_callback), | 56 destruction_callback_(destruction_callback), |
57 callback_(callback) { | 57 callback_(callback) { |
58 } | 58 } |
59 virtual ~MockMediaFolderFinder() { | 59 ~MockMediaFolderFinder() override { destruction_callback_.Run(); } |
60 destruction_callback_.Run(); | |
61 } | |
62 | 60 |
63 virtual void StartScan() override { | 61 void StartScan() override { started_callback_.Run(callback_); } |
64 started_callback_.Run(callback_); | |
65 } | |
66 | 62 |
67 private: | 63 private: |
68 FindFoldersStartedCallback started_callback_; | 64 FindFoldersStartedCallback started_callback_; |
69 base::Closure destruction_callback_; | 65 base::Closure destruction_callback_; |
70 MediaFolderFinderResultsCallback callback_; | 66 MediaFolderFinderResultsCallback callback_; |
71 | 67 |
72 DISALLOW_COPY_AND_ASSIGN(MockMediaFolderFinder); | 68 DISALLOW_COPY_AND_ASSIGN(MockMediaFolderFinder); |
73 }; | 69 }; |
74 | 70 |
75 } // namespace | 71 } // namespace |
76 | 72 |
77 class TestMediaScanManager : public MediaScanManager { | 73 class TestMediaScanManager : public MediaScanManager { |
78 public: | 74 public: |
79 typedef base::Callback<MediaFolderFinder*( | 75 typedef base::Callback<MediaFolderFinder*( |
80 const MediaFolderFinder::MediaFolderFinderResultsCallback&)> | 76 const MediaFolderFinder::MediaFolderFinderResultsCallback&)> |
81 MediaFolderFinderFactory; | 77 MediaFolderFinderFactory; |
82 | 78 |
83 explicit TestMediaScanManager(const MediaFolderFinderFactory& factory) { | 79 explicit TestMediaScanManager(const MediaFolderFinderFactory& factory) { |
84 SetMediaFolderFinderFactory(factory); | 80 SetMediaFolderFinderFactory(factory); |
85 } | 81 } |
86 virtual ~TestMediaScanManager() {} | 82 ~TestMediaScanManager() override {} |
87 | 83 |
88 private: | 84 private: |
89 DISALLOW_COPY_AND_ASSIGN(TestMediaScanManager); | 85 DISALLOW_COPY_AND_ASSIGN(TestMediaScanManager); |
90 }; | 86 }; |
91 | 87 |
92 class MediaScanManagerTest : public MediaScanManagerObserver, | 88 class MediaScanManagerTest : public MediaScanManagerObserver, |
93 public testing::Test { | 89 public testing::Test { |
94 public: | 90 public: |
95 MediaScanManagerTest() | 91 MediaScanManagerTest() |
96 : find_folders_start_count_(0), | 92 : find_folders_start_count_(0), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 return; | 220 return; |
225 } | 221 } |
226 MediaGalleriesPrefInfoMap::const_iterator pref_info = | 222 MediaGalleriesPrefInfoMap::const_iterator pref_info = |
227 known_galleries().find(pref_id); | 223 known_galleries().find(pref_id); |
228 EXPECT_EQ(audio_count, pref_info->second.audio_count); | 224 EXPECT_EQ(audio_count, pref_info->second.audio_count); |
229 EXPECT_EQ(image_count, pref_info->second.image_count); | 225 EXPECT_EQ(image_count, pref_info->second.image_count); |
230 EXPECT_EQ(video_count, pref_info->second.video_count); | 226 EXPECT_EQ(video_count, pref_info->second.video_count); |
231 } | 227 } |
232 | 228 |
233 // MediaScanManagerObserver implementation. | 229 // MediaScanManagerObserver implementation. |
234 virtual void OnScanFinished( | 230 void OnScanFinished(const std::string& extension_id, |
235 const std::string& extension_id, | 231 int gallery_count, |
236 int gallery_count, | 232 const MediaGalleryScanResult& file_counts) override { |
237 const MediaGalleryScanResult& file_counts) override { | |
238 EXPECT_EQ(extension_->id(), extension_id); | 233 EXPECT_EQ(extension_->id(), extension_id); |
239 EXPECT_EQ(expected_gallery_count_, gallery_count); | 234 EXPECT_EQ(expected_gallery_count_, gallery_count); |
240 EXPECT_EQ(expected_file_counts_.audio_count, file_counts.audio_count); | 235 EXPECT_EQ(expected_file_counts_.audio_count, file_counts.audio_count); |
241 EXPECT_EQ(expected_file_counts_.image_count, file_counts.image_count); | 236 EXPECT_EQ(expected_file_counts_.image_count, file_counts.image_count); |
242 EXPECT_EQ(expected_file_counts_.video_count, file_counts.video_count); | 237 EXPECT_EQ(expected_file_counts_.video_count, file_counts.video_count); |
243 } | 238 } |
244 | 239 |
245 protected: | 240 protected: |
246 // So derived tests can access ...::FindContainerScanResults(). | 241 // So derived tests can access ...::FindContainerScanResults(). |
247 MediaFolderFinder::MediaFolderFinderResults FindContainerScanResults( | 242 MediaFolderFinder::MediaFolderFinderResults FindContainerScanResults( |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 file_counts.audio_count *= kGalleriesAdded; | 722 file_counts.audio_count *= kGalleriesAdded; |
728 file_counts.image_count *= kGalleriesAdded; | 723 file_counts.image_count *= kGalleriesAdded; |
729 file_counts.video_count *= kGalleriesAdded; | 724 file_counts.video_count *= kGalleriesAdded; |
730 SetExpectedScanResults(kGalleriesAdded, file_counts); | 725 SetExpectedScanResults(kGalleriesAdded, file_counts); |
731 StartScan(); | 726 StartScan(); |
732 | 727 |
733 base::RunLoop().RunUntilIdle(); | 728 base::RunLoop().RunUntilIdle(); |
734 EXPECT_EQ(1, FindFolderDestroyCount()); | 729 EXPECT_EQ(1, FindFolderDestroyCount()); |
735 EXPECT_EQ(galleries_before + kGalleriesAdded, gallery_count()); | 730 EXPECT_EQ(galleries_before + kGalleriesAdded, gallery_count()); |
736 } | 731 } |
OLD | NEW |