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.h" | 12 #include "base/message_loop.h" |
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" | |
22 #include "chrome/common/extensions/background_info.h" | 21 #include "chrome/common/extensions/background_info.h" |
23 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
24 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
25 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread.h" |
26 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
27 #include "sync/api/string_ordinal.h" | 26 #include "sync/api/string_ordinal.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
29 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
30 | 29 |
31 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 base::MessageLoop loop_; | 240 base::MessageLoop loop_; |
242 content::TestBrowserThread ui_thread_; | 241 content::TestBrowserThread ui_thread_; |
243 content::TestBrowserThread file_thread_; | 242 content::TestBrowserThread file_thread_; |
244 | 243 |
245 #if defined OS_CHROMEOS | 244 #if defined OS_CHROMEOS |
246 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 245 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
247 chromeos::ScopedTestCrosSettings test_cros_settings_; | 246 chromeos::ScopedTestCrosSettings test_cros_settings_; |
248 chromeos::ScopedTestUserManager test_user_manager_; | 247 chromeos::ScopedTestUserManager test_user_manager_; |
249 #endif | 248 #endif |
250 | 249 |
251 test::TestStorageMonitor monitor_; | |
252 scoped_ptr<TestingProfile> profile_; | 250 scoped_ptr<TestingProfile> profile_; |
253 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; | 251 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; |
254 | 252 |
255 uint64 default_galleries_count_; | 253 uint64 default_galleries_count_; |
256 | 254 |
257 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferencesTest); | 255 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPreferencesTest); |
258 }; | 256 }; |
259 | 257 |
260 base::FilePath MakePath(std::string dir) { | 258 base::FilePath MakePath(std::string dir) { |
261 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 Verify(); | 803 Verify(); |
806 EXPECT_EQ(1, observer.notifications()); | 804 EXPECT_EQ(1, observer.notifications()); |
807 | 805 |
808 // No gallery for type. | 806 // No gallery for type. |
809 std::string new_device_id = | 807 std::string new_device_id = |
810 StorageInfo::MakeDeviceId(StorageInfo::PICASA, path.AsUTF8Unsafe()); | 808 StorageInfo::MakeDeviceId(StorageInfo::PICASA, path.AsUTF8Unsafe()); |
811 EXPECT_FALSE(UpdateDeviceIDForSingletonType(new_device_id)); | 809 EXPECT_FALSE(UpdateDeviceIDForSingletonType(new_device_id)); |
812 } | 810 } |
813 | 811 |
814 TEST(MediaGalleryPrefInfoTest, NameGeneration) { | 812 TEST(MediaGalleryPrefInfoTest, NameGeneration) { |
815 test::TestStorageMonitor monitor; | 813 test::TestStorageMonitor monitor; |
Lei Zhang
2013/06/27 00:09:38
TestStorageMonitor still used here although the #i
Greg Billock
2013/06/27 18:25:43
Oops. Shouldn't need it.
| |
816 | 814 |
817 MediaGalleryPrefInfo info; | 815 MediaGalleryPrefInfo info; |
818 info.pref_id = 1; | 816 info.pref_id = 1; |
819 info.display_name = ASCIIToUTF16("override"); | 817 info.display_name = ASCIIToUTF16("override"); |
820 info.device_id = StorageInfo::MakeDeviceId( | 818 info.device_id = StorageInfo::MakeDeviceId( |
821 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, "unique"); | 819 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, "unique"); |
822 | 820 |
823 EXPECT_EQ(ASCIIToUTF16("override"), info.GetGalleryDisplayName()); | 821 EXPECT_EQ(ASCIIToUTF16("override"), info.GetGalleryDisplayName()); |
824 | 822 |
825 info.display_name = ASCIIToUTF16("o2"); | 823 info.display_name = ASCIIToUTF16("o2"); |
(...skipping 21 matching lines...) Expand all Loading... | |
847 info.volume_label = string16(); | 845 info.volume_label = string16(); |
848 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); | 846 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); |
849 | 847 |
850 info.device_id = StorageInfo::MakeDeviceId( | 848 info.device_id = StorageInfo::MakeDeviceId( |
851 StorageInfo::FIXED_MASS_STORAGE, "unique"); | 849 StorageInfo::FIXED_MASS_STORAGE, "unique"); |
852 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), | 850 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), |
853 UTF16ToUTF8(info.GetGalleryTooltip())); | 851 UTF16ToUTF8(info.GetGalleryTooltip())); |
854 } | 852 } |
855 | 853 |
856 } // namespace chrome | 854 } // namespace chrome |
OLD | NEW |