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

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

Issue 23072036: Adds an integration test for uninstalling app list search results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get test passing on windows, expected event is not being observed though Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/path_service.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/browser/ui/app_list/app_list_service.h" 14 #include "chrome/browser/ui/app_list/app_list_service.h"
12 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/chrome_paths.h"
13 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "ui/app_list/app_list_model.h"
22 #include "ui/app_list/search_box_model.h"
23 #include "ui/app_list/search_result.h"
24 #include "ui/app_list/search_result_observer.h"
17 25
18 // Browser Test for AppListController that runs on all platforms supporting 26 // Browser Test for AppListController that runs on all platforms supporting
19 // app_list. 27 // app_list.
20 class AppListControllerBrowserTest : public InProcessBrowserTest { 28 class AppListControllerBrowserTest : public ExtensionBrowserTest,
29 public app_list::SearchResultObserver {
21 public: 30 public:
22 AppListControllerBrowserTest() 31 AppListControllerBrowserTest()
23 : profile2_(NULL) {} 32 : profile2_(NULL),
33 item_uninstall_count_(0) {}
24 34
25 void OnProfileCreated(Profile* profile, Profile::CreateStatus status) { 35 void OnProfileCreated(Profile* profile, Profile::CreateStatus status) {
26 if (status == Profile::CREATE_STATUS_INITIALIZED) { 36 if (status == Profile::CREATE_STATUS_INITIALIZED) {
27 profile2_ = profile; 37 profile2_ = profile;
28 base::MessageLoop::current()->Quit(); 38 base::MessageLoop::current()->Quit();
29 } 39 }
30 } 40 }
31 41
32 protected: 42 protected:
43 // SearchResultObserver overrides:
44 virtual void OnIconChanged() OVERRIDE {}
45 virtual void OnActionsChanged() OVERRIDE {}
46 virtual void OnIsInstallingChanged() OVERRIDE {}
47 virtual void OnPercentDownloadedChanged() OVERRIDE {}
48 virtual void OnItemInstalled() OVERRIDE {}
49 virtual void OnItemUninstalled() OVERRIDE {
50 ++item_uninstall_count_;
51 EXPECT_TRUE(observed_result_);
52
53 // Remove the observer here to match what the app list UI does.
54 observed_result_->RemoveObserver(this);
tapted 2013/08/23 07:07:04 Note that without this line, there are actually tw
55 }
56
33 base::ScopedTempDir temp_profile_dir_; 57 base::ScopedTempDir temp_profile_dir_;
34 Profile* profile2_; 58 Profile* profile2_;
59 app_list::SearchResult* observed_result_;
60 int item_uninstall_count_;
35 61
36 private: 62 private:
37 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); 63 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest);
38 }; 64 };
39 65
66 // Test showing search results, and uninstalling one of them while displayed.
67 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, UninstallSearchResult) {
68 base::FilePath test_extension_path;
69 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path));
70 test_extension_path = test_extension_path.AppendASCII("extensions")
71 .AppendASCII("platform_apps")
72 .AppendASCII("minimal");
73 const extensions::Extension* extension =
74 InstallExtension(test_extension_path, 1);
75 EXPECT_TRUE(extension);
76
77 AppListService* service = AppListService::Get();
78 service->ShowForProfile(browser()->profile());
79 app_list::AppListModel* model = service->GetAppListModelForTesting();
80 model->SetSignedIn(true);
81 model->search_box()->SetText(ASCIIToUTF16("minimal"));
82
83 // Ensure the search found the extension. It should always be first since the
84 // only other apps installed are the webstore and chrome, and apps come first.
85 app_list::AppListModel::SearchResults* results = model->results();
86 EXPECT_LE(1u, results->item_count());
87 observed_result_ = results->GetItemAt(0);
88 EXPECT_EQ(observed_result_->title(), ASCIIToUTF16(extension->name()));
89
90 // Now uninstall and ensure this browser test observes it.
91 observed_result_->AddObserver(this);
92 EXPECT_EQ(0, item_uninstall_count_);
93 UninstallExtension(extension->id());
94 EXPECT_EQ(1, item_uninstall_count_);
95 }
96
40 #if !defined(OS_CHROMEOS) && !defined(USE_AURA) 97 #if !defined(OS_CHROMEOS) && !defined(USE_AURA)
41 // Show the app list, then dismiss it. 98 // Show the app list, then dismiss it.
42 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { 99 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) {
43 AppListService* service = AppListService::Get(); 100 AppListService* service = AppListService::Get();
44 ASSERT_FALSE(service->IsAppListVisible()); 101 ASSERT_FALSE(service->IsAppListVisible());
45 service->ShowForProfile(browser()->profile()); 102 service->ShowForProfile(browser()->profile());
46 ASSERT_TRUE(service->IsAppListVisible()); 103 ASSERT_TRUE(service->IsAppListVisible());
47 service->DismissAppList(); 104 service->DismissAppList();
48 ASSERT_FALSE(service->IsAppListVisible()); 105 ASSERT_FALSE(service->IsAppListVisible());
49 } 106 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // switches::kShowAppList. 145 // switches::kShowAppList.
89 ASSERT_TRUE(service->IsAppListVisible()); 146 ASSERT_TRUE(service->IsAppListVisible());
90 147
91 // Create a browser to prevent shutdown when we dismiss the app list. We 148 // Create a browser to prevent shutdown when we dismiss the app list. We
92 // need to do this because switches::kShowAppList suppresses the creation of 149 // need to do this because switches::kShowAppList suppresses the creation of
93 // any browsers. 150 // any browsers.
94 CreateBrowser(service->GetCurrentAppListProfile()); 151 CreateBrowser(service->GetCurrentAppListProfile());
95 service->DismissAppList(); 152 service->DismissAppList();
96 } 153 }
97 #endif // !defined(OS_CHROMEOS) && !defined(USE_AURA) 154 #endif // !defined(OS_CHROMEOS) && !defined(USE_AURA)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698