| 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/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 : observed_result_(NULL), | 54 : observed_result_(NULL), |
| 55 item_uninstall_count_(0), | 55 item_uninstall_count_(0), |
| 56 observed_results_list_(NULL) {} | 56 observed_results_list_(NULL) {} |
| 57 | 57 |
| 58 void WatchResultsLookingForItem( | 58 void WatchResultsLookingForItem( |
| 59 app_list::AppListModel::SearchResults* search_results, | 59 app_list::AppListModel::SearchResults* search_results, |
| 60 const std::string& extension_name) { | 60 const std::string& extension_name) { |
| 61 EXPECT_FALSE(observed_results_list_); | 61 EXPECT_FALSE(observed_results_list_); |
| 62 observed_results_list_ = search_results; | 62 observed_results_list_ = search_results; |
| 63 observed_results_list_->AddObserver(this); | 63 observed_results_list_->AddObserver(this); |
| 64 item_to_observe_ = ASCIIToUTF16(extension_name); | 64 item_to_observe_ = base::ASCIIToUTF16(extension_name); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void StopWatchingResults() { | 67 void StopWatchingResults() { |
| 68 EXPECT_TRUE(observed_results_list_); | 68 EXPECT_TRUE(observed_results_list_); |
| 69 observed_results_list_->RemoveObserver(this); | 69 observed_results_list_->RemoveObserver(this); |
| 70 } | 70 } |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 void AttemptToLocateItem() { | 73 void AttemptToLocateItem() { |
| 74 if (observed_result_) { | 74 if (observed_result_) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 AppListService* service = test::GetAppListService(); | 137 AppListService* service = test::GetAppListService(); |
| 138 ASSERT_TRUE(service); | 138 ASSERT_TRUE(service); |
| 139 service->ShowForProfile(browser()->profile()); | 139 service->ShowForProfile(browser()->profile()); |
| 140 | 140 |
| 141 app_list::AppListModel* model = test::GetAppListModel(service); | 141 app_list::AppListModel* model = test::GetAppListModel(service); |
| 142 ASSERT_TRUE(model); | 142 ASSERT_TRUE(model); |
| 143 WatchResultsLookingForItem(model->results(), extension->name()); | 143 WatchResultsLookingForItem(model->results(), extension->name()); |
| 144 | 144 |
| 145 // Ensure a search finds the extension. | 145 // Ensure a search finds the extension. |
| 146 EXPECT_FALSE(observed_result_); | 146 EXPECT_FALSE(observed_result_); |
| 147 model->search_box()->SetText(ASCIIToUTF16("minimal")); | 147 model->search_box()->SetText(base::ASCIIToUTF16("minimal")); |
| 148 EXPECT_TRUE(observed_result_); | 148 EXPECT_TRUE(observed_result_); |
| 149 | 149 |
| 150 // Ensure the UI is updated. This is via PostTask in views. | 150 // Ensure the UI is updated. This is via PostTask in views. |
| 151 base::RunLoop().RunUntilIdle(); | 151 base::RunLoop().RunUntilIdle(); |
| 152 | 152 |
| 153 // Now uninstall and ensure this browser test observes it. | 153 // Now uninstall and ensure this browser test observes it. |
| 154 EXPECT_EQ(0, item_uninstall_count_); | 154 EXPECT_EQ(0, item_uninstall_count_); |
| 155 UninstallExtension(extension->id()); | 155 UninstallExtension(extension->id()); |
| 156 EXPECT_EQ(1, item_uninstall_count_); | 156 EXPECT_EQ(1, item_uninstall_count_); |
| 157 | 157 |
| 158 // Results should not be immediately refreshed. When they are, the item should | 158 // Results should not be immediately refreshed. When they are, the item should |
| 159 // be removed from the model. | 159 // be removed from the model. |
| 160 EXPECT_TRUE(observed_result_); | 160 EXPECT_TRUE(observed_result_); |
| 161 base::RunLoop().RunUntilIdle(); | 161 base::RunLoop().RunUntilIdle(); |
| 162 EXPECT_FALSE(observed_result_); | 162 EXPECT_FALSE(observed_result_); |
| 163 StopWatchingResults(); | 163 StopWatchingResults(); |
| 164 service->DismissAppList(); | 164 service->DismissAppList(); |
| 165 } | 165 } |
| OLD | NEW |