| 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.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // pinned V2 app will start with a '*' + small letter. | 839 // pinned V2 app will start with a '*' + small letter. |
| 840 std::string GetPinnedAppStatus() { | 840 std::string GetPinnedAppStatus() { |
| 841 std::string result; | 841 std::string result; |
| 842 for (int i = 0; i < model_->item_count(); i++) { | 842 for (int i = 0; i < model_->item_count(); i++) { |
| 843 if (!result.empty()) | 843 if (!result.empty()) |
| 844 result.append(", "); | 844 result.append(", "); |
| 845 switch (model_->items()[i].type) { | 845 switch (model_->items()[i].type) { |
| 846 case ash::TYPE_APP: { | 846 case ash::TYPE_APP: { |
| 847 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) | 847 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) |
| 848 result += "*"; | 848 result += "*"; |
| 849 const std::string& app = | 849 const std::string& app = model_->items()[i].id.app_id; |
| 850 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | |
| 851 EXPECT_FALSE(launcher_controller_->IsAppPinned(app)); | 850 EXPECT_FALSE(launcher_controller_->IsAppPinned(app)); |
| 852 if (app == extension1_->id()) { | 851 if (app == extension1_->id()) { |
| 853 result += "app1"; | 852 result += "app1"; |
| 854 } else if (app == extension2_->id()) { | 853 } else if (app == extension2_->id()) { |
| 855 result += "app2"; | 854 result += "app2"; |
| 856 } else if (app == extension3_->id()) { | 855 } else if (app == extension3_->id()) { |
| 857 result += "app3"; | 856 result += "app3"; |
| 858 } else if (app == extension4_->id()) { | 857 } else if (app == extension4_->id()) { |
| 859 result += "app4"; | 858 result += "app4"; |
| 860 } else if (app == extension5_->id()) { | 859 } else if (app == extension5_->id()) { |
| 861 result += "app5"; | 860 result += "app5"; |
| 862 } else if (app == extension6_->id()) { | 861 } else if (app == extension6_->id()) { |
| 863 result += "app6"; | 862 result += "app6"; |
| 864 } else if (app == extension7_->id()) { | 863 } else if (app == extension7_->id()) { |
| 865 result += "app7"; | 864 result += "app7"; |
| 866 } else if (app == extension8_->id()) { | 865 } else if (app == extension8_->id()) { |
| 867 result += "app8"; | 866 result += "app8"; |
| 868 } else if (app == extension_platform_app_->id()) { | 867 } else if (app == extension_platform_app_->id()) { |
| 869 result += "platform_app"; | 868 result += "platform_app"; |
| 870 } else { | 869 } else { |
| 871 result += "unknown"; | 870 result += "unknown"; |
| 872 } | 871 } |
| 873 break; | 872 break; |
| 874 } | 873 } |
| 875 case ash::TYPE_PINNED_APP: { | 874 case ash::TYPE_PINNED_APP: { |
| 876 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) | 875 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) |
| 877 result += "*"; | 876 result += "*"; |
| 878 const std::string& app = | 877 const std::string& app = model_->items()[i].id.app_id; |
| 879 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | |
| 880 EXPECT_TRUE(launcher_controller_->IsAppPinned(app)); | 878 EXPECT_TRUE(launcher_controller_->IsAppPinned(app)); |
| 881 if (app == extension1_->id()) { | 879 if (app == extension1_->id()) { |
| 882 result += "App1"; | 880 result += "App1"; |
| 883 } else if (app == extension2_->id()) { | 881 } else if (app == extension2_->id()) { |
| 884 result += "App2"; | 882 result += "App2"; |
| 885 } else if (app == extension3_->id()) { | 883 } else if (app == extension3_->id()) { |
| 886 result += "App3"; | 884 result += "App3"; |
| 887 } else if (app == extension4_->id()) { | 885 } else if (app == extension4_->id()) { |
| 888 result += "App4"; | 886 result += "App4"; |
| 889 } else if (app == extension5_->id()) { | 887 } else if (app == extension5_->id()) { |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 UnloadedExtensionReason::UPDATE); | 1692 UnloadedExtensionReason::UPDATE); |
| 1695 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1693 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 1696 } | 1694 } |
| 1697 | 1695 |
| 1698 // Test the V1 app interaction flow: run it, activate it, close it. | 1696 // Test the V1 app interaction flow: run it, activate it, close it. |
| 1699 TEST_F(ChromeLauncherControllerTest, V1AppRunActivateClose) { | 1697 TEST_F(ChromeLauncherControllerTest, V1AppRunActivateClose) { |
| 1700 InitLauncherController(); | 1698 InitLauncherController(); |
| 1701 // The model should only contain the browser shortcut and app list items. | 1699 // The model should only contain the browser shortcut and app list items. |
| 1702 EXPECT_EQ(2, model_->item_count()); | 1700 EXPECT_EQ(2, model_->item_count()); |
| 1703 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1701 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1704 EXPECT_TRUE( | 1702 EXPECT_EQ(nullptr, |
| 1705 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1703 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1706 | 1704 |
| 1707 // Reporting that the app is running should create a new shelf item. | 1705 // Reporting that the app is running should create a new shelf item. |
| 1708 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); | 1706 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); |
| 1709 EXPECT_EQ(3, model_->item_count()); | 1707 EXPECT_EQ(3, model_->item_count()); |
| 1710 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); | 1708 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1711 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); | 1709 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); |
| 1712 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1710 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1713 EXPECT_FALSE( | 1711 EXPECT_NE(nullptr, |
| 1714 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1712 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1715 | 1713 |
| 1716 // Reporting an active status should just update the existing item. | 1714 // Reporting an active status should just update the existing item. |
| 1717 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_ACTIVE); | 1715 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_ACTIVE); |
| 1718 EXPECT_EQ(3, model_->item_count()); | 1716 EXPECT_EQ(3, model_->item_count()); |
| 1719 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[2].status); | 1717 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[2].status); |
| 1720 | 1718 |
| 1721 // Reporting that the app is closed should remove its shelf item. | 1719 // Reporting that the app is closed should remove its shelf item. |
| 1722 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); | 1720 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); |
| 1723 EXPECT_EQ(2, model_->item_count()); | 1721 EXPECT_EQ(2, model_->item_count()); |
| 1724 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1722 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1725 EXPECT_TRUE( | 1723 EXPECT_EQ(nullptr, |
| 1726 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1724 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1727 | 1725 |
| 1728 // Reporting that the app is closed again should have no effect. | 1726 // Reporting that the app is closed again should have no effect. |
| 1729 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); | 1727 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); |
| 1730 EXPECT_EQ(2, model_->item_count()); | 1728 EXPECT_EQ(2, model_->item_count()); |
| 1731 } | 1729 } |
| 1732 | 1730 |
| 1733 // Test the V1 app interaction flow: pin it, run it, close it, unpin it. | 1731 // Test the V1 app interaction flow: pin it, run it, close it, unpin it. |
| 1734 TEST_F(ChromeLauncherControllerTest, V1AppPinRunCloseUnpin) { | 1732 TEST_F(ChromeLauncherControllerTest, V1AppPinRunCloseUnpin) { |
| 1735 InitLauncherController(); | 1733 InitLauncherController(); |
| 1736 // The model should only contain the browser shortcut and app list items. | 1734 // The model should only contain the browser shortcut and app list items. |
| 1737 EXPECT_EQ(2, model_->item_count()); | 1735 EXPECT_EQ(2, model_->item_count()); |
| 1738 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1736 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1739 EXPECT_TRUE( | 1737 EXPECT_EQ(nullptr, |
| 1740 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1738 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1741 | 1739 |
| 1742 // Pinning the app should create a new shelf item. | 1740 // Pinning the app should create a new shelf item. |
| 1743 launcher_controller_->PinAppWithID(extension1_->id()); | 1741 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1744 EXPECT_EQ(3, model_->item_count()); | 1742 EXPECT_EQ(3, model_->item_count()); |
| 1745 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1743 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1746 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); | 1744 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); |
| 1747 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1745 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1748 EXPECT_FALSE( | 1746 EXPECT_NE(nullptr, |
| 1749 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1747 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1750 | 1748 |
| 1751 // Reporting that the app is running should just update the existing item. | 1749 // Reporting that the app is running should just update the existing item. |
| 1752 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); | 1750 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); |
| 1753 EXPECT_EQ(3, model_->item_count()); | 1751 EXPECT_EQ(3, model_->item_count()); |
| 1754 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1752 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1755 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); | 1753 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); |
| 1756 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1754 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1757 EXPECT_FALSE( | 1755 EXPECT_NE(nullptr, |
| 1758 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1756 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1759 | 1757 |
| 1760 // Reporting that the app is closed should just update the existing item. | 1758 // Reporting that the app is closed should just update the existing item. |
| 1761 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); | 1759 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); |
| 1762 EXPECT_EQ(3, model_->item_count()); | 1760 EXPECT_EQ(3, model_->item_count()); |
| 1763 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1761 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1764 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); | 1762 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); |
| 1765 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1763 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1766 EXPECT_FALSE( | 1764 EXPECT_NE(nullptr, |
| 1767 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1765 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1768 | 1766 |
| 1769 // Unpinning the app should remove its shelf item. | 1767 // Unpinning the app should remove its shelf item. |
| 1770 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1768 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1771 EXPECT_EQ(2, model_->item_count()); | 1769 EXPECT_EQ(2, model_->item_count()); |
| 1772 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1770 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1773 EXPECT_TRUE( | 1771 EXPECT_EQ(nullptr, |
| 1774 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1772 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1775 } | 1773 } |
| 1776 | 1774 |
| 1777 // Test the V1 app interaction flow: run it, pin it, close it, unpin it. | 1775 // Test the V1 app interaction flow: run it, pin it, close it, unpin it. |
| 1778 TEST_F(ChromeLauncherControllerTest, V1AppRunPinCloseUnpin) { | 1776 TEST_F(ChromeLauncherControllerTest, V1AppRunPinCloseUnpin) { |
| 1779 InitLauncherController(); | 1777 InitLauncherController(); |
| 1780 // The model should only contain the browser shortcut and app list items. | 1778 // The model should only contain the browser shortcut and app list items. |
| 1781 EXPECT_EQ(2, model_->item_count()); | 1779 EXPECT_EQ(2, model_->item_count()); |
| 1782 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1780 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1783 EXPECT_TRUE( | 1781 EXPECT_EQ(nullptr, |
| 1784 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1782 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1785 | 1783 |
| 1786 // Reporting that the app is running should create a new shelf item. | 1784 // Reporting that the app is running should create a new shelf item. |
| 1787 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); | 1785 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); |
| 1788 EXPECT_EQ(3, model_->item_count()); | 1786 EXPECT_EQ(3, model_->item_count()); |
| 1789 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); | 1787 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1790 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); | 1788 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); |
| 1791 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1789 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1792 EXPECT_FALSE( | 1790 EXPECT_NE(nullptr, |
| 1793 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1791 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1794 | 1792 |
| 1795 // Pinning the app should just update the existing item. | 1793 // Pinning the app should just update the existing item. |
| 1796 launcher_controller_->PinAppWithID(extension1_->id()); | 1794 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1797 EXPECT_EQ(3, model_->item_count()); | 1795 EXPECT_EQ(3, model_->item_count()); |
| 1798 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1796 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1799 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); | 1797 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); |
| 1800 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1798 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1801 EXPECT_FALSE( | 1799 EXPECT_NE(nullptr, |
| 1802 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1800 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1803 | 1801 |
| 1804 // Reporting that the app is closed should just update the existing item. | 1802 // Reporting that the app is closed should just update the existing item. |
| 1805 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); | 1803 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); |
| 1806 EXPECT_EQ(3, model_->item_count()); | 1804 EXPECT_EQ(3, model_->item_count()); |
| 1807 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1805 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1808 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); | 1806 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); |
| 1809 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1807 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1810 EXPECT_FALSE( | 1808 EXPECT_NE(nullptr, |
| 1811 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1809 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1812 | 1810 |
| 1813 // Unpinning the app should remove its shelf item. | 1811 // Unpinning the app should remove its shelf item. |
| 1814 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1812 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1815 EXPECT_EQ(2, model_->item_count()); | 1813 EXPECT_EQ(2, model_->item_count()); |
| 1816 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1814 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1817 EXPECT_TRUE( | 1815 EXPECT_EQ(nullptr, |
| 1818 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1816 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1819 } | 1817 } |
| 1820 | 1818 |
| 1821 // Test the V1 app interaction flow: pin it, run it, unpin it, close it. | 1819 // Test the V1 app interaction flow: pin it, run it, unpin it, close it. |
| 1822 TEST_F(ChromeLauncherControllerTest, V1AppPinRunUnpinClose) { | 1820 TEST_F(ChromeLauncherControllerTest, V1AppPinRunUnpinClose) { |
| 1823 InitLauncherController(); | 1821 InitLauncherController(); |
| 1824 // The model should only contain the browser shortcut and app list items. | 1822 // The model should only contain the browser shortcut and app list items. |
| 1825 EXPECT_EQ(2, model_->item_count()); | 1823 EXPECT_EQ(2, model_->item_count()); |
| 1826 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1824 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1827 EXPECT_TRUE( | 1825 EXPECT_EQ(nullptr, |
| 1828 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1826 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1829 | 1827 |
| 1830 // Pinning the app should create a new shelf item. | 1828 // Pinning the app should create a new shelf item. |
| 1831 launcher_controller_->PinAppWithID(extension1_->id()); | 1829 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1832 EXPECT_EQ(3, model_->item_count()); | 1830 EXPECT_EQ(3, model_->item_count()); |
| 1833 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1831 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1834 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); | 1832 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); |
| 1835 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1833 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1836 EXPECT_FALSE( | 1834 EXPECT_NE(nullptr, |
| 1837 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1835 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1838 | 1836 |
| 1839 // Reporting that the app is running should just update the existing item. | 1837 // Reporting that the app is running should just update the existing item. |
| 1840 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); | 1838 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); |
| 1841 EXPECT_EQ(3, model_->item_count()); | 1839 EXPECT_EQ(3, model_->item_count()); |
| 1842 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 1840 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 1843 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); | 1841 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); |
| 1844 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1842 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1845 EXPECT_FALSE( | 1843 EXPECT_NE(nullptr, |
| 1846 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1844 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1847 | 1845 |
| 1848 // Unpinning the app should just update the existing item. | 1846 // Unpinning the app should just update the existing item. |
| 1849 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1847 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1850 EXPECT_EQ(3, model_->item_count()); | 1848 EXPECT_EQ(3, model_->item_count()); |
| 1851 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); | 1849 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1852 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); | 1850 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); |
| 1853 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1851 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1854 EXPECT_FALSE( | 1852 EXPECT_NE(nullptr, |
| 1855 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1853 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1856 | 1854 |
| 1857 // Reporting that the app is closed should remove its shelf item. | 1855 // Reporting that the app is closed should remove its shelf item. |
| 1858 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); | 1856 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); |
| 1859 EXPECT_EQ(2, model_->item_count()); | 1857 EXPECT_EQ(2, model_->item_count()); |
| 1860 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1858 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1861 EXPECT_TRUE( | 1859 EXPECT_EQ(nullptr, |
| 1862 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsNull()); | 1860 launcher_controller_->GetItem(ash::ShelfID(extension1_->id()))); |
| 1863 } | 1861 } |
| 1864 | 1862 |
| 1865 // Ensure unpinned V1 app ordering is properly restored after user changes. | 1863 // Ensure unpinned V1 app ordering is properly restored after user changes. |
| 1866 TEST_F(ChromeLauncherControllerTest, CheckRunningV1AppOrder) { | 1864 TEST_F(ChromeLauncherControllerTest, CheckRunningV1AppOrder) { |
| 1867 InitLauncherController(); | 1865 InitLauncherController(); |
| 1868 // The model should only contain the browser shortcut and app list items. | 1866 // The model should only contain the browser shortcut and app list items. |
| 1869 EXPECT_EQ(2, model_->item_count()); | 1867 EXPECT_EQ(2, model_->item_count()); |
| 1870 | 1868 |
| 1871 // Add a few running applications. | 1869 // Add a few running applications. |
| 1872 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); | 1870 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1920 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1923 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1921 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1924 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1922 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1925 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); | 1923 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); |
| 1926 | 1924 |
| 1927 SendListOfArcApps(); | 1925 SendListOfArcApps(); |
| 1928 SendListOfArcShortcuts(); | 1926 SendListOfArcShortcuts(); |
| 1929 | 1927 |
| 1930 arc_test_.StopArcInstance(); | 1928 arc_test_.StopArcInstance(); |
| 1931 | 1929 |
| 1932 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 1930 const ash::ShelfID shelf_id_app_1(arc_app_id1); |
| 1933 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 1931 const ash::ShelfID shelf_id_app_2(arc_app_id2); |
| 1934 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsNull()); | 1932 const ash::ShelfID shelf_id_app_3(arc_app_id3); |
| 1935 EXPECT_TRUE( | 1933 const ash::ShelfID shelf_id_shortcut(arc_shortcut_id); |
| 1936 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id).IsNull()); | 1934 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_1)); |
| 1935 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_2)); |
| 1936 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_3)); |
| 1937 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_shortcut)); |
| 1937 | 1938 |
| 1938 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); | 1939 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); |
| 1939 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); | 1940 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); |
| 1940 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); | 1941 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); |
| 1941 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); | 1942 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); |
| 1942 arc::LaunchApp(profile(), arc_shortcut_id, ui::EF_LEFT_MOUSE_BUTTON); | 1943 arc::LaunchApp(profile(), arc_shortcut_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 1943 | 1944 |
| 1944 const ash::ShelfID shelf_id_app_1 = | 1945 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_app_1)); |
| 1945 launcher_controller_->GetShelfIDForAppID(arc_app_id1); | 1946 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_app_2)); |
| 1946 const ash::ShelfID shelf_id_app_2 = | 1947 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_app_3)); |
| 1947 launcher_controller_->GetShelfIDForAppID(arc_app_id2); | 1948 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_shortcut)); |
| 1948 const ash::ShelfID shelf_id_app_3 = | |
| 1949 launcher_controller_->GetShelfIDForAppID(arc_app_id3); | |
| 1950 const ash::ShelfID shelf_id_shortcut = | |
| 1951 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id); | |
| 1952 EXPECT_FALSE(shelf_id_app_1.IsNull()); | |
| 1953 EXPECT_FALSE(shelf_id_app_2.IsNull()); | |
| 1954 EXPECT_FALSE(shelf_id_app_3.IsNull()); | |
| 1955 EXPECT_FALSE(shelf_id_shortcut.IsNull()); | |
| 1956 | 1949 |
| 1957 // We activated arc_app_id1 twice but expect one close for item controller | 1950 // We activated arc_app_id1 twice but expect one close for item controller |
| 1958 // stops launching request. | 1951 // stops launching request. |
| 1959 ash::ShelfItemDelegate* item_delegate = | 1952 ash::ShelfItemDelegate* item_delegate = |
| 1960 model_->GetShelfItemDelegate(shelf_id_app_1); | 1953 model_->GetShelfItemDelegate(shelf_id_app_1); |
| 1961 ASSERT_NE(nullptr, item_delegate); | 1954 ASSERT_NE(nullptr, item_delegate); |
| 1962 item_delegate->Close(); | 1955 item_delegate->Close(); |
| 1963 base::RunLoop().RunUntilIdle(); | 1956 base::RunLoop().RunUntilIdle(); |
| 1964 | 1957 |
| 1965 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 1958 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_1)); |
| 1966 EXPECT_EQ(shelf_id_app_2, | 1959 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_app_2)); |
| 1967 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1960 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_app_3)); |
| 1968 EXPECT_EQ(shelf_id_app_3, | 1961 EXPECT_TRUE(launcher_controller_->GetItem(shelf_id_shortcut)); |
| 1969 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | |
| 1970 | 1962 |
| 1971 arc_test_.RestartArcInstance(); | 1963 arc_test_.RestartArcInstance(); |
| 1972 SendListOfArcApps(); | 1964 SendListOfArcApps(); |
| 1973 | 1965 |
| 1974 base::RunLoop().RunUntilIdle(); | 1966 base::RunLoop().RunUntilIdle(); |
| 1975 | 1967 |
| 1976 // Now deferred contollers should go away together with shelf items and ARC | 1968 // Now deferred contollers should go away together with shelf items and ARC |
| 1977 // app instance should receive request for launching apps and shortcuts. | 1969 // app instance should receive request for launching apps and shortcuts. |
| 1978 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 1970 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_1)); |
| 1979 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 1971 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_2)); |
| 1980 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsNull()); | 1972 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_app_3)); |
| 1973 EXPECT_FALSE(launcher_controller_->GetItem(shelf_id_shortcut)); |
| 1981 | 1974 |
| 1982 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); | 1975 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); |
| 1983 ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size()); | 1976 ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size()); |
| 1984 | 1977 |
| 1985 const arc::FakeAppInstance::Request* request1 = | 1978 const arc::FakeAppInstance::Request* request1 = |
| 1986 arc_test_.app_instance()->launch_requests()[0].get(); | 1979 arc_test_.app_instance()->launch_requests()[0].get(); |
| 1987 const arc::FakeAppInstance::Request* request2 = | 1980 const arc::FakeAppInstance::Request* request2 = |
| 1988 arc_test_.app_instance()->launch_requests()[1].get(); | 1981 arc_test_.app_instance()->launch_requests()[1].get(); |
| 1989 | 1982 |
| 1990 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1983 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1991 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1984 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| 1992 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), | 1985 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), |
| 1993 shortcut.intent_uri); | 1986 shortcut.intent_uri); |
| 1994 } | 1987 } |
| 1995 | 1988 |
| 1996 // Ensure the deferred controller does not override the active app controller | 1989 // Ensure the deferred controller does not override the active app controller |
| 1997 // (crbug.com/701152). | 1990 // (crbug.com/701152). |
| 1998 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunchForActiveApp) { | 1991 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunchForActiveApp) { |
| 1999 InitLauncherController(); | 1992 InitLauncherController(); |
| 2000 SendListOfArcApps(); | 1993 SendListOfArcApps(); |
| 2001 arc_test_.StopArcInstance(); | 1994 arc_test_.StopArcInstance(); |
| 2002 | 1995 |
| 2003 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; | 1996 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; |
| 2004 const std::string app_id = ArcAppTest::GetAppId(app); | 1997 const std::string app_id = ArcAppTest::GetAppId(app); |
| 2005 | 1998 |
| 2006 launcher_controller_->PinAppWithID(app_id); | 1999 launcher_controller_->PinAppWithID(app_id); |
| 2007 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 2000 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 2008 const ash::ShelfID shelf_id = | 2001 const ash::ShelfID shelf_id(app_id); |
| 2009 launcher_controller_->GetShelfIDForAppID(app_id); | 2002 const ash::ShelfItem* item = launcher_controller_->GetItem(shelf_id); |
| 2010 EXPECT_FALSE(shelf_id.IsNull()); | 2003 ASSERT_NE(nullptr, item); |
| 2011 | 2004 EXPECT_EQ(ash::STATUS_CLOSED, item->status); |
| 2012 int item_index = model_->ItemIndexByID(shelf_id); | 2005 EXPECT_EQ(ash::TYPE_PINNED_APP, item->type); |
| 2013 ASSERT_GE(item_index, 0); | |
| 2014 | |
| 2015 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); | |
| 2016 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); | |
| 2017 | 2006 |
| 2018 // Play Store app is ARC app that might be represented by native Chrome | 2007 // Play Store app is ARC app that might be represented by native Chrome |
| 2019 // platform app. | 2008 // platform app. |
| 2020 model_->SetShelfItemDelegate( | 2009 model_->SetShelfItemDelegate( |
| 2021 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>( | 2010 shelf_id, |
| 2022 ash::ShelfID(app_id))); | 2011 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id)); |
| 2023 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 2012 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 2024 | 2013 |
| 2025 // This launch request should be ignored in case of active app. | 2014 // This launch request should be ignored in case of active app. |
| 2026 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 2015 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 2027 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 2016 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 2028 | 2017 |
| 2029 // Close app but shortcut should exist. | 2018 // Closing the app should leave a pinned but closed shelf item shortcut. |
| 2030 launcher_controller_->CloseLauncherItem(shelf_id); | 2019 launcher_controller_->CloseLauncherItem(shelf_id); |
| 2031 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id)); | 2020 item = launcher_controller_->GetItem(shelf_id); |
| 2032 | 2021 ASSERT_NE(nullptr, item); |
| 2033 // This should switch shelf item into closed state. | 2022 EXPECT_EQ(ash::STATUS_CLOSED, item->status); |
| 2034 item_index = model_->ItemIndexByID(shelf_id); | 2023 EXPECT_EQ(ash::TYPE_PINNED_APP, item->type); |
| 2035 ASSERT_GE(item_index, 0); | |
| 2036 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); | |
| 2037 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); | |
| 2038 | 2024 |
| 2039 // Now launch request should not be ignored. | 2025 // Now launch request should not be ignored. |
| 2040 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); | 2026 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 2041 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 2027 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 2042 } | 2028 } |
| 2043 | 2029 |
| 2044 TEST_P(ChromeLauncherControllerMultiProfileWithArcTest, ArcMultiUser) { | 2030 TEST_P(ChromeLauncherControllerMultiProfileWithArcTest, ArcMultiUser) { |
| 2045 SendListOfArcApps(); | 2031 SendListOfArcApps(); |
| 2046 | 2032 |
| 2047 InitLauncherController(); | 2033 InitLauncherController(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2066 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2052 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2067 const std::string arc_app_id2 = | 2053 const std::string arc_app_id2 = |
| 2068 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2054 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 2069 const std::string arc_app_id3 = | 2055 const std::string arc_app_id3 = |
| 2070 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); | 2056 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); |
| 2071 | 2057 |
| 2072 std::string window_app_id1("org.chromium.arc.1"); | 2058 std::string window_app_id1("org.chromium.arc.1"); |
| 2073 views::Widget* arc_window1 = CreateArcWindow(window_app_id1); | 2059 views::Widget* arc_window1 = CreateArcWindow(window_app_id1); |
| 2074 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2060 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2075 std::string()); | 2061 std::string()); |
| 2076 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2062 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2077 | 2063 |
| 2078 std::string window_app_id2("org.chromium.arc.2"); | 2064 std::string window_app_id2("org.chromium.arc.2"); |
| 2079 views::Widget* arc_window2 = CreateArcWindow(window_app_id2); | 2065 views::Widget* arc_window2 = CreateArcWindow(window_app_id2); |
| 2080 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], | 2066 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], |
| 2081 std::string()); | 2067 std::string()); |
| 2082 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2068 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2083 | 2069 |
| 2084 launcher_controller_->SetProfileForTest(profile2); | 2070 launcher_controller_->SetProfileForTest(profile2); |
| 2085 SwitchActiveUser(account_id2); | 2071 SwitchActiveUser(account_id2); |
| 2086 | 2072 |
| 2087 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2073 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2088 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2074 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2089 | 2075 |
| 2090 std::string window_app_id3("org.chromium.arc.3"); | 2076 std::string window_app_id3("org.chromium.arc.3"); |
| 2091 views::Widget* arc_window3 = CreateArcWindow(window_app_id3); | 2077 views::Widget* arc_window3 = CreateArcWindow(window_app_id3); |
| 2092 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[2], | 2078 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[2], |
| 2093 std::string()); | 2079 std::string()); |
| 2094 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsNull()); | 2080 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id3))); |
| 2095 | 2081 |
| 2096 arc_window2->CloseNow(); | 2082 arc_window2->CloseNow(); |
| 2097 arc_test_.app_instance()->SendTaskDestroyed(2); | 2083 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 2098 | 2084 |
| 2099 launcher_controller_->SetProfileForTest(profile()); | 2085 launcher_controller_->SetProfileForTest(profile()); |
| 2100 SwitchActiveUser(account_id); | 2086 SwitchActiveUser(account_id); |
| 2101 | 2087 |
| 2102 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2088 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2103 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2089 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2104 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsNull()); | 2090 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id3))); |
| 2105 | 2091 |
| 2106 // Close active window to let test passes. | 2092 // Close active window to let test passes. |
| 2107 arc_window1->CloseNow(); | 2093 arc_window1->CloseNow(); |
| 2108 arc_window3->CloseNow(); | 2094 arc_window3->CloseNow(); |
| 2109 } | 2095 } |
| 2110 | 2096 |
| 2111 TEST_P(ChromeLauncherControllerWithArcTest, ArcRunningApp) { | 2097 TEST_P(ChromeLauncherControllerWithArcTest, ArcRunningApp) { |
| 2112 InitLauncherController(); | 2098 InitLauncherController(); |
| 2113 | 2099 |
| 2114 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2100 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2115 SendListOfArcApps(); | 2101 SendListOfArcApps(); |
| 2116 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2102 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2117 | 2103 |
| 2118 // Normal flow, create/destroy tasks. | 2104 // Normal flow, create/destroy tasks. |
| 2119 std::string window_app_id1("org.chromium.arc.1"); | 2105 std::string window_app_id1("org.chromium.arc.1"); |
| 2120 std::string window_app_id2("org.chromium.arc.2"); | 2106 std::string window_app_id2("org.chromium.arc.2"); |
| 2121 std::string window_app_id3("org.chromium.arc.3"); | 2107 std::string window_app_id3("org.chromium.arc.3"); |
| 2122 CreateArcWindow(window_app_id1); | 2108 CreateArcWindow(window_app_id1); |
| 2123 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2109 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2124 std::string()); | 2110 std::string()); |
| 2125 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2111 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2126 CreateArcWindow(window_app_id2); | 2112 CreateArcWindow(window_app_id2); |
| 2127 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0], | 2113 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0], |
| 2128 std::string()); | 2114 std::string()); |
| 2129 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2115 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2130 arc_test_.app_instance()->SendTaskDestroyed(1); | 2116 arc_test_.app_instance()->SendTaskDestroyed(1); |
| 2131 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2117 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2132 arc_test_.app_instance()->SendTaskDestroyed(2); | 2118 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 2133 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2119 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2134 | 2120 |
| 2135 // Stopping bridge removes apps. | 2121 // Stopping bridge removes apps. |
| 2136 CreateArcWindow(window_app_id3); | 2122 CreateArcWindow(window_app_id3); |
| 2137 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0], | 2123 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0], |
| 2138 std::string()); | 2124 std::string()); |
| 2139 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2125 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2140 arc_test_.StopArcInstance(); | 2126 arc_test_.StopArcInstance(); |
| 2141 base::RunLoop().RunUntilIdle(); | 2127 base::RunLoop().RunUntilIdle(); |
| 2142 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsNull()); | 2128 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2143 } | 2129 } |
| 2144 | 2130 |
| 2145 // Test race creation/deletion of ARC app. | 2131 // Test race creation/deletion of ARC app. |
| 2146 // TODO(khmel): Remove after moving everything to wayland protocol. | 2132 // TODO(khmel): Remove after moving everything to wayland protocol. |
| 2147 TEST_P(ChromeLauncherControllerWithArcTest, ArcRaceCreateClose) { | 2133 TEST_P(ChromeLauncherControllerWithArcTest, ArcRaceCreateClose) { |
| 2148 InitLauncherController(); | 2134 InitLauncherController(); |
| 2149 | 2135 |
| 2150 const std::string arc_app_id1 = | 2136 const std::string arc_app_id1 = |
| 2151 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2137 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2152 const std::string arc_app_id2 = | 2138 const std::string arc_app_id2 = |
| 2153 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2139 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 2154 SendListOfArcApps(); | 2140 SendListOfArcApps(); |
| 2155 | 2141 |
| 2156 // ARC window created before and closed after mojom notification. | 2142 // ARC window created before and closed after mojom notification. |
| 2157 std::string window_app_id1("org.chromium.arc.1"); | 2143 std::string window_app_id1("org.chromium.arc.1"); |
| 2158 views::Widget* arc_window = CreateArcWindow(window_app_id1); | 2144 views::Widget* arc_window = CreateArcWindow(window_app_id1); |
| 2159 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2145 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2160 ASSERT_TRUE(arc_window); | 2146 ASSERT_TRUE(arc_window); |
| 2161 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2147 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2162 std::string()); | 2148 std::string()); |
| 2163 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2149 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2164 arc_test_.app_instance()->SendTaskDestroyed(1); | 2150 arc_test_.app_instance()->SendTaskDestroyed(1); |
| 2165 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2151 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2166 arc_window->Close(); | 2152 arc_window->Close(); |
| 2167 base::RunLoop().RunUntilIdle(); | 2153 base::RunLoop().RunUntilIdle(); |
| 2168 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsNull()); | 2154 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id1))); |
| 2169 | 2155 |
| 2170 // ARC window created after and closed before mojom notification. | 2156 // ARC window created after and closed before mojom notification. |
| 2171 std::string window_app_id2("org.chromium.arc.2"); | 2157 std::string window_app_id2("org.chromium.arc.2"); |
| 2172 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], | 2158 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], |
| 2173 std::string()); | 2159 std::string()); |
| 2174 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2160 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2175 arc_window = CreateArcWindow(window_app_id2); | 2161 arc_window = CreateArcWindow(window_app_id2); |
| 2176 ASSERT_TRUE(arc_window); | 2162 ASSERT_TRUE(arc_window); |
| 2177 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2163 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2178 arc_window->Close(); | 2164 arc_window->Close(); |
| 2179 base::RunLoop().RunUntilIdle(); | 2165 base::RunLoop().RunUntilIdle(); |
| 2180 // Closing window does not close shelf item. It is closed on task destroy. | 2166 // Closing window does not close shelf item. It is closed on task destroy. |
| 2181 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2167 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2182 arc_test_.app_instance()->SendTaskDestroyed(2); | 2168 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 2183 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsNull()); | 2169 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id2))); |
| 2184 } | 2170 } |
| 2185 | 2171 |
| 2186 TEST_P(ChromeLauncherControllerWithArcTest, ArcWindowRecreation) { | 2172 TEST_P(ChromeLauncherControllerWithArcTest, ArcWindowRecreation) { |
| 2187 InitLauncherController(); | 2173 InitLauncherController(); |
| 2188 | 2174 |
| 2189 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2175 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2190 SendListOfArcApps(); | 2176 SendListOfArcApps(); |
| 2191 | 2177 |
| 2192 std::string window_app_id("org.chromium.arc.1"); | 2178 std::string window_app_id("org.chromium.arc.1"); |
| 2193 views::Widget* arc_window = CreateArcWindow(window_app_id); | 2179 views::Widget* arc_window = CreateArcWindow(window_app_id); |
| 2194 ASSERT_TRUE(arc_window); | 2180 ASSERT_TRUE(arc_window); |
| 2195 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2181 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2196 std::string()); | 2182 std::string()); |
| 2197 const ash::ShelfID shelf_id = | 2183 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2198 launcher_controller_->GetShelfIDForAppID(arc_app_id); | |
| 2199 EXPECT_FALSE(shelf_id.IsNull()); | |
| 2200 | 2184 |
| 2201 for (int i = 0; i < 3; ++i) { | 2185 for (int i = 0; i < 3; ++i) { |
| 2202 arc_window->Close(); | 2186 arc_window->Close(); |
| 2203 base::RunLoop().RunUntilIdle(); | 2187 base::RunLoop().RunUntilIdle(); |
| 2204 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2188 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2205 | 2189 |
| 2206 arc_window = CreateArcWindow(window_app_id); | 2190 arc_window = CreateArcWindow(window_app_id); |
| 2207 ASSERT_TRUE(arc_window); | 2191 ASSERT_TRUE(arc_window); |
| 2208 base::RunLoop().RunUntilIdle(); | 2192 base::RunLoop().RunUntilIdle(); |
| 2209 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2193 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(arc_app_id))); |
| 2210 } | 2194 } |
| 2211 } | 2195 } |
| 2212 | 2196 |
| 2213 // Validate that ARC app is pinned correctly and pin is removed automatically | 2197 // Validate that ARC app is pinned correctly and pin is removed automatically |
| 2214 // once app is uninstalled. | 2198 // once app is uninstalled. |
| 2215 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPin) { | 2199 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPin) { |
| 2216 InitLauncherController(); | 2200 InitLauncherController(); |
| 2217 | 2201 |
| 2218 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2202 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2219 | 2203 |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2894 // Check that browsers get reflected correctly in the launcher menu. | 2878 // Check that browsers get reflected correctly in the launcher menu. |
| 2895 TEST_F(ChromeLauncherControllerTest, BrowserMenuGeneration) { | 2879 TEST_F(ChromeLauncherControllerTest, BrowserMenuGeneration) { |
| 2896 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 2880 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
| 2897 chrome::NewTab(browser()); | 2881 chrome::NewTab(browser()); |
| 2898 | 2882 |
| 2899 InitLauncherController(); | 2883 InitLauncherController(); |
| 2900 | 2884 |
| 2901 // Check that the browser list is empty at this time. | 2885 // Check that the browser list is empty at this time. |
| 2902 ash::ShelfItem item_browser; | 2886 ash::ShelfItem item_browser; |
| 2903 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2887 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 2904 item_browser.id = | 2888 item_browser.id = ash::ShelfID(extension_misc::kChromeAppId); |
| 2905 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | |
| 2906 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); | 2889 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); |
| 2907 | 2890 |
| 2908 // Now make the created browser() visible by showing its browser window. | 2891 // Now make the created browser() visible by showing its browser window. |
| 2909 browser()->window()->Show(); | 2892 browser()->window()->Show(); |
| 2910 base::string16 title1 = ASCIIToUTF16("Test1"); | 2893 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 2911 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); | 2894 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); |
| 2912 base::string16 one_menu_item[] = {title1}; | 2895 base::string16 one_menu_item[] = {title1}; |
| 2913 | 2896 |
| 2914 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item); | 2897 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item); |
| 2915 | 2898 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2932 } | 2915 } |
| 2933 | 2916 |
| 2934 // Check the multi profile case where only user related browsers should show up. | 2917 // Check the multi profile case where only user related browsers should show up. |
| 2935 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 2918 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 2936 BrowserMenuGenerationTwoUsers) { | 2919 BrowserMenuGenerationTwoUsers) { |
| 2937 // Create a browser item in the LauncherController. | 2920 // Create a browser item in the LauncherController. |
| 2938 InitLauncherController(); | 2921 InitLauncherController(); |
| 2939 | 2922 |
| 2940 ash::ShelfItem item_browser; | 2923 ash::ShelfItem item_browser; |
| 2941 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2924 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 2942 item_browser.id = | 2925 item_browser.id = ash::ShelfID(extension_misc::kChromeAppId); |
| 2943 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | |
| 2944 | 2926 |
| 2945 // Check that the menu is empty. | 2927 // Check that the menu is empty. |
| 2946 chrome::NewTab(browser()); | 2928 chrome::NewTab(browser()); |
| 2947 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); | 2929 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); |
| 2948 | 2930 |
| 2949 // Show the created |browser()| by showing its window. | 2931 // Show the created |browser()| by showing its window. |
| 2950 browser()->window()->Show(); | 2932 browser()->window()->Show(); |
| 2951 base::string16 title1 = ASCIIToUTF16("Test1"); | 2933 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 2952 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); | 2934 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); |
| 2953 base::string16 one_menu_item1[] = {title1}; | 2935 base::string16 one_menu_item1[] = {title1}; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2984 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) { | 2966 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) { |
| 2985 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 2967 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
| 2986 EXPECT_EQ(0, browser()->tab_strip_model()->count()); | 2968 EXPECT_EQ(0, browser()->tab_strip_model()->count()); |
| 2987 | 2969 |
| 2988 InitLauncherControllerWithBrowser(); | 2970 InitLauncherControllerWithBrowser(); |
| 2989 | 2971 |
| 2990 // The model should only contain the browser shortcut and app list items. | 2972 // The model should only contain the browser shortcut and app list items. |
| 2991 EXPECT_EQ(2, model_->item_count()); | 2973 EXPECT_EQ(2, model_->item_count()); |
| 2992 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 2974 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 2993 | 2975 |
| 2994 // Installing |extension3_| adds it to the launcher. | 2976 // Installing |extension3_| pins it to the launcher. |
| 2995 const ash::ShelfID gmail_id(extension3_->id()); | 2977 const ash::ShelfID gmail_id(extension3_->id()); |
| 2996 extension_service_->AddExtension(extension3_.get()); | 2978 extension_service_->AddExtension(extension3_.get()); |
| 2997 EXPECT_EQ(3, model_->item_count()); | |
| 2998 int gmail_index = model_->ItemIndexByID(gmail_id); | |
| 2999 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | |
| 3000 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 2979 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 3001 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); | 2980 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); |
| 3002 | 2981 |
| 3003 // Check the menu content. | 2982 // Check the menu content. |
| 3004 ash::ShelfItem item_browser; | 2983 ash::ShelfItem item_browser; |
| 3005 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2984 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 3006 item_browser.id = | 2985 item_browser.id = ash::ShelfID(extension_misc::kChromeAppId); |
| 3007 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | |
| 3008 | 2986 |
| 3009 ash::ShelfItem item_gmail; | 2987 ash::ShelfItem item_gmail; |
| 3010 item_gmail.type = ash::TYPE_PINNED_APP; | 2988 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3011 item_gmail.id = gmail_id; | 2989 item_gmail.id = gmail_id; |
| 3012 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); | 2990 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3013 | 2991 |
| 3014 // Set the gmail URL to a new tab. | 2992 // Set the gmail URL to a new tab. |
| 3015 base::string16 title1 = ASCIIToUTF16("Test1"); | 2993 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3016 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); | 2994 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); |
| 3017 | 2995 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3044 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2); | 3022 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2); |
| 3045 } | 3023 } |
| 3046 | 3024 |
| 3047 // Check the multi profile case where only user related apps should show up. | 3025 // Check the multi profile case where only user related apps should show up. |
| 3048 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 3026 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
| 3049 V1AppMenuGenerationTwoUsers) { | 3027 V1AppMenuGenerationTwoUsers) { |
| 3050 // Create a browser item in the LauncherController. | 3028 // Create a browser item in the LauncherController. |
| 3051 InitLauncherController(); | 3029 InitLauncherController(); |
| 3052 chrome::NewTab(browser()); | 3030 chrome::NewTab(browser()); |
| 3053 | 3031 |
| 3054 // Installing |extension3_| adds it to the launcher. | 3032 // Installing |extension3_| pins it to the launcher. |
| 3055 const ash::ShelfID gmail_id(extension3_->id()); | 3033 const ash::ShelfID gmail_id(extension3_->id()); |
| 3056 extension_service_->AddExtension(extension3_.get()); | 3034 extension_service_->AddExtension(extension3_.get()); |
| 3057 EXPECT_EQ(3, model_->item_count()); | |
| 3058 int gmail_index = model_->ItemIndexByID(gmail_id); | |
| 3059 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | |
| 3060 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3035 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 3061 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); | 3036 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(kGmailUrl)); |
| 3062 | 3037 |
| 3063 // Check the menu content. | 3038 // Check the menu content. |
| 3064 ash::ShelfItem item_browser; | 3039 ash::ShelfItem item_browser; |
| 3065 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 3040 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 3066 item_browser.id = | 3041 item_browser.id = ash::ShelfID(extension_misc::kChromeAppId); |
| 3067 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | |
| 3068 | 3042 |
| 3069 ash::ShelfItem item_gmail; | 3043 ash::ShelfItem item_gmail; |
| 3070 item_gmail.type = ash::TYPE_PINNED_APP; | 3044 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3071 item_gmail.id = gmail_id; | 3045 item_gmail.id = gmail_id; |
| 3072 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); | 3046 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3073 | 3047 |
| 3074 // Set the gmail URL to a new tab. | 3048 // Set the gmail URL to a new tab. |
| 3075 base::string16 title1 = ASCIIToUTF16("Test1"); | 3049 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3076 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); | 3050 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title1); |
| 3077 | 3051 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3417 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. | 3391 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. |
| 3418 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( | 3392 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( |
| 3419 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); | 3393 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); |
| 3420 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); | 3394 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); |
| 3421 int panel_index = model_observer_->last_index(); | 3395 int panel_index = model_observer_->last_index(); |
| 3422 EXPECT_EQ(1, model_observer_->added()); | 3396 EXPECT_EQ(1, model_observer_->added()); |
| 3423 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3397 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 3424 model_observer_->clear_counts(); | 3398 model_observer_->clear_counts(); |
| 3425 | 3399 |
| 3426 // App panels should have a separate identifier than the app id | 3400 // App panels should have a separate identifier than the app id |
| 3427 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(app_id).IsNull()); | 3401 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(app_id))); |
| 3428 | 3402 |
| 3429 // Setting the app image should not change the panel, which has a window icon. | 3403 // Setting the app image should not change the panel, which has a window icon. |
| 3430 gfx::ImageSkia image; | 3404 gfx::ImageSkia image; |
| 3431 launcher_controller_->OnAppImageUpdated(app_id, image); | 3405 launcher_controller_->OnAppImageUpdated(app_id, image); |
| 3432 EXPECT_EQ(0, model_observer_->changed()); | 3406 EXPECT_EQ(0, model_observer_->changed()); |
| 3433 model_observer_->clear_counts(); | 3407 model_observer_->clear_counts(); |
| 3434 | 3408 |
| 3435 // Make a second app panel and verify that it gets the same index as the first | 3409 // Make a second app panel and verify that it gets the same index as the first |
| 3436 // panel, being added to the left of the existing panel. | 3410 // panel, being added to the left of the existing panel. |
| 3437 std::unique_ptr<V2App> app_panel2 = base::MakeUnique<V2App>( | 3411 std::unique_ptr<V2App> app_panel2 = base::MakeUnique<V2App>( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3453 // Create a Gmail browser tab. | 3427 // Create a Gmail browser tab. |
| 3454 chrome::NewTab(browser()); | 3428 chrome::NewTab(browser()); |
| 3455 base::string16 title = ASCIIToUTF16("Test"); | 3429 base::string16 title = ASCIIToUTF16("Test"); |
| 3456 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title); | 3430 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kGmailUrl), title); |
| 3457 content::WebContents* content = | 3431 content::WebContents* content = |
| 3458 browser()->tab_strip_model()->GetActiveWebContents(); | 3432 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3459 | 3433 |
| 3460 // Check that the launcher controller does not recognize the running app. | 3434 // Check that the launcher controller does not recognize the running app. |
| 3461 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 3435 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 3462 | 3436 |
| 3463 // Installing |extension3_| adds it to the launcher. | 3437 // Installing |extension3_| pins it to the launcher. |
| 3464 const ash::ShelfID gmail_id(extension3_->id()); | 3438 const ash::ShelfID gmail_id(extension3_->id()); |
| 3465 extension_service_->AddExtension(extension3_.get()); | 3439 extension_service_->AddExtension(extension3_.get()); |
| 3466 EXPECT_EQ(3, model_->item_count()); | |
| 3467 int gmail_index = model_->ItemIndexByID(gmail_id); | |
| 3468 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | |
| 3469 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3440 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 3470 | 3441 |
| 3471 // Check that it is now handled. | 3442 // Check that it is now handled. |
| 3472 EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 3443 EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 3473 | 3444 |
| 3474 // Check also that the app has detected that properly. | 3445 // Check also that the app has detected that properly. |
| 3475 ash::ShelfItem item_gmail; | 3446 ash::ShelfItem item_gmail; |
| 3476 item_gmail.type = ash::TYPE_PINNED_APP; | 3447 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3477 item_gmail.id = gmail_id; | 3448 item_gmail.id = gmail_id; |
| 3478 EXPECT_EQ(1U, | 3449 EXPECT_EQ(1U, |
| 3479 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size()); | 3450 launcher_controller_->GetAppMenuItemsForTesting(item_gmail).size()); |
| 3480 } | 3451 } |
| 3481 | 3452 |
| 3482 // Tests that the Gmail extension does not match the offline verison. | 3453 // Tests that the Gmail extension does not match the offline verison. |
| 3483 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) { | 3454 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) { |
| 3484 InitLauncherControllerWithBrowser(); | 3455 InitLauncherControllerWithBrowser(); |
| 3485 | 3456 |
| 3486 // Create a Gmail browser tab. | 3457 // Create a Gmail browser tab. |
| 3487 chrome::NewTab(browser()); | 3458 chrome::NewTab(browser()); |
| 3488 base::string16 title = ASCIIToUTF16("Test"); | 3459 base::string16 title = ASCIIToUTF16("Test"); |
| 3489 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kOfflineGmailUrl), title); | 3460 NavigateAndCommitActiveTabWithTitle(browser(), GURL(kOfflineGmailUrl), title); |
| 3490 content::WebContents* content = | 3461 content::WebContents* content = |
| 3491 browser()->tab_strip_model()->GetActiveWebContents(); | 3462 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3492 | 3463 |
| 3493 // Installing |extension3_| adds it to the launcher. | 3464 // Installing |extension3_| pins it to the launcher. |
| 3494 const ash::ShelfID gmail_id(extension3_->id()); | 3465 const ash::ShelfID gmail_id(extension3_->id()); |
| 3495 extension_service_->AddExtension(extension3_.get()); | 3466 extension_service_->AddExtension(extension3_.get()); |
| 3496 EXPECT_EQ(3, model_->item_count()); | |
| 3497 int gmail_index = model_->ItemIndexByID(gmail_id); | |
| 3498 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | |
| 3499 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3467 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 3500 | 3468 |
| 3501 // The content should not be able to be handled by the app. | 3469 // The content should not be able to be handled by the app. |
| 3502 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 3470 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 3503 } | 3471 } |
| 3504 | 3472 |
| 3505 // Verify that the launcher item positions are persisted and restored. | 3473 // Verify that the launcher item positions are persisted and restored. |
| 3506 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) { | 3474 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) { |
| 3507 InitLauncherController(); | 3475 InitLauncherController(); |
| 3508 | 3476 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3563 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 3531 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 3564 SetLauncherControllerHelper(helper); | 3532 SetLauncherControllerHelper(helper); |
| 3565 | 3533 |
| 3566 // app_icon_loader is owned by ChromeLauncherController. | 3534 // app_icon_loader is owned by ChromeLauncherController. |
| 3567 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; | 3535 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; |
| 3568 app_icon_loader->AddSupportedApp("1"); | 3536 app_icon_loader->AddSupportedApp("1"); |
| 3569 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | 3537 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 3570 EXPECT_EQ(0, app_icon_loader->fetch_count()); | 3538 EXPECT_EQ(0, app_icon_loader->fetch_count()); |
| 3571 | 3539 |
| 3572 launcher_controller_->PinAppWithID("1"); | 3540 launcher_controller_->PinAppWithID("1"); |
| 3573 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); | 3541 const int app_index = model_->ItemIndexByID(ash::ShelfID("1")); |
| 3574 int app_index = model_->ItemIndexByID(id); | |
| 3575 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3542 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 3576 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); | 3543 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); |
| 3577 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 3544 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 3578 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 3545 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 3579 EXPECT_EQ(initial_size + 1, model_->items().size()); | 3546 EXPECT_EQ(initial_size + 1, model_->items().size()); |
| 3580 | 3547 |
| 3581 RecreateLauncherController(); | 3548 RecreateLauncherController(); |
| 3582 helper = new TestLauncherControllerHelper(profile()); | 3549 helper = new TestLauncherControllerHelper(profile()); |
| 3583 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 3550 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 3584 SetLauncherControllerHelper(helper); | 3551 SetLauncherControllerHelper(helper); |
| 3585 // app_icon_loader is owned by ChromeLauncherController. | 3552 // app_icon_loader is owned by ChromeLauncherController. |
| 3586 app_icon_loader = new TestAppIconLoaderImpl; | 3553 app_icon_loader = new TestAppIconLoaderImpl; |
| 3587 app_icon_loader->AddSupportedApp("1"); | 3554 app_icon_loader->AddSupportedApp("1"); |
| 3588 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | 3555 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 3589 launcher_controller_->Init(); | 3556 launcher_controller_->Init(); |
| 3590 | 3557 |
| 3591 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3558 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 3592 ASSERT_EQ(initial_size + 1, model_->items().size()); | 3559 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 3593 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 3560 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 3594 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 3561 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 3595 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); | 3562 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); |
| 3596 | 3563 |
| 3597 launcher_controller_->UnpinAppWithID("1"); | 3564 launcher_controller_->UnpinAppWithID("1"); |
| 3598 ASSERT_EQ(initial_size, model_->items().size()); | 3565 ASSERT_EQ(initial_size, model_->items().size()); |
| 3599 } | 3566 } |
| 3600 | 3567 |
| 3601 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) { | 3568 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) { |
| 3602 InitLauncherControllerWithBrowser(); | 3569 InitLauncherControllerWithBrowser(); |
| 3603 | 3570 |
| 3604 const std::string app_id1 = extension1_->id(); | 3571 const ash::ShelfID shelf_id1(extension1_->id()); |
| 3605 const std::string app_id2 = extension2_->id(); | 3572 const ash::ShelfID shelf_id2(extension2_->id()); |
| 3606 const std::string app_id3 = extension3_->id(); | 3573 const ash::ShelfID shelf_id3(extension3_->id()); |
| 3607 // app_icon_loader1 and app_icon_loader2 are owned by | 3574 // app_icon_loader1 and app_icon_loader2 are owned by |
| 3608 // ChromeLauncherController. | 3575 // ChromeLauncherController. |
| 3609 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 3576 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
| 3610 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 3577 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
| 3611 app_icon_loader1->AddSupportedApp(app_id1); | 3578 app_icon_loader1->AddSupportedApp(shelf_id1.app_id); |
| 3612 app_icon_loader2->AddSupportedApp(app_id2); | 3579 app_icon_loader2->AddSupportedApp(shelf_id2.app_id); |
| 3613 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), | 3580 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
| 3614 std::unique_ptr<AppIconLoader>(app_icon_loader2)); | 3581 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
| 3615 | 3582 |
| 3616 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( | 3583 launcher_controller_->CreateAppLauncherItem( |
| 3617 base::MakeUnique<ExtensionAppWindowLauncherItemController>( | 3584 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id3), |
| 3618 ash::ShelfID(app_id3)), | |
| 3619 ash::STATUS_RUNNING); | 3585 ash::STATUS_RUNNING); |
| 3620 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3586 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 3621 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3587 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3622 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 3588 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
| 3623 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3589 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3624 | 3590 |
| 3625 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( | 3591 launcher_controller_->CreateAppLauncherItem( |
| 3626 base::MakeUnique<ExtensionAppWindowLauncherItemController>( | 3592 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id2), |
| 3627 ash::ShelfID(app_id2)), | |
| 3628 ash::STATUS_RUNNING); | 3593 ash::STATUS_RUNNING); |
| 3629 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3594 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 3630 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3595 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3631 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3596 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3632 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3597 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3633 | 3598 |
| 3634 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( | 3599 launcher_controller_->CreateAppLauncherItem( |
| 3635 base::MakeUnique<ExtensionAppWindowLauncherItemController>( | 3600 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id1), |
| 3636 ash::ShelfID(app_id1)), | |
| 3637 ash::STATUS_RUNNING); | 3601 ash::STATUS_RUNNING); |
| 3638 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3602 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3639 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3603 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3640 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3604 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3641 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3605 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3642 | 3606 |
| 3643 launcher_controller_->CloseLauncherItem(shelfId1); | 3607 launcher_controller_->CloseLauncherItem(shelf_id1); |
| 3644 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3608 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3645 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3609 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 3646 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3610 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3647 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3611 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3648 | 3612 |
| 3649 launcher_controller_->CloseLauncherItem(shelfId2); | 3613 launcher_controller_->CloseLauncherItem(shelf_id2); |
| 3650 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3614 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3651 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3615 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 3652 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3616 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3653 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3617 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3654 | 3618 |
| 3655 launcher_controller_->CloseLauncherItem(shelfId3); | 3619 launcher_controller_->CloseLauncherItem(shelf_id3); |
| 3656 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3620 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3657 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3621 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 3658 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3622 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3659 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3623 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3660 } | 3624 } |
| 3661 | 3625 |
| 3662 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinPolicy) { | 3626 TEST_P(ChromeLauncherControllerWithArcTest, ArcAppPinPolicy) { |
| 3663 InitLauncherControllerWithBrowser(); | 3627 InitLauncherControllerWithBrowser(); |
| 3664 arc::mojom::AppInfo appinfo = CreateAppInfo( | 3628 arc::mojom::AppInfo appinfo = CreateAppInfo( |
| 3665 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); | 3629 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 EXPECT_TRUE(window1->IsActive()); | 3718 EXPECT_TRUE(window1->IsActive()); |
| 3755 | 3719 |
| 3756 NotifyOnTaskCreated(appinfo, 2 /* task_id */); | 3720 NotifyOnTaskCreated(appinfo, 2 /* task_id */); |
| 3757 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2"); | 3721 views::Widget* window2 = CreateArcWindow("org.chromium.arc.2"); |
| 3758 ASSERT_TRUE(window2); | 3722 ASSERT_TRUE(window2); |
| 3759 | 3723 |
| 3760 EXPECT_FALSE(window1->IsActive()); | 3724 EXPECT_FALSE(window1->IsActive()); |
| 3761 EXPECT_TRUE(window2->IsActive()); | 3725 EXPECT_TRUE(window2->IsActive()); |
| 3762 | 3726 |
| 3763 const std::string app_id = ArcAppTest::GetAppId(appinfo); | 3727 const std::string app_id = ArcAppTest::GetAppId(appinfo); |
| 3764 | |
| 3765 const ash::ShelfID shelf_id = | |
| 3766 launcher_controller_->GetShelfIDForAppID(app_id); | |
| 3767 ash::ShelfItemDelegate* item_delegate = | 3728 ash::ShelfItemDelegate* item_delegate = |
| 3768 model_->GetShelfItemDelegate(shelf_id); | 3729 model_->GetShelfItemDelegate(ash::ShelfID(app_id)); |
| 3769 ASSERT_TRUE(item_delegate); | 3730 ASSERT_TRUE(item_delegate); |
| 3770 | 3731 |
| 3771 // Selecting the item will show its application menu. It does not change the | 3732 // Selecting the item will show its application menu. It does not change the |
| 3772 // active window. | 3733 // active window. |
| 3773 SelectItem(item_delegate); | 3734 SelectItem(item_delegate); |
| 3774 EXPECT_FALSE(window1->IsActive()); | 3735 EXPECT_FALSE(window1->IsActive()); |
| 3775 EXPECT_TRUE(window2->IsActive()); | 3736 EXPECT_TRUE(window2->IsActive()); |
| 3776 | 3737 |
| 3777 // Command ids are just app window indices. Note, apps are registered in | 3738 // Command ids are just app window indices. Note, apps are registered in |
| 3778 // opposite order. Last created goes in front. | 3739 // opposite order. Last created goes in front. |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4057 // Prevent safe decoding which requires IPC. | 4018 // Prevent safe decoding which requires IPC. |
| 4058 ArcAppIcon::DisableSafeDecodingForTesting(); | 4019 ArcAppIcon::DisableSafeDecodingForTesting(); |
| 4059 | 4020 |
| 4060 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 4021 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 4061 EnablePlayStore(false); | 4022 EnablePlayStore(false); |
| 4062 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4023 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4063 ASSERT_TRUE(prefs->GetAppIds().size()); | 4024 ASSERT_TRUE(prefs->GetAppIds().size()); |
| 4064 | 4025 |
| 4065 const std::string app_id = | 4026 const std::string app_id = |
| 4066 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); | 4027 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
| 4067 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(app_id).IsNull()); | 4028 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(app_id))); |
| 4068 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4029 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
| 4069 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4030 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4070 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(app_id).IsNull()); | 4031 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(app_id))); |
| 4071 | 4032 |
| 4072 // Stop ARC again. Shelf item should go away. | 4033 // Stop ARC again. Shelf item should go away. |
| 4073 EnablePlayStore(false); | 4034 EnablePlayStore(false); |
| 4074 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(app_id).IsNull()); | 4035 EXPECT_FALSE(launcher_controller_->GetItem(ash::ShelfID(app_id))); |
| 4075 | 4036 |
| 4076 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4037 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
| 4077 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4038 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4078 | 4039 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(app_id))); |
| 4079 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(app_id).IsNull()); | |
| 4080 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 4040 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 4081 | 4041 |
| 4082 std::string window_app_id("org.chromium.arc.1"); | 4042 std::string window_app_id("org.chromium.arc.1"); |
| 4083 CreateArcWindow(window_app_id); | 4043 CreateArcWindow(window_app_id); |
| 4084 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_default_apps()[0], | 4044 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_default_apps()[0], |
| 4085 std::string()); | 4045 std::string()); |
| 4086 | 4046 EXPECT_TRUE(launcher_controller_->GetItem(ash::ShelfID(app_id))); |
| 4087 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(app_id).IsNull()); | |
| 4088 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 4047 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 4089 } | 4048 } |
| 4090 | 4049 |
| 4091 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, PlayStoreDeferredLaunch) { | 4050 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, PlayStoreDeferredLaunch) { |
| 4092 // Add ARC host app to enable Play Store default app. | 4051 // Add ARC host app to enable Play Store default app. |
| 4093 extension_service_->AddExtension(arc_support_host_.get()); | 4052 extension_service_->AddExtension(arc_support_host_.get()); |
| 4094 arc_test_.SetUp(profile()); | 4053 arc_test_.SetUp(profile()); |
| 4095 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 4054 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 4096 EXPECT_TRUE(prefs->IsRegistered(arc::kPlayStoreAppId)); | 4055 EXPECT_TRUE(prefs->IsRegistered(arc::kPlayStoreAppId)); |
| 4097 | 4056 |
| 4098 InitLauncherController(); | 4057 InitLauncherController(); |
| 4099 | 4058 |
| 4100 EnablePlayStore(true); | 4059 EnablePlayStore(true); |
| 4101 | 4060 |
| 4102 // Pin Play Store. It should be pinned but not scheduled for deferred launch. | 4061 // Pin Play Store. It should be pinned but not scheduled for deferred launch. |
| 4103 launcher_controller_->PinAppWithID(arc::kPlayStoreAppId); | 4062 launcher_controller_->PinAppWithID(arc::kPlayStoreAppId); |
| 4104 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); | 4063 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); |
| 4105 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp( | 4064 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp( |
| 4106 arc::kPlayStoreAppId)); | 4065 arc::kPlayStoreAppId)); |
| 4107 | 4066 |
| 4108 // Simulate click. This should schedule Play Store for deferred launch. | 4067 // Simulate click. This should schedule Play Store for deferred launch. |
| 4109 ash::ShelfItemDelegate* item_delegate = model_->GetShelfItemDelegate( | 4068 ash::ShelfItemDelegate* item_delegate = |
| 4110 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId)); | 4069 model_->GetShelfItemDelegate(ash::ShelfID(arc::kPlayStoreAppId)); |
| 4111 EXPECT_TRUE(item_delegate); | 4070 EXPECT_TRUE(item_delegate); |
| 4112 SelectItem(item_delegate); | 4071 SelectItem(item_delegate); |
| 4113 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); | 4072 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); |
| 4114 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp( | 4073 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp( |
| 4115 arc::kPlayStoreAppId)); | 4074 arc::kPlayStoreAppId)); |
| 4116 } | 4075 } |
| 4117 | 4076 |
| 4118 // Checks the case when several app items have the same ordinal position (which | 4077 // Checks the case when several app items have the same ordinal position (which |
| 4119 // is valid case). | 4078 // is valid case). |
| 4120 TEST_F(ChromeLauncherControllerTest, CheckPositionConflict) { | 4079 TEST_F(ChromeLauncherControllerTest, CheckPositionConflict) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4257 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4216 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4258 shelf_controller->auto_hide()); | 4217 shelf_controller->auto_hide()); |
| 4259 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4218 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4260 | 4219 |
| 4261 PrefService* prefs = profile()->GetTestingPrefService(); | 4220 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4262 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4221 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4263 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4222 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4264 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4223 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4265 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4224 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4266 } | 4225 } |
| OLD | NEW |