Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chrome/browser/ui/app_list/app_list_controller_browsertest.cc

Issue 12207104: Refactor app_list_util.h into AppListService abstract base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase (conflicts in webstore_private_api.cc) Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_WIN) && !defined(USE_AURA) 40 #if defined(OS_WIN) || defined(OS_CHROMEOS)
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 #endif // defined(OS_WIN) || defined(OS_CHROMEOS)
50 51
52 #if defined(OS_WIN)
51 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) { 53 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) {
52 ProfileManager* profile_manager = g_browser_process->profile_manager(); 54 ProfileManager* profile_manager = g_browser_process->profile_manager();
53 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); 55 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir());
54 profile_manager->CreateProfileAsync( 56 profile_manager->CreateProfileAsync(
55 temp_profile_dir_.path(), 57 temp_profile_dir_.path(),
56 base::Bind(&AppListControllerBrowserTest::OnProfileCreated, 58 base::Bind(&AppListControllerBrowserTest::OnProfileCreated,
57 this), 59 this),
58 string16(), string16(), false); 60 string16(), string16(), false);
59 content::RunMessageLoop(); // Will stop in OnProfileCreated(). 61 content::RunMessageLoop(); // Will stop in OnProfileCreated().
60 62
61 ASSERT_FALSE(chrome::IsAppListVisible()); 63 AppListService* service = AppListService::Get();
62 chrome::ShowAppList(browser()->profile()); 64 ASSERT_FALSE(service->IsAppListVisible());
63 ASSERT_TRUE(chrome::IsAppListVisible()); 65 service->ShowAppList(browser()->profile());
64 ASSERT_EQ(browser()->profile(), chrome::GetCurrentAppListProfile()); 66 ASSERT_TRUE(service->IsAppListVisible());
65 chrome::ShowAppList(profile2_); 67 ASSERT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
66 ASSERT_TRUE(chrome::IsAppListVisible()); 68 service->ShowAppList(profile2_);
67 ASSERT_EQ(profile2_, chrome::GetCurrentAppListProfile()); 69 ASSERT_TRUE(service->IsAppListVisible());
68 chrome::DismissAppList(); 70 ASSERT_EQ(profile2_, service->GetCurrentAppListProfile());
69 ASSERT_FALSE(chrome::IsAppListVisible()); 71 service->DismissAppList();
72 ASSERT_FALSE(service->IsAppListVisible());
70 } 73 }
71 74
72 class ShowAppListBrowserTest : public InProcessBrowserTest { 75 class ShowAppListBrowserTest : public InProcessBrowserTest {
73 public: 76 public:
74 ShowAppListBrowserTest() {} 77 ShowAppListBrowserTest() {}
75 78
76 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 79 void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
77 command_line->AppendSwitch(switches::kShowAppList); 80 command_line->AppendSwitch(switches::kShowAppList);
78 } 81 }
79 82
80 private: 83 private:
81 DISALLOW_COPY_AND_ASSIGN(ShowAppListBrowserTest); 84 DISALLOW_COPY_AND_ASSIGN(ShowAppListBrowserTest);
82 }; 85 };
83 86
84 IN_PROC_BROWSER_TEST_F(ShowAppListBrowserTest, ShowAppListFlag) { 87 IN_PROC_BROWSER_TEST_F(ShowAppListBrowserTest, ShowAppListFlag) {
88 AppListService* service = AppListService::Get();
85 // The app list should already be shown because we passed 89 // The app list should already be shown because we passed
86 // switches::kShowAppList. 90 // switches::kShowAppList.
87 ASSERT_TRUE(chrome::IsAppListVisible()); 91 ASSERT_TRUE(service->IsAppListVisible());
88 92
89 // Create a browser to prevent shutdown when we dismiss the app list. We 93 // Create a browser to prevent shutdown when we dismiss the app list. We
90 // need to do this because switches::kShowAppList suppresses the creation of 94 // need to do this because switches::kShowAppList suppresses the creation of
91 // any browsers. 95 // any browsers.
92 CreateBrowser(chrome::GetCurrentAppListProfile()); 96 CreateBrowser(service->GetCurrentAppListProfile());
93 chrome::DismissAppList(); 97 service->DismissAppList();
94 } 98 }
95 #endif // defined(OS_WIN) && !defined(USE_AURA) 99 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698