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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 247 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
248 } | 248 } |
249 | 249 |
250 const ash::ShelfItem& GetLastLauncherPanelItem() { | 250 const ash::ShelfItem& GetLastLauncherPanelItem() { |
251 // Panels show up on the right side of the shelf, so the desired item | 251 // Panels show up on the right side of the shelf, so the desired item |
252 // will be the last one. | 252 // will be the last one. |
253 return shelf_model()->items()[shelf_model()->item_count() - 1]; | 253 return shelf_model()->items()[shelf_model()->item_count() - 1]; |
254 } | 254 } |
255 | 255 |
256 ash::ShelfItemDelegate* GetShelfItemDelegate(ash::ShelfID id) { | 256 ash::ShelfItemDelegate* GetShelfItemDelegate(ash::ShelfID id) { |
257 return controller_->GetShelfItemDelegate(id); | 257 return shelf_model()->GetShelfItemDelegate(id); |
258 } | 258 } |
259 | 259 |
260 ChromeLauncherControllerImpl* controller_; | 260 ChromeLauncherControllerImpl* controller_; |
261 | 261 |
262 private: | 262 private: |
263 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); | 263 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); |
264 }; | 264 }; |
265 | 265 |
266 enum RipOffCommand { | 266 enum RipOffCommand { |
267 // Drag the item off the shelf and let the mouse go. | 267 // Drag the item off the shelf and let the mouse go. |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 params.focused = false; | 781 params.focused = false; |
782 AppWindow* panel = | 782 AppWindow* panel = |
783 CreateAppWindowFromParams(browser()->profile(), extension1, params); | 783 CreateAppWindowFromParams(browser()->profile(), extension1, params); |
784 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 784 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
785 // Panels should not be active by default. | 785 // Panels should not be active by default. |
786 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); | 786 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); |
787 // Confirm that an item delegate was created and is in the correct state. | 787 // Confirm that an item delegate was created and is in the correct state. |
788 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); | 788 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); |
789 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); | 789 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); |
790 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 790 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
791 EXPECT_EQ(nullptr, GetShelfItemDelegate(item1.id)); | 791 ash::ShelfItemDelegate* item1_delegate = GetShelfItemDelegate(item1.id); |
792 ash::ShelfItemDelegate* item1_delegate = | |
793 shelf_model()->GetShelfItemDelegate(item1.id); | |
794 EXPECT_EQ(ash::TYPE_APP_PANEL, | 792 EXPECT_EQ(ash::TYPE_APP_PANEL, |
795 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); | 793 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); |
796 // Click the item and confirm that the panel is activated. | 794 // Click the item and confirm that the panel is activated. |
797 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); | 795 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
798 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 796 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
799 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 797 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
800 // Click the item again and confirm that the panel is minimized. | 798 // Click the item again and confirm that the panel is minimized. |
801 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); | 799 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
802 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); | 800 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); |
803 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 801 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
(...skipping 17 matching lines...) Expand all Loading... |
821 params.focused = false; | 819 params.focused = false; |
822 AppWindow* panel = | 820 AppWindow* panel = |
823 CreateAppWindowFromParams(browser()->profile(), extension1, params); | 821 CreateAppWindowFromParams(browser()->profile(), extension1, params); |
824 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 822 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
825 // Panels should not be active by default. | 823 // Panels should not be active by default. |
826 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); | 824 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); |
827 // Confirm that an item delegate was created and is in the correct state. | 825 // Confirm that an item delegate was created and is in the correct state. |
828 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); | 826 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); |
829 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); | 827 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); |
830 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 828 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
831 EXPECT_EQ(nullptr, GetShelfItemDelegate(item1.id)); | 829 ash::ShelfItemDelegate* item1_delegate = GetShelfItemDelegate(item1.id); |
832 ash::ShelfItemDelegate* item1_delegate = | |
833 shelf_model()->GetShelfItemDelegate(item1.id); | |
834 EXPECT_EQ(ash::TYPE_APP_PANEL, | 830 EXPECT_EQ(ash::TYPE_APP_PANEL, |
835 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); | 831 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); |
836 // Click the item and confirm that the panel is activated. | 832 // Click the item and confirm that the panel is activated. |
837 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); | 833 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
838 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 834 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
839 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 835 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
840 // Click the item again and confirm that the panel is minimized. | 836 // Click the item again and confirm that the panel is minimized. |
841 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); | 837 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
842 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); | 838 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); |
843 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 839 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 const ash::ShelfItemDelegate* app_item_delegate = | 899 const ash::ShelfItemDelegate* app_item_delegate = |
904 GetShelfItemDelegate(app_item.id); | 900 GetShelfItemDelegate(app_item.id); |
905 ASSERT_TRUE(app_item_delegate); | 901 ASSERT_TRUE(app_item_delegate); |
906 EXPECT_FALSE(app_item_delegate->image_set_by_controller()); | 902 EXPECT_FALSE(app_item_delegate->image_set_by_controller()); |
907 | 903 |
908 const ash::ShelfItemDelegate* app_custom_icon_item_delegate = | 904 const ash::ShelfItemDelegate* app_custom_icon_item_delegate = |
909 GetShelfItemDelegate(app_custom_icon_item.id); | 905 GetShelfItemDelegate(app_custom_icon_item.id); |
910 ASSERT_TRUE(app_custom_icon_item_delegate); | 906 ASSERT_TRUE(app_custom_icon_item_delegate); |
911 EXPECT_TRUE(app_custom_icon_item_delegate->image_set_by_controller()); | 907 EXPECT_TRUE(app_custom_icon_item_delegate->image_set_by_controller()); |
912 | 908 |
913 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController. | |
914 EXPECT_EQ(nullptr, GetShelfItemDelegate(panel_item.id)); | |
915 // Ensure icon heights are correct (see test.js in app_icon/ test directory) | 909 // Ensure icon heights are correct (see test.js in app_icon/ test directory) |
916 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALL, app_item.image.height()); | 910 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALL, app_item.image.height()); |
917 EXPECT_EQ(extension_misc::EXTENSION_ICON_LARGE, | 911 EXPECT_EQ(extension_misc::EXTENSION_ICON_LARGE, |
918 app_custom_icon_item.image.height()); | 912 app_custom_icon_item.image.height()); |
919 EXPECT_EQ(64, panel_item.image.height()); | 913 EXPECT_EQ(64, panel_item.image.height()); |
920 } | 914 } |
921 | 915 |
922 // Test that we can launch an app with a shortcut. | 916 // Test that we can launch an app with a shortcut. |
923 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) { | 917 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) { |
924 TabStripModel* tab_strip = browser()->tab_strip_model(); | 918 TabStripModel* tab_strip = browser()->tab_strip_model(); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 AppWindow::CreateParams params; | 1533 AppWindow::CreateParams params; |
1540 params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 1534 params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
1541 params.focused = false; | 1535 params.focused = false; |
1542 AppWindow* panel = | 1536 AppWindow* panel = |
1543 CreateAppWindowFromParams(browser()->profile(), extension, params); | 1537 CreateAppWindowFromParams(browser()->profile(), extension, params); |
1544 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 1538 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
1545 // Panels should not be active by default. | 1539 // Panels should not be active by default. |
1546 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); | 1540 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); |
1547 // Confirm that a shelf item was created and is the correct state. | 1541 // Confirm that a shelf item was created and is the correct state. |
1548 const ash::ShelfItem& item = GetLastLauncherPanelItem(); | 1542 const ash::ShelfItem& item = GetLastLauncherPanelItem(); |
1549 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController. | 1543 ash::ShelfItemDelegate* shelf_item_delegate = GetShelfItemDelegate(item.id); |
1550 EXPECT_EQ(nullptr, GetShelfItemDelegate(item.id)); | |
1551 ash::ShelfItemDelegate* shelf_item_delegate = | |
1552 shelf_model()->GetShelfItemDelegate(item.id); | |
1553 EXPECT_NE(nullptr, shelf_item_delegate); | 1544 EXPECT_NE(nullptr, shelf_item_delegate); |
1554 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); | 1545 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); |
1555 EXPECT_EQ(ash::STATUS_RUNNING, item.status); | 1546 EXPECT_EQ(ash::STATUS_RUNNING, item.status); |
1556 | 1547 |
1557 // App windows should go to attention state. | 1548 // App windows should go to attention state. |
1558 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); | 1549 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); |
1559 EXPECT_EQ(ash::STATUS_ATTENTION, item.status); | 1550 EXPECT_EQ(ash::STATUS_ATTENTION, item.status); |
1560 | 1551 |
1561 // Click the item and confirm that the panel is activated. | 1552 // Click the item and confirm that the panel is activated. |
1562 EXPECT_EQ(ash::SHELF_ACTION_WINDOW_ACTIVATED, | 1553 EXPECT_EQ(ash::SHELF_ACTION_WINDOW_ACTIVATED, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 browser()); | 1758 browser()); |
1768 // Check that the LRU browser list does only contain the original browser. | 1759 // Check that the LRU browser list does only contain the original browser. |
1769 BrowserList* browser_list = BrowserList::GetInstance(); | 1760 BrowserList* browser_list = BrowserList::GetInstance(); |
1770 BrowserList::const_reverse_iterator it = browser_list->begin_last_active(); | 1761 BrowserList::const_reverse_iterator it = browser_list->begin_last_active(); |
1771 EXPECT_EQ(*it, browser()); | 1762 EXPECT_EQ(*it, browser()); |
1772 ++it; | 1763 ++it; |
1773 EXPECT_EQ(it, browser_list->end_last_active()); | 1764 EXPECT_EQ(it, browser_list->end_last_active()); |
1774 | 1765 |
1775 // Now request to either activate an existing app or create a new one. | 1766 // Now request to either activate an existing app or create a new one. |
1776 ash::ShelfItemDelegate* item_delegate = | 1767 ash::ShelfItemDelegate* item_delegate = |
1777 controller_->GetShelfItemDelegate(shortcut_id); | 1768 model_->GetShelfItemDelegate(shortcut_id); |
1778 SelectItem(item_delegate, ui::ET_KEY_RELEASED); | 1769 SelectItem(item_delegate, ui::ET_KEY_RELEASED); |
1779 | 1770 |
1780 // Check that we have set focus on the existing application and nothing new | 1771 // Check that we have set focus on the existing application and nothing new |
1781 // was created. | 1772 // was created. |
1782 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1773 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1783 EXPECT_EQ(tab_count1, tab_strip->count()); | 1774 EXPECT_EQ(tab_count1, tab_strip->count()); |
1784 EXPECT_EQ(tab_count2, tab_strip2->count()); | 1775 EXPECT_EQ(tab_count2, tab_strip2->count()); |
1785 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), | 1776 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), |
1786 browser2); | 1777 browser2); |
1787 } | 1778 } |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 | 2409 |
2419 // Close all windows via the menu item. | 2410 // Close all windows via the menu item. |
2420 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2411 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2421 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2412 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2422 | 2413 |
2423 // Check if "Close" is removed from the context menu. | 2414 // Check if "Close" is removed from the context menu. |
2424 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2415 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2425 ASSERT_FALSE( | 2416 ASSERT_FALSE( |
2426 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2417 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2427 } | 2418 } |
OLD | NEW |