| 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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 void RestoreUnpinnedRunningApplicationOrder(const AccountId& account_id) { | 871 void RestoreUnpinnedRunningApplicationOrder(const AccountId& account_id) { |
| 872 launcher_controller_->RestoreUnpinnedRunningApplicationOrder( | 872 launcher_controller_->RestoreUnpinnedRunningApplicationOrder( |
| 873 account_id.GetUserEmail()); | 873 account_id.GetUserEmail()); |
| 874 } | 874 } |
| 875 | 875 |
| 876 void SendListOfArcApps() { | 876 void SendListOfArcApps() { |
| 877 arc_test_.app_instance()->RefreshAppList(); | 877 arc_test_.app_instance()->RefreshAppList(); |
| 878 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); | 878 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); |
| 879 } | 879 } |
| 880 | 880 |
| 881 void SendListOfArcShortcuts() { |
| 882 arc_test_.app_instance()->SendInstallShortcuts(arc_test_.fake_shortcuts()); |
| 883 } |
| 884 |
| 881 void UninstallArcApps() { | 885 void UninstallArcApps() { |
| 882 arc_test_.app_instance()->RefreshAppList(); | 886 arc_test_.app_instance()->RefreshAppList(); |
| 883 arc_test_.app_instance()->SendRefreshAppList( | 887 arc_test_.app_instance()->SendRefreshAppList( |
| 884 std::vector<arc::mojom::AppInfo>()); | 888 std::vector<arc::mojom::AppInfo>()); |
| 885 } | 889 } |
| 886 | 890 |
| 887 void EnableArc(bool enabled) { | 891 void EnableArc(bool enabled) { |
| 888 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled); | 892 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled); |
| 889 base::RunLoop().RunUntilIdle(); | 893 base::RunLoop().RunUntilIdle(); |
| 890 } | 894 } |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1845 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1842 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 1846 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 1843 } | 1847 } |
| 1844 | 1848 |
| 1845 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { | 1849 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { |
| 1846 RecreateChromeLauncher(); | 1850 RecreateChromeLauncher(); |
| 1847 | 1851 |
| 1848 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1852 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
| 1849 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1853 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1850 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1854 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1855 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0]; |
| 1851 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1856 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1852 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1857 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1853 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1858 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1859 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); |
| 1854 | 1860 |
| 1855 SendListOfArcApps(); | 1861 SendListOfArcApps(); |
| 1862 SendListOfArcShortcuts(); |
| 1856 | 1863 |
| 1857 arc_test_.StopArcInstance(); | 1864 arc_test_.StopArcInstance(); |
| 1858 | 1865 |
| 1859 EXPECT_EQ(ash::kInvalidShelfID, | 1866 EXPECT_EQ(ash::kInvalidShelfID, |
| 1860 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1867 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1861 EXPECT_EQ(ash::kInvalidShelfID, | 1868 EXPECT_EQ(ash::kInvalidShelfID, |
| 1862 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1869 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1863 EXPECT_EQ(ash::kInvalidShelfID, | 1870 EXPECT_EQ(ash::kInvalidShelfID, |
| 1864 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1871 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1872 EXPECT_EQ(ash::kInvalidShelfID, |
| 1873 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id)); |
| 1865 | 1874 |
| 1866 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); | 1875 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); |
| 1867 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); | 1876 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); |
| 1868 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); | 1877 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); |
| 1869 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); | 1878 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); |
| 1870 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); | 1879 arc::LaunchApp(profile(), arc_shortcut_id, ui::EF_LEFT_MOUSE_BUTTON); |
| 1871 | 1880 |
| 1872 const ash::ShelfID shelf_id_app_1 = | 1881 const ash::ShelfID shelf_id_app_1 = |
| 1873 launcher_controller_->GetShelfIDForAppID(arc_app_id1); | 1882 launcher_controller_->GetShelfIDForAppID(arc_app_id1); |
| 1874 const ash::ShelfID shelf_id_app_2 = | 1883 const ash::ShelfID shelf_id_app_2 = |
| 1875 launcher_controller_->GetShelfIDForAppID(arc_app_id2); | 1884 launcher_controller_->GetShelfIDForAppID(arc_app_id2); |
| 1876 const ash::ShelfID shelf_id_app_3 = | 1885 const ash::ShelfID shelf_id_app_3 = |
| 1877 launcher_controller_->GetShelfIDForAppID(arc_app_id3); | 1886 launcher_controller_->GetShelfIDForAppID(arc_app_id3); |
| 1887 const ash::ShelfID shelf_id_shortcut = |
| 1888 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id); |
| 1878 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); | 1889 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); |
| 1879 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); | 1890 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); |
| 1880 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); | 1891 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); |
| 1892 EXPECT_NE(ash::kInvalidShelfID, shelf_id_shortcut); |
| 1881 | 1893 |
| 1882 // We activated arc_app_id1 twice but expect one close for item controller | 1894 // We activated arc_app_id1 twice but expect one close for item controller |
| 1883 // stops launching request. | 1895 // stops launching request. |
| 1884 LauncherItemController* item_controller = | 1896 LauncherItemController* item_controller = |
| 1885 launcher_controller_->GetLauncherItemController(shelf_id_app_1); | 1897 launcher_controller_->GetLauncherItemController(shelf_id_app_1); |
| 1886 ASSERT_NE(nullptr, item_controller); | 1898 ASSERT_NE(nullptr, item_controller); |
| 1887 item_controller->Close(); | 1899 item_controller->Close(); |
| 1888 base::RunLoop().RunUntilIdle(); | 1900 base::RunLoop().RunUntilIdle(); |
| 1889 | 1901 |
| 1890 EXPECT_EQ(ash::kInvalidShelfID, | 1902 EXPECT_EQ(ash::kInvalidShelfID, |
| 1891 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1903 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1892 EXPECT_EQ(shelf_id_app_2, | 1904 EXPECT_EQ(shelf_id_app_2, |
| 1893 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1905 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1894 EXPECT_EQ(shelf_id_app_3, | 1906 EXPECT_EQ(shelf_id_app_3, |
| 1895 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1907 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1896 | 1908 |
| 1897 arc_test_.RestartArcInstance(); | 1909 arc_test_.RestartArcInstance(); |
| 1898 SendListOfArcApps(); | 1910 SendListOfArcApps(); |
| 1899 | 1911 |
| 1900 base::RunLoop().RunUntilIdle(); | 1912 base::RunLoop().RunUntilIdle(); |
| 1901 | 1913 |
| 1914 // Now deferred contollers should go away together with shelf items and ARC |
| 1915 // app instance should receive request for launching apps and shortcuts. |
| 1902 EXPECT_EQ(ash::kInvalidShelfID, | 1916 EXPECT_EQ(ash::kInvalidShelfID, |
| 1903 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1917 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1904 EXPECT_EQ(ash::kInvalidShelfID, | 1918 EXPECT_EQ(ash::kInvalidShelfID, |
| 1905 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1919 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1906 EXPECT_EQ(ash::kInvalidShelfID, | 1920 EXPECT_EQ(ash::kInvalidShelfID, |
| 1907 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1921 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1908 | 1922 |
| 1909 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); | 1923 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); |
| 1924 ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size()); |
| 1910 | 1925 |
| 1911 const arc::FakeAppInstance::Request* request1 = | 1926 const arc::FakeAppInstance::Request* request1 = |
| 1912 arc_test_.app_instance()->launch_requests()[0].get(); | 1927 arc_test_.app_instance()->launch_requests()[0].get(); |
| 1913 const arc::FakeAppInstance::Request* request2 = | 1928 const arc::FakeAppInstance::Request* request2 = |
| 1914 arc_test_.app_instance()->launch_requests()[1].get(); | 1929 arc_test_.app_instance()->launch_requests()[1].get(); |
| 1915 | 1930 |
| 1916 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1931 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1917 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1932 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| 1933 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), |
| 1934 shortcut.intent_uri); |
| 1918 } | 1935 } |
| 1919 | 1936 |
| 1920 // Ensure the deferred controller does not override the active app controller | 1937 // Ensure the deferred controller does not override the active app controller |
| 1921 // (crbug.com/701152). | 1938 // (crbug.com/701152). |
| 1922 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { | 1939 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { |
| 1923 RecreateChromeLauncher(); | 1940 RecreateChromeLauncher(); |
| 1924 SendListOfArcApps(); | 1941 SendListOfArcApps(); |
| 1925 arc_test_.StopArcInstance(); | 1942 arc_test_.StopArcInstance(); |
| 1926 | 1943 |
| 1927 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; | 1944 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; |
| (...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4372 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4389 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4373 shelf_controller->auto_hide()); | 4390 shelf_controller->auto_hide()); |
| 4374 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4391 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4375 | 4392 |
| 4376 PrefService* prefs = profile()->GetTestingPrefService(); | 4393 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4377 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4394 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4378 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4395 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4379 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4396 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4380 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4397 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4381 } | 4398 } |
| OLD | NEW |