Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // MediaGalleriesPreferences unit tests. | 5 // MediaGalleriesPreferences unit tests. |
| 6 | 6 |
| 7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
|
Lei Zhang
2013/08/09 21:32:03
No longer used -> remove?
| |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/extensions/test_extension_system.h" | 16 #include "chrome/browser/extensions/test_extension_system.h" |
| 17 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 17 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 18 #include "chrome/browser/media_galleries/media_galleries_test_util.h" | 18 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
| 19 #include "chrome/browser/storage_monitor/media_storage_util.h" | 19 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 20 #include "chrome/browser/storage_monitor/storage_monitor.h" | 20 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 21 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 21 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 22 #include "chrome/common/extensions/background_info.h" | 22 #include "chrome/common/extensions/background_info.h" |
| 23 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
| 25 #include "content/public/test/test_browser_thread.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "sync/api/string_ordinal.h" | 27 #include "sync/api/string_ordinal.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 | 30 |
| 31 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
| 32 #include "chrome/browser/chromeos/login/user_manager.h" | 32 #include "chrome/browser/chromeos/login/user_manager.h" |
| 33 #include "chrome/browser/chromeos/settings/cros_settings.h" | 33 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 34 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 34 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 35 #endif | 35 #endif |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 class MediaGalleriesPreferencesTest : public testing::Test { | 69 class MediaGalleriesPreferencesTest : public testing::Test { |
| 70 public: | 70 public: |
| 71 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> | 71 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> |
| 72 DeviceIdPrefIdsMap; | 72 DeviceIdPrefIdsMap; |
| 73 | 73 |
| 74 MediaGalleriesPreferencesTest() | 74 MediaGalleriesPreferencesTest() |
| 75 : ui_thread_(content::BrowserThread::UI, &loop_), | 75 : profile_(new TestingProfile()), |
| 76 file_thread_(content::BrowserThread::FILE, &loop_), | |
| 77 profile_(new TestingProfile()), | |
| 78 default_galleries_count_(0) { | 76 default_galleries_count_(0) { |
| 79 } | 77 } |
| 80 | 78 |
| 81 virtual ~MediaGalleriesPreferencesTest() { | 79 virtual ~MediaGalleriesPreferencesTest() { |
| 82 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile | |
| 83 // and then run the message queue to clean up. | |
| 84 profile_.reset(); | |
| 85 base::MessageLoop::current()->RunUntilIdle(); | |
| 86 } | 80 } |
| 87 | 81 |
| 88 virtual void SetUp() OVERRIDE { | 82 virtual void SetUp() OVERRIDE { |
| 89 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); | 83 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); |
| 90 | 84 |
| 91 extensions::TestExtensionSystem* extension_system( | 85 extensions::TestExtensionSystem* extension_system( |
| 92 static_cast<extensions::TestExtensionSystem*>( | 86 static_cast<extensions::TestExtensionSystem*>( |
| 93 extensions::ExtensionSystem::Get(profile_.get()))); | 87 extensions::ExtensionSystem::Get(profile_.get()))); |
| 94 extension_system->CreateExtensionService( | 88 extension_system->CreateExtensionService( |
| 95 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 89 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 | 227 |
| 234 std::set<MediaGalleryPrefId> expected_galleries_for_all; | 228 std::set<MediaGalleryPrefId> expected_galleries_for_all; |
| 235 std::set<MediaGalleryPrefId> expected_galleries_for_regular; | 229 std::set<MediaGalleryPrefId> expected_galleries_for_regular; |
| 236 | 230 |
| 237 DeviceIdPrefIdsMap expected_device_map; | 231 DeviceIdPrefIdsMap expected_device_map; |
| 238 | 232 |
| 239 MediaGalleriesPrefInfoMap expected_galleries_; | 233 MediaGalleriesPrefInfoMap expected_galleries_; |
| 240 | 234 |
| 241 private: | 235 private: |
| 242 // Needed for extension service & friends to work. | 236 // Needed for extension service & friends to work. |
| 243 base::MessageLoop loop_; | 237 content::TestBrowserThreadBundle thread_bundle_; |
| 244 content::TestBrowserThread ui_thread_; | |
| 245 content::TestBrowserThread file_thread_; | |
| 246 | 238 |
| 247 #if defined OS_CHROMEOS | 239 #if defined OS_CHROMEOS |
| 248 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 240 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 249 chromeos::ScopedTestCrosSettings test_cros_settings_; | 241 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 250 chromeos::ScopedTestUserManager test_user_manager_; | 242 chromeos::ScopedTestUserManager test_user_manager_; |
| 251 #endif | 243 #endif |
| 252 | 244 |
| 253 test::TestStorageMonitor monitor_; | 245 test::TestStorageMonitor monitor_; |
| 254 scoped_ptr<TestingProfile> profile_; | 246 scoped_ptr<TestingProfile> profile_; |
| 255 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; | 247 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 info.volume_label = string16(); | 841 info.volume_label = string16(); |
| 850 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); | 842 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); |
| 851 | 843 |
| 852 info.device_id = StorageInfo::MakeDeviceId( | 844 info.device_id = StorageInfo::MakeDeviceId( |
| 853 StorageInfo::FIXED_MASS_STORAGE, "unique"); | 845 StorageInfo::FIXED_MASS_STORAGE, "unique"); |
| 854 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), | 846 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), |
| 855 UTF16ToUTF8(info.GetGalleryTooltip())); | 847 UTF16ToUTF8(info.GetGalleryTooltip())); |
| 856 } | 848 } |
| 857 | 849 |
| 858 } // namespace chrome | 850 } // namespace chrome |
| OLD | NEW |