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" | 5 #include "base/command_line.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
11 #include "chrome/browser/ui/app_list/app_list_util.h" | 11 #include "chrome/browser/ui/app_list/app_list_service.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #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" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 | 17 |
18 | |
19 // Browser Test for AppListController that runs on all platforms supporting | 18 // Browser Test for AppListController that runs on all platforms supporting |
20 // app_list. | 19 // app_list. |
21 class AppListControllerBrowserTest : public InProcessBrowserTest { | 20 class AppListControllerBrowserTest : public InProcessBrowserTest { |
22 public: | 21 public: |
23 AppListControllerBrowserTest() | 22 AppListControllerBrowserTest() |
24 : profile2_(NULL) {} | 23 : profile2_(NULL) {} |
25 | 24 |
26 void OnProfileCreated(Profile* profile, Profile::CreateStatus status) { | 25 void OnProfileCreated(Profile* profile, Profile::CreateStatus status) { |
27 if (status == Profile::CREATE_STATUS_INITIALIZED) { | 26 if (status == Profile::CREATE_STATUS_INITIALIZED) { |
28 profile2_ = profile; | 27 profile2_ = profile; |
29 MessageLoop::current()->Quit(); | 28 MessageLoop::current()->Quit(); |
30 } | 29 } |
31 } | 30 } |
32 | 31 |
33 protected: | 32 protected: |
34 base::ScopedTempDir temp_profile_dir_; | 33 base::ScopedTempDir temp_profile_dir_; |
35 Profile* profile2_; | 34 Profile* profile2_; |
36 | 35 |
37 private: | 36 private: |
38 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); | 37 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); |
39 }; | 38 }; |
40 | 39 |
41 #if !defined(OS_CHROMEOS) && !defined(USE_AURA) | 40 #if !defined(OS_CHROMEOS) && !defined(USE_AURA) |
42 // Show the app list, then dismiss it. | 41 // Show the app list, then dismiss it. |
43 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { | 42 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { |
44 ASSERT_FALSE(chrome::IsAppListVisible()); | 43 AppListService* service = AppListService::Get(); |
45 chrome::ShowAppList(browser()->profile()); | 44 ASSERT_FALSE(service->IsAppListVisible()); |
46 ASSERT_TRUE(chrome::IsAppListVisible()); | 45 service->ShowAppList(browser()->profile()); |
47 chrome::DismissAppList(); | 46 ASSERT_TRUE(service->IsAppListVisible()); |
48 ASSERT_FALSE(chrome::IsAppListVisible()); | 47 service->DismissAppList(); |
| 48 ASSERT_FALSE(service->IsAppListVisible()); |
49 } | 49 } |
50 | 50 |
51 // TODO(tapted): Enable this when profile switching code has been moved up the | 51 // TODO(tapted): Enable this when profile switching code has been moved up the |
52 // app list controller hierarchy. | 52 // app list controller hierarchy. |
53 #if !defined(OS_MACOSX) | 53 #if !defined(OS_MACOSX) |
54 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) { | 54 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) { |
55 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 55 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
56 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | 56 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); |
57 profile_manager->CreateProfileAsync( | 57 profile_manager->CreateProfileAsync( |
58 temp_profile_dir_.path(), | 58 temp_profile_dir_.path(), |
59 base::Bind(&AppListControllerBrowserTest::OnProfileCreated, | 59 base::Bind(&AppListControllerBrowserTest::OnProfileCreated, |
60 this), | 60 this), |
61 string16(), string16(), false); | 61 string16(), string16(), false); |
62 content::RunMessageLoop(); // Will stop in OnProfileCreated(). | 62 content::RunMessageLoop(); // Will stop in OnProfileCreated(). |
63 | 63 |
64 ASSERT_FALSE(chrome::IsAppListVisible()); | 64 AppListService* service = AppListService::Get(); |
65 chrome::ShowAppList(browser()->profile()); | 65 ASSERT_FALSE(service->IsAppListVisible()); |
66 ASSERT_TRUE(chrome::IsAppListVisible()); | 66 service->ShowAppList(browser()->profile()); |
67 ASSERT_EQ(browser()->profile(), chrome::GetCurrentAppListProfile()); | 67 ASSERT_TRUE(service->IsAppListVisible()); |
68 chrome::ShowAppList(profile2_); | 68 ASSERT_EQ(browser()->profile(), service->GetCurrentAppListProfile()); |
69 ASSERT_TRUE(chrome::IsAppListVisible()); | 69 service->ShowAppList(profile2_); |
70 ASSERT_EQ(profile2_, chrome::GetCurrentAppListProfile()); | 70 ASSERT_TRUE(service->IsAppListVisible()); |
71 chrome::DismissAppList(); | 71 ASSERT_EQ(profile2_, service->GetCurrentAppListProfile()); |
72 ASSERT_FALSE(chrome::IsAppListVisible()); | 72 service->DismissAppList(); |
| 73 ASSERT_FALSE(service->IsAppListVisible()); |
73 } | 74 } |
74 | 75 |
75 class ShowAppListBrowserTest : public InProcessBrowserTest { | 76 class ShowAppListBrowserTest : public InProcessBrowserTest { |
76 public: | 77 public: |
77 ShowAppListBrowserTest() {} | 78 ShowAppListBrowserTest() {} |
78 | 79 |
79 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 80 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
80 command_line->AppendSwitch(switches::kShowAppList); | 81 command_line->AppendSwitch(switches::kShowAppList); |
81 } | 82 } |
82 | 83 |
83 private: | 84 private: |
84 DISALLOW_COPY_AND_ASSIGN(ShowAppListBrowserTest); | 85 DISALLOW_COPY_AND_ASSIGN(ShowAppListBrowserTest); |
85 }; | 86 }; |
86 | 87 |
87 IN_PROC_BROWSER_TEST_F(ShowAppListBrowserTest, ShowAppListFlag) { | 88 IN_PROC_BROWSER_TEST_F(ShowAppListBrowserTest, ShowAppListFlag) { |
| 89 AppListService* service = AppListService::Get(); |
88 // The app list should already be shown because we passed | 90 // The app list should already be shown because we passed |
89 // switches::kShowAppList. | 91 // switches::kShowAppList. |
90 ASSERT_TRUE(chrome::IsAppListVisible()); | 92 ASSERT_TRUE(service->IsAppListVisible()); |
91 | 93 |
92 // Create a browser to prevent shutdown when we dismiss the app list. We | 94 // 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 | 95 // need to do this because switches::kShowAppList suppresses the creation of |
94 // any browsers. | 96 // any browsers. |
95 CreateBrowser(chrome::GetCurrentAppListProfile()); | 97 CreateBrowser(service->GetCurrentAppListProfile()); |
96 chrome::DismissAppList(); | 98 service->DismissAppList(); |
97 } | 99 } |
98 #endif // !defined(OS_MACOSX) | 100 #endif // !defined(OS_MACOSX) |
99 #endif // !defined(OS_CHROMEOS) && !defined(USE_AURA) | 101 #endif // !defined(OS_CHROMEOS) && !defined(USE_AURA) |
OLD | NEW |