Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2799813003: arc: Make shortcuts runnable in deferred mode. (Closed)
Patch Set: remove not-needed check Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 void RestoreUnpinnedRunningApplicationOrder(const AccountId& account_id) { 863 void RestoreUnpinnedRunningApplicationOrder(const AccountId& account_id) {
864 launcher_controller_->RestoreUnpinnedRunningApplicationOrder( 864 launcher_controller_->RestoreUnpinnedRunningApplicationOrder(
865 account_id.GetUserEmail()); 865 account_id.GetUserEmail());
866 } 866 }
867 867
868 void SendListOfArcApps() { 868 void SendListOfArcApps() {
869 arc_test_.app_instance()->RefreshAppList(); 869 arc_test_.app_instance()->RefreshAppList();
870 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); 870 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps());
871 } 871 }
872 872
873 void SendListOfArcShortcuts() {
874 arc_test_.app_instance()->SendInstallShortcuts(arc_test_.fake_shortcuts());
875 }
876
873 void UninstallArcApps() { 877 void UninstallArcApps() {
874 arc_test_.app_instance()->RefreshAppList(); 878 arc_test_.app_instance()->RefreshAppList();
875 arc_test_.app_instance()->SendRefreshAppList( 879 arc_test_.app_instance()->SendRefreshAppList(
876 std::vector<arc::mojom::AppInfo>()); 880 std::vector<arc::mojom::AppInfo>());
877 } 881 }
878 882
879 // TODO(victorhsieh): Add test coverage for when ARC is started regardless 883 // TODO(victorhsieh): Add test coverage for when ARC is started regardless
880 // Play Store opt-in status, and the followed opt-in and opt-out. 884 // Play Store opt-in status, and the followed opt-in and opt-out.
881 void EnablePlayStore(bool enabled) { 885 void EnablePlayStore(bool enabled) {
882 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled); 886 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled);
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1854 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1851 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1855 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1852 } 1856 }
1853 1857
1854 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { 1858 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
1855 RecreateChromeLauncher(); 1859 RecreateChromeLauncher();
1856 1860
1857 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1861 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1858 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1862 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1859 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1863 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
1864 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0];
1860 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1865 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1861 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1866 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1862 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1867 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1868 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut);
1863 1869
1864 SendListOfArcApps(); 1870 SendListOfArcApps();
1871 SendListOfArcShortcuts();
1865 1872
1866 arc_test_.StopArcInstance(); 1873 arc_test_.StopArcInstance();
1867 1874
1868 EXPECT_EQ(ash::kInvalidShelfID, 1875 EXPECT_EQ(ash::kInvalidShelfID,
1869 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1876 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1870 EXPECT_EQ(ash::kInvalidShelfID, 1877 EXPECT_EQ(ash::kInvalidShelfID,
1871 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1878 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1872 EXPECT_EQ(ash::kInvalidShelfID, 1879 EXPECT_EQ(ash::kInvalidShelfID,
1873 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1880 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1881 EXPECT_EQ(ash::kInvalidShelfID,
1882 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id));
1874 1883
1875 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); 1884 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1876 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); 1885 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1877 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); 1886 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON);
1878 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); 1887 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON);
1879 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); 1888 arc::LaunchApp(profile(), arc_shortcut_id, ui::EF_LEFT_MOUSE_BUTTON);
1880 1889
1881 const ash::ShelfID shelf_id_app_1 = 1890 const ash::ShelfID shelf_id_app_1 =
1882 launcher_controller_->GetShelfIDForAppID(arc_app_id1); 1891 launcher_controller_->GetShelfIDForAppID(arc_app_id1);
1883 const ash::ShelfID shelf_id_app_2 = 1892 const ash::ShelfID shelf_id_app_2 =
1884 launcher_controller_->GetShelfIDForAppID(arc_app_id2); 1893 launcher_controller_->GetShelfIDForAppID(arc_app_id2);
1885 const ash::ShelfID shelf_id_app_3 = 1894 const ash::ShelfID shelf_id_app_3 =
1886 launcher_controller_->GetShelfIDForAppID(arc_app_id3); 1895 launcher_controller_->GetShelfIDForAppID(arc_app_id3);
1896 const ash::ShelfID shelf_id_shortcut =
1897 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id);
1887 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); 1898 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1);
1888 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); 1899 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2);
1889 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); 1900 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3);
1901 EXPECT_NE(ash::kInvalidShelfID, shelf_id_shortcut);
1890 1902
1891 // We activated arc_app_id1 twice but expect one close for item controller 1903 // We activated arc_app_id1 twice but expect one close for item controller
1892 // stops launching request. 1904 // stops launching request.
1893 ash::ShelfItemDelegate* item_delegate = 1905 ash::ShelfItemDelegate* item_delegate =
1894 launcher_controller_->GetShelfItemDelegate(shelf_id_app_1); 1906 launcher_controller_->GetShelfItemDelegate(shelf_id_app_1);
1895 ASSERT_NE(nullptr, item_delegate); 1907 ASSERT_NE(nullptr, item_delegate);
1896 item_delegate->Close(); 1908 item_delegate->Close();
1897 base::RunLoop().RunUntilIdle(); 1909 base::RunLoop().RunUntilIdle();
1898 1910
1899 EXPECT_EQ(ash::kInvalidShelfID, 1911 EXPECT_EQ(ash::kInvalidShelfID,
1900 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1912 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1901 EXPECT_EQ(shelf_id_app_2, 1913 EXPECT_EQ(shelf_id_app_2,
1902 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1914 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1903 EXPECT_EQ(shelf_id_app_3, 1915 EXPECT_EQ(shelf_id_app_3,
1904 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1916 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1905 1917
1906 arc_test_.RestartArcInstance(); 1918 arc_test_.RestartArcInstance();
1907 SendListOfArcApps(); 1919 SendListOfArcApps();
1908 1920
1909 base::RunLoop().RunUntilIdle(); 1921 base::RunLoop().RunUntilIdle();
1910 1922
1923 // Now deferred contollers should go away together with shelf items and ARC
1924 // app instance should receive request for launching apps and shortcuts.
1911 EXPECT_EQ(ash::kInvalidShelfID, 1925 EXPECT_EQ(ash::kInvalidShelfID,
1912 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1926 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1913 EXPECT_EQ(ash::kInvalidShelfID, 1927 EXPECT_EQ(ash::kInvalidShelfID,
1914 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1928 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1915 EXPECT_EQ(ash::kInvalidShelfID, 1929 EXPECT_EQ(ash::kInvalidShelfID,
1916 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1930 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1917 1931
1918 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); 1932 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size());
1933 ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size());
1919 1934
1920 const arc::FakeAppInstance::Request* request1 = 1935 const arc::FakeAppInstance::Request* request1 =
1921 arc_test_.app_instance()->launch_requests()[0].get(); 1936 arc_test_.app_instance()->launch_requests()[0].get();
1922 const arc::FakeAppInstance::Request* request2 = 1937 const arc::FakeAppInstance::Request* request2 =
1923 arc_test_.app_instance()->launch_requests()[1].get(); 1938 arc_test_.app_instance()->launch_requests()[1].get();
1924 1939
1925 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1940 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
1926 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1941 (request1->IsForApp(app3) && request2->IsForApp(app2)));
1942 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(),
1943 shortcut.intent_uri);
1927 } 1944 }
1928 1945
1929 // Ensure the deferred controller does not override the active app controller 1946 // Ensure the deferred controller does not override the active app controller
1930 // (crbug.com/701152). 1947 // (crbug.com/701152).
1931 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { 1948 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) {
1932 RecreateChromeLauncher(); 1949 RecreateChromeLauncher();
1933 SendListOfArcApps(); 1950 SendListOfArcApps();
1934 arc_test_.StopArcInstance(); 1951 arc_test_.StopArcInstance();
1935 1952
1936 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; 1953 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0];
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
4321 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4338 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4322 shelf_controller->auto_hide()); 4339 shelf_controller->auto_hide());
4323 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4340 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4324 4341
4325 PrefService* prefs = profile()->GetTestingPrefService(); 4342 PrefService* prefs = profile()->GetTestingPrefService();
4326 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4343 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4327 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4344 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4328 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4345 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4329 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4346 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4330 } 4347 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698