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

Unified Diff: chrome/browser/ui/app_list/app_list_controller_browsertest.cc

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove binary changes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shell/app_list.cc ('k') | chrome/browser/ui/app_list/app_list_controller_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/app_list_controller_browsertest.cc
diff --git a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
index ce2d5b14daa48bb9ae8b0966a98e9ab313ad4cb9..ef0e746c6dff0f28ac1a3e1f0d24527b3c6647ce 100644
--- a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
+++ b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
-#include "base/files/scoped_temp_dir.h"
+#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
@@ -39,6 +39,18 @@ class AppListControllerBrowserTest : public InProcessBrowserTest {
AppListControllerBrowserTest()
: profile2_(NULL) {}
+ void InitSecondProfile() {
+ 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(&AppListControllerBrowserTest::OnProfileCreated,
+ this),
+ string16(), string16(), std::string());
+ content::RunMessageLoop(); // Will stop in OnProfileCreated().
+ }
+
void OnProfileCreated(Profile* profile, Profile::CreateStatus status) {
if (status == Profile::CREATE_STATUS_INITIALIZED) {
profile2_ = profile;
@@ -47,7 +59,6 @@ class AppListControllerBrowserTest : public InProcessBrowserTest {
}
protected:
- base::ScopedTempDir temp_profile_dir_;
Profile* profile2_;
private:
@@ -86,24 +97,76 @@ IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) {
}
IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir());
- profile_manager->CreateProfileAsync(
- temp_profile_dir_.path(),
- base::Bind(&AppListControllerBrowserTest::OnProfileCreated,
- this),
- string16(), string16(), std::string());
- content::RunMessageLoop(); // Will stop in OnProfileCreated().
+ InitSecondProfile();
AppListService* service = AppListService::Get();
+ scoped_ptr<test::AppListServiceTestApi> test_api(
+ test::AppListServiceTestApi::Create(chrome::HOST_DESKTOP_TYPE_NATIVE));
+ ASSERT_TRUE(service);
+ ASSERT_TRUE(test_api);
+
+ scoped_ptr<AppListControllerDelegate> controller(
+ service->CreateControllerDelegate());
+ ASSERT_TRUE(controller);
+
+ // Open the app list with the browser's profile.
ASSERT_FALSE(service->IsAppListVisible());
- service->ShowForProfile(browser()->profile());
+ controller->ShowForProfileByPath(browser()->profile()->GetPath());
+ app_list::AppListModel* model = test_api->GetAppListModel();
+ ASSERT_TRUE(model);
+ model->SetSignedIn(true);
+ base::RunLoop().RunUntilIdle();
+
ASSERT_TRUE(service->IsAppListVisible());
ASSERT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
- service->ShowForProfile(profile2_);
+
+ // Open the app list with the second profile.
+ controller->ShowForProfileByPath(profile2_->GetPath());
+ model = test_api->GetAppListModel();
+ ASSERT_TRUE(model);
+ model->SetSignedIn(true);
+ base::RunLoop().RunUntilIdle();
+
ASSERT_TRUE(service->IsAppListVisible());
ASSERT_EQ(profile2_, service->GetCurrentAppListProfile());
- service->DismissAppList();
+
+ controller->DismissView();
+}
+
+IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest,
+ SwitchAppListProfilesDuringSearch) {
+ InitSecondProfile();
+
+ AppListService* service = AppListService::Get();
+ scoped_ptr<test::AppListServiceTestApi> test_api(
+ test::AppListServiceTestApi::Create(chrome::HOST_DESKTOP_TYPE_NATIVE));
+ ASSERT_TRUE(service);
+ ASSERT_TRUE(test_api);
+
+ scoped_ptr<AppListControllerDelegate> controller(
+ service->CreateControllerDelegate());
+ ASSERT_TRUE(controller);
+
+ // Set a search with original profile.
+ controller->ShowForProfileByPath(browser()->profile()->GetPath());
+ app_list::AppListModel* model = test_api->GetAppListModel();
+ ASSERT_TRUE(model);
+ model->SetSignedIn(true);
+ model->search_box()->SetText(ASCIIToUTF16("minimal"));
+ base::RunLoop().RunUntilIdle();
+
+ // Switch to the second profile.
+ controller->ShowForProfileByPath(profile2_->GetPath());
+ model = test_api->GetAppListModel();
+ ASSERT_TRUE(model);
+ model->SetSignedIn(true);
+ base::RunLoop().RunUntilIdle();
+
+ // Ensure the search box is empty.
+ ASSERT_TRUE(model->search_box()->text().empty());
+ ASSERT_EQ(profile2_, service->GetCurrentAppListProfile());
+
+ controller->DismissView();
ASSERT_FALSE(service->IsAppListVisible());
}
« no previous file with comments | « ash/shell/app_list.cc ('k') | chrome/browser/ui/app_list/app_list_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698