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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e773383d1c3f62902682bdec62ab5219104aa525..63b2e6350156b4b20b8e08277409fdb19befae3a 100644
--- a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
+++ b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
@@ -5,22 +5,32 @@
#include "base/command_line.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
+#include "base/path_service.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_paths.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"
+#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/search_box_model.h"
+#include "ui/app_list/search_result.h"
+#include "ui/app_list/search_result_observer.h"
// Browser Test for AppListController that runs on all platforms supporting
// app_list.
-class AppListControllerBrowserTest : public InProcessBrowserTest {
+class AppListControllerBrowserTest : public ExtensionBrowserTest,
+ public app_list::SearchResultObserver {
public:
AppListControllerBrowserTest()
- : profile2_(NULL) {}
+ : profile2_(NULL),
+ item_uninstall_count_(0) {}
void OnProfileCreated(Profile* profile, Profile::CreateStatus status) {
if (status == Profile::CREATE_STATUS_INITIALIZED) {
@@ -30,13 +40,60 @@ class AppListControllerBrowserTest : public InProcessBrowserTest {
}
protected:
+ // SearchResultObserver overrides:
+ virtual void OnIconChanged() OVERRIDE {}
+ virtual void OnActionsChanged() OVERRIDE {}
+ virtual void OnIsInstallingChanged() OVERRIDE {}
+ virtual void OnPercentDownloadedChanged() OVERRIDE {}
+ virtual void OnItemInstalled() OVERRIDE {}
+ virtual void OnItemUninstalled() OVERRIDE {
+ ++item_uninstall_count_;
+ EXPECT_TRUE(observed_result_);
+
+ // Remove the observer here to match what the app list UI does.
+ observed_result_->RemoveObserver(this);
tapted 2013/08/23 07:07:04 Note that without this line, there are actually tw
+ }
+
base::ScopedTempDir temp_profile_dir_;
Profile* profile2_;
+ app_list::SearchResult* observed_result_;
+ int item_uninstall_count_;
private:
DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest);
};
+// Test showing search results, and uninstalling one of them while displayed.
+IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, UninstallSearchResult) {
+ base::FilePath test_extension_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path));
+ test_extension_path = test_extension_path.AppendASCII("extensions")
+ .AppendASCII("platform_apps")
+ .AppendASCII("minimal");
+ const extensions::Extension* extension =
+ InstallExtension(test_extension_path, 1);
+ EXPECT_TRUE(extension);
+
+ AppListService* service = AppListService::Get();
+ service->ShowForProfile(browser()->profile());
+ app_list::AppListModel* model = service->GetAppListModelForTesting();
+ model->SetSignedIn(true);
+ model->search_box()->SetText(ASCIIToUTF16("minimal"));
+
+ // Ensure the search found the extension. It should always be first since the
+ // only other apps installed are the webstore and chrome, and apps come first.
+ app_list::AppListModel::SearchResults* results = model->results();
+ EXPECT_LE(1u, results->item_count());
+ observed_result_ = results->GetItemAt(0);
+ EXPECT_EQ(observed_result_->title(), ASCIIToUTF16(extension->name()));
+
+ // Now uninstall and ensure this browser test observes it.
+ observed_result_->AddObserver(this);
+ EXPECT_EQ(0, item_uninstall_count_);
+ UninstallExtension(extension->id());
+ EXPECT_EQ(1, item_uninstall_count_);
+}
+
#if !defined(OS_CHROMEOS) && !defined(USE_AURA)
// Show the app list, then dismiss it.
IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) {
« 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