Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | |
| 6 #include "base/files/scoped_temp_dir.h" | |
| 7 #include "base/message_loop.h" | |
| 8 #include "chrome/browser/browser_process.h" | |
| 9 #include "chrome/browser/prefs/pref_service_simple.h" | |
| 10 #include "chrome/browser/profiles/profile_manager.h" | |
| 5 #include "chrome/browser/ui/app_list/app_list_util.h" | 11 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 12 #include "chrome/browser/ui/browser.h" | |
| 13 #include "chrome/common/chrome_switches.h" | |
| 14 #include "chrome/common/pref_names.h" | |
| 6 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | |
| 17 | |
| 7 | 18 |
| 8 // Browser Test for AppListController that runs on all platforms supporting | 19 // Browser Test for AppListController that runs on all platforms supporting |
| 9 // app_list. | 20 // app_list. |
| 10 class AppListControllerBrowserTest : public InProcessBrowserTest { | 21 class AppListControllerBrowserTest : public InProcessBrowserTest { |
| 11 public: | 22 public: |
| 12 AppListControllerBrowserTest() {} | 23 AppListControllerBrowserTest() |
| 24 : profile2_(NULL) {} | |
| 25 | |
| 26 void OnProfileCreated(Profile* profile, Profile::CreateStatus status) { | |
| 27 if (status == Profile::CREATE_STATUS_INITIALIZED) { | |
| 28 profile2_ = profile; | |
| 29 MessageLoop::current()->Quit(); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 protected: | |
| 34 base::ScopedTempDir temp_profile_dir_; | |
| 35 Profile* profile2_; | |
| 13 | 36 |
| 14 private: | 37 private: |
| 15 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); | 38 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); |
| 16 }; | 39 }; |
| 17 | 40 |
| 18 // Disabled on Windows. Investigating in http://crbug.com/169114 . | 41 // Show the app list, then dismiss it. |
| 19 #if defined(OS_WIN) | 42 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { |
| 20 #define MAYBE_ShowAndShutdown DISABLED_ShowAndShutdown | 43 ASSERT_FALSE(chrome::IsAppListVisible()); |
| 21 #else | 44 chrome::ShowAppList(browser()->profile()); |
| 22 #define MAYBE_ShowAndShutdown ShowAndShutdown | 45 ASSERT_TRUE(chrome::IsAppListVisible()); |
| 23 #endif | 46 chrome::DismissAppList(); |
| 47 ASSERT_FALSE(chrome::IsAppListVisible()); | |
| 48 } | |
| 24 | 49 |
| 25 // Test showing the app list, followed by browser close. | 50 // You can't switch profiles for the launcher in ChromeOS. |
| 26 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, MAYBE_ShowAndShutdown) { | 51 #if !defined(OS_CHROMEOS) |
| 27 chrome::ShowAppList(); | 52 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) { |
| 53 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 54 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | |
| 55 profile_manager->CreateProfileAsync( | |
| 56 temp_profile_dir_.path(), | |
| 57 base::Bind(&AppListControllerBrowserTest::OnProfileCreated, | |
| 58 this), | |
| 59 string16(), string16(), false); | |
| 60 content::RunMessageLoop(); // Will stop in OnProfileCreated(). | |
| 61 | |
| 62 ASSERT_FALSE(chrome::IsAppListVisible()); | |
| 63 chrome::ShowAppList(browser()->profile()); | |
| 64 ASSERT_TRUE(chrome::IsAppListVisible()); | |
| 65 ASSERT_EQ(browser()->profile(), chrome::GetCurrentAppListProfile()); | |
| 66 chrome::ShowAppList(profile2_); | |
| 67 ASSERT_TRUE(chrome::IsAppListVisible()); | |
| 68 ASSERT_EQ(profile2_, chrome::GetCurrentAppListProfile()); | |
| 69 chrome::DismissAppList(); | |
| 70 ASSERT_FALSE(chrome::IsAppListVisible()); | |
| 28 } | 71 } |
| 72 #endif // !defined(OS_CHROMEOS) | |
| 73 | |
| 74 class ShowAppListBrowserTest : public InProcessBrowserTest { | |
| 75 public: | |
| 76 ShowAppListBrowserTest() {} | |
| 77 | |
| 78 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 79 command_line->AppendSwitch(switches::kShowAppList); | |
| 80 } | |
| 81 | |
| 82 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.
| |
| 83 }; | |
| 84 | |
| 85 // This command line flag isn't used on ChromeOS. | |
| 86 #if !defined(OS_CHROMEOS) | |
| 87 IN_PROC_BROWSER_TEST_F(ShowAppListBrowserTest, ShowAppListFlag) { | |
| 88 // The app list should already be shown because we passed | |
| 89 // switches::kShowAppList. | |
| 90 ASSERT_TRUE(chrome::IsAppListVisible()); | |
| 91 | |
| 92 // Create a browser to prevent shutdown when we dismiss the app list. We | |
| 93 // need to do this because switches::kShowAppList suppresses the creation of | |
| 94 // any browsers. | |
| 95 CreateBrowser(chrome::GetCurrentAppListProfile()); | |
| 96 chrome::DismissAppList(); | |
| 97 } | |
| 98 #endif // !defined(OS_CHROMEOS) | |
| OLD | NEW |