Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: chrome/browser/media_galleries/media_galleries_preferences_unittest.cc

Issue 22625008: Use TestBrowserThreadBundle in MediaGalleriesPreferences tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed unused include Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/extensions/extension_system.h" 14 #include "chrome/browser/extensions/extension_system.h"
16 #include "chrome/browser/extensions/test_extension_system.h" 15 #include "chrome/browser/extensions/test_extension_system.h"
17 #include "chrome/browser/media_galleries/media_file_system_registry.h" 16 #include "chrome/browser/media_galleries/media_file_system_registry.h"
18 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 17 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
19 #include "chrome/browser/storage_monitor/media_storage_util.h" 18 #include "chrome/browser/storage_monitor/media_storage_util.h"
20 #include "chrome/browser/storage_monitor/storage_monitor.h" 19 #include "chrome/browser/storage_monitor/storage_monitor.h"
21 #include "chrome/browser/storage_monitor/test_storage_monitor.h" 20 #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_bundle.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)
32 #include "chrome/browser/chromeos/login/user_manager.h" 31 #include "chrome/browser/chromeos/login/user_manager.h"
33 #include "chrome/browser/chromeos/settings/cros_settings.h" 32 #include "chrome/browser/chromeos/settings/cros_settings.h"
34 #include "chrome/browser/chromeos/settings/device_settings_service.h" 33 #include "chrome/browser/chromeos/settings/device_settings_service.h"
35 #endif 34 #endif
(...skipping 29 matching lines...) Expand all
65 }; 64 };
66 65
67 } // namespace 66 } // namespace
68 67
69 class MediaGalleriesPreferencesTest : public testing::Test { 68 class MediaGalleriesPreferencesTest : public testing::Test {
70 public: 69 public:
71 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> 70 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet>
72 DeviceIdPrefIdsMap; 71 DeviceIdPrefIdsMap;
73 72
74 MediaGalleriesPreferencesTest() 73 MediaGalleriesPreferencesTest()
75 : ui_thread_(content::BrowserThread::UI, &loop_), 74 : profile_(new TestingProfile()),
76 file_thread_(content::BrowserThread::FILE, &loop_),
77 profile_(new TestingProfile()),
78 default_galleries_count_(0) { 75 default_galleries_count_(0) {
79 } 76 }
80 77
81 virtual ~MediaGalleriesPreferencesTest() { 78 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 } 79 }
87 80
88 virtual void SetUp() OVERRIDE { 81 virtual void SetUp() OVERRIDE {
89 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); 82 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall());
90 83
91 extensions::TestExtensionSystem* extension_system( 84 extensions::TestExtensionSystem* extension_system(
92 static_cast<extensions::TestExtensionSystem*>( 85 static_cast<extensions::TestExtensionSystem*>(
93 extensions::ExtensionSystem::Get(profile_.get()))); 86 extensions::ExtensionSystem::Get(profile_.get())));
94 extension_system->CreateExtensionService( 87 extension_system->CreateExtensionService(
95 CommandLine::ForCurrentProcess(), base::FilePath(), false); 88 CommandLine::ForCurrentProcess(), base::FilePath(), false);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 226
234 std::set<MediaGalleryPrefId> expected_galleries_for_all; 227 std::set<MediaGalleryPrefId> expected_galleries_for_all;
235 std::set<MediaGalleryPrefId> expected_galleries_for_regular; 228 std::set<MediaGalleryPrefId> expected_galleries_for_regular;
236 229
237 DeviceIdPrefIdsMap expected_device_map; 230 DeviceIdPrefIdsMap expected_device_map;
238 231
239 MediaGalleriesPrefInfoMap expected_galleries_; 232 MediaGalleriesPrefInfoMap expected_galleries_;
240 233
241 private: 234 private:
242 // Needed for extension service & friends to work. 235 // Needed for extension service & friends to work.
243 base::MessageLoop loop_; 236 content::TestBrowserThreadBundle thread_bundle_;
244 content::TestBrowserThread ui_thread_;
245 content::TestBrowserThread file_thread_;
246 237
247 #if defined OS_CHROMEOS 238 #if defined OS_CHROMEOS
248 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 239 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
249 chromeos::ScopedTestCrosSettings test_cros_settings_; 240 chromeos::ScopedTestCrosSettings test_cros_settings_;
250 chromeos::ScopedTestUserManager test_user_manager_; 241 chromeos::ScopedTestUserManager test_user_manager_;
251 #endif 242 #endif
252 243
253 test::TestStorageMonitor monitor_; 244 test::TestStorageMonitor monitor_;
254 scoped_ptr<TestingProfile> profile_; 245 scoped_ptr<TestingProfile> profile_;
255 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; 246 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_;
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 info.volume_label = string16(); 840 info.volume_label = string16();
850 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); 841 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName());
851 842
852 info.device_id = StorageInfo::MakeDeviceId( 843 info.device_id = StorageInfo::MakeDeviceId(
853 StorageInfo::FIXED_MASS_STORAGE, "unique"); 844 StorageInfo::FIXED_MASS_STORAGE, "unique");
854 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), 845 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(),
855 UTF16ToUTF8(info.GetGalleryTooltip())); 846 UTF16ToUTF8(info.GetGalleryTooltip()));
856 } 847 }
857 848
858 } // namespace chrome 849 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698