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

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

Issue 2295343002: arc: Dont sync app list change caused by Arc opt out. (Closed)
Patch Set: nit Created 4 years, 3 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/ash/launcher/chrome_launcher_controller_impl.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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 manifest.SetString(extensions::manifest_keys::kDescription, 339 manifest.SetString(extensions::manifest_keys::kDescription,
340 "for testing pinned apps"); 340 "for testing pinned apps");
341 341
342 extensions::TestExtensionSystem* extension_system( 342 extensions::TestExtensionSystem* extension_system(
343 static_cast<extensions::TestExtensionSystem*>( 343 static_cast<extensions::TestExtensionSystem*>(
344 extensions::ExtensionSystem::Get(profile()))); 344 extensions::ExtensionSystem::Get(profile())));
345 extension_service_ = extension_system->CreateExtensionService( 345 extension_service_ = extension_system->CreateExtensionService(
346 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); 346 base::CommandLine::ForCurrentProcess(), base::FilePath(), false);
347 extension_service_->Init(); 347 extension_service_->Init();
348 348
349 if (auto_start_arc_test_)
350 arc_test_.SetUp(profile());
351
349 app_service_ = 352 app_service_ =
350 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); 353 app_list::AppListSyncableServiceFactory::GetForProfile(profile());
351 StartAppSyncService(syncer::SyncDataList()); 354 StartAppSyncService(syncer::SyncDataList());
352 355
353 std::string error; 356 std::string error;
354 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 357 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
355 manifest, 358 manifest,
356 Extension::NO_FLAGS, 359 Extension::NO_FLAGS,
357 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 360 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
358 &error); 361 &error);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 scoped_refptr<Extension> extension2_; 904 scoped_refptr<Extension> extension2_;
902 scoped_refptr<Extension> extension3_; 905 scoped_refptr<Extension> extension3_;
903 scoped_refptr<Extension> extension4_; 906 scoped_refptr<Extension> extension4_;
904 scoped_refptr<Extension> extension5_; 907 scoped_refptr<Extension> extension5_;
905 scoped_refptr<Extension> extension6_; 908 scoped_refptr<Extension> extension6_;
906 scoped_refptr<Extension> extension7_; 909 scoped_refptr<Extension> extension7_;
907 scoped_refptr<Extension> extension8_; 910 scoped_refptr<Extension> extension8_;
908 scoped_refptr<Extension> arc_support_host_; 911 scoped_refptr<Extension> arc_support_host_;
909 912
910 ArcAppTest arc_test_; 913 ArcAppTest arc_test_;
914 bool auto_start_arc_test_ = false;
911 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; 915 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_;
912 std::unique_ptr<TestShelfModelObserver> model_observer_; 916 std::unique_ptr<TestShelfModelObserver> model_observer_;
913 std::unique_ptr<ash::ShelfModel> model_; 917 std::unique_ptr<ash::ShelfModel> model_;
914 std::unique_ptr<TestingProfileManager> profile_manager_; 918 std::unique_ptr<TestingProfileManager> profile_manager_;
915 919
916 // |item_delegate_manager_| owns |test_controller_|. 920 // |item_delegate_manager_| owns |test_controller_|.
917 LauncherItemController* test_controller_; 921 LauncherItemController* test_controller_;
918 922
919 ExtensionService* extension_service_; 923 ExtensionService* extension_service_;
920 924
921 app_list::AppListSyncableService* app_service_; 925 app_list::AppListSyncableService* app_service_;
922 926
923 private: 927 private:
924 TestBrowserWindow* CreateTestBrowserWindowAura() { 928 TestBrowserWindow* CreateTestBrowserWindowAura() {
925 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 929 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
926 window->set_id(0); 930 window->set_id(0);
927 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 931 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
928 window->Init(ui::LAYER_TEXTURED); 932 window->Init(ui::LAYER_TEXTURED);
929 aura::client::ParentWindowWithContext(window.get(), GetContext(), 933 aura::client::ParentWindowWithContext(window.get(), GetContext(),
930 gfx::Rect(200, 200)); 934 gfx::Rect(200, 200));
931 935
932 return new TestBrowserWindowAura(std::move(window)); 936 return new TestBrowserWindowAura(std::move(window));
933 } 937 }
934 938
935 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); 939 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest);
936 }; 940 };
937 941
942 class ChromeLauncherControllerImplWithArcTest
943 : public ChromeLauncherControllerImplTest {
944 protected:
945 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; }
946 ~ChromeLauncherControllerImplWithArcTest() override {}
947
948 private:
949 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest);
950 };
951
938 // Watches WebContents and blocks until it is destroyed. This is needed for 952 // Watches WebContents and blocks until it is destroyed. This is needed for
939 // the destruction of a V2 application. 953 // the destruction of a V2 application.
940 class WebContentsDestroyedWatcher : public content::WebContentsObserver { 954 class WebContentsDestroyedWatcher : public content::WebContentsObserver {
941 public: 955 public:
942 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) 956 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents)
943 : content::WebContentsObserver(web_contents), 957 : content::WebContentsObserver(web_contents),
944 message_loop_runner_(new content::MessageLoopRunner) { 958 message_loop_runner_(new content::MessageLoopRunner) {
945 EXPECT_TRUE(web_contents != NULL); 959 EXPECT_TRUE(web_contents != NULL);
946 } 960 }
947 ~WebContentsDestroyedWatcher() override {} 961 ~WebContentsDestroyedWatcher() override {}
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1231 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1218 1232
1219 // Installing |extension3_| should add it to the launcher - behind the 1233 // Installing |extension3_| should add it to the launcher - behind the
1220 // chrome icon. 1234 // chrome icon.
1221 extension_service_->AddExtension(extension3_.get()); 1235 extension_service_->AddExtension(extension3_.get());
1222 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1236 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1223 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1237 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1224 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1238 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1225 } 1239 }
1226 1240
1227 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinCrossPlatformWorkflow) { 1241 TEST_F(ChromeLauncherControllerImplWithArcTest,
1242 ArcAppPinCrossPlatformWorkflow) {
1228 // Work on Arc-disabled platform first. 1243 // Work on Arc-disabled platform first.
1229 arc_test_.SetUp(profile());
1230
1231 const std::string arc_app_id1 = 1244 const std::string arc_app_id1 =
1232 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1245 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1233 const std::string arc_app_id2 = 1246 const std::string arc_app_id2 =
1234 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1247 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1235 const std::string arc_app_id3 = 1248 const std::string arc_app_id3 =
1236 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); 1249 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]);
1237 1250
1238 InitLauncherController(); 1251 InitLauncherController();
1239 1252
1240 extension_service_->AddExtension(extension1_.get()); 1253 extension_service_->AddExtension(extension1_.get());
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 1758
1746 // Check that removing more items does not crash and changes nothing. 1759 // Check that removing more items does not crash and changes nothing.
1747 launcher_controller_->UnlockV1AppWithID(extension2_->id()); 1760 launcher_controller_->UnlockV1AppWithID(extension2_->id());
1748 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1761 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1749 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); 1762 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus());
1750 launcher_controller_->UnlockV1AppWithID(extension3_->id()); 1763 launcher_controller_->UnlockV1AppWithID(extension3_->id());
1751 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1764 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1752 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1765 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1753 } 1766 }
1754 1767
1755 TEST_F(ChromeLauncherControllerImplTest, ArcDeferredLaunch) { 1768 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
1756 arc_test_.SetUp(profile());
1757
1758 RecreateChromeLauncher(); 1769 RecreateChromeLauncher();
1759 1770
1760 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1771 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1761 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1772 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1762 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1773 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
1763 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1774 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1764 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1775 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1765 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1776 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1766 1777
1767 SendListOfArcApps(); 1778 SendListOfArcApps();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 1826
1816 const arc::FakeAppInstance::Request* request1 = 1827 const arc::FakeAppInstance::Request* request1 =
1817 arc_test_.app_instance()->launch_requests()[0]; 1828 arc_test_.app_instance()->launch_requests()[0];
1818 const arc::FakeAppInstance::Request* request2 = 1829 const arc::FakeAppInstance::Request* request2 =
1819 arc_test_.app_instance()->launch_requests()[1]; 1830 arc_test_.app_instance()->launch_requests()[1];
1820 1831
1821 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1832 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
1822 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1833 (request1->IsForApp(app3) && request2->IsForApp(app2)));
1823 } 1834 }
1824 1835
1825 TEST_F(ChromeLauncherControllerImplTest, ArcRunningApp) { 1836 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) {
1826 arc_test_.SetUp(profile());
1827 InitLauncherController(); 1837 InitLauncherController();
1828 1838
1829 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1839 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1830 SendListOfArcApps(); 1840 SendListOfArcApps();
1831 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1841 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1832 1842
1833 // Normal flow, create/destroy tasks. 1843 // Normal flow, create/destroy tasks.
1834 std::string window_app_id1("org.chromium.arc.1"); 1844 std::string window_app_id1("org.chromium.arc.1");
1835 std::string window_app_id2("org.chromium.arc.2"); 1845 std::string window_app_id2("org.chromium.arc.2");
1836 std::string window_app_id3("org.chromium.arc.3"); 1846 std::string window_app_id3("org.chromium.arc.3");
(...skipping 12 matching lines...) Expand all
1849 CreateArcWindow(window_app_id3); 1859 CreateArcWindow(window_app_id3);
1850 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1860 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1851 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1861 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1852 arc_test_.StopArcInstance(); 1862 arc_test_.StopArcInstance();
1853 base::RunLoop().RunUntilIdle(); 1863 base::RunLoop().RunUntilIdle();
1854 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1864 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1855 } 1865 }
1856 1866
1857 // Test race creation/deletion of Arc app. 1867 // Test race creation/deletion of Arc app.
1858 // TODO (khmel): Remove after moving everything to wayland protocol. 1868 // TODO (khmel): Remove after moving everything to wayland protocol.
1859 TEST_F(ChromeLauncherControllerImplTest, ArcRaceCreateClose) { 1869 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
1860 arc_test_.SetUp(profile());
1861 InitLauncherController(); 1870 InitLauncherController();
1862 1871
1863 const std::string arc_app_id1 = 1872 const std::string arc_app_id1 =
1864 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1873 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1865 const std::string arc_app_id2 = 1874 const std::string arc_app_id2 =
1866 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1875 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1867 SendListOfArcApps(); 1876 SendListOfArcApps();
1868 1877
1869 // Arc window created before and closed after mojom notification. 1878 // Arc window created before and closed after mojom notification.
1870 std::string window_app_id1("org.chromium.arc.1"); 1879 std::string window_app_id1("org.chromium.arc.1");
(...skipping 16 matching lines...) Expand all
1887 ASSERT_TRUE(arc_window); 1896 ASSERT_TRUE(arc_window);
1888 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1897 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1889 arc_window->Close(); 1898 arc_window->Close();
1890 base::RunLoop().RunUntilIdle(); 1899 base::RunLoop().RunUntilIdle();
1891 // Closing window does not close shelf item. It is closed on task destroy. 1900 // Closing window does not close shelf item. It is closed on task destroy.
1892 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1901 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1893 arc_test_.app_instance()->SendTaskDestroyed(2); 1902 arc_test_.app_instance()->SendTaskDestroyed(2);
1894 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1903 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1895 } 1904 }
1896 1905
1897 TEST_F(ChromeLauncherControllerImplTest, ArcWindowRecreation) { 1906 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) {
1898 arc_test_.SetUp(profile());
1899 InitLauncherController(); 1907 InitLauncherController();
1900 1908
1901 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1909 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1902 SendListOfArcApps(); 1910 SendListOfArcApps();
1903 1911
1904 std::string window_app_id("org.chromium.arc.1"); 1912 std::string window_app_id("org.chromium.arc.1");
1905 views::Widget* arc_window = CreateArcWindow(window_app_id); 1913 views::Widget* arc_window = CreateArcWindow(window_app_id);
1906 ASSERT_TRUE(arc_window); 1914 ASSERT_TRUE(arc_window);
1907 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); 1915 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]);
1908 const ash::ShelfID shelf_id = 1916 const ash::ShelfID shelf_id =
1909 launcher_controller_->GetShelfIDForAppID(arc_app_id); 1917 launcher_controller_->GetShelfIDForAppID(arc_app_id);
1910 EXPECT_NE(0, shelf_id); 1918 EXPECT_NE(0, shelf_id);
1911 1919
1912 for (int i = 0; i < 3; ++i) { 1920 for (int i = 0; i < 3; ++i) {
1913 arc_window->Close(); 1921 arc_window->Close();
1914 base::RunLoop().RunUntilIdle(); 1922 base::RunLoop().RunUntilIdle();
1915 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1923 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1916 1924
1917 arc_window = CreateArcWindow(window_app_id); 1925 arc_window = CreateArcWindow(window_app_id);
1918 ASSERT_TRUE(arc_window); 1926 ASSERT_TRUE(arc_window);
1919 base::RunLoop().RunUntilIdle(); 1927 base::RunLoop().RunUntilIdle();
1920 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1928 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1921 } 1929 }
1922 } 1930 }
1923 1931
1924 // Validate that Arc app is pinned correctly and pin is removed automatically 1932 // Validate that Arc app is pinned correctly and pin is removed automatically
1925 // once app is uninstalled. 1933 // once app is uninstalled.
1926 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { 1934 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
1927 arc_test_.SetUp(profile());
1928 InitLauncherController(); 1935 InitLauncherController();
1929 1936
1930 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1937 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1931 1938
1932 SendListOfArcApps(); 1939 SendListOfArcApps();
1933 extension_service_->AddExtension(extension1_.get()); 1940 extension_service_->AddExtension(extension1_.get());
1934 extension_service_->AddExtension(extension2_.get()); 1941 extension_service_->AddExtension(extension2_.get());
1935 1942
1936 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1943 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1937 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); 1944 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id));
(...skipping 20 matching lines...) Expand all
1958 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 1965 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
1959 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile()); 1966 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile());
1960 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 1967 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
1961 1968
1962 // Opt-Out/Opt-In remove item from the shelf. 1969 // Opt-Out/Opt-In remove item from the shelf.
1963 EnableArc(false); 1970 EnableArc(false);
1964 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1971 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1965 EnableArc(true); 1972 EnableArc(true);
1966 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1973 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1967 SendListOfArcApps(); 1974 SendListOfArcApps();
1975 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
1976 }
1977
1978 // Validates that Arc app pins persist across OptOut/OptIn.
1979 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
1980 InitLauncherController();
1981
1982 const std::string arc_app_id1 =
1983 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1984 const std::string arc_app_id2 =
1985 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1986
1987 SendListOfArcApps();
1988 extension_service_->AddExtension(extension1_.get());
1989 extension_service_->AddExtension(extension2_.get());
1990
1991 launcher_controller_->PinAppWithID(extension1_->id());
1992 launcher_controller_->PinAppWithID(arc_app_id2);
1993 launcher_controller_->PinAppWithID(extension2_->id());
1994 launcher_controller_->PinAppWithID(arc_app_id1);
1995
1996 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1997 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
1998 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1999 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
2000 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2001 GetPinnedAppStatus());
2002
2003 EnableArc(false);
2004
1968 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 2005 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
2006 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2007 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1));
2008 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2009 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2));
2010
2011 EnableArc(true);
2012 SendListOfArcApps();
2013 base::RunLoop().RunUntilIdle();
2014
2015 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2016 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
2017 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2018 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
2019
2020 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2021 GetPinnedAppStatus());
1969 } 2022 }
1970 2023
1971 // Check that with multi profile V1 apps are properly added / removed from the 2024 // Check that with multi profile V1 apps are properly added / removed from the
1972 // shelf. 2025 // shelf.
1973 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2026 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1974 V1AppUpdateOnUserSwitch) { 2027 V1AppUpdateOnUserSwitch) {
1975 // Create a browser item in the LauncherController. 2028 // Create a browser item in the LauncherController.
1976 InitLauncherController(); 2029 InitLauncherController();
1977 EXPECT_EQ(2, model_->item_count()); 2030 EXPECT_EQ(2, model_->item_count());
1978 { 2031 {
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3421 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3474 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3422 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3475 EXPECT_EQ(1, app_icon_loader2->clear_count());
3423 3476
3424 launcher_controller_->CloseLauncherItem(shelfId3); 3477 launcher_controller_->CloseLauncherItem(shelfId3);
3425 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3478 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3426 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3479 EXPECT_EQ(1, app_icon_loader1->clear_count());
3427 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3480 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3428 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3481 EXPECT_EQ(1, app_icon_loader2->clear_count());
3429 } 3482 }
3430 3483
3431 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinPolicy) { 3484 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) {
3432 arc_test_.SetUp(profile());
3433 InitLauncherControllerWithBrowser(); 3485 InitLauncherControllerWithBrowser();
3434 arc::mojom::AppInfo appinfo = CreateAppInfo( 3486 arc::mojom::AppInfo appinfo = CreateAppInfo(
3435 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); 3487 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE);
3436 const std::string app_id = AddArcAppAndShortcut(appinfo); 3488 const std::string app_id = AddArcAppAndShortcut(appinfo);
3437 3489
3438 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app 3490 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app
3439 // package_name (not hash) specified as id. In this test we check that 3491 // package_name (not hash) specified as id. In this test we check that
3440 // by hash we can determine that appropriate package was set by policy. 3492 // by hash we can determine that appropriate package was set by policy.
3441 base::ListValue policy_value; 3493 base::ListValue policy_value;
3442 InsertPrefValue(&policy_value, 0, appinfo.package_name); 3494 InsertPrefValue(&policy_value, 0, appinfo.package_name);
3443 profile()->GetTestingPrefService()->SetManagedPref( 3495 profile()->GetTestingPrefService()->SetManagedPref(
3444 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); 3496 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy());
3445 3497
3446 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3498 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3447 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3499 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3448 GetPinnableForAppID(app_id, profile())); 3500 GetPinnableForAppID(app_id, profile()));
3449 } 3501 }
3450 3502
3451 TEST_F(ChromeLauncherControllerImplTest, ArcManaged) { 3503 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
3452 extension_service_->AddExtension(arc_support_host_.get()); 3504 extension_service_->AddExtension(arc_support_host_.get());
3453 arc_test_.SetUp(profile());
3454 // Test enables Arc, so turn it off for initial values. 3505 // Test enables Arc, so turn it off for initial values.
3455 EnableArc(false); 3506 EnableArc(false);
3456 3507
3457 InitLauncherController(); 3508 InitLauncherController();
3458 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3509 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3459 3510
3460 // Initial run, Arc is not managed and disabled, Play Store pin should be 3511 // Initial run, Arc is not managed and disabled, Play Store pin should be
3461 // available. 3512 // available.
3462 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, 3513 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED,
3463 "AppList, Chrome, Play Store"); 3514 "AppList, Chrome, Play Store");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 3546
3496 // Even if re-enable it again, Play Store pin does not appear automatically. 3547 // Even if re-enable it again, Play Store pin does not appear automatically.
3497 EnableArc(true); 3548 EnableArc(true);
3498 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, 3549 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE,
3499 "AppList, Chrome"); 3550 "AppList, Chrome");
3500 } 3551 }
3501 3552
3502 namespace { 3553 namespace {
3503 3554
3504 class ChromeLauncherControllerOrientationTest 3555 class ChromeLauncherControllerOrientationTest
3505 : public ChromeLauncherControllerImplTest { 3556 : public ChromeLauncherControllerImplWithArcTest {
3506 public: 3557 public:
3507 ChromeLauncherControllerOrientationTest() {} 3558 ChromeLauncherControllerOrientationTest() {}
3508 ~ChromeLauncherControllerOrientationTest() override {} 3559 ~ChromeLauncherControllerOrientationTest() override {}
3509 3560
3510 protected: 3561 protected:
3511 void InitApps() { 3562 void InitApps() {
3512 appinfo_none_ = 3563 appinfo_none_ =
3513 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE); 3564 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE);
3514 appinfo_landscape_ = 3565 appinfo_landscape_ =
3515 CreateAppInfo("Landscape", "Landscape", "com.example.app", 3566 CreateAppInfo("Landscape", "Landscape", "com.example.app",
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 private: 3641 private:
3591 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); 3642 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest);
3592 }; 3643 };
3593 3644
3594 } // namespace 3645 } // namespace
3595 3646
3596 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { 3647 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) {
3597 ASSERT_TRUE(display::Display::HasInternalDisplay()); 3648 ASSERT_TRUE(display::Display::HasInternalDisplay());
3598 3649
3599 extension_service_->AddExtension(arc_support_host_.get()); 3650 extension_service_->AddExtension(arc_support_host_.get());
3600 arc_test_.SetUp(profile());
3601 EnableArc(true); 3651 EnableArc(true);
3602 EnableTabletMode(true); 3652 EnableTabletMode(true);
3603 3653
3604 InitLauncherController(); 3654 InitLauncherController();
3605 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3655 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3606 3656
3607 InitApps(); 3657 InitApps();
3608 ash::ScreenOrientationController* controller = 3658 ash::ScreenOrientationController* controller =
3609 ash::Shell::GetInstance()->screen_orientation_controller(); 3659 ash::Shell::GetInstance()->screen_orientation_controller();
3610 3660
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3689 3739
3690 // Manually unlock first. 3740 // Manually unlock first.
3691 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); 3741 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE);
3692 EXPECT_FALSE(controller->rotation_locked()); 3742 EXPECT_FALSE(controller->rotation_locked());
3693 } 3743 }
3694 3744
3695 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { 3745 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) {
3696 ASSERT_TRUE(display::Display::HasInternalDisplay()); 3746 ASSERT_TRUE(display::Display::HasInternalDisplay());
3697 3747
3698 extension_service_->AddExtension(arc_support_host_.get()); 3748 extension_service_->AddExtension(arc_support_host_.get());
3699 arc_test_.SetUp(profile());
3700 EnableArc(true); 3749 EnableArc(true);
3701 EnableTabletMode(true); 3750 EnableTabletMode(true);
3702 3751
3703 InitLauncherController(); 3752 InitLauncherController();
3704 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3753 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3705 3754
3706 InitApps(); 3755 InitApps();
3707 ash::ScreenOrientationController* controller = 3756 ash::ScreenOrientationController* controller =
3708 ash::Shell::GetInstance()->screen_orientation_controller(); 3757 ash::Shell::GetInstance()->screen_orientation_controller();
3709 3758
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3832 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
3784 3833
3785 std::string window_app_id("org.chromium.arc.1"); 3834 std::string window_app_id("org.chromium.arc.1");
3786 CreateArcWindow(window_app_id); 3835 CreateArcWindow(window_app_id);
3787 arc_test_.app_instance()->SendTaskCreated(1, 3836 arc_test_.app_instance()->SendTaskCreated(1,
3788 arc_test_.fake_default_apps()[0]); 3837 arc_test_.fake_default_apps()[0]);
3789 3838
3790 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3839 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id));
3791 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 3840 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
3792 } 3841 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698