Chromium Code Reviews| 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) { |