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