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 // MediaFileSystemRegistry unit tests. | 5 // MediaFileSystemRegistry unit tests. |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // delete everything that references the profile. | 467 // delete everything that references the profile. |
468 single_web_contents_.reset(); | 468 single_web_contents_.reset(); |
469 shared_web_contents1_.reset(); | 469 shared_web_contents1_.reset(); |
470 shared_web_contents2_.reset(); | 470 shared_web_contents2_.reset(); |
471 profile_.reset(); | 471 profile_.reset(); |
472 | 472 |
473 base::MessageLoop::current()->RunUntilIdle(); | 473 base::MessageLoop::current()->RunUntilIdle(); |
474 } | 474 } |
475 | 475 |
476 MediaGalleriesPreferences* ProfileState::GetMediaGalleriesPrefs() { | 476 MediaGalleriesPreferences* ProfileState::GetMediaGalleriesPrefs() { |
477 return MediaGalleriesPreferencesFactory::GetForProfile(profile_.get()); | 477 MediaGalleriesPreferences* prefs = |
| 478 MediaGalleriesPreferencesFactory::GetForProfile(profile_.get()); |
| 479 base::RunLoop loop; |
| 480 prefs->EnsureInitialized(loop.QuitClosure()); |
| 481 loop.Run(); |
| 482 return prefs; |
478 } | 483 } |
479 | 484 |
480 void ProfileState::CheckGalleries( | 485 void ProfileState::CheckGalleries( |
481 const std::string& test, | 486 const std::string& test, |
482 const std::vector<MediaFileSystemInfo>& regular_extension_galleries, | 487 const std::vector<MediaFileSystemInfo>& regular_extension_galleries, |
483 const std::vector<MediaFileSystemInfo>& all_extension_galleries) { | 488 const std::vector<MediaFileSystemInfo>& all_extension_galleries) { |
484 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); | 489 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); |
485 MediaFileSystemRegistry* registry = | 490 MediaFileSystemRegistry* registry = |
486 g_browser_process->media_file_system_registry(); | 491 g_browser_process->media_file_system_registry(); |
487 | 492 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 profile_states_.push_back(state); | 610 profile_states_.push_back(state); |
606 } | 611 } |
607 } | 612 } |
608 | 613 |
609 ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) { | 614 ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) { |
610 return profile_states_[i]; | 615 return profile_states_[i]; |
611 } | 616 } |
612 | 617 |
613 MediaGalleriesPreferences* MediaFileSystemRegistryTest::GetPreferences( | 618 MediaGalleriesPreferences* MediaFileSystemRegistryTest::GetPreferences( |
614 Profile* profile) { | 619 Profile* profile) { |
615 return registry()->GetPreferences(profile); | 620 MediaGalleriesPreferences* prefs = registry()->GetPreferences(profile); |
| 621 base::RunLoop loop; |
| 622 prefs->EnsureInitialized(loop.QuitClosure()); |
| 623 loop.Run(); |
| 624 return prefs; |
616 } | 625 } |
617 | 626 |
618 std::string MediaFileSystemRegistryTest::AddUserGallery( | 627 std::string MediaFileSystemRegistryTest::AddUserGallery( |
619 StorageInfo::Type type, | 628 StorageInfo::Type type, |
620 const std::string& unique_id, | 629 const std::string& unique_id, |
621 const base::FilePath& path) { | 630 const base::FilePath& path) { |
622 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); | 631 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); |
623 DCHECK(!StorageInfo::IsMediaDevice(device_id)); | 632 DCHECK(!StorageInfo::IsMediaDevice(device_id)); |
624 | 633 |
625 for (size_t i = 0; i < profile_states_.size(); ++i) { | 634 for (size_t i = 0; i < profile_states_.size(); ++i) { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); | 1063 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); |
1055 #else | 1064 #else |
1056 profile_state->AddNameForAllCompare(path.LossyDisplayName()); | 1065 profile_state->AddNameForAllCompare(path.LossyDisplayName()); |
1057 #endif | 1066 #endif |
1058 | 1067 |
1059 profile_state->CheckGalleries("names-dir", one_expectation, auto_galleries); | 1068 profile_state->CheckGalleries("names-dir", one_expectation, auto_galleries); |
1060 } else { | 1069 } else { |
1061 profile_state->CheckGalleries("names", one_expectation, one_expectation); | 1070 profile_state->CheckGalleries("names", one_expectation, one_expectation); |
1062 } | 1071 } |
1063 } | 1072 } |
OLD | NEW |