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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/common/shelf/app_list_button.h" | 9 #include "ash/common/shelf/app_list_button.h" |
10 #include "ash/common/shelf/shelf_button.h" | 10 #include "ash/common/shelf/shelf_button.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 void RunTestOnMainThreadLoop() override { | 227 void RunTestOnMainThreadLoop() override { |
228 // Ensure ash starts the session and creates the shelf and controller. | 228 // Ensure ash starts the session and creates the shelf and controller. |
229 SessionControllerClient::FlushForTesting(); | 229 SessionControllerClient::FlushForTesting(); |
230 | 230 |
231 controller_ = GetChromeLauncherControllerImpl(); | 231 controller_ = GetChromeLauncherControllerImpl(); |
232 ASSERT_TRUE(controller_); | 232 ASSERT_TRUE(controller_); |
233 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); | 233 return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); |
234 } | 234 } |
235 | 235 |
236 ash::ShelfModel* shelf_model() { return ash::WmShell::Get()->shelf_model(); } | 236 ash::ShelfModel* shelf_model() { return ash::Shell::Get()->shelf_model(); } |
237 | 237 |
238 ash::ShelfID CreateAppShortcutLauncherItem( | 238 ash::ShelfID CreateAppShortcutLauncherItem( |
239 const ash::AppLaunchId& app_launch_id) { | 239 const ash::AppLaunchId& app_launch_id) { |
240 return controller_->CreateAppShortcutLauncherItem( | 240 return controller_->CreateAppShortcutLauncherItem( |
241 app_launch_id, shelf_model()->item_count()); | 241 app_launch_id, shelf_model()->item_count()); |
242 } | 242 } |
243 | 243 |
244 const ash::ShelfItem& GetLastLauncherItem() { | 244 const ash::ShelfItem& GetLastLauncherItem() { |
245 // Unless there are any panels, the item at index [count - 1] will be | 245 // Unless there are any panels, the item at index [count - 1] will be |
246 // the desired item. | 246 // the desired item. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 280 } |
281 | 281 |
282 ~ShelfAppBrowserTest() override {} | 282 ~ShelfAppBrowserTest() override {} |
283 | 283 |
284 void RunTestOnMainThreadLoop() override { | 284 void RunTestOnMainThreadLoop() override { |
285 // Ensure ash starts the session and creates the shelf and controller. | 285 // Ensure ash starts the session and creates the shelf and controller. |
286 SessionControllerClient::FlushForTesting(); | 286 SessionControllerClient::FlushForTesting(); |
287 | 287 |
288 shelf_ = | 288 shelf_ = |
289 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); | 289 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); |
290 model_ = ash::WmShell::Get()->shelf_model(); | 290 model_ = ash::Shell::Get()->shelf_model(); |
291 controller_ = GetChromeLauncherControllerImpl(); | 291 controller_ = GetChromeLauncherControllerImpl(); |
292 ASSERT_TRUE(controller_); | 292 ASSERT_TRUE(controller_); |
293 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); | 293 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); |
294 } | 294 } |
295 | 295 |
296 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { | 296 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { |
297 LauncherItemController* item_controller = | 297 LauncherItemController* item_controller = |
298 controller_->GetBrowserShortcutLauncherItemController(); | 298 controller_->GetBrowserShortcutLauncherItemController(); |
299 return item_controller | 299 return item_controller |
300 ->GetAppMenuItems(show_all_tabs ? ui::EF_SHIFT_DOWN : 0) | 300 ->GetAppMenuItems(show_all_tabs ? ui::EF_SHIFT_DOWN : 0) |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 1555 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
1556 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1556 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1557 | 1557 |
1558 // Active windows don't show attention. | 1558 // Active windows don't show attention. |
1559 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); | 1559 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); |
1560 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1560 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1561 } | 1561 } |
1562 | 1562 |
1563 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, | 1563 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
1564 ShowInShelfWindowsWithWindowKeySet) { | 1564 ShowInShelfWindowsWithWindowKeySet) { |
1565 ash::ShelfModel* shelf_model = ash::WmShell::Get()->shelf_model(); | 1565 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); |
1566 | 1566 |
1567 // Add a window with shelf True, close it | 1567 // Add a window with shelf True, close it |
1568 int item_count = shelf_model->item_count(); | 1568 int item_count = shelf_model->item_count(); |
1569 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 1569 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
1570 AppWindow::CreateParams params; | 1570 AppWindow::CreateParams params; |
1571 | 1571 |
1572 params.show_in_shelf = true; | 1572 params.show_in_shelf = true; |
1573 params.window_key = "window1"; | 1573 params.window_key = "window1"; |
1574 AppWindow* window1 = | 1574 AppWindow* window1 = |
1575 CreateAppWindowFromParams(browser()->profile(), extension, params); | 1575 CreateAppWindowFromParams(browser()->profile(), extension, params); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 TabStripModel::CLOSE_NONE); | 2270 TabStripModel::CLOSE_NONE); |
2271 // Make sure that the app is really gone. | 2271 // Make sure that the app is really gone. |
2272 base::RunLoop().RunUntilIdle(); | 2272 base::RunLoop().RunUntilIdle(); |
2273 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); | 2273 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); |
2274 } | 2274 } |
2275 | 2275 |
2276 // Checks that a opening a settings window creates a new launcher item. | 2276 // Checks that a opening a settings window creates a new launcher item. |
2277 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, SettingsWindow) { | 2277 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, SettingsWindow) { |
2278 chrome::SettingsWindowManager* settings_manager = | 2278 chrome::SettingsWindowManager* settings_manager = |
2279 chrome::SettingsWindowManager::GetInstance(); | 2279 chrome::SettingsWindowManager::GetInstance(); |
2280 ash::ShelfModel* shelf_model = ash::WmShell::Get()->shelf_model(); | 2280 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); |
2281 | 2281 |
2282 // Get the number of items in the shelf and browser menu. | 2282 // Get the number of items in the shelf and browser menu. |
2283 int item_count = shelf_model->item_count(); | 2283 int item_count = shelf_model->item_count(); |
2284 size_t browser_count = NumberOfDetectedLauncherBrowsers(false); | 2284 size_t browser_count = NumberOfDetectedLauncherBrowsers(false); |
2285 | 2285 |
2286 // Open a settings window. Number of browser items should remain unchanged, | 2286 // Open a settings window. Number of browser items should remain unchanged, |
2287 // number of shelf items should increase. | 2287 // number of shelf items should increase. |
2288 settings_manager->ShowChromePageForProfile( | 2288 settings_manager->ShowChromePageForProfile( |
2289 browser()->profile(), | 2289 browser()->profile(), |
2290 chrome::GetSettingsUrl(std::string())); | 2290 chrome::GetSettingsUrl(std::string())); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2410 | 2410 |
2411 // Close all windows via the menu item. | 2411 // Close all windows via the menu item. |
2412 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2412 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2413 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2413 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2414 | 2414 |
2415 // Check if "Close" is removed from the context menu. | 2415 // Check if "Close" is removed from the context menu. |
2416 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2416 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2417 ASSERT_FALSE( | 2417 ASSERT_FALSE( |
2418 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2418 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2419 } | 2419 } |
OLD | NEW |