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

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

Powered by Google App Engine
This is Rietveld 408576698