| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 Profile* profile2_; | 62 Profile* profile2_; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); | 65 DISALLOW_COPY_AND_ASSIGN(AppListControllerBrowserTest); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Test the CreateNewWindow function of the controller delegate. | 68 // Test the CreateNewWindow function of the controller delegate. |
| 69 // TODO(mgiuca): Enable on Linux when supported. |
| 70 #if !defined(OS_LINUX) |
| 69 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, CreateNewWindow) { | 71 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, CreateNewWindow) { |
| 70 const chrome::HostDesktopType desktop = chrome::GetActiveDesktop(); | 72 const chrome::HostDesktopType desktop = chrome::GetActiveDesktop(); |
| 71 AppListService* service = AppListService::Get(); | 73 AppListService* service = AppListService::Get(); |
| 72 scoped_ptr<AppListControllerDelegate> controller( | 74 scoped_ptr<AppListControllerDelegate> controller( |
| 73 service->CreateControllerDelegate()); | 75 service->CreateControllerDelegate()); |
| 74 ASSERT_TRUE(controller); | 76 ASSERT_TRUE(controller); |
| 75 | 77 |
| 76 EXPECT_EQ(1U, chrome::GetBrowserCount(browser()->profile(), desktop)); | 78 EXPECT_EQ(1U, chrome::GetBrowserCount(browser()->profile(), desktop)); |
| 77 EXPECT_EQ(0U, chrome::GetBrowserCount( | 79 EXPECT_EQ(0U, chrome::GetBrowserCount( |
| 78 browser()->profile()->GetOffTheRecordProfile(), desktop)); | 80 browser()->profile()->GetOffTheRecordProfile(), desktop)); |
| 79 | 81 |
| 80 controller->CreateNewWindow(browser()->profile(), false); | 82 controller->CreateNewWindow(browser()->profile(), false); |
| 81 EXPECT_EQ(2U, chrome::GetBrowserCount(browser()->profile(), desktop)); | 83 EXPECT_EQ(2U, chrome::GetBrowserCount(browser()->profile(), desktop)); |
| 82 | 84 |
| 83 controller->CreateNewWindow(browser()->profile(), true); | 85 controller->CreateNewWindow(browser()->profile(), true); |
| 84 EXPECT_EQ(1U, chrome::GetBrowserCount( | 86 EXPECT_EQ(1U, chrome::GetBrowserCount( |
| 85 browser()->profile()->GetOffTheRecordProfile(), desktop)); | 87 browser()->profile()->GetOffTheRecordProfile(), desktop)); |
| 86 } | 88 } |
| 89 #endif // !defined(OS_LINUX) |
| 87 | 90 |
| 88 #if !defined(OS_CHROMEOS) | 91 // TODO(mgiuca): Enable on Linux when supported. |
| 92 #if !defined(OS_CHROMEOS) && !defined(OS_LINUX) |
| 89 // Show the app list, then dismiss it. | 93 // Show the app list, then dismiss it. |
| 90 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { | 94 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, ShowAndDismiss) { |
| 91 AppListService* service = AppListService::Get(); | 95 AppListService* service = AppListService::Get(); |
| 92 ASSERT_FALSE(service->IsAppListVisible()); | 96 ASSERT_FALSE(service->IsAppListVisible()); |
| 93 service->ShowForProfile(browser()->profile()); | 97 service->ShowForProfile(browser()->profile()); |
| 94 ASSERT_TRUE(service->IsAppListVisible()); | 98 ASSERT_TRUE(service->IsAppListVisible()); |
| 95 service->DismissAppList(); | 99 service->DismissAppList(); |
| 96 ASSERT_FALSE(service->IsAppListVisible()); | 100 ASSERT_FALSE(service->IsAppListVisible()); |
| 97 } | 101 } |
| 98 | 102 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // The app list should already be shown because we passed | 191 // The app list should already be shown because we passed |
| 188 // switches::kShowAppList. | 192 // switches::kShowAppList. |
| 189 ASSERT_TRUE(service->IsAppListVisible()); | 193 ASSERT_TRUE(service->IsAppListVisible()); |
| 190 | 194 |
| 191 // Create a browser to prevent shutdown when we dismiss the app list. We | 195 // Create a browser to prevent shutdown when we dismiss the app list. We |
| 192 // need to do this because switches::kShowAppList suppresses the creation of | 196 // need to do this because switches::kShowAppList suppresses the creation of |
| 193 // any browsers. | 197 // any browsers. |
| 194 CreateBrowser(service->GetCurrentAppListProfile()); | 198 CreateBrowser(service->GetCurrentAppListProfile()); |
| 195 service->DismissAppList(); | 199 service->DismissAppList(); |
| 196 } | 200 } |
| 197 #endif // !defined(OS_CHROMEOS) | 201 #endif // !defined(OS_CHROMEOS) && !defined(OS_LINUX) |
| 198 | 202 |
| 199 // Browser Test for AppListController that observes search result changes. | 203 // Browser Test for AppListController that observes search result changes. |
| 200 class AppListControllerSearchResultsBrowserTest | 204 class AppListControllerSearchResultsBrowserTest |
| 201 : public ExtensionBrowserTest, | 205 : public ExtensionBrowserTest, |
| 202 public app_list::SearchResultObserver, | 206 public app_list::SearchResultObserver, |
| 203 public ui::ListModelObserver { | 207 public ui::ListModelObserver { |
| 204 public: | 208 public: |
| 205 AppListControllerSearchResultsBrowserTest() | 209 AppListControllerSearchResultsBrowserTest() |
| 206 : observed_result_(NULL), | 210 : observed_result_(NULL), |
| 207 item_uninstall_count_(0), | 211 item_uninstall_count_(0), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 int item_uninstall_count_; | 270 int item_uninstall_count_; |
| 267 | 271 |
| 268 private: | 272 private: |
| 269 base::string16 item_to_observe_; | 273 base::string16 item_to_observe_; |
| 270 app_list::AppListModel::SearchResults* observed_results_list_; | 274 app_list::AppListModel::SearchResults* observed_results_list_; |
| 271 | 275 |
| 272 DISALLOW_COPY_AND_ASSIGN(AppListControllerSearchResultsBrowserTest); | 276 DISALLOW_COPY_AND_ASSIGN(AppListControllerSearchResultsBrowserTest); |
| 273 }; | 277 }; |
| 274 | 278 |
| 275 // Test showing search results, and uninstalling one of them while displayed. | 279 // Test showing search results, and uninstalling one of them while displayed. |
| 280 // TODO(mgiuca): Enable on Linux when supported. |
| 281 #if !defined(OS_LINUX) |
| 276 IN_PROC_BROWSER_TEST_F(AppListControllerSearchResultsBrowserTest, | 282 IN_PROC_BROWSER_TEST_F(AppListControllerSearchResultsBrowserTest, |
| 277 UninstallSearchResult) { | 283 UninstallSearchResult) { |
| 278 base::FilePath test_extension_path; | 284 base::FilePath test_extension_path; |
| 279 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path)); | 285 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path)); |
| 280 test_extension_path = test_extension_path.AppendASCII("extensions") | 286 test_extension_path = test_extension_path.AppendASCII("extensions") |
| 281 .AppendASCII("platform_apps") | 287 .AppendASCII("platform_apps") |
| 282 .AppendASCII("minimal"); | 288 .AppendASCII("minimal"); |
| 283 const extensions::Extension* extension = | 289 const extensions::Extension* extension = |
| 284 InstallExtension(test_extension_path, | 290 InstallExtension(test_extension_path, |
| 285 1 /* expected_change: new install */); | 291 1 /* expected_change: new install */); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 311 EXPECT_EQ(1, item_uninstall_count_); | 317 EXPECT_EQ(1, item_uninstall_count_); |
| 312 | 318 |
| 313 // Results should not be immediately refreshed. When they are, the item should | 319 // Results should not be immediately refreshed. When they are, the item should |
| 314 // be removed from the model. | 320 // be removed from the model. |
| 315 EXPECT_TRUE(observed_result_); | 321 EXPECT_TRUE(observed_result_); |
| 316 base::RunLoop().RunUntilIdle(); | 322 base::RunLoop().RunUntilIdle(); |
| 317 EXPECT_FALSE(observed_result_); | 323 EXPECT_FALSE(observed_result_); |
| 318 StopWatchingResults(); | 324 StopWatchingResults(); |
| 319 service->DismissAppList(); | 325 service->DismissAppList(); |
| 320 } | 326 } |
| 327 #endif // !defined(OS_LINUX) |
| 321 | 328 |
| 322 } // namespace | 329 } // namespace |
| OLD | NEW |