| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~MockMediaFolderFinder() { |
| 60 destruction_callback_.Run(); | 60 destruction_callback_.Run(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual void StartScan() OVERRIDE { | 63 virtual void StartScan() override { |
| 64 started_callback_.Run(callback_); | 64 started_callback_.Run(callback_); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 FindFoldersStartedCallback started_callback_; | 68 FindFoldersStartedCallback started_callback_; |
| 69 base::Closure destruction_callback_; | 69 base::Closure destruction_callback_; |
| 70 MediaFolderFinderResultsCallback callback_; | 70 MediaFolderFinderResultsCallback callback_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(MockMediaFolderFinder); | 72 DISALLOW_COPY_AND_ASSIGN(MockMediaFolderFinder); |
| 73 }; | 73 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 : find_folders_start_count_(0), | 96 : find_folders_start_count_(0), |
| 97 find_folders_destroy_count_(0), | 97 find_folders_destroy_count_(0), |
| 98 find_folders_success_(false), | 98 find_folders_success_(false), |
| 99 expected_gallery_count_(0), | 99 expected_gallery_count_(0), |
| 100 profile_(new TestingProfile()) {} | 100 profile_(new TestingProfile()) {} |
| 101 | 101 |
| 102 virtual ~MediaScanManagerTest() { | 102 virtual ~MediaScanManagerTest() { |
| 103 EXPECT_EQ(find_folders_start_count_, find_folders_destroy_count_); | 103 EXPECT_EQ(find_folders_start_count_, find_folders_destroy_count_); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual void SetUp() OVERRIDE { | 106 virtual void SetUp() override { |
| 107 ASSERT_TRUE(storage_monitor::TestStorageMonitor::CreateAndInstall()); | 107 ASSERT_TRUE(storage_monitor::TestStorageMonitor::CreateAndInstall()); |
| 108 | 108 |
| 109 extensions::TestExtensionSystem* extension_system( | 109 extensions::TestExtensionSystem* extension_system( |
| 110 static_cast<extensions::TestExtensionSystem*>( | 110 static_cast<extensions::TestExtensionSystem*>( |
| 111 extensions::ExtensionSystem::Get(profile_.get()))); | 111 extensions::ExtensionSystem::Get(profile_.get()))); |
| 112 extension_system->CreateExtensionService( | 112 extension_system->CreateExtensionService( |
| 113 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 113 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 114 | 114 |
| 115 gallery_prefs_ = | 115 gallery_prefs_ = |
| 116 MediaGalleriesPreferencesFactory::GetForProfile(profile_.get()); | 116 MediaGalleriesPreferencesFactory::GetForProfile(profile_.get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 131 base::Closure destruction_callback = | 131 base::Closure destruction_callback = |
| 132 base::Bind(&MediaScanManagerTest::OnFindFoldersDestroyed, | 132 base::Bind(&MediaScanManagerTest::OnFindFoldersDestroyed, |
| 133 base::Unretained(this)); | 133 base::Unretained(this)); |
| 134 TestMediaScanManager::MediaFolderFinderFactory factory = | 134 TestMediaScanManager::MediaFolderFinderFactory factory = |
| 135 base::Bind(&MockMediaFolderFinder::CreateMockMediaFolderFinder, | 135 base::Bind(&MockMediaFolderFinder::CreateMockMediaFolderFinder, |
| 136 started_callback, destruction_callback); | 136 started_callback, destruction_callback); |
| 137 media_scan_manager_.reset(new TestMediaScanManager(factory)); | 137 media_scan_manager_.reset(new TestMediaScanManager(factory)); |
| 138 media_scan_manager_->AddObserver(profile_.get(), this); | 138 media_scan_manager_->AddObserver(profile_.get(), this); |
| 139 } | 139 } |
| 140 | 140 |
| 141 virtual void TearDown() OVERRIDE { | 141 virtual void TearDown() override { |
| 142 media_scan_manager_->RemoveObserver(profile_.get()); | 142 media_scan_manager_->RemoveObserver(profile_.get()); |
| 143 media_scan_manager_.reset(); | 143 media_scan_manager_.reset(); |
| 144 storage_monitor::TestStorageMonitor::Destroy(); | 144 storage_monitor::TestStorageMonitor::Destroy(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Create a test folder in the test specific scoped temp dir and return the | 147 // Create a test folder in the test specific scoped temp dir and return the |
| 148 // final path in |full_path|. | 148 // final path in |full_path|. |
| 149 void MakeTestFolder(const std::string& root_relative_path, | 149 void MakeTestFolder(const std::string& root_relative_path, |
| 150 base::FilePath* full_path) { | 150 base::FilePath* full_path) { |
| 151 ASSERT_TRUE(test_results_dir_.IsValid()); | 151 ASSERT_TRUE(test_results_dir_.IsValid()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 known_galleries().find(pref_id); | 227 known_galleries().find(pref_id); |
| 228 EXPECT_EQ(audio_count, pref_info->second.audio_count); | 228 EXPECT_EQ(audio_count, pref_info->second.audio_count); |
| 229 EXPECT_EQ(image_count, pref_info->second.image_count); | 229 EXPECT_EQ(image_count, pref_info->second.image_count); |
| 230 EXPECT_EQ(video_count, pref_info->second.video_count); | 230 EXPECT_EQ(video_count, pref_info->second.video_count); |
| 231 } | 231 } |
| 232 | 232 |
| 233 // MediaScanManagerObserver implementation. | 233 // MediaScanManagerObserver implementation. |
| 234 virtual void OnScanFinished( | 234 virtual void OnScanFinished( |
| 235 const std::string& extension_id, | 235 const std::string& extension_id, |
| 236 int gallery_count, | 236 int gallery_count, |
| 237 const MediaGalleryScanResult& file_counts) OVERRIDE { | 237 const MediaGalleryScanResult& file_counts) override { |
| 238 EXPECT_EQ(extension_->id(), extension_id); | 238 EXPECT_EQ(extension_->id(), extension_id); |
| 239 EXPECT_EQ(expected_gallery_count_, gallery_count); | 239 EXPECT_EQ(expected_gallery_count_, gallery_count); |
| 240 EXPECT_EQ(expected_file_counts_.audio_count, file_counts.audio_count); | 240 EXPECT_EQ(expected_file_counts_.audio_count, file_counts.audio_count); |
| 241 EXPECT_EQ(expected_file_counts_.image_count, file_counts.image_count); | 241 EXPECT_EQ(expected_file_counts_.image_count, file_counts.image_count); |
| 242 EXPECT_EQ(expected_file_counts_.video_count, file_counts.video_count); | 242 EXPECT_EQ(expected_file_counts_.video_count, file_counts.video_count); |
| 243 } | 243 } |
| 244 | 244 |
| 245 protected: | 245 protected: |
| 246 // So derived tests can access ...::FindContainerScanResults(). | 246 // So derived tests can access ...::FindContainerScanResults(). |
| 247 MediaFolderFinder::MediaFolderFinderResults FindContainerScanResults( | 247 MediaFolderFinder::MediaFolderFinderResults FindContainerScanResults( |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 file_counts.audio_count *= kGalleriesAdded; | 727 file_counts.audio_count *= kGalleriesAdded; |
| 728 file_counts.image_count *= kGalleriesAdded; | 728 file_counts.image_count *= kGalleriesAdded; |
| 729 file_counts.video_count *= kGalleriesAdded; | 729 file_counts.video_count *= kGalleriesAdded; |
| 730 SetExpectedScanResults(kGalleriesAdded, file_counts); | 730 SetExpectedScanResults(kGalleriesAdded, file_counts); |
| 731 StartScan(); | 731 StartScan(); |
| 732 | 732 |
| 733 base::RunLoop().RunUntilIdle(); | 733 base::RunLoop().RunUntilIdle(); |
| 734 EXPECT_EQ(1, FindFolderDestroyCount()); | 734 EXPECT_EQ(1, FindFolderDestroyCount()); |
| 735 EXPECT_EQ(galleries_before + kGalleriesAdded, gallery_count()); | 735 EXPECT_EQ(galleries_before + kGalleriesAdded, gallery_count()); |
| 736 } | 736 } |
| OLD | NEW |