| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 manifest.SetString(extensions::manifest_keys::kDescription, | 337 manifest.SetString(extensions::manifest_keys::kDescription, |
| 338 "for testing pinned apps"); | 338 "for testing pinned apps"); |
| 339 | 339 |
| 340 extensions::TestExtensionSystem* extension_system( | 340 extensions::TestExtensionSystem* extension_system( |
| 341 static_cast<extensions::TestExtensionSystem*>( | 341 static_cast<extensions::TestExtensionSystem*>( |
| 342 extensions::ExtensionSystem::Get(profile()))); | 342 extensions::ExtensionSystem::Get(profile()))); |
| 343 extension_service_ = extension_system->CreateExtensionService( | 343 extension_service_ = extension_system->CreateExtensionService( |
| 344 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); | 344 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 345 extension_service_->Init(); | 345 extension_service_->Init(); |
| 346 | 346 |
| 347 if (auto_start_arc_test_) |
| 348 arc_test_.SetUp(profile()); |
| 349 |
| 347 app_service_ = | 350 app_service_ = |
| 348 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 351 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 349 StartAppSyncService(syncer::SyncDataList()); | 352 StartAppSyncService(syncer::SyncDataList()); |
| 350 | 353 |
| 351 std::string error; | 354 std::string error; |
| 352 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 355 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 353 manifest, | 356 manifest, |
| 354 Extension::NO_FLAGS, | 357 Extension::NO_FLAGS, |
| 355 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | 358 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 356 &error); | 359 &error); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 scoped_refptr<Extension> extension2_; | 902 scoped_refptr<Extension> extension2_; |
| 900 scoped_refptr<Extension> extension3_; | 903 scoped_refptr<Extension> extension3_; |
| 901 scoped_refptr<Extension> extension4_; | 904 scoped_refptr<Extension> extension4_; |
| 902 scoped_refptr<Extension> extension5_; | 905 scoped_refptr<Extension> extension5_; |
| 903 scoped_refptr<Extension> extension6_; | 906 scoped_refptr<Extension> extension6_; |
| 904 scoped_refptr<Extension> extension7_; | 907 scoped_refptr<Extension> extension7_; |
| 905 scoped_refptr<Extension> extension8_; | 908 scoped_refptr<Extension> extension8_; |
| 906 scoped_refptr<Extension> arc_support_host_; | 909 scoped_refptr<Extension> arc_support_host_; |
| 907 | 910 |
| 908 ArcAppTest arc_test_; | 911 ArcAppTest arc_test_; |
| 912 bool auto_start_arc_test_ = false; |
| 909 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; | 913 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; |
| 910 std::unique_ptr<TestShelfModelObserver> model_observer_; | 914 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 911 std::unique_ptr<ash::ShelfModel> model_; | 915 std::unique_ptr<ash::ShelfModel> model_; |
| 912 std::unique_ptr<TestingProfileManager> profile_manager_; | 916 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 913 | 917 |
| 914 // |item_delegate_manager_| owns |test_controller_|. | 918 // |item_delegate_manager_| owns |test_controller_|. |
| 915 LauncherItemController* test_controller_; | 919 LauncherItemController* test_controller_; |
| 916 | 920 |
| 917 ExtensionService* extension_service_; | 921 ExtensionService* extension_service_; |
| 918 | 922 |
| 919 app_list::AppListSyncableService* app_service_; | 923 app_list::AppListSyncableService* app_service_; |
| 920 | 924 |
| 921 private: | 925 private: |
| 922 TestBrowserWindow* CreateTestBrowserWindowAura() { | 926 TestBrowserWindow* CreateTestBrowserWindowAura() { |
| 923 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); | 927 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 924 window->set_id(0); | 928 window->set_id(0); |
| 925 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 929 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 926 window->Init(ui::LAYER_TEXTURED); | 930 window->Init(ui::LAYER_TEXTURED); |
| 927 aura::client::ParentWindowWithContext(window.get(), GetContext(), | 931 aura::client::ParentWindowWithContext(window.get(), GetContext(), |
| 928 gfx::Rect(200, 200)); | 932 gfx::Rect(200, 200)); |
| 929 | 933 |
| 930 return new TestBrowserWindowAura(std::move(window)); | 934 return new TestBrowserWindowAura(std::move(window)); |
| 931 } | 935 } |
| 932 | 936 |
| 933 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); | 937 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); |
| 934 }; | 938 }; |
| 935 | 939 |
| 940 class ChromeLauncherControllerImplWithArcTest |
| 941 : public ChromeLauncherControllerImplTest { |
| 942 protected: |
| 943 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; } |
| 944 ~ChromeLauncherControllerImplWithArcTest() override {} |
| 945 |
| 946 private: |
| 947 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest); |
| 948 }; |
| 949 |
| 936 // Watches WebContents and blocks until it is destroyed. This is needed for | 950 // Watches WebContents and blocks until it is destroyed. This is needed for |
| 937 // the destruction of a V2 application. | 951 // the destruction of a V2 application. |
| 938 class WebContentsDestroyedWatcher : public content::WebContentsObserver { | 952 class WebContentsDestroyedWatcher : public content::WebContentsObserver { |
| 939 public: | 953 public: |
| 940 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) | 954 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) |
| 941 : content::WebContentsObserver(web_contents), | 955 : content::WebContentsObserver(web_contents), |
| 942 message_loop_runner_(new content::MessageLoopRunner) { | 956 message_loop_runner_(new content::MessageLoopRunner) { |
| 943 EXPECT_TRUE(web_contents != NULL); | 957 EXPECT_TRUE(web_contents != NULL); |
| 944 } | 958 } |
| 945 ~WebContentsDestroyedWatcher() override {} | 959 ~WebContentsDestroyedWatcher() override {} |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 1229 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1216 | 1230 |
| 1217 // Installing |extension3_| should add it to the launcher - behind the | 1231 // Installing |extension3_| should add it to the launcher - behind the |
| 1218 // chrome icon. | 1232 // chrome icon. |
| 1219 extension_service_->AddExtension(extension3_.get()); | 1233 extension_service_->AddExtension(extension3_.get()); |
| 1220 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1234 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 1221 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1235 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1222 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1236 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1223 } | 1237 } |
| 1224 | 1238 |
| 1225 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinCrossPlatformWorkflow) { | 1239 TEST_F(ChromeLauncherControllerImplWithArcTest, |
| 1240 ArcAppPinCrossPlatformWorkflow) { |
| 1226 // Work on Arc-disabled platform first. | 1241 // Work on Arc-disabled platform first. |
| 1227 arc_test_.SetUp(profile()); | |
| 1228 | |
| 1229 const std::string arc_app_id1 = | 1242 const std::string arc_app_id1 = |
| 1230 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1243 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1231 const std::string arc_app_id2 = | 1244 const std::string arc_app_id2 = |
| 1232 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1245 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1233 const std::string arc_app_id3 = | 1246 const std::string arc_app_id3 = |
| 1234 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); | 1247 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); |
| 1235 | 1248 |
| 1236 InitLauncherController(); | 1249 InitLauncherController(); |
| 1237 | 1250 |
| 1238 extension_service_->AddExtension(extension1_.get()); | 1251 extension_service_->AddExtension(extension1_.get()); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 | 1756 |
| 1744 // Check that removing more items does not crash and changes nothing. | 1757 // Check that removing more items does not crash and changes nothing. |
| 1745 launcher_controller_->UnlockV1AppWithID(extension2_->id()); | 1758 launcher_controller_->UnlockV1AppWithID(extension2_->id()); |
| 1746 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1759 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1747 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); | 1760 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); |
| 1748 launcher_controller_->UnlockV1AppWithID(extension3_->id()); | 1761 launcher_controller_->UnlockV1AppWithID(extension3_->id()); |
| 1749 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1762 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1750 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 1763 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 1751 } | 1764 } |
| 1752 | 1765 |
| 1753 TEST_F(ChromeLauncherControllerImplTest, ArcDeferredLaunch) { | 1766 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { |
| 1754 arc_test_.SetUp(profile()); | |
| 1755 | |
| 1756 RecreateChromeLauncher(); | 1767 RecreateChromeLauncher(); |
| 1757 | 1768 |
| 1758 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1769 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
| 1759 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1770 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1760 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1771 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1761 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1772 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1762 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1773 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1763 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1774 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1764 | 1775 |
| 1765 SendListOfArcApps(); | 1776 SendListOfArcApps(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 | 1824 |
| 1814 const arc::FakeAppInstance::Request* request1 = | 1825 const arc::FakeAppInstance::Request* request1 = |
| 1815 arc_test_.app_instance()->launch_requests()[0]; | 1826 arc_test_.app_instance()->launch_requests()[0]; |
| 1816 const arc::FakeAppInstance::Request* request2 = | 1827 const arc::FakeAppInstance::Request* request2 = |
| 1817 arc_test_.app_instance()->launch_requests()[1]; | 1828 arc_test_.app_instance()->launch_requests()[1]; |
| 1818 | 1829 |
| 1819 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1830 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1820 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1831 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| 1821 } | 1832 } |
| 1822 | 1833 |
| 1823 TEST_F(ChromeLauncherControllerImplTest, ArcRunningApp) { | 1834 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { |
| 1824 arc_test_.SetUp(profile()); | |
| 1825 InitLauncherController(); | 1835 InitLauncherController(); |
| 1826 | 1836 |
| 1827 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1837 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1828 SendListOfArcApps(); | 1838 SendListOfArcApps(); |
| 1829 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1839 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1830 | 1840 |
| 1831 // Normal flow, create/destroy tasks. | 1841 // Normal flow, create/destroy tasks. |
| 1832 std::string window_app_id1("org.chromium.arc.1"); | 1842 std::string window_app_id1("org.chromium.arc.1"); |
| 1833 std::string window_app_id2("org.chromium.arc.2"); | 1843 std::string window_app_id2("org.chromium.arc.2"); |
| 1834 std::string window_app_id3("org.chromium.arc.3"); | 1844 std::string window_app_id3("org.chromium.arc.3"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1847 CreateArcWindow(window_app_id3); | 1857 CreateArcWindow(window_app_id3); |
| 1848 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); | 1858 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); |
| 1849 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1859 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1850 arc_test_.StopArcInstance(); | 1860 arc_test_.StopArcInstance(); |
| 1851 base::RunLoop().RunUntilIdle(); | 1861 base::RunLoop().RunUntilIdle(); |
| 1852 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1862 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1853 } | 1863 } |
| 1854 | 1864 |
| 1855 // Test race creation/deletion of Arc app. | 1865 // Test race creation/deletion of Arc app. |
| 1856 // TODO (khmel): Remove after moving everything to wayland protocol. | 1866 // TODO (khmel): Remove after moving everything to wayland protocol. |
| 1857 TEST_F(ChromeLauncherControllerImplTest, ArcRaceCreateClose) { | 1867 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { |
| 1858 arc_test_.SetUp(profile()); | |
| 1859 InitLauncherController(); | 1868 InitLauncherController(); |
| 1860 | 1869 |
| 1861 const std::string arc_app_id1 = | 1870 const std::string arc_app_id1 = |
| 1862 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1871 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1863 const std::string arc_app_id2 = | 1872 const std::string arc_app_id2 = |
| 1864 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1873 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1865 SendListOfArcApps(); | 1874 SendListOfArcApps(); |
| 1866 | 1875 |
| 1867 // Arc window created before and closed after mojom notification. | 1876 // Arc window created before and closed after mojom notification. |
| 1868 std::string window_app_id1("org.chromium.arc.1"); | 1877 std::string window_app_id1("org.chromium.arc.1"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1885 ASSERT_TRUE(arc_window); | 1894 ASSERT_TRUE(arc_window); |
| 1886 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1895 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1887 arc_window->Close(); | 1896 arc_window->Close(); |
| 1888 base::RunLoop().RunUntilIdle(); | 1897 base::RunLoop().RunUntilIdle(); |
| 1889 // Closing window does not close shelf item. It is closed on task destroy. | 1898 // Closing window does not close shelf item. It is closed on task destroy. |
| 1890 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1899 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1891 arc_test_.app_instance()->SendTaskDestroyed(2); | 1900 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 1892 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1901 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1893 } | 1902 } |
| 1894 | 1903 |
| 1895 TEST_F(ChromeLauncherControllerImplTest, ArcWindowRecreation) { | 1904 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { |
| 1896 arc_test_.SetUp(profile()); | |
| 1897 InitLauncherController(); | 1905 InitLauncherController(); |
| 1898 | 1906 |
| 1899 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1907 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1900 SendListOfArcApps(); | 1908 SendListOfArcApps(); |
| 1901 | 1909 |
| 1902 std::string window_app_id("org.chromium.arc.1"); | 1910 std::string window_app_id("org.chromium.arc.1"); |
| 1903 views::Widget* arc_window = CreateArcWindow(window_app_id); | 1911 views::Widget* arc_window = CreateArcWindow(window_app_id); |
| 1904 ASSERT_TRUE(arc_window); | 1912 ASSERT_TRUE(arc_window); |
| 1905 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); | 1913 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); |
| 1906 const ash::ShelfID shelf_id = | 1914 const ash::ShelfID shelf_id = |
| 1907 launcher_controller_->GetShelfIDForAppID(arc_app_id); | 1915 launcher_controller_->GetShelfIDForAppID(arc_app_id); |
| 1908 EXPECT_NE(0, shelf_id); | 1916 EXPECT_NE(0, shelf_id); |
| 1909 | 1917 |
| 1910 for (int i = 0; i < 3; ++i) { | 1918 for (int i = 0; i < 3; ++i) { |
| 1911 arc_window->Close(); | 1919 arc_window->Close(); |
| 1912 base::RunLoop().RunUntilIdle(); | 1920 base::RunLoop().RunUntilIdle(); |
| 1913 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1921 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1914 | 1922 |
| 1915 arc_window = CreateArcWindow(window_app_id); | 1923 arc_window = CreateArcWindow(window_app_id); |
| 1916 ASSERT_TRUE(arc_window); | 1924 ASSERT_TRUE(arc_window); |
| 1917 base::RunLoop().RunUntilIdle(); | 1925 base::RunLoop().RunUntilIdle(); |
| 1918 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1926 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1919 } | 1927 } |
| 1920 } | 1928 } |
| 1921 | 1929 |
| 1922 // Validate that Arc app is pinned correctly and pin is removed automatically | 1930 // Validate that Arc app is pinned correctly and pin is removed automatically |
| 1923 // once app is uninstalled. | 1931 // once app is uninstalled. |
| 1924 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { | 1932 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { |
| 1925 arc_test_.SetUp(profile()); | |
| 1926 InitLauncherController(); | 1933 InitLauncherController(); |
| 1927 | 1934 |
| 1928 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1935 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1929 | 1936 |
| 1930 SendListOfArcApps(); | 1937 SendListOfArcApps(); |
| 1931 extension_service_->AddExtension(extension1_.get()); | 1938 extension_service_->AddExtension(extension1_.get()); |
| 1932 extension_service_->AddExtension(extension2_.get()); | 1939 extension_service_->AddExtension(extension2_.get()); |
| 1933 | 1940 |
| 1934 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1941 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1935 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); | 1942 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1956 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 1963 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 1957 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile()); | 1964 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile()); |
| 1958 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 1965 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 1959 | 1966 |
| 1960 // Opt-Out/Opt-In remove item from the shelf. | 1967 // Opt-Out/Opt-In remove item from the shelf. |
| 1961 EnableArc(false); | 1968 EnableArc(false); |
| 1962 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 1969 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 1963 EnableArc(true); | 1970 EnableArc(true); |
| 1964 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 1971 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 1965 SendListOfArcApps(); | 1972 SendListOfArcApps(); |
| 1973 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 1974 } |
| 1975 |
| 1976 // Validates that Arc app pins persist across OptOut/OptIn. |
| 1977 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { |
| 1978 InitLauncherController(); |
| 1979 |
| 1980 const std::string arc_app_id1 = |
| 1981 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1982 const std::string arc_app_id2 = |
| 1983 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1984 |
| 1985 SendListOfArcApps(); |
| 1986 extension_service_->AddExtension(extension1_.get()); |
| 1987 extension_service_->AddExtension(extension2_.get()); |
| 1988 |
| 1989 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1990 launcher_controller_->PinAppWithID(arc_app_id2); |
| 1991 launcher_controller_->PinAppWithID(extension2_->id()); |
| 1992 launcher_controller_->PinAppWithID(arc_app_id1); |
| 1993 |
| 1994 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1995 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1996 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1997 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1998 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 1999 GetPinnedAppStatus()); |
| 2000 |
| 2001 EnableArc(false); |
| 2002 |
| 1966 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2003 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2004 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2005 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2006 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2007 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2008 |
| 2009 EnableArc(true); |
| 2010 SendListOfArcApps(); |
| 2011 base::RunLoop().RunUntilIdle(); |
| 2012 |
| 2013 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2014 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2015 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2016 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2017 |
| 2018 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 2019 GetPinnedAppStatus()); |
| 1967 } | 2020 } |
| 1968 | 2021 |
| 1969 // Check that with multi profile V1 apps are properly added / removed from the | 2022 // Check that with multi profile V1 apps are properly added / removed from the |
| 1970 // shelf. | 2023 // shelf. |
| 1971 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2024 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 1972 V1AppUpdateOnUserSwitch) { | 2025 V1AppUpdateOnUserSwitch) { |
| 1973 // Create a browser item in the LauncherController. | 2026 // Create a browser item in the LauncherController. |
| 1974 InitLauncherController(); | 2027 InitLauncherController(); |
| 1975 EXPECT_EQ(2, model_->item_count()); | 2028 EXPECT_EQ(2, model_->item_count()); |
| 1976 { | 2029 { |
| (...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3472 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3420 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3473 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3421 | 3474 |
| 3422 launcher_controller_->CloseLauncherItem(shelfId3); | 3475 launcher_controller_->CloseLauncherItem(shelfId3); |
| 3423 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3476 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3424 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3477 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 3425 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3478 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3426 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3479 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3427 } | 3480 } |
| 3428 | 3481 |
| 3429 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinPolicy) { | 3482 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { |
| 3430 arc_test_.SetUp(profile()); | |
| 3431 InitLauncherControllerWithBrowser(); | 3483 InitLauncherControllerWithBrowser(); |
| 3432 arc::mojom::AppInfo appinfo = CreateAppInfo( | 3484 arc::mojom::AppInfo appinfo = CreateAppInfo( |
| 3433 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); | 3485 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); |
| 3434 const std::string app_id = AddArcAppAndShortcut(appinfo); | 3486 const std::string app_id = AddArcAppAndShortcut(appinfo); |
| 3435 | 3487 |
| 3436 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app | 3488 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app |
| 3437 // package_name (not hash) specified as id. In this test we check that | 3489 // package_name (not hash) specified as id. In this test we check that |
| 3438 // by hash we can determine that appropriate package was set by policy. | 3490 // by hash we can determine that appropriate package was set by policy. |
| 3439 base::ListValue policy_value; | 3491 base::ListValue policy_value; |
| 3440 InsertPrefValue(&policy_value, 0, appinfo.package_name); | 3492 InsertPrefValue(&policy_value, 0, appinfo.package_name); |
| 3441 profile()->GetTestingPrefService()->SetManagedPref( | 3493 profile()->GetTestingPrefService()->SetManagedPref( |
| 3442 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); | 3494 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); |
| 3443 | 3495 |
| 3444 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 3496 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 3445 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, | 3497 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
| 3446 GetPinnableForAppID(app_id, profile())); | 3498 GetPinnableForAppID(app_id, profile())); |
| 3447 } | 3499 } |
| 3448 | 3500 |
| 3449 TEST_F(ChromeLauncherControllerImplTest, ArcManaged) { | 3501 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) { |
| 3450 extension_service_->AddExtension(arc_support_host_.get()); | 3502 extension_service_->AddExtension(arc_support_host_.get()); |
| 3451 arc_test_.SetUp(profile()); | |
| 3452 // Test enables Arc, so turn it off for initial values. | 3503 // Test enables Arc, so turn it off for initial values. |
| 3453 EnableArc(false); | 3504 EnableArc(false); |
| 3454 | 3505 |
| 3455 InitLauncherController(); | 3506 InitLauncherController(); |
| 3456 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); | 3507 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); |
| 3457 | 3508 |
| 3458 // Initial run, Arc is not managed and disabled, Play Store pin should be | 3509 // Initial run, Arc is not managed and disabled, Play Store pin should be |
| 3459 // available. | 3510 // available. |
| 3460 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, | 3511 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, |
| 3461 "AppList, Chrome, Play Store"); | 3512 "AppList, Chrome, Play Store"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3493 | 3544 |
| 3494 // Even if re-enable it again, Play Store pin does not appear automatically. | 3545 // Even if re-enable it again, Play Store pin does not appear automatically. |
| 3495 EnableArc(true); | 3546 EnableArc(true); |
| 3496 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, | 3547 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, |
| 3497 "AppList, Chrome"); | 3548 "AppList, Chrome"); |
| 3498 } | 3549 } |
| 3499 | 3550 |
| 3500 namespace { | 3551 namespace { |
| 3501 | 3552 |
| 3502 class ChromeLauncherControllerOrientationTest | 3553 class ChromeLauncherControllerOrientationTest |
| 3503 : public ChromeLauncherControllerImplTest { | 3554 : public ChromeLauncherControllerImplWithArcTest { |
| 3504 public: | 3555 public: |
| 3505 ChromeLauncherControllerOrientationTest() {} | 3556 ChromeLauncherControllerOrientationTest() {} |
| 3506 ~ChromeLauncherControllerOrientationTest() override {} | 3557 ~ChromeLauncherControllerOrientationTest() override {} |
| 3507 | 3558 |
| 3508 protected: | 3559 protected: |
| 3509 void InitApps() { | 3560 void InitApps() { |
| 3510 appinfo_none_ = | 3561 appinfo_none_ = |
| 3511 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE); | 3562 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE); |
| 3512 appinfo_landscape_ = | 3563 appinfo_landscape_ = |
| 3513 CreateAppInfo("Landscape", "Landscape", "com.example.app", | 3564 CreateAppInfo("Landscape", "Landscape", "com.example.app", |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3572 private: | 3623 private: |
| 3573 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); | 3624 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); |
| 3574 }; | 3625 }; |
| 3575 | 3626 |
| 3576 } // namespace | 3627 } // namespace |
| 3577 | 3628 |
| 3578 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { | 3629 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { |
| 3579 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3630 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3580 | 3631 |
| 3581 extension_service_->AddExtension(arc_support_host_.get()); | 3632 extension_service_->AddExtension(arc_support_host_.get()); |
| 3582 arc_test_.SetUp(profile()); | |
| 3583 EnableArc(true); | 3633 EnableArc(true); |
| 3584 EnableTabletMode(true); | 3634 EnableTabletMode(true); |
| 3585 | 3635 |
| 3586 InitLauncherController(); | 3636 InitLauncherController(); |
| 3587 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); | 3637 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); |
| 3588 | 3638 |
| 3589 InitApps(); | 3639 InitApps(); |
| 3590 ash::ScreenOrientationController* controller = | 3640 ash::ScreenOrientationController* controller = |
| 3591 ash::Shell::GetInstance()->screen_orientation_controller(); | 3641 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3592 | 3642 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3671 | 3721 |
| 3672 // Manually unlock first. | 3722 // Manually unlock first. |
| 3673 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); | 3723 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); |
| 3674 EXPECT_FALSE(controller->rotation_locked()); | 3724 EXPECT_FALSE(controller->rotation_locked()); |
| 3675 } | 3725 } |
| 3676 | 3726 |
| 3677 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { | 3727 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { |
| 3678 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3728 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3679 | 3729 |
| 3680 extension_service_->AddExtension(arc_support_host_.get()); | 3730 extension_service_->AddExtension(arc_support_host_.get()); |
| 3681 arc_test_.SetUp(profile()); | |
| 3682 EnableArc(true); | 3731 EnableArc(true); |
| 3683 EnableTabletMode(true); | 3732 EnableTabletMode(true); |
| 3684 | 3733 |
| 3685 InitLauncherController(); | 3734 InitLauncherController(); |
| 3686 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); | 3735 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); |
| 3687 | 3736 |
| 3688 InitApps(); | 3737 InitApps(); |
| 3689 ash::ScreenOrientationController* controller = | 3738 ash::ScreenOrientationController* controller = |
| 3690 ash::Shell::GetInstance()->screen_orientation_controller(); | 3739 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3691 | 3740 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3729 EXPECT_FALSE(controller->rotation_locked()); | 3778 EXPECT_FALSE(controller->rotation_locked()); |
| 3730 EXPECT_EQ(display::Display::ROTATE_0, | 3779 EXPECT_EQ(display::Display::ROTATE_0, |
| 3731 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3780 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3732 | 3781 |
| 3733 NotifyOnTaskOrientationLockRequested(task_id_current_, | 3782 NotifyOnTaskOrientationLockRequested(task_id_current_, |
| 3734 OrientationLock::CURRENT); | 3783 OrientationLock::CURRENT); |
| 3735 EXPECT_TRUE(controller->rotation_locked()); | 3784 EXPECT_TRUE(controller->rotation_locked()); |
| 3736 EXPECT_EQ(display::Display::ROTATE_0, | 3785 EXPECT_EQ(display::Display::ROTATE_0, |
| 3737 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3786 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3738 } | 3787 } |
| OLD | NEW |