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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_apitest.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, 3 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 26 matching lines...) Expand all
37 #endif 37 #endif
38 38
39 const char kTestGalleries[] = "testGalleries(%d)"; 39 const char kTestGalleries[] = "testGalleries(%d)";
40 40
41 } // namespace 41 } // namespace
42 42
43 // This function is to ensure at least one (fake) media gallery exists for 43 // This function is to ensure at least one (fake) media gallery exists for
44 // testing platforms with no default media galleries, such as CHROMEOS. 44 // testing platforms with no default media galleries, such as CHROMEOS.
45 void MakeFakeMediaGalleryForTest(Profile* profile, const base::FilePath& path) { 45 void MakeFakeMediaGalleryForTest(Profile* profile, const base::FilePath& path) {
46 base::RunLoop runloop; 46 base::RunLoop runloop;
47 StorageMonitor::GetInstance()->EnsureInitialized(runloop.QuitClosure());
48 runloop.Run();
49
50 MediaGalleriesPreferences* preferences = 47 MediaGalleriesPreferences* preferences =
51 g_browser_process->media_file_system_registry()->GetPreferences(profile); 48 g_browser_process->media_file_system_registry()->GetPreferences(profile);
49 preferences->EnsureInitialized(runloop.QuitClosure());
50 runloop.Run();
52 51
53 MediaGalleryPrefInfo gallery_info; 52 MediaGalleryPrefInfo gallery_info;
54 ASSERT_FALSE(preferences->LookUpGalleryByPath(path, &gallery_info)); 53 ASSERT_FALSE(preferences->LookUpGalleryByPath(path, &gallery_info));
55 preferences->AddGallery(gallery_info.device_id, 54 preferences->AddGallery(gallery_info.device_id,
56 gallery_info.path, 55 gallery_info.path,
57 false /* user_added */, 56 false /* user_added */,
58 gallery_info.volume_label, 57 gallery_info.volume_label,
59 gallery_info.vendor_name, 58 gallery_info.vendor_name,
60 gallery_info.model_name, 59 gallery_info.model_name,
61 gallery_info.total_size_in_bytes, 60 gallery_info.total_size_in_bytes,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 165
167 DetachFakeDevice(); 166 DetachFakeDevice();
168 } 167 }
169 168
170 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, 169 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
171 GetFilesystemMetadata) { 170 GetFilesystemMetadata) {
172 EnsureMediaDirectoriesExists media_directories; 171 EnsureMediaDirectoriesExists media_directories;
173 ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/metadata")) 172 ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/metadata"))
174 << message_; 173 << message_;
175 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698