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 874f47fb44ba33d9219c00d0a537ca4b08362e69..77caf7e2616105fb12af7adbf74e5df8cf3958e3 100644 |
--- a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc |
+++ b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc |
@@ -44,6 +44,50 @@ IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, CreateNewWindow) { |
browser()->profile()->GetOffTheRecordProfile(), desktop)); |
} |
+// Test creating the app list for an incognito version of the current profile. |
+IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, RegularThenIncognito) { |
+ AppListService* service = test::GetAppListService(); |
+ // On Ash, the app list always has a profile. |
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
+ EXPECT_TRUE(service->GetCurrentAppListProfile()); |
+ else |
+ EXPECT_FALSE(service->GetCurrentAppListProfile()); |
+ |
+ service->ShowForProfile(browser()->profile()); |
+ EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile()); |
+ |
+ AppListControllerDelegate* controller = service->GetControllerDelegate(); |
+ service->ShowForProfile(browser()->profile()->GetOffTheRecordProfile()); |
+ |
+ // Should be showing the same profile. |
+ EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile()); |
+ |
+ // Should not have been reconstructed. |
+ EXPECT_EQ(controller, service->GetControllerDelegate()); |
+ |
+ // Same set of tests using ShowForAppInstall, which the webstore uses and was |
+ // traditionally where issues with incognito-mode app launchers started. Pass |
+ // true for start_discovery_tracking to emulate what the webstore does on the |
+ // first app install, to cover AppListServiceImpl::CreateForProfile(). |
+ service->ShowForAppInstall( |
+ browser()->profile()->GetOffTheRecordProfile(), "", true); |
+ EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile()); |
+ EXPECT_EQ(controller, service->GetControllerDelegate()); |
+} |
+ |
+// Test creating the initial app list for incognito profile. |
+IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, Incognito) { |
+ AppListService* service = test::GetAppListService(); |
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) |
+ EXPECT_TRUE(service->GetCurrentAppListProfile()); |
+ else |
+ EXPECT_FALSE(service->GetCurrentAppListProfile()); |
+ |
+ service->ShowForProfile(browser()->profile()->GetOffTheRecordProfile()); |
+ // Initial load should have picked the non-incongito profile. |
+ EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile()); |
+} |
+ |
// Browser Test for AppListController that observes search result changes. |
class AppListControllerSearchResultsBrowserTest |
: public ExtensionBrowserTest, |