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

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

Issue 2316273004: [Merge-M53] arc: Don't sync app list change caused by Arc opt out. (Closed)
Patch Set: 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 manifest.SetString(extensions::manifest_keys::kDescription, 343 manifest.SetString(extensions::manifest_keys::kDescription,
344 "for testing pinned apps"); 344 "for testing pinned apps");
345 345
346 extensions::TestExtensionSystem* extension_system( 346 extensions::TestExtensionSystem* extension_system(
347 static_cast<extensions::TestExtensionSystem*>( 347 static_cast<extensions::TestExtensionSystem*>(
348 extensions::ExtensionSystem::Get(profile()))); 348 extensions::ExtensionSystem::Get(profile())));
349 extension_service_ = extension_system->CreateExtensionService( 349 extension_service_ = extension_system->CreateExtensionService(
350 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); 350 base::CommandLine::ForCurrentProcess(), base::FilePath(), false);
351 extension_service_->Init(); 351 extension_service_->Init();
352 352
353 if (auto_start_arc_test_)
354 arc_test_.SetUp(profile());
355
353 app_service_ = 356 app_service_ =
354 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); 357 app_list::AppListSyncableServiceFactory::GetForProfile(profile());
355 StartAppSyncService(syncer::SyncDataList()); 358 StartAppSyncService(syncer::SyncDataList());
356 359
357 std::string error; 360 std::string error;
358 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 361 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
359 manifest, 362 manifest,
360 Extension::NO_FLAGS, 363 Extension::NO_FLAGS,
361 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 364 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
362 &error); 365 &error);
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 scoped_refptr<Extension> extension2_; 919 scoped_refptr<Extension> extension2_;
917 scoped_refptr<Extension> extension3_; 920 scoped_refptr<Extension> extension3_;
918 scoped_refptr<Extension> extension4_; 921 scoped_refptr<Extension> extension4_;
919 scoped_refptr<Extension> extension5_; 922 scoped_refptr<Extension> extension5_;
920 scoped_refptr<Extension> extension6_; 923 scoped_refptr<Extension> extension6_;
921 scoped_refptr<Extension> extension7_; 924 scoped_refptr<Extension> extension7_;
922 scoped_refptr<Extension> extension8_; 925 scoped_refptr<Extension> extension8_;
923 scoped_refptr<Extension> arc_support_host_; 926 scoped_refptr<Extension> arc_support_host_;
924 927
925 ArcAppTest arc_test_; 928 ArcAppTest arc_test_;
929 bool auto_start_arc_test_ = false;
926 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; 930 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_;
927 std::unique_ptr<TestShelfModelObserver> model_observer_; 931 std::unique_ptr<TestShelfModelObserver> model_observer_;
928 std::unique_ptr<ash::ShelfModel> model_; 932 std::unique_ptr<ash::ShelfModel> model_;
929 std::unique_ptr<TestingProfileManager> profile_manager_; 933 std::unique_ptr<TestingProfileManager> profile_manager_;
930 934
931 // |item_delegate_manager_| owns |test_controller_|. 935 // |item_delegate_manager_| owns |test_controller_|.
932 LauncherItemController* test_controller_; 936 LauncherItemController* test_controller_;
933 937
934 ExtensionService* extension_service_; 938 ExtensionService* extension_service_;
935 939
936 app_list::AppListSyncableService* app_service_; 940 app_list::AppListSyncableService* app_service_;
937 941
938 ash::ShelfItemDelegateManager* item_delegate_manager_; 942 ash::ShelfItemDelegateManager* item_delegate_manager_;
939 943
940 private: 944 private:
941 TestBrowserWindow* CreateTestBrowserWindowAura() { 945 TestBrowserWindow* CreateTestBrowserWindowAura() {
942 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 946 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
943 window->set_id(0); 947 window->set_id(0);
944 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 948 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
945 window->Init(ui::LAYER_TEXTURED); 949 window->Init(ui::LAYER_TEXTURED);
946 aura::client::ParentWindowWithContext(window.get(), GetContext(), 950 aura::client::ParentWindowWithContext(window.get(), GetContext(),
947 gfx::Rect(200, 200)); 951 gfx::Rect(200, 200));
948 952
949 return new TestBrowserWindowAura(std::move(window)); 953 return new TestBrowserWindowAura(std::move(window));
950 } 954 }
951 955
952 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); 956 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest);
953 }; 957 };
954 958
959 class ChromeLauncherControllerImplWithArcTest
960 : public ChromeLauncherControllerImplTest {
961 protected:
962 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; }
963 ~ChromeLauncherControllerImplWithArcTest() override {}
964
965 private:
966 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest);
967 };
968
955 // Watches WebContents and blocks until it is destroyed. This is needed for 969 // Watches WebContents and blocks until it is destroyed. This is needed for
956 // the destruction of a V2 application. 970 // the destruction of a V2 application.
957 class WebContentsDestroyedWatcher : public content::WebContentsObserver { 971 class WebContentsDestroyedWatcher : public content::WebContentsObserver {
958 public: 972 public:
959 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) 973 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents)
960 : content::WebContentsObserver(web_contents), 974 : content::WebContentsObserver(web_contents),
961 message_loop_runner_(new content::MessageLoopRunner) { 975 message_loop_runner_(new content::MessageLoopRunner) {
962 EXPECT_TRUE(web_contents != NULL); 976 EXPECT_TRUE(web_contents != NULL);
963 } 977 }
964 ~WebContentsDestroyedWatcher() override {} 978 ~WebContentsDestroyedWatcher() override {}
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1248 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1235 1249
1236 // Installing |extension3_| should add it to the launcher - behind the 1250 // Installing |extension3_| should add it to the launcher - behind the
1237 // chrome icon. 1251 // chrome icon.
1238 extension_service_->AddExtension(extension3_.get()); 1252 extension_service_->AddExtension(extension3_.get());
1239 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1253 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1240 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1254 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1241 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1255 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1242 } 1256 }
1243 1257
1244 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinCrossPlatformWorkflow) { 1258 TEST_F(ChromeLauncherControllerImplWithArcTest,
1259 ArcAppPinCrossPlatformWorkflow) {
1245 // Work on Arc-disabled platform first. 1260 // Work on Arc-disabled platform first.
1246 arc_test_.SetUp(profile());
1247
1248 const std::string arc_app_id1 = 1261 const std::string arc_app_id1 =
1249 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1262 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1250 const std::string arc_app_id2 = 1263 const std::string arc_app_id2 =
1251 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1264 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1252 const std::string arc_app_id3 = 1265 const std::string arc_app_id3 =
1253 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); 1266 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]);
1254 1267
1255 InitLauncherController(); 1268 InitLauncherController();
1256 1269
1257 extension_service_->AddExtension(extension1_.get()); 1270 extension_service_->AddExtension(extension1_.get());
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 1775
1763 // Check that removing more items does not crash and changes nothing. 1776 // Check that removing more items does not crash and changes nothing.
1764 launcher_controller_->UnlockV1AppWithID(extension2_->id()); 1777 launcher_controller_->UnlockV1AppWithID(extension2_->id());
1765 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1778 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1766 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); 1779 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus());
1767 launcher_controller_->UnlockV1AppWithID(extension3_->id()); 1780 launcher_controller_->UnlockV1AppWithID(extension3_->id());
1768 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1781 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1769 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1782 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1770 } 1783 }
1771 1784
1772 TEST_F(ChromeLauncherControllerImplTest, ArcDeferredLaunch) { 1785 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
1773 arc_test_.SetUp(profile());
1774
1775 RecreateChromeLauncher(); 1786 RecreateChromeLauncher();
1776 1787
1777 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1788 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1778 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1789 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1779 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1790 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
1780 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1791 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1781 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1792 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1782 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1793 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1783 1794
1784 SendListOfArcApps(); 1795 SendListOfArcApps();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 1843
1833 const arc::FakeAppInstance::Request* request1 = 1844 const arc::FakeAppInstance::Request* request1 =
1834 arc_test_.app_instance()->launch_requests()[0]; 1845 arc_test_.app_instance()->launch_requests()[0];
1835 const arc::FakeAppInstance::Request* request2 = 1846 const arc::FakeAppInstance::Request* request2 =
1836 arc_test_.app_instance()->launch_requests()[1]; 1847 arc_test_.app_instance()->launch_requests()[1];
1837 1848
1838 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1849 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
1839 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1850 (request1->IsForApp(app3) && request2->IsForApp(app2)));
1840 } 1851 }
1841 1852
1842 TEST_F(ChromeLauncherControllerImplTest, ArcRunningApp) { 1853 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) {
1843 arc_test_.SetUp(profile());
1844 InitLauncherController(); 1854 InitLauncherController();
1845 1855
1846 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1856 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1847 SendListOfArcApps(); 1857 SendListOfArcApps();
1848 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1858 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1849 1859
1850 // Normal flow, create/destroy tasks. 1860 // Normal flow, create/destroy tasks.
1851 std::string window_app_id1("org.chromium.arc.1"); 1861 std::string window_app_id1("org.chromium.arc.1");
1852 std::string window_app_id2("org.chromium.arc.2"); 1862 std::string window_app_id2("org.chromium.arc.2");
1853 std::string window_app_id3("org.chromium.arc.3"); 1863 std::string window_app_id3("org.chromium.arc.3");
(...skipping 12 matching lines...) Expand all
1866 CreateArcWindow(window_app_id3); 1876 CreateArcWindow(window_app_id3);
1867 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1877 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1868 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1878 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1869 arc_test_.StopArcInstance(); 1879 arc_test_.StopArcInstance();
1870 base::RunLoop().RunUntilIdle(); 1880 base::RunLoop().RunUntilIdle();
1871 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1881 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1872 } 1882 }
1873 1883
1874 // Test race creation/deletion of Arc app. 1884 // Test race creation/deletion of Arc app.
1875 // TODO (khmel): Remove after moving everything to wayland protocol. 1885 // TODO (khmel): Remove after moving everything to wayland protocol.
1876 TEST_F(ChromeLauncherControllerImplTest, ArcRaceCreateClose) { 1886 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) {
1877 arc_test_.SetUp(profile());
1878 InitLauncherController(); 1887 InitLauncherController();
1879 1888
1880 const std::string arc_app_id1 = 1889 const std::string arc_app_id1 =
1881 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1890 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1882 const std::string arc_app_id2 = 1891 const std::string arc_app_id2 =
1883 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 1892 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1884 SendListOfArcApps(); 1893 SendListOfArcApps();
1885 1894
1886 // Arc window created before and closed after mojom notification. 1895 // Arc window created before and closed after mojom notification.
1887 std::string window_app_id1("org.chromium.arc.1"); 1896 std::string window_app_id1("org.chromium.arc.1");
(...skipping 17 matching lines...) Expand all
1905 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1914 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1906 arc_window->Close(); 1915 arc_window->Close();
1907 base::RunLoop().RunUntilIdle(); 1916 base::RunLoop().RunUntilIdle();
1908 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1917 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1909 arc_test_.app_instance()->SendTaskDestroyed(2); 1918 arc_test_.app_instance()->SendTaskDestroyed(2);
1910 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1919 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1911 } 1920 }
1912 1921
1913 // Validate that Arc app is pinned correctly and pin is removed automatically 1922 // Validate that Arc app is pinned correctly and pin is removed automatically
1914 // once app is uninstalled. 1923 // once app is uninstalled.
1915 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) { 1924 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) {
1916 arc_test_.SetUp(profile());
1917 InitLauncherController(); 1925 InitLauncherController();
1918 1926
1919 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1927 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1920 1928
1921 SendListOfArcApps(); 1929 SendListOfArcApps();
1922 extension_service_->AddExtension(extension1_.get()); 1930 extension_service_->AddExtension(extension1_.get());
1923 extension_service_->AddExtension(extension2_.get()); 1931 extension_service_->AddExtension(extension2_.get());
1924 1932
1925 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1933 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1926 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); 1934 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id));
(...skipping 20 matching lines...) Expand all
1947 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 1955 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
1948 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile()); 1956 arc::ArcAuthService::Get()->OnPrimaryUserProfilePrepared(profile());
1949 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); 1957 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
1950 1958
1951 // Opt-Out/Opt-In remove item from the shelf. 1959 // Opt-Out/Opt-In remove item from the shelf.
1952 EnableArc(false); 1960 EnableArc(false);
1953 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1961 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1954 EnableArc(true); 1962 EnableArc(true);
1955 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1963 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1956 SendListOfArcApps(); 1964 SendListOfArcApps();
1965 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus());
1966 }
1967
1968 // Validates that Arc app pins persist across OptOut/OptIn.
1969 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) {
1970 InitLauncherController();
1971
1972 const std::string arc_app_id1 =
1973 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1974 const std::string arc_app_id2 =
1975 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
1976
1977 SendListOfArcApps();
1978 extension_service_->AddExtension(extension1_.get());
1979 extension_service_->AddExtension(extension2_.get());
1980
1981 launcher_controller_->PinAppWithID(extension1_->id());
1982 launcher_controller_->PinAppWithID(arc_app_id2);
1983 launcher_controller_->PinAppWithID(extension2_->id());
1984 launcher_controller_->PinAppWithID(arc_app_id1);
1985
1986 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1987 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
1988 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1989 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
1990 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
1991 GetPinnedAppStatus());
1992
1993 EnableArc(false);
1994
1957 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1995 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1996 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1997 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1));
1998 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1999 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2));
2000
2001 EnableArc(true);
2002 SendListOfArcApps();
2003 base::RunLoop().RunUntilIdle();
2004
2005 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2006 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1));
2007 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2008 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2));
2009
2010 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0",
2011 GetPinnedAppStatus());
1958 } 2012 }
1959 2013
1960 // Check that with multi profile V1 apps are properly added / removed from the 2014 // Check that with multi profile V1 apps are properly added / removed from the
1961 // shelf. 2015 // shelf.
1962 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, 2016 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1963 V1AppUpdateOnUserSwitch) { 2017 V1AppUpdateOnUserSwitch) {
1964 // Create a browser item in the LauncherController. 2018 // Create a browser item in the LauncherController.
1965 InitLauncherController(); 2019 InitLauncherController();
1966 EXPECT_EQ(2, model_->item_count()); 2020 EXPECT_EQ(2, model_->item_count());
1967 { 2021 {
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3488 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3435 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3489 EXPECT_EQ(1, app_icon_loader2->clear_count());
3436 3490
3437 launcher_controller_->CloseLauncherItem(shelfId3); 3491 launcher_controller_->CloseLauncherItem(shelfId3);
3438 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3492 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3439 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3493 EXPECT_EQ(1, app_icon_loader1->clear_count());
3440 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3494 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3441 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3495 EXPECT_EQ(1, app_icon_loader2->clear_count());
3442 } 3496 }
3443 3497
3444 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinPolicy) { 3498 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) {
3445 arc_test_.SetUp(profile());
3446 InitLauncherControllerWithBrowser(); 3499 InitLauncherControllerWithBrowser();
3447 arc::mojom::AppInfo appinfo = CreateAppInfo( 3500 arc::mojom::AppInfo appinfo = CreateAppInfo(
3448 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); 3501 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE);
3449 const std::string app_id = AddArcAppAndShortcut(appinfo); 3502 const std::string app_id = AddArcAppAndShortcut(appinfo);
3450 3503
3451 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app 3504 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app
3452 // package_name (not hash) specified as id. In this test we check that 3505 // package_name (not hash) specified as id. In this test we check that
3453 // by hash we can determine that appropriate package was set by policy. 3506 // by hash we can determine that appropriate package was set by policy.
3454 base::ListValue policy_value; 3507 base::ListValue policy_value;
3455 InsertPrefValue(&policy_value, 0, appinfo.package_name); 3508 InsertPrefValue(&policy_value, 0, appinfo.package_name);
3456 profile()->GetTestingPrefService()->SetManagedPref( 3509 profile()->GetTestingPrefService()->SetManagedPref(
3457 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); 3510 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy());
3458 3511
3459 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3512 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3460 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3513 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3461 GetPinnableForAppID(app_id, profile())); 3514 GetPinnableForAppID(app_id, profile()));
3462 } 3515 }
3463 3516
3464 TEST_F(ChromeLauncherControllerImplTest, ArcManaged) { 3517 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
3465 extension_service_->AddExtension(arc_support_host_.get()); 3518 extension_service_->AddExtension(arc_support_host_.get());
3466 arc_test_.SetUp(profile());
3467 // Test enables Arc, so turn it off for initial values. 3519 // Test enables Arc, so turn it off for initial values.
3468 EnableArc(false); 3520 EnableArc(false);
3469 3521
3470 InitLauncherController(); 3522 InitLauncherController();
3471 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3523 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3472 3524
3473 // Initial run, Arc is not managed and disabled, Play Store pin should be 3525 // Initial run, Arc is not managed and disabled, Play Store pin should be
3474 // available. (Note: Play Store pin is removed in M53, thus is unavailable 3526 // available. (Note: Play Store pin is removed in M53, thus is unavailable
3475 // in both managed or unmanaged case.) 3527 // in both managed or unmanaged case.)
3476 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, 3528 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 3561
3510 // Even if re-enable it again, Play Store pin does not appear automatically. 3562 // Even if re-enable it again, Play Store pin does not appear automatically.
3511 EnableArc(true); 3563 EnableArc(true);
3512 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, 3564 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE,
3513 "AppList, Chrome"); 3565 "AppList, Chrome");
3514 } 3566 }
3515 3567
3516 namespace { 3568 namespace {
3517 3569
3518 class ChromeLauncherControllerOrientationTest 3570 class ChromeLauncherControllerOrientationTest
3519 : public ChromeLauncherControllerImplTest { 3571 : public ChromeLauncherControllerImplWithArcTest {
3520 public: 3572 public:
3521 ChromeLauncherControllerOrientationTest() {} 3573 ChromeLauncherControllerOrientationTest() {}
3522 ~ChromeLauncherControllerOrientationTest() override {} 3574 ~ChromeLauncherControllerOrientationTest() override {}
3523 3575
3524 protected: 3576 protected:
3525 void InitApps() { 3577 void InitApps() {
3526 appinfo_none_ = 3578 appinfo_none_ =
3527 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE); 3579 CreateAppInfo("None", "None", "com.example.app", OrientationLock::NONE);
3528 appinfo_landscape_ = 3580 appinfo_landscape_ =
3529 CreateAppInfo("Landscape", "Landscape", "com.example.app", 3581 CreateAppInfo("Landscape", "Landscape", "com.example.app",
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3588 private: 3640 private:
3589 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); 3641 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest);
3590 }; 3642 };
3591 3643
3592 } // namespace 3644 } // namespace
3593 3645
3594 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { 3646 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) {
3595 ASSERT_TRUE(display::Display::HasInternalDisplay()); 3647 ASSERT_TRUE(display::Display::HasInternalDisplay());
3596 3648
3597 extension_service_->AddExtension(arc_support_host_.get()); 3649 extension_service_->AddExtension(arc_support_host_.get());
3598 arc_test_.SetUp(profile());
3599 EnableArc(true); 3650 EnableArc(true);
3600 EnableTabletMode(true); 3651 EnableTabletMode(true);
3601 3652
3602 InitLauncherController(); 3653 InitLauncherController();
3603 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3654 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3604 3655
3605 InitApps(); 3656 InitApps();
3606 ash::ScreenOrientationController* controller = 3657 ash::ScreenOrientationController* controller =
3607 ash::Shell::GetInstance()->screen_orientation_controller(); 3658 ash::Shell::GetInstance()->screen_orientation_controller();
3608 3659
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 3738
3688 // Manually unlock first. 3739 // Manually unlock first.
3689 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); 3740 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE);
3690 EXPECT_FALSE(controller->rotation_locked()); 3741 EXPECT_FALSE(controller->rotation_locked());
3691 } 3742 }
3692 3743
3693 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { 3744 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) {
3694 ASSERT_TRUE(display::Display::HasInternalDisplay()); 3745 ASSERT_TRUE(display::Display::HasInternalDisplay());
3695 3746
3696 extension_service_->AddExtension(arc_support_host_.get()); 3747 extension_service_->AddExtension(arc_support_host_.get());
3697 arc_test_.SetUp(profile());
3698 EnableArc(true); 3748 EnableArc(true);
3699 EnableTabletMode(true); 3749 EnableTabletMode(true);
3700 3750
3701 InitLauncherController(); 3751 InitLauncherController();
3702 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3752 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3703 3753
3704 InitApps(); 3754 InitApps();
3705 ash::ScreenOrientationController* controller = 3755 ash::ScreenOrientationController* controller =
3706 ash::Shell::GetInstance()->screen_orientation_controller(); 3756 ash::Shell::GetInstance()->screen_orientation_controller();
3707 3757
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 EXPECT_FALSE(controller->rotation_locked()); 3795 EXPECT_FALSE(controller->rotation_locked());
3746 EXPECT_EQ(display::Display::ROTATE_0, 3796 EXPECT_EQ(display::Display::ROTATE_0,
3747 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3797 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3748 3798
3749 NotifyOnTaskOrientationLockRequested(task_id_current_, 3799 NotifyOnTaskOrientationLockRequested(task_id_current_,
3750 OrientationLock::CURRENT); 3800 OrientationLock::CURRENT);
3751 EXPECT_TRUE(controller->rotation_locked()); 3801 EXPECT_TRUE(controller->rotation_locked());
3752 EXPECT_EQ(display::Display::ROTATE_0, 3802 EXPECT_EQ(display::Display::ROTATE_0,
3753 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3803 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3754 } 3804 }
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