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

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

Issue 24269007: Media Galleries API: Fix MediaGalleriesPreferences finders race. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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/run_loop.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/extensions/extension_system.h" 15 #include "chrome/browser/extensions/extension_system.h"
15 #include "chrome/browser/extensions/test_extension_system.h" 16 #include "chrome/browser/extensions/test_extension_system.h"
16 #include "chrome/browser/media_galleries/media_file_system_registry.h" 17 #include "chrome/browser/media_galleries/media_file_system_registry.h"
17 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 18 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
18 #include "chrome/browser/storage_monitor/media_storage_util.h" 19 #include "chrome/browser/storage_monitor/media_storage_util.h"
19 #include "chrome/browser/storage_monitor/storage_monitor.h" 20 #include "chrome/browser/storage_monitor/storage_monitor.h"
20 #include "chrome/browser/storage_monitor/test_storage_monitor.h" 21 #include "chrome/browser/storage_monitor/test_storage_monitor.h"
21 #include "chrome/common/extensions/background_info.h" 22 #include "chrome/common/extensions/background_info.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 virtual void SetUp() OVERRIDE { 104 virtual void SetUp() OVERRIDE {
104 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); 105 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall());
105 106
106 extensions::TestExtensionSystem* extension_system( 107 extensions::TestExtensionSystem* extension_system(
107 static_cast<extensions::TestExtensionSystem*>( 108 static_cast<extensions::TestExtensionSystem*>(
108 extensions::ExtensionSystem::Get(profile_.get()))); 109 extensions::ExtensionSystem::Get(profile_.get())));
109 extension_system->CreateExtensionService( 110 extension_system->CreateExtensionService(
110 CommandLine::ForCurrentProcess(), base::FilePath(), false); 111 CommandLine::ForCurrentProcess(), base::FilePath(), false);
111 112
112 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); 113 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get()));
114 base::RunLoop loop;
115 gallery_prefs_->EnsureInitialized(loop.QuitClosure());
116 loop.Run();
113 117
114 // Load the default galleries into the expectations. 118 // Load the default galleries into the expectations.
115 const MediaGalleriesPrefInfoMap& known_galleries = 119 const MediaGalleriesPrefInfoMap& known_galleries =
116 gallery_prefs_->known_galleries(); 120 gallery_prefs_->known_galleries();
117 if (known_galleries.size()) { 121 if (known_galleries.size()) {
118 ASSERT_EQ(3U, known_galleries.size()); 122 ASSERT_EQ(3U, known_galleries.size());
119 default_galleries_count_ = 3; 123 default_galleries_count_ = 3;
120 MediaGalleriesPrefInfoMap::const_iterator it; 124 MediaGalleriesPrefInfoMap::const_iterator it;
121 for (it = known_galleries.begin(); it != known_galleries.end(); ++it) { 125 for (it = known_galleries.begin(); it != known_galleries.end(); ++it) {
122 expected_galleries_[it->first] = it->second; 126 expected_galleries_[it->first] = it->second;
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 info.volume_label = string16(); 867 info.volume_label = string16();
864 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName()); 868 EXPECT_EQ(ASCIIToUTF16("vendor, model"), info.GetGalleryDisplayName());
865 869
866 info.device_id = StorageInfo::MakeDeviceId( 870 info.device_id = StorageInfo::MakeDeviceId(
867 StorageInfo::FIXED_MASS_STORAGE, "unique"); 871 StorageInfo::FIXED_MASS_STORAGE, "unique");
868 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(), 872 EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("unique")).AsUTF8Unsafe(),
869 UTF16ToUTF8(info.GetGalleryTooltip())); 873 UTF16ToUTF8(info.GetGalleryTooltip()));
870 874
871 TestStorageMonitor::RemoveSingleton(); 875 TestStorageMonitor::RemoveSingleton();
872 } 876 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698