| 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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 virtual ~MediaGalleriesPreferencesTest() { | 81 virtual ~MediaGalleriesPreferencesTest() { |
| 82 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile | 82 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile |
| 83 // and then run the message queue to clean up. | 83 // and then run the message queue to clean up. |
| 84 profile_.reset(); | 84 profile_.reset(); |
| 85 base::MessageLoop::current()->RunUntilIdle(); | 85 base::MessageLoop::current()->RunUntilIdle(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void SetUp() OVERRIDE { | 88 virtual void SetUp() OVERRIDE { |
| 89 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); |
| 90 |
| 89 extensions::TestExtensionSystem* extension_system( | 91 extensions::TestExtensionSystem* extension_system( |
| 90 static_cast<extensions::TestExtensionSystem*>( | 92 static_cast<extensions::TestExtensionSystem*>( |
| 91 extensions::ExtensionSystem::Get(profile_.get()))); | 93 extensions::ExtensionSystem::Get(profile_.get()))); |
| 92 extension_system->CreateExtensionService( | 94 extension_system->CreateExtensionService( |
| 93 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 95 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 94 | 96 |
| 95 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); | 97 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); |
| 96 | 98 |
| 97 // Load the default galleries into the expectations. | 99 // Load the default galleries into the expectations. |
| 98 const MediaGalleriesPrefInfoMap& known_galleries = | 100 const MediaGalleriesPrefInfoMap& known_galleries = |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 Verify(); | 807 Verify(); |
| 806 EXPECT_EQ(1, observer.notifications()); | 808 EXPECT_EQ(1, observer.notifications()); |
| 807 | 809 |
| 808 // No gallery for type. | 810 // No gallery for type. |
| 809 std::string new_device_id = | 811 std::string new_device_id = |
| 810 StorageInfo::MakeDeviceId(StorageInfo::PICASA, path.AsUTF8Unsafe()); | 812 StorageInfo::MakeDeviceId(StorageInfo::PICASA, path.AsUTF8Unsafe()); |
| 811 EXPECT_FALSE(UpdateDeviceIDForSingletonType(new_device_id)); | 813 EXPECT_FALSE(UpdateDeviceIDForSingletonType(new_device_id)); |
| 812 } | 814 } |
| 813 | 815 |
| 814 TEST(MediaGalleryPrefInfoTest, NameGeneration) { | 816 TEST(MediaGalleryPrefInfoTest, NameGeneration) { |
| 815 test::TestStorageMonitor monitor; | 817 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); |
| 816 | 818 |
| 817 MediaGalleryPrefInfo info; | 819 MediaGalleryPrefInfo info; |
| 818 info.pref_id = 1; | 820 info.pref_id = 1; |
| 819 info.display_name = ASCIIToUTF16("override"); | 821 info.display_name = ASCIIToUTF16("override"); |
| 820 info.device_id = StorageInfo::MakeDeviceId( | 822 info.device_id = StorageInfo::MakeDeviceId( |
| 821 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, "unique"); | 823 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, "unique"); |
| 822 | 824 |
| 823 EXPECT_EQ(ASCIIToUTF16("override"), info.GetGalleryDisplayName()); | 825 EXPECT_EQ(ASCIIToUTF16("override"), info.GetGalleryDisplayName()); |
| 824 | 826 |
| 825 info.display_name = ASCIIToUTF16("o2"); | 827 info.display_name = ASCIIToUTF16("o2"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 847 info.volume_label = string16(); | 849 info.volume_label = string16(); |
| 848 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); | 850 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); |
| 849 | 851 |
| 850 info.device_id = StorageInfo::MakeDeviceId( | 852 info.device_id = StorageInfo::MakeDeviceId( |
| 851 StorageInfo::FIXED_MASS_STORAGE, "unique"); | 853 StorageInfo::FIXED_MASS_STORAGE, "unique"); |
| 852 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), | 854 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), |
| 853 UTF16ToUTF8(info.GetGalleryTooltip())); | 855 UTF16ToUTF8(info.GetGalleryTooltip())); |
| 854 } | 856 } |
| 855 | 857 |
| 856 } // namespace chrome | 858 } // namespace chrome |
| OLD | NEW |