Chromium Code Reviews| 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 a928fe14706070fa49e3364f682d968b8f1b3406..190488acf53ad607d4ced0f5e3f7d1cfa2e8fda7 100644 |
| --- a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc |
| +++ b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc |
| @@ -2,27 +2,97 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/command_line.h" |
| +#include "base/files/scoped_temp_dir.h" |
| +#include "base/message_loop.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/prefs/pref_service_simple.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/app_list/app_list_util.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| + |
| // Browser Test for AppListController that runs on all platforms supporting |
| // app_list. |
| class AppListControllerBrowserTest : public InProcessBrowserTest { |
| public: |
| - AppListControllerBrowserTest() {} |
| + AppListControllerBrowserTest() |
| + : profile2_(NULL) {} |
| + |
| + void OnProfileCreated(Profile* profile, Profile::CreateStatus status) { |
| + if (status == Profile::CREATE_STATUS_INITIALIZED) { |
| + profile2_ = profile; |
| + MessageLoop::current()->Quit(); |
| + } |
| + } |
| + |
| + protected: |
| + base::ScopedTempDir temp_profile_dir_; |
| + Profile* profile2_; |
| private: |
| DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); |
| }; |
| -// Disabled on Windows. Investigating in http://crbug.com/169114 . |
| -#if defined(OS_WIN) |
| -#define MAYBE_ShowAndShutdown DISABLED_ShowAndShutdown |
| -#else |
| -#define MAYBE_ShowAndShutdown ShowAndShutdown |
| -#endif |
| +// Show the app list, then dismiss it. |
| +IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { |
| + ASSERT_FALSE(chrome::IsAppListVisible()); |
| + chrome::ShowAppList(browser()->profile()); |
| + ASSERT_TRUE(chrome::IsAppListVisible()); |
| + chrome::DismissAppList(); |
| + ASSERT_FALSE(chrome::IsAppListVisible()); |
| +} |
| + |
| +// You can't switch profiles for the launcher in ChromeOS. |
| +#if !defined(OS_CHROMEOS) |
| +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(), false); |
| + content::RunMessageLoop(); // Will stop in OnProfileCreated(). |
| + |
| + ASSERT_FALSE(chrome::IsAppListVisible()); |
| + chrome::ShowAppList(browser()->profile()); |
| + ASSERT_TRUE(chrome::IsAppListVisible()); |
| + ASSERT_EQ(browser()->profile(), chrome::GetCurrentAppListProfile()); |
| + chrome::ShowAppList(profile2_); |
| + ASSERT_TRUE(chrome::IsAppListVisible()); |
| + ASSERT_EQ(profile2_, chrome::GetCurrentAppListProfile()); |
| + chrome::DismissAppList(); |
| + ASSERT_FALSE(chrome::IsAppListVisible()); |
| +} |
| +#endif // !defined(OS_CHROMEOS) |
| + |
| +class ShowAppListBrowserTest : public InProcessBrowserTest { |
| + public: |
| + ShowAppListBrowserTest() {} |
| + |
| + void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| + command_line->AppendSwitch(switches::kShowAppList); |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ShowAppListBrowserTest); |
|
sail
2013/01/29 18:28:56
private:
koz (OOO until 15th September)
2013/01/29 22:59:02
Done.
|
| +}; |
| + |
| +// This command line flag isn't used on ChromeOS. |
| +#if !defined(OS_CHROMEOS) |
| +IN_PROC_BROWSER_TEST_F(ShowAppListBrowserTest, ShowAppListFlag) { |
| + // The app list should already be shown because we passed |
| + // switches::kShowAppList. |
| + ASSERT_TRUE(chrome::IsAppListVisible()); |
| -// Test showing the app list, followed by browser close. |
| -IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, MAYBE_ShowAndShutdown) { |
| - chrome::ShowAppList(); |
| + // Create a browser to prevent shutdown when we dismiss the app list. We |
| + // need to do this because switches::kShowAppList suppresses the creation of |
| + // any browsers. |
| + CreateBrowser(chrome::GetCurrentAppListProfile()); |
| + chrome::DismissAppList(); |
| } |
| +#endif // !defined(OS_CHROMEOS) |