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

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, 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 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/safe_numerics.h" 9 #include "base/safe_numerics.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 21 matching lines...) Expand all
32 #else 32 #else
33 base::FilePath::CharType kDevicePath[] = FILE_PATH_LITERAL("/qux"); 33 base::FilePath::CharType kDevicePath[] = FILE_PATH_LITERAL("/qux");
34 #endif 34 #endif
35 35
36 } // namespace 36 } // namespace
37 37
38 // This function is to ensure at least one (fake) media gallery exists for 38 // This function is to ensure at least one (fake) media gallery exists for
39 // testing platforms with no default media galleries, such as CHROMEOS. 39 // testing platforms with no default media galleries, such as CHROMEOS.
40 void MakeFakeMediaGalleryForTest(Profile* profile, const base::FilePath& path) { 40 void MakeFakeMediaGalleryForTest(Profile* profile, const base::FilePath& path) {
41 base::RunLoop runloop; 41 base::RunLoop runloop;
42 StorageMonitor::GetInstance()->EnsureInitialized(runloop.QuitClosure());
43 runloop.Run();
44
45 MediaGalleriesPreferences* preferences = 42 MediaGalleriesPreferences* preferences =
46 g_browser_process->media_file_system_registry()->GetPreferences(profile); 43 g_browser_process->media_file_system_registry()->GetPreferences(profile);
44 preferences->EnsureInitialized(runloop.QuitClosure());
45 runloop.Run();
47 46
48 MediaGalleryPrefInfo gallery_info; 47 MediaGalleryPrefInfo gallery_info;
49 ASSERT_FALSE(preferences->LookUpGalleryByPath(path, &gallery_info)); 48 ASSERT_FALSE(preferences->LookUpGalleryByPath(path, &gallery_info));
50 preferences->AddGallery(gallery_info.device_id, 49 preferences->AddGallery(gallery_info.device_id,
51 gallery_info.path, 50 gallery_info.path,
52 false /* user_added */, 51 false /* user_added */,
53 gallery_info.volume_label, 52 gallery_info.volume_label,
54 gallery_info.vendor_name, 53 gallery_info.vendor_name,
55 gallery_info.model_name, 54 gallery_info.model_name,
56 gallery_info.total_size_in_bytes, 55 gallery_info.total_size_in_bytes,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT_TRUE(RunMediaGalleriesTestWithArg("access_attached", custom_args)) 200 ASSERT_TRUE(RunMediaGalleriesTestWithArg("access_attached", custom_args))
202 << message_; 201 << message_;
203 202
204 DetachFakeDevice(); 203 DetachFakeDevice();
205 } 204 }
206 205
207 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, 206 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest,
208 GetFilesystemMetadata) { 207 GetFilesystemMetadata) {
209 ASSERT_TRUE(RunMediaGalleriesTest("metadata")) << message_; 208 ASSERT_TRUE(RunMediaGalleriesTest("metadata")) << message_;
210 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698