Index: chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc |
diff --git a/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc b/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc |
index 34f6f83d621872edbab5abf39c377bb7a58dea7b..bfc943ed38b843e11e5a8cef84abb69793ad0676 100644 |
--- a/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc |
+++ b/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc |
@@ -4,12 +4,53 @@ |
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h" |
+#include "base/run_loop.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/ui/app_list/app_list_service.h" |
+#include "chrome/browser/ui/app_list/app_list_service_impl.h" |
#include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
#include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
namespace test { |
+namespace { |
+ |
+class CreateProfileHelper { |
+ public: |
+ CreateProfileHelper() : profile_(NULL) {} |
+ |
+ Profile* CreateAsync() { |
+ ProfileManager* profile_manager = g_browser_process->profile_manager(); |
+ base::FilePath temp_profile_dir = |
+ profile_manager->user_data_dir().AppendASCII("Profile 1"); |
+ profile_manager->CreateProfileAsync( |
+ temp_profile_dir, |
+ base::Bind(&CreateProfileHelper::OnProfileCreated, |
+ base::Unretained(this)), |
+ base::string16(), |
+ base::string16(), |
+ std::string()); |
+ run_loop_.Run(); |
+ return profile_; |
+ } |
+ |
+ private: |
+ void OnProfileCreated(Profile* profile, Profile::CreateStatus status) { |
+ if (status == Profile::CREATE_STATUS_INITIALIZED) { |
+ profile_ = profile; |
+ run_loop_.Quit(); |
+ } |
+ } |
+ |
+ base::RunLoop run_loop_; |
+ Profile* profile_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CreateProfileHelper); |
+}; |
+ |
+} // namespace |
+ |
app_list::AppListModel* GetAppListModel(AppListService* service) { |
return app_list::AppListSyncableServiceFactory::GetForProfile( |
service->GetCurrentAppListProfile())->model(); |
@@ -20,4 +61,15 @@ AppListService* GetAppListService() { |
return AppListService::Get(chrome::GetActiveDesktop()); |
} |
+AppListServiceImpl* GetAppListServiceImpl() { |
+ // AppListServiceImpl is the only subclass of AppListService, which has pure |
+ // virtuals. So this must either be NULL, or an AppListServiceImpl. |
+ return static_cast<AppListServiceImpl*>(GetAppListService()); |
+} |
+ |
+Profile* CreateSecondProfileAsync() { |
+ CreateProfileHelper helper; |
+ return helper.CreateAsync(); |
+} |
+ |
} // namespace test |