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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 using extensions::Extension; | 87 using extensions::Extension; |
88 using content::WebContents; | 88 using content::WebContents; |
89 | 89 |
90 namespace { | 90 namespace { |
91 | 91 |
92 ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() { | 92 ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() { |
93 return static_cast<ChromeLauncherControllerImpl*>( | 93 return static_cast<ChromeLauncherControllerImpl*>( |
94 ChromeLauncherController::instance()); | 94 ChromeLauncherController::instance()); |
95 } | 95 } |
96 | 96 |
| 97 // Calls ShelfItemDelegate::SelectItem with an event type and default arguments. |
| 98 ash::ShelfAction SelectItem(ash::ShelfItemDelegate* delegate, |
| 99 ui::EventType event_type) { |
| 100 return delegate->ItemSelected(event_type, ui::EF_NONE, |
| 101 display::kInvalidDisplayId, |
| 102 ash::LAUNCH_FROM_UNKNOWN); |
| 103 } |
| 104 |
97 class TestEvent : public ui::Event { | 105 class TestEvent : public ui::Event { |
98 public: | 106 public: |
99 explicit TestEvent(ui::EventType type) | 107 explicit TestEvent(ui::EventType type) |
100 : ui::Event(type, base::TimeTicks(), 0) {} | 108 : ui::Event(type, base::TimeTicks(), 0) {} |
101 ~TestEvent() override {} | 109 ~TestEvent() override {} |
102 | 110 |
103 private: | 111 private: |
104 DISALLOW_COPY_AND_ASSIGN(TestEvent); | 112 DISALLOW_COPY_AND_ASSIGN(TestEvent); |
105 }; | 113 }; |
106 | 114 |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1); | 704 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1); |
697 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 705 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
698 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 706 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
699 | 707 |
700 // Confirm that a controller item was created and is the correct state. | 708 // Confirm that a controller item was created and is the correct state. |
701 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 709 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
702 LauncherItemController* item1_controller = GetItemController(item1.id); | 710 LauncherItemController* item1_controller = GetItemController(item1.id); |
703 EXPECT_EQ(ash::TYPE_APP, item1.type); | 711 EXPECT_EQ(ash::TYPE_APP, item1.type); |
704 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 712 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
705 // Since it is already active, clicking it should minimize. | 713 // Since it is already active, clicking it should minimize. |
706 TestEvent click_event(ui::ET_MOUSE_PRESSED); | 714 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); |
707 item1_controller->ItemSelected(click_event); | |
708 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible()); | 715 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible()); |
709 EXPECT_FALSE(window1->GetBaseWindow()->IsActive()); | 716 EXPECT_FALSE(window1->GetBaseWindow()->IsActive()); |
710 EXPECT_TRUE(window1->GetBaseWindow()->IsMinimized()); | 717 EXPECT_TRUE(window1->GetBaseWindow()->IsMinimized()); |
711 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 718 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
712 // Clicking the item again should activate the window again. | 719 // Clicking the item again should activate the window again. |
713 item1_controller->ItemSelected(click_event); | 720 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); |
714 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 721 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
715 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 722 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
716 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 723 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
717 // Maximizing a window should preserve state after minimize + click. | 724 // Maximizing a window should preserve state after minimize + click. |
718 window1->GetBaseWindow()->Maximize(); | 725 window1->GetBaseWindow()->Maximize(); |
719 window1->GetBaseWindow()->Minimize(); | 726 window1->GetBaseWindow()->Minimize(); |
720 item1_controller->ItemSelected(click_event); | 727 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); |
721 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 728 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
722 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 729 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
723 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); | 730 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); |
724 window1->GetBaseWindow()->Restore(); | 731 window1->GetBaseWindow()->Restore(); |
725 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 732 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
726 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 733 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
727 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized()); | 734 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized()); |
728 | 735 |
729 // Creating a second window of the same type should change the behavior so | 736 // Creating a second window of the same type should change the behavior so |
730 // that a click does not change the activation state. | 737 // that a click does not change the activation state. |
731 AppWindow* window1a = CreateAppWindow(browser()->profile(), extension1); | 738 AppWindow* window1a = CreateAppWindow(browser()->profile(), extension1); |
732 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); | 739 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); |
733 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive()); | 740 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive()); |
734 // The first click does nothing. | 741 // The first click does nothing. |
735 item1_controller->ItemSelected(click_event); | 742 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); |
736 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 743 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
737 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); | 744 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); |
738 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 745 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
739 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); | 746 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); |
740 // The second neither. | 747 // The second neither. |
741 item1_controller->ItemSelected(click_event); | 748 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); |
742 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 749 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
743 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); | 750 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); |
744 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 751 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
745 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); | 752 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); |
746 } | 753 } |
747 | 754 |
748 // Confirm that ash::ShelfWindowWatcher correctly handles app panels. | 755 // Confirm that ash::ShelfWindowWatcher correctly handles app panels. |
749 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanel) { | 756 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanel) { |
750 // Enable experimental APIs to allow panel creation. | 757 // Enable experimental APIs to allow panel creation. |
751 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 758 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
(...skipping 11 matching lines...) Expand all Loading... |
763 // Confirm that an item delegate was created and is in the correct state. | 770 // Confirm that an item delegate was created and is in the correct state. |
764 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); | 771 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); |
765 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); | 772 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); |
766 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 773 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
767 EXPECT_EQ(nullptr, GetItemController(item1.id)); | 774 EXPECT_EQ(nullptr, GetItemController(item1.id)); |
768 ash::ShelfItemDelegate* item1_delegate = | 775 ash::ShelfItemDelegate* item1_delegate = |
769 shelf_model()->GetShelfItemDelegate(item1.id); | 776 shelf_model()->GetShelfItemDelegate(item1.id); |
770 EXPECT_EQ(ash::TYPE_APP_PANEL, | 777 EXPECT_EQ(ash::TYPE_APP_PANEL, |
771 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); | 778 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); |
772 // Click the item and confirm that the panel is activated. | 779 // Click the item and confirm that the panel is activated. |
773 TestEvent click_event(ui::ET_MOUSE_PRESSED); | 780 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
774 item1_delegate->ItemSelected(click_event); | |
775 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 781 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
776 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 782 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
777 // Click the item again and confirm that the panel is minimized. | 783 // Click the item again and confirm that the panel is minimized. |
778 item1_delegate->ItemSelected(click_event); | 784 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
779 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); | 785 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); |
780 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 786 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
781 // Click the item again and confirm that the panel is activated. | 787 // Click the item again and confirm that the panel is activated. |
782 item1_delegate->ItemSelected(click_event); | 788 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
783 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 789 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
784 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 790 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
785 EXPECT_FALSE(panel->GetBaseWindow()->IsMinimized()); | 791 EXPECT_FALSE(panel->GetBaseWindow()->IsMinimized()); |
786 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 792 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
787 } | 793 } |
788 | 794 |
789 // Confirm that click behavior for app panels is correct. | 795 // Confirm that click behavior for app panels is correct. |
790 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanelClickBehavior) { | 796 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanelClickBehavior) { |
791 // Enable experimental APIs to allow panel creation. | 797 // Enable experimental APIs to allow panel creation. |
792 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 798 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
(...skipping 11 matching lines...) Expand all Loading... |
804 // Confirm that an item delegate was created and is in the correct state. | 810 // Confirm that an item delegate was created and is in the correct state. |
805 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); | 811 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); |
806 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); | 812 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); |
807 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 813 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
808 EXPECT_EQ(nullptr, GetItemController(item1.id)); | 814 EXPECT_EQ(nullptr, GetItemController(item1.id)); |
809 ash::ShelfItemDelegate* item1_delegate = | 815 ash::ShelfItemDelegate* item1_delegate = |
810 shelf_model()->GetShelfItemDelegate(item1.id); | 816 shelf_model()->GetShelfItemDelegate(item1.id); |
811 EXPECT_EQ(ash::TYPE_APP_PANEL, | 817 EXPECT_EQ(ash::TYPE_APP_PANEL, |
812 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); | 818 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); |
813 // Click the item and confirm that the panel is activated. | 819 // Click the item and confirm that the panel is activated. |
814 TestEvent click_event(ui::ET_MOUSE_PRESSED); | 820 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
815 item1_delegate->ItemSelected(click_event); | |
816 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 821 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
817 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 822 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
818 // Click the item again and confirm that the panel is minimized. | 823 // Click the item again and confirm that the panel is minimized. |
819 item1_delegate->ItemSelected(click_event); | 824 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
820 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); | 825 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); |
821 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | 826 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); |
822 // Click the item again and confirm that the panel is activated. | 827 // Click the item again and confirm that the panel is activated. |
823 item1_delegate->ItemSelected(click_event); | 828 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); |
824 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); | 829 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); |
825 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 830 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
826 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | 831 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); |
827 } | 832 } |
828 | 833 |
829 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { | 834 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) { |
830 int item_count = shelf_model()->item_count(); | 835 int item_count = shelf_model()->item_count(); |
831 | 836 |
832 // First run app. | 837 // First run app. |
833 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 838 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 shelf_model()->GetShelfItemDelegate(item.id); | 1523 shelf_model()->GetShelfItemDelegate(item.id); |
1519 EXPECT_NE(nullptr, shelf_item_delegate); | 1524 EXPECT_NE(nullptr, shelf_item_delegate); |
1520 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); | 1525 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); |
1521 EXPECT_EQ(ash::STATUS_RUNNING, item.status); | 1526 EXPECT_EQ(ash::STATUS_RUNNING, item.status); |
1522 | 1527 |
1523 // App windows should go to attention state. | 1528 // App windows should go to attention state. |
1524 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); | 1529 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); |
1525 EXPECT_EQ(ash::STATUS_ATTENTION, item.status); | 1530 EXPECT_EQ(ash::STATUS_ATTENTION, item.status); |
1526 | 1531 |
1527 // Click the item and confirm that the panel is activated. | 1532 // Click the item and confirm that the panel is activated. |
1528 TestEvent click_event(ui::ET_MOUSE_PRESSED); | 1533 EXPECT_EQ(ash::SHELF_ACTION_WINDOW_ACTIVATED, |
1529 EXPECT_EQ(ash::ShelfItemDelegate::kExistingWindowActivated, | 1534 SelectItem(shelf_item_delegate, ui::ET_MOUSE_PRESSED)); |
1530 shelf_item_delegate->ItemSelected(click_event)); | |
1531 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 1535 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
1532 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1536 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1533 | 1537 |
1534 // Active windows don't show attention. | 1538 // Active windows don't show attention. |
1535 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); | 1539 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); |
1536 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1540 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1537 } | 1541 } |
1538 | 1542 |
1539 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, | 1543 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
1540 ShowInShelfWindowsWithWindowKeySet) { | 1544 ShowInShelfWindowsWithWindowKeySet) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 // Check that the LRU browser list does only contain the original browser. | 1739 // Check that the LRU browser list does only contain the original browser. |
1736 BrowserList* browser_list = BrowserList::GetInstance(); | 1740 BrowserList* browser_list = BrowserList::GetInstance(); |
1737 BrowserList::const_reverse_iterator it = browser_list->begin_last_active(); | 1741 BrowserList::const_reverse_iterator it = browser_list->begin_last_active(); |
1738 EXPECT_EQ(*it, browser()); | 1742 EXPECT_EQ(*it, browser()); |
1739 ++it; | 1743 ++it; |
1740 EXPECT_EQ(it, browser_list->end_last_active()); | 1744 EXPECT_EQ(it, browser_list->end_last_active()); |
1741 | 1745 |
1742 // Now request to either activate an existing app or create a new one. | 1746 // Now request to either activate an existing app or create a new one. |
1743 LauncherItemController* item_controller = | 1747 LauncherItemController* item_controller = |
1744 controller_->GetLauncherItemController(shortcut_id); | 1748 controller_->GetLauncherItemController(shortcut_id); |
1745 item_controller->ItemSelected(ui::KeyEvent(ui::ET_KEY_RELEASED, | 1749 SelectItem(item_controller, ui::ET_KEY_RELEASED); |
1746 ui::VKEY_RETURN, | |
1747 ui::EF_NONE)); | |
1748 | 1750 |
1749 // Check that we have set focus on the existing application and nothing new | 1751 // Check that we have set focus on the existing application and nothing new |
1750 // was created. | 1752 // was created. |
1751 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); | 1753 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); |
1752 EXPECT_EQ(tab_count1, tab_strip->count()); | 1754 EXPECT_EQ(tab_count1, tab_strip->count()); |
1753 EXPECT_EQ(tab_count2, tab_strip2->count()); | 1755 EXPECT_EQ(tab_count2, tab_strip2->count()); |
1754 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), | 1756 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), |
1755 browser2); | 1757 browser2); |
1756 } | 1758 } |
1757 | 1759 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 controller_->GetBrowserShortcutLauncherItemController(); | 2123 controller_->GetBrowserShortcutLauncherItemController(); |
2122 const ash::ShelfID id = item_controller->shelf_id(); | 2124 const ash::ShelfID id = item_controller->shelf_id(); |
2123 EXPECT_NE(ash::kInvalidShelfID, id); | 2125 EXPECT_NE(ash::kInvalidShelfID, id); |
2124 | 2126 |
2125 // Get the number of browsers. | 2127 // Get the number of browsers. |
2126 size_t running_browser = chrome::GetTotalBrowserCount(); | 2128 size_t running_browser = chrome::GetTotalBrowserCount(); |
2127 EXPECT_EQ(0u, running_browser); | 2129 EXPECT_EQ(0u, running_browser); |
2128 EXPECT_FALSE(controller_->IsOpen(id)); | 2130 EXPECT_FALSE(controller_->IsOpen(id)); |
2129 | 2131 |
2130 // Activate. This creates new browser | 2132 // Activate. This creates new browser |
2131 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); | 2133 SelectItem(item_controller, ui::ET_UNKNOWN); |
2132 // New Window is created. | 2134 // New Window is created. |
2133 running_browser = chrome::GetTotalBrowserCount(); | 2135 running_browser = chrome::GetTotalBrowserCount(); |
2134 EXPECT_EQ(1u, running_browser); | 2136 EXPECT_EQ(1u, running_browser); |
2135 EXPECT_TRUE(controller_->IsOpen(id)); | 2137 EXPECT_TRUE(controller_->IsOpen(id)); |
2136 | 2138 |
2137 // Minimize Window. | 2139 // Minimize Window. |
2138 ash::wm::WindowState* window_state = ash::wm::GetActiveWindowState(); | 2140 ash::wm::WindowState* window_state = ash::wm::GetActiveWindowState(); |
2139 window_state->Minimize(); | 2141 window_state->Minimize(); |
2140 EXPECT_TRUE(window_state->IsMinimized()); | 2142 EXPECT_TRUE(window_state->IsMinimized()); |
2141 | 2143 |
2142 // Activate again. This doesn't create new browser. | 2144 // Activate again. This doesn't create new browser, it activates the window. |
2143 // It activates window. | 2145 SelectItem(item_controller, ui::ET_UNKNOWN); |
2144 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); | |
2145 running_browser = chrome::GetTotalBrowserCount(); | 2146 running_browser = chrome::GetTotalBrowserCount(); |
2146 EXPECT_EQ(1u, running_browser); | 2147 EXPECT_EQ(1u, running_browser); |
2147 EXPECT_TRUE(controller_->IsOpen(id)); | 2148 EXPECT_TRUE(controller_->IsOpen(id)); |
2148 EXPECT_FALSE(window_state->IsMinimized()); | 2149 EXPECT_FALSE(window_state->IsMinimized()); |
2149 } | 2150 } |
2150 | 2151 |
2151 // Check that the window's ShelfID property matches that of the active tab. | 2152 // Check that the window's ShelfID property matches that of the active tab. |
2152 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { | 2153 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { |
2153 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 2154 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
2154 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 2155 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 | 2391 |
2391 // Close all windows via the menu item. | 2392 // Close all windows via the menu item. |
2392 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2393 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2393 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2394 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2394 | 2395 |
2395 // Check if "Close" is removed from the context menu. | 2396 // Check if "Close" is removed from the context menu. |
2396 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2397 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2397 ASSERT_FALSE( | 2398 ASSERT_FALSE( |
2398 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2399 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2399 } | 2400 } |
OLD | NEW |