15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/app_list/app_list_service.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/command_line.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/json/json_file_value_serializer.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/message_loop/message_loop.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/path_service.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/browser_process.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/profiles/profile.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h" 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h" 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/browser.h" 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.h" 20116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/ui/startup/startup_browser_creator.h" 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/common/chrome_constants.h" 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/common/chrome_paths.h" 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/common/pref_names.h" 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/test/base/in_process_browser_test.h" 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/test/base/ui_test_utils.h" 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/app_list/app_list_model.h" 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/app_list/search_box_model.h" 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Interactive UI Test for AppListService that runs on all platforms supporting 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// app_list. Interactive because the app list uses focus changes to dismiss 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// itself, which will cause tests that check the visibility to fail flakily. 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AppListServiceInteractiveTest : public InProcessBrowserTest { 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListServiceInteractiveTest() 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : profile2_(NULL) {} 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci void InitSecondProfile() { profile2_ = test::CreateSecondProfileAsync(); } 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected: 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Profile* profile2_; 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AppListServiceInteractiveTest); 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// ChromeOS does not support ShowForProfile(), or profile switching within the 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// app list. Profile switching on CrOS goes through a different code path. 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(OS_CHROMEOS) 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_ShowAndDismiss DISABLED_ShowAndDismiss 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_SwitchAppListProfiles DISABLED_SwitchAppListProfiles 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_SwitchAppListProfilesDuringSearch \ 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISABLED_SwitchAppListProfilesDuringSearch 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_ShowAppListNonDefaultProfile \ 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISABLED_ShowAppListNonDefaultProfile 561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define MAYBE_DeleteShowingAppList DISABLED_DeleteShowingAppList 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#else 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_ShowAndDismiss ShowAndDismiss 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_SwitchAppListProfiles SwitchAppListProfiles 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_SwitchAppListProfilesDuringSearch \ 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SwitchAppListProfilesDuringSearch 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MAYBE_ShowAppListNonDefaultProfile ShowAppListNonDefaultProfile 631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define MAYBE_DeleteShowingAppList DeleteShowingAppList 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Show the app list, then dismiss it. 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest, MAYBE_ShowAndDismiss) { 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListService* service = test::GetAppListService(); 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(service->IsAppListVisible()); 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) service->ShowForProfile(browser()->profile()); 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(service->IsAppListVisible()); 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) service->DismissAppList(); 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(service->IsAppListVisible()); 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Switch profiles on the app list while it is showing. 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest, 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MAYBE_SwitchAppListProfiles) { 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) InitSecondProfile(); 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListService* service = test::GetAppListService(); 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(service); 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListControllerDelegate* controller(service->GetControllerDelegate()); 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(controller); 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Open the app list with the browser's profile. 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(service->IsAppListVisible()); 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller->ShowForProfileByPath(browser()->profile()->GetPath()); 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) app_list::AppListModel* model = test::GetAppListModel(service); 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(model); 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::RunLoop().RunUntilIdle(); 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(service->IsAppListVisible()); 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_EQ(browser()->profile(), service->GetCurrentAppListProfile()); 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Open the app list with the second profile. 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller->ShowForProfileByPath(profile2_->GetPath()); 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) model = test::GetAppListModel(service); 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(model); 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::RunLoop().RunUntilIdle(); 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(service->IsAppListVisible()); 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_EQ(profile2_, service->GetCurrentAppListProfile()); 1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller->DismissView(); 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Test switching app list profiles while search results are visibile. 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(AppListServiceInteractiveTest, 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MAYBE_SwitchAppListProfilesDuringSearch) { 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) InitSecondProfile(); 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListService* service = test::GetAppListService(); 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(service); 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListControllerDelegate* controller(service->GetControllerDelegate()); 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(controller); 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set a search with original profile. 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller->ShowForProfileByPath(browser()->profile()->GetPath()); 1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) app_list::AppListModel* model = test::GetAppListModel(service); 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(model); 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) model->search_box()->SetText(base::ASCIIToUTF16("minimal")); 1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::RunLoop().RunUntilIdle(); 1285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Switch to the second profile. 1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller->ShowForProfileByPath(profile2_->GetPath()); 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) model = test::GetAppListModel(service); 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(model); 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::RunLoop().RunUntilIdle(); 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Ensure the search box is empty. 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(model->search_box()->text().empty()); 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_EQ(profile2_, service->GetCurrentAppListProfile()); 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller->DismissView(); 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_FALSE(service->IsAppListVisible()); 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Interactive UI test that adds the --show-app-list command line switch. 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ShowAppListInteractiveTest : public InProcessBrowserTest { 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShowAppListInteractiveTest() {} 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) command_line->AppendSwitch(switches::kShowAppList); 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ShowAppListInteractiveTest); 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Test showing the app list using the command line switch. 1575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if defined(OS_CHROMEOS) 1585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// http://crbug.com/396499 1595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#define MAYBE_ShowAppListFlag DISABLED_ShowAppListFlag 1605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#else 1615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#define MAYBE_ShowAppListFlag ShowAppListFlag 1625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif 1635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(ShowAppListInteractiveTest, MAYBE_ShowAppListFlag) { 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListService* service = test::GetAppListService(); 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The app list should already be shown because we passed 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // switches::kShowAppList. 167116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch EXPECT_TRUE(service->IsAppListVisible()); 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Create a browser to prevent shutdown when we dismiss the app list. We 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // need to do this because switches::kShowAppList suppresses the creation of 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // any browsers. 172116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch Profile* profile = service->GetCurrentAppListProfile(); 173116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch CreateBrowser(profile); 174116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 175116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch service->DismissAppList(); 176116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch EXPECT_FALSE(service->IsAppListVisible()); 177116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 178116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // With Chrome still running, test receiving a second --show-app-list request 179116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // via the process singleton. ChromeOS has no process singleton so exclude it. 180116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(OS_CHROMEOS) 181116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch CommandLine command_line(CommandLine::NO_PROGRAM); 182116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch command_line.AppendSwitch(switches::kShowAppList); 183116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch StartupBrowserCreator::ProcessCommandLineAlreadyRunning( 184116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch command_line, base::FilePath(), profile->GetPath()); 185116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 186116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch EXPECT_TRUE(service->IsAppListVisible()); 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) service->DismissAppList(); 188116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch EXPECT_FALSE(service->IsAppListVisible()); 189116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Interactive UI test that creates a non-default profile and configures it for 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// the --show-app-list flag. 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ShowAppListNonDefaultInteractiveTest : public ShowAppListInteractiveTest { 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShowAppListNonDefaultInteractiveTest() 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : second_profile_name_(FILE_PATH_LITERAL("Profile 1")) { 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual bool SetUpUserDataDirectory() OVERRIDE { 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Create a temp dir for "Profile 1" and seed the user data dir with a Local 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // State file configuring the app list to use it. 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::FilePath user_data_dir; 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::FilePath profile_path = user_data_dir.Append(second_profile_name_); 2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CHECK(second_profile_temp_dir_.Set(profile_path)); 2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::FilePath local_pref_path = 2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_data_dir.Append(chrome::kLocalStateFilename); 2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::DictionaryValue dict; 2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dict.SetString(prefs::kAppListProfile, 2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) second_profile_name_.MaybeAsASCII()); 2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CHECK(JSONFileValueSerializer(local_pref_path).Serialize(dict)); 2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return InProcessBrowserTest::SetUpUserDataDirectory(); 2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected: 2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const base::FilePath second_profile_name_; 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::ScopedTempDir second_profile_temp_dir_; 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ShowAppListNonDefaultInteractiveTest); 2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Test showing the app list for a profile that doesn't match the browser 2275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// profile. 2285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(ShowAppListNonDefaultInteractiveTest, 2295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MAYBE_ShowAppListNonDefaultProfile) { 2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListService* service = test::GetAppListService(); 2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_TRUE(service->IsAppListVisible()); 2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(second_profile_name_.value(), 2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) service->GetCurrentAppListProfile()->GetPath().BaseName().value()); 2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Check that the default profile hasn't been loaded. 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProfileManager* profile_manager = g_browser_process->profile_manager(); 2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles()); 2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Create a browser for the Default profile. This stops MaybeTeminate being 2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // called when the app list window is dismissed. Use the last used browser 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // profile to verify that it is different and causes ProfileManager to load a 2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // new profile. 2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateBrowser(profile_manager->GetLastUsedProfile()); 2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(2u, profile_manager->GetNumberOfProfiles()); 2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) service->DismissAppList(); 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Test showing the app list for a profile then deleting that profile while the 2501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// app list is visible. 2511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciIN_PROC_BROWSER_TEST_F(ShowAppListNonDefaultInteractiveTest, 2521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci MAYBE_DeleteShowingAppList) { 2531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AppListService* service = test::GetAppListService(); 2541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci EXPECT_TRUE(service->IsAppListVisible()); 2551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci EXPECT_EQ(second_profile_name_.value(), 2561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci service->GetCurrentAppListProfile()->GetPath().BaseName().value()); 2571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ProfileManager* profile_manager = g_browser_process->profile_manager(); 2591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Create a browser for the Default profile. 2611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci CreateBrowser(profile_manager->GetLastUsedProfile()); 2621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Delete the profile being used by the app list. 2641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci profile_manager->ScheduleProfileForDeletion( 2651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci service->GetCurrentAppListProfile()->GetPath(), 2661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ProfileManager::CreateCallback()); 2671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // App Launcher should get closed immediately and nothing should explode. 2691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci EXPECT_FALSE(service->IsAppListVisible()); 2701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 271