OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "chrome/common/chrome_constants.h" | 76 #include "chrome/common/chrome_constants.h" |
77 #include "chrome/common/chrome_switches.h" | 77 #include "chrome/common/chrome_switches.h" |
78 #include "chrome/common/extensions/extension_constants.h" | 78 #include "chrome/common/extensions/extension_constants.h" |
79 #include "chrome/common/pref_names.h" | 79 #include "chrome/common/pref_names.h" |
80 #include "chrome/test/base/browser_with_test_window_test.h" | 80 #include "chrome/test/base/browser_with_test_window_test.h" |
81 #include "chrome/test/base/test_browser_window_aura.h" | 81 #include "chrome/test/base/test_browser_window_aura.h" |
82 #include "chrome/test/base/testing_browser_process.h" | 82 #include "chrome/test/base/testing_browser_process.h" |
83 #include "chrome/test/base/testing_profile.h" | 83 #include "chrome/test/base/testing_profile.h" |
84 #include "chrome/test/base/testing_profile_manager.h" | 84 #include "chrome/test/base/testing_profile_manager.h" |
85 #include "chromeos/chromeos_switches.h" | 85 #include "chromeos/chromeos_switches.h" |
| 86 #include "components/arc/arc_util.h" |
86 #include "components/arc/common/app.mojom.h" | 87 #include "components/arc/common/app.mojom.h" |
87 #include "components/arc/test/fake_app_instance.h" | 88 #include "components/arc/test/fake_app_instance.h" |
88 #include "components/exo/shell_surface.h" | 89 #include "components/exo/shell_surface.h" |
89 #include "components/prefs/pref_notifier_impl.h" | 90 #include "components/prefs/pref_notifier_impl.h" |
90 #include "components/signin/core/account_id/account_id.h" | 91 #include "components/signin/core/account_id/account_id.h" |
91 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" | 92 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" |
92 #include "components/sync/model/fake_sync_change_processor.h" | 93 #include "components/sync/model/fake_sync_change_processor.h" |
93 #include "components/sync/model/sync_error_factory_mock.h" | 94 #include "components/sync/model/sync_error_factory_mock.h" |
94 #include "components/sync/protocol/sync.pb.h" | 95 #include "components/sync/protocol/sync.pb.h" |
95 #include "components/sync_preferences/pref_model_associator.h" | 96 #include "components/sync_preferences/pref_model_associator.h" |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 arc_test_.app_instance()->RefreshAppList(); | 871 arc_test_.app_instance()->RefreshAppList(); |
871 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); | 872 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); |
872 } | 873 } |
873 | 874 |
874 void UninstallArcApps() { | 875 void UninstallArcApps() { |
875 arc_test_.app_instance()->RefreshAppList(); | 876 arc_test_.app_instance()->RefreshAppList(); |
876 arc_test_.app_instance()->SendRefreshAppList( | 877 arc_test_.app_instance()->SendRefreshAppList( |
877 std::vector<arc::mojom::AppInfo>()); | 878 std::vector<arc::mojom::AppInfo>()); |
878 } | 879 } |
879 | 880 |
880 void EnableArc(bool enabled) { | 881 // TODO(victorhsieh): Add test coverage for when ARC is started regardless |
| 882 // Play Store opt-in status, and the followed opt-in and opt-out. |
| 883 void EnablePlayStore(bool enabled) { |
881 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled); | 884 arc::SetArcPlayStoreEnabledForProfile(profile(), enabled); |
882 base::RunLoop().RunUntilIdle(); | 885 base::RunLoop().RunUntilIdle(); |
883 } | 886 } |
884 | 887 |
885 void EnableTabletMode(bool enable) { | 888 void EnableTabletMode(bool enable) { |
886 ash::MaximizeModeController* controller = | 889 ash::MaximizeModeController* controller = |
887 ash::WmShell::Get()->maximize_mode_controller(); | 890 ash::WmShell::Get()->maximize_mode_controller(); |
888 controller->EnableMaximizeModeWindowManager(enable); | 891 controller->EnableMaximizeModeWindowManager(enable); |
889 } | 892 } |
890 | 893 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 aura::client::ParentWindowWithContext(window.get(), GetContext(), | 994 aura::client::ParentWindowWithContext(window.get(), GetContext(), |
992 gfx::Rect(200, 200)); | 995 gfx::Rect(200, 200)); |
993 | 996 |
994 return new TestBrowserWindowAura(std::move(window)); | 997 return new TestBrowserWindowAura(std::move(window)); |
995 } | 998 } |
996 | 999 |
997 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); | 1000 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); |
998 }; | 1001 }; |
999 | 1002 |
1000 class ChromeLauncherControllerImplWithArcTest | 1003 class ChromeLauncherControllerImplWithArcTest |
1001 : public ChromeLauncherControllerImplTest { | 1004 : public ChromeLauncherControllerImplTest, |
| 1005 public ::testing::WithParamInterface<bool> { |
1002 protected: | 1006 protected: |
1003 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; } | 1007 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; } |
1004 ~ChromeLauncherControllerImplWithArcTest() override {} | 1008 ~ChromeLauncherControllerImplWithArcTest() override {} |
1005 | 1009 |
| 1010 void SetUp() override { |
| 1011 if (GetParam()) |
| 1012 arc::SetArcAlwaysStartForTesting(); |
| 1013 ChromeLauncherControllerImplTest::SetUp(); |
| 1014 } |
| 1015 |
1006 private: | 1016 private: |
1007 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest); | 1017 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest); |
1008 }; | 1018 }; |
1009 | 1019 |
| 1020 INSTANTIATE_TEST_CASE_P(, |
| 1021 ChromeLauncherControllerImplWithArcTest, |
| 1022 ::testing::Bool()); |
| 1023 |
1010 // Watches WebContents and blocks until it is destroyed. This is needed for | 1024 // Watches WebContents and blocks until it is destroyed. This is needed for |
1011 // the destruction of a V2 application. | 1025 // the destruction of a V2 application. |
1012 class WebContentsDestroyedWatcher : public content::WebContentsObserver { | 1026 class WebContentsDestroyedWatcher : public content::WebContentsObserver { |
1013 public: | 1027 public: |
1014 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) | 1028 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) |
1015 : content::WebContentsObserver(web_contents), | 1029 : content::WebContentsObserver(web_contents), |
1016 message_loop_runner_(new content::MessageLoopRunner) { | 1030 message_loop_runner_(new content::MessageLoopRunner) { |
1017 EXPECT_TRUE(web_contents != NULL); | 1031 EXPECT_TRUE(web_contents != NULL); |
1018 } | 1032 } |
1019 ~WebContentsDestroyedWatcher() override {} | 1033 ~WebContentsDestroyedWatcher() override {} |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 | 1292 |
1279 ash::test::TestShellDelegate* shell_delegate_; | 1293 ash::test::TestShellDelegate* shell_delegate_; |
1280 | 1294 |
1281 ProfileToNameMap created_profiles_; | 1295 ProfileToNameMap created_profiles_; |
1282 | 1296 |
1283 DISALLOW_COPY_AND_ASSIGN( | 1297 DISALLOW_COPY_AND_ASSIGN( |
1284 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); | 1298 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); |
1285 }; | 1299 }; |
1286 | 1300 |
1287 class ChromeLauncherControllerImplMultiProfileWithArcTest | 1301 class ChromeLauncherControllerImplMultiProfileWithArcTest |
1288 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
{ // NOLINT(whitespace/line_length) | 1302 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
, // NOLINT(whitespace/line_length) |
| 1303 public ::testing::WithParamInterface<bool> { |
1289 protected: | 1304 protected: |
1290 ChromeLauncherControllerImplMultiProfileWithArcTest() { | 1305 ChromeLauncherControllerImplMultiProfileWithArcTest() { |
1291 auto_start_arc_test_ = true; | 1306 auto_start_arc_test_ = true; |
1292 } | 1307 } |
1293 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} | 1308 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} |
1294 | 1309 |
| 1310 void SetUp() override { |
| 1311 if (GetParam()) |
| 1312 arc::SetArcAlwaysStartForTesting(); |
| 1313 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest:: |
| 1314 SetUp(); |
| 1315 } |
| 1316 |
1295 private: | 1317 private: |
1296 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); | 1318 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); |
1297 }; | 1319 }; |
1298 | 1320 |
| 1321 INSTANTIATE_TEST_CASE_P(, |
| 1322 ChromeLauncherControllerImplMultiProfileWithArcTest, |
| 1323 ::testing::Bool()); |
| 1324 |
1299 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { | 1325 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { |
1300 InitLauncherController(); | 1326 InitLauncherController(); |
1301 // Model should only contain the browser shortcut and app list items. | 1327 // Model should only contain the browser shortcut and app list items. |
1302 EXPECT_EQ(2, model_->item_count()); | 1328 EXPECT_EQ(2, model_->item_count()); |
1303 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1329 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
1304 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1330 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
1305 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 1331 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
1306 | 1332 |
1307 // Installing |extension3_| should add it to the launcher - behind the | 1333 // Installing |extension3_| should add it to the launcher - behind the |
1308 // chrome icon. | 1334 // chrome icon. |
1309 extension_service_->AddExtension(extension3_.get()); | 1335 extension_service_->AddExtension(extension3_.get()); |
1310 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1336 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
1311 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1337 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
1312 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1338 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
1313 } | 1339 } |
1314 | 1340 |
1315 TEST_F(ChromeLauncherControllerImplWithArcTest, | 1341 TEST_P(ChromeLauncherControllerImplWithArcTest, |
1316 ArcAppPinCrossPlatformWorkflow) { | 1342 ArcAppPinCrossPlatformWorkflow) { |
1317 // Work on ARC disabled platform first. | 1343 // Work on ARC disabled platform first. |
1318 const std::string arc_app_id1 = | 1344 const std::string arc_app_id1 = |
1319 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1345 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
1320 const std::string arc_app_id2 = | 1346 const std::string arc_app_id2 = |
1321 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1347 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
1322 const std::string arc_app_id3 = | 1348 const std::string arc_app_id3 = |
1323 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); | 1349 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); |
1324 | 1350 |
1325 InitLauncherController(); | 1351 InitLauncherController(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); | 1409 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); |
1384 | 1410 |
1385 launcher_controller_.reset(); | 1411 launcher_controller_.reset(); |
1386 ResetPinModel(); | 1412 ResetPinModel(); |
1387 | 1413 |
1388 SendPinChanges(syncer::SyncChangeList(), true); | 1414 SendPinChanges(syncer::SyncChangeList(), true); |
1389 StopAppSyncService(); | 1415 StopAppSyncService(); |
1390 EXPECT_EQ(0U, app_service_->sync_items().size()); | 1416 EXPECT_EQ(0U, app_service_->sync_items().size()); |
1391 | 1417 |
1392 // Move back to ARC disabled platform. | 1418 // Move back to ARC disabled platform. |
1393 EnableArc(false); | 1419 // TODO(victorhsieh): Implement opt-out. |
| 1420 if (arc::ShouldArcAlwaysStart()) |
| 1421 return; |
| 1422 EnablePlayStore(false); |
1394 StartAppSyncService(copy_sync_list); | 1423 StartAppSyncService(copy_sync_list); |
1395 RecreateChromeLauncher(); | 1424 RecreateChromeLauncher(); |
1396 | 1425 |
1397 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1426 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
1398 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1427 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
1399 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 1428 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
1400 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1429 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
1401 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1430 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
1402 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1431 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
1403 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); | 1432 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); |
1404 | 1433 |
1405 // Now move/remove pins on ARC disabled platform. | 1434 // Now move/remove pins on ARC disabled platform. |
1406 model_->Move(4, 2); | 1435 model_->Move(4, 2); |
1407 launcher_controller_->UnpinAppWithID(extension2_->id()); | 1436 launcher_controller_->UnpinAppWithID(extension2_->id()); |
1408 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); | 1437 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); |
1409 EnableArc(true); | 1438 EnablePlayStore(true); |
1410 | 1439 |
1411 SendListOfArcApps(); | 1440 SendListOfArcApps(); |
1412 | 1441 |
1413 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1442 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
1414 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1443 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
1415 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1444 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
1416 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1445 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
1417 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1446 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
1418 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1447 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
1419 EXPECT_EQ("AppList, Fake App 1, App3, Chrome, App1, Fake App 0", | 1448 EXPECT_EQ("AppList, Fake App 1, App3, Chrome, App1, Fake App 0", |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 | 1865 |
1837 // Check that removing more items does not crash and changes nothing. | 1866 // Check that removing more items does not crash and changes nothing. |
1838 launcher_controller_->UnlockV1AppWithID(extension2_->id()); | 1867 launcher_controller_->UnlockV1AppWithID(extension2_->id()); |
1839 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1868 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
1840 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); | 1869 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); |
1841 launcher_controller_->UnlockV1AppWithID(extension3_->id()); | 1870 launcher_controller_->UnlockV1AppWithID(extension3_->id()); |
1842 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1871 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
1843 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 1872 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
1844 } | 1873 } |
1845 | 1874 |
1846 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { | 1875 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { |
1847 RecreateChromeLauncher(); | 1876 RecreateChromeLauncher(); |
1848 | 1877 |
1849 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1878 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
1850 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1879 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
1851 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1880 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
1852 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1881 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
1853 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1882 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
1854 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1883 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
1855 | 1884 |
1856 SendListOfArcApps(); | 1885 SendListOfArcApps(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 | 1940 |
1912 const arc::FakeAppInstance::Request* request1 = | 1941 const arc::FakeAppInstance::Request* request1 = |
1913 arc_test_.app_instance()->launch_requests()[0].get(); | 1942 arc_test_.app_instance()->launch_requests()[0].get(); |
1914 const arc::FakeAppInstance::Request* request2 = | 1943 const arc::FakeAppInstance::Request* request2 = |
1915 arc_test_.app_instance()->launch_requests()[1].get(); | 1944 arc_test_.app_instance()->launch_requests()[1].get(); |
1916 | 1945 |
1917 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1946 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
1918 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1947 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
1919 } | 1948 } |
1920 | 1949 |
1921 TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { | 1950 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { |
1922 SendListOfArcApps(); | 1951 SendListOfArcApps(); |
1923 | 1952 |
1924 InitLauncherController(); | 1953 InitLauncherController(); |
1925 SetLauncherControllerHelper(new TestLauncherControllerHelper); | 1954 SetLauncherControllerHelper(new TestLauncherControllerHelper); |
1926 | 1955 |
1927 // App1 exists all the time. | 1956 // App1 exists all the time. |
1928 // App2 is created when primary user is active and destroyed when secondary | 1957 // App2 is created when primary user is active and destroyed when secondary |
1929 // user is active. | 1958 // user is active. |
1930 // App3 created when secondary user is active. | 1959 // App3 created when secondary user is active. |
1931 | 1960 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 EXPECT_EQ(ash::kInvalidShelfID, | 2012 EXPECT_EQ(ash::kInvalidShelfID, |
1984 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2013 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
1985 EXPECT_NE(ash::kInvalidShelfID, | 2014 EXPECT_NE(ash::kInvalidShelfID, |
1986 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 2015 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
1987 | 2016 |
1988 // Close active window to let test passes. | 2017 // Close active window to let test passes. |
1989 arc_window1->CloseNow(); | 2018 arc_window1->CloseNow(); |
1990 arc_window3->CloseNow(); | 2019 arc_window3->CloseNow(); |
1991 } | 2020 } |
1992 | 2021 |
1993 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { | 2022 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { |
1994 InitLauncherController(); | 2023 InitLauncherController(); |
1995 | 2024 |
1996 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2025 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
1997 SendListOfArcApps(); | 2026 SendListOfArcApps(); |
1998 EXPECT_EQ(ash::kInvalidShelfID, | 2027 EXPECT_EQ(ash::kInvalidShelfID, |
1999 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2028 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
2000 | 2029 |
2001 // Normal flow, create/destroy tasks. | 2030 // Normal flow, create/destroy tasks. |
2002 std::string window_app_id1("org.chromium.arc.1"); | 2031 std::string window_app_id1("org.chromium.arc.1"); |
2003 std::string window_app_id2("org.chromium.arc.2"); | 2032 std::string window_app_id2("org.chromium.arc.2"); |
(...skipping 22 matching lines...) Expand all Loading... |
2026 EXPECT_NE(ash::kInvalidShelfID, | 2055 EXPECT_NE(ash::kInvalidShelfID, |
2027 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2056 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
2028 arc_test_.StopArcInstance(); | 2057 arc_test_.StopArcInstance(); |
2029 base::RunLoop().RunUntilIdle(); | 2058 base::RunLoop().RunUntilIdle(); |
2030 EXPECT_EQ(ash::kInvalidShelfID, | 2059 EXPECT_EQ(ash::kInvalidShelfID, |
2031 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2060 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
2032 } | 2061 } |
2033 | 2062 |
2034 // Test race creation/deletion of ARC app. | 2063 // Test race creation/deletion of ARC app. |
2035 // TODO(khmel): Remove after moving everything to wayland protocol. | 2064 // TODO(khmel): Remove after moving everything to wayland protocol. |
2036 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { | 2065 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { |
2037 InitLauncherController(); | 2066 InitLauncherController(); |
2038 | 2067 |
2039 const std::string arc_app_id1 = | 2068 const std::string arc_app_id1 = |
2040 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2069 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
2041 const std::string arc_app_id2 = | 2070 const std::string arc_app_id2 = |
2042 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2071 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
2043 SendListOfArcApps(); | 2072 SendListOfArcApps(); |
2044 | 2073 |
2045 // ARC window created before and closed after mojom notification. | 2074 // ARC window created before and closed after mojom notification. |
2046 std::string window_app_id1("org.chromium.arc.1"); | 2075 std::string window_app_id1("org.chromium.arc.1"); |
(...skipping 26 matching lines...) Expand all Loading... |
2073 arc_window->Close(); | 2102 arc_window->Close(); |
2074 base::RunLoop().RunUntilIdle(); | 2103 base::RunLoop().RunUntilIdle(); |
2075 // Closing window does not close shelf item. It is closed on task destroy. | 2104 // Closing window does not close shelf item. It is closed on task destroy. |
2076 EXPECT_NE(ash::kInvalidShelfID, | 2105 EXPECT_NE(ash::kInvalidShelfID, |
2077 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2106 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
2078 arc_test_.app_instance()->SendTaskDestroyed(2); | 2107 arc_test_.app_instance()->SendTaskDestroyed(2); |
2079 EXPECT_EQ(ash::kInvalidShelfID, | 2108 EXPECT_EQ(ash::kInvalidShelfID, |
2080 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2109 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
2081 } | 2110 } |
2082 | 2111 |
2083 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { | 2112 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { |
2084 InitLauncherController(); | 2113 InitLauncherController(); |
2085 | 2114 |
2086 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2115 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
2087 SendListOfArcApps(); | 2116 SendListOfArcApps(); |
2088 | 2117 |
2089 std::string window_app_id("org.chromium.arc.1"); | 2118 std::string window_app_id("org.chromium.arc.1"); |
2090 views::Widget* arc_window = CreateArcWindow(window_app_id); | 2119 views::Widget* arc_window = CreateArcWindow(window_app_id); |
2091 ASSERT_TRUE(arc_window); | 2120 ASSERT_TRUE(arc_window); |
2092 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2121 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
2093 std::string()); | 2122 std::string()); |
2094 const ash::ShelfID shelf_id = | 2123 const ash::ShelfID shelf_id = |
2095 launcher_controller_->GetShelfIDForAppID(arc_app_id); | 2124 launcher_controller_->GetShelfIDForAppID(arc_app_id); |
2096 EXPECT_NE(ash::kInvalidShelfID, shelf_id); | 2125 EXPECT_NE(ash::kInvalidShelfID, shelf_id); |
2097 | 2126 |
2098 for (int i = 0; i < 3; ++i) { | 2127 for (int i = 0; i < 3; ++i) { |
2099 arc_window->Close(); | 2128 arc_window->Close(); |
2100 base::RunLoop().RunUntilIdle(); | 2129 base::RunLoop().RunUntilIdle(); |
2101 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2130 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
2102 | 2131 |
2103 arc_window = CreateArcWindow(window_app_id); | 2132 arc_window = CreateArcWindow(window_app_id); |
2104 ASSERT_TRUE(arc_window); | 2133 ASSERT_TRUE(arc_window); |
2105 base::RunLoop().RunUntilIdle(); | 2134 base::RunLoop().RunUntilIdle(); |
2106 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2135 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
2107 } | 2136 } |
2108 } | 2137 } |
2109 | 2138 |
2110 // Validate that ARC app is pinned correctly and pin is removed automatically | 2139 // Validate that ARC app is pinned correctly and pin is removed automatically |
2111 // once app is uninstalled. | 2140 // once app is uninstalled. |
2112 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { | 2141 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { |
2113 InitLauncherController(); | 2142 InitLauncherController(); |
2114 | 2143 |
2115 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2144 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
2116 | 2145 |
2117 SendListOfArcApps(); | 2146 SendListOfArcApps(); |
2118 extension_service_->AddExtension(extension1_.get()); | 2147 extension_service_->AddExtension(extension1_.get()); |
2119 extension_service_->AddExtension(extension2_.get()); | 2148 extension_service_->AddExtension(extension2_.get()); |
2120 | 2149 |
2121 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2150 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
2122 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); | 2151 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
2123 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 2152 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
2124 | 2153 |
2125 launcher_controller_->PinAppWithID(extension1_->id()); | 2154 launcher_controller_->PinAppWithID(extension1_->id()); |
2126 launcher_controller_->PinAppWithID(arc_app_id); | 2155 launcher_controller_->PinAppWithID(arc_app_id); |
2127 launcher_controller_->PinAppWithID(extension2_->id()); | 2156 launcher_controller_->PinAppWithID(extension2_->id()); |
2128 | 2157 |
2129 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2158 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
2130 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); | 2159 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); |
2131 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2160 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
2132 | 2161 |
2133 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); | 2162 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); |
| 2163 // In opt-out mode, only system apps are available and can't be uninstalled. |
| 2164 // Skip the rest of the test. |
| 2165 if (arc::ShouldArcAlwaysStart()) |
| 2166 return; |
2134 UninstallArcApps(); | 2167 UninstallArcApps(); |
| 2168 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
2135 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2169 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
2136 SendListOfArcApps(); | 2170 SendListOfArcApps(); |
| 2171 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
2137 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2172 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
2138 | 2173 |
2139 // Opt-Out/Opt-In remove item from the shelf. | 2174 // Opt-Out/Opt-In remove item from the shelf. |
2140 launcher_controller_->PinAppWithID(arc_app_id); | 2175 launcher_controller_->PinAppWithID(arc_app_id); |
2141 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2176 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
2142 EnableArc(false); | 2177 EnablePlayStore(false); |
2143 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2178 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
2144 EnableArc(true); | 2179 EnablePlayStore(true); |
2145 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2180 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
2146 SendListOfArcApps(); | 2181 SendListOfArcApps(); |
2147 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2182 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
2148 } | 2183 } |
2149 | 2184 |
2150 // Validates that ARC app pins persist across OptOut/OptIn. | 2185 // Validates that ARC app pins persist across OptOut/OptIn. |
2151 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { | 2186 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { |
2152 InitLauncherController(); | 2187 InitLauncherController(); |
2153 | 2188 |
2154 const std::string arc_app_id1 = | 2189 const std::string arc_app_id1 = |
2155 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2190 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
2156 const std::string arc_app_id2 = | 2191 const std::string arc_app_id2 = |
2157 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2192 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
2158 | 2193 |
2159 SendListOfArcApps(); | 2194 SendListOfArcApps(); |
2160 extension_service_->AddExtension(extension1_.get()); | 2195 extension_service_->AddExtension(extension1_.get()); |
2161 extension_service_->AddExtension(extension2_.get()); | 2196 extension_service_->AddExtension(extension2_.get()); |
2162 | 2197 |
2163 launcher_controller_->PinAppWithID(extension1_->id()); | 2198 launcher_controller_->PinAppWithID(extension1_->id()); |
2164 launcher_controller_->PinAppWithID(arc_app_id2); | 2199 launcher_controller_->PinAppWithID(arc_app_id2); |
2165 launcher_controller_->PinAppWithID(extension2_->id()); | 2200 launcher_controller_->PinAppWithID(extension2_->id()); |
2166 launcher_controller_->PinAppWithID(arc_app_id1); | 2201 launcher_controller_->PinAppWithID(arc_app_id1); |
2167 | 2202 |
2168 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2203 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
2169 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2204 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
2170 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2205 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
2171 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2206 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
2172 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2207 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
2173 GetPinnedAppStatus()); | 2208 GetPinnedAppStatus()); |
2174 | 2209 |
2175 EnableArc(false); | 2210 // TODO(victorhsieh): Implement opt-out. |
| 2211 if (arc::ShouldArcAlwaysStart()) |
| 2212 return; |
| 2213 EnablePlayStore(false); |
2176 | 2214 |
2177 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2215 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
2178 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2216 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
2179 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2217 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
2180 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2218 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
2181 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2219 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
2182 | 2220 |
2183 EnableArc(true); | 2221 EnablePlayStore(true); |
2184 SendListOfArcApps(); | 2222 SendListOfArcApps(); |
2185 base::RunLoop().RunUntilIdle(); | 2223 base::RunLoop().RunUntilIdle(); |
2186 | 2224 |
2187 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2225 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
2188 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2226 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
2189 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2227 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
2190 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2228 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
2191 | 2229 |
2192 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2230 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
2193 GetPinnedAppStatus()); | 2231 GetPinnedAppStatus()); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3596 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3634 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3597 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3635 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
3598 | 3636 |
3599 launcher_controller_->CloseLauncherItem(shelfId3); | 3637 launcher_controller_->CloseLauncherItem(shelfId3); |
3600 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3638 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
3601 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3639 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
3602 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3640 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3603 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3641 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
3604 } | 3642 } |
3605 | 3643 |
3606 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { | 3644 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { |
3607 InitLauncherControllerWithBrowser(); | 3645 InitLauncherControllerWithBrowser(); |
3608 arc::mojom::AppInfo appinfo = CreateAppInfo( | 3646 arc::mojom::AppInfo appinfo = CreateAppInfo( |
3609 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); | 3647 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); |
3610 const std::string app_id = AddArcAppAndShortcut(appinfo); | 3648 const std::string app_id = AddArcAppAndShortcut(appinfo); |
3611 | 3649 |
3612 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app | 3650 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app |
3613 // package_name (not hash) specified as id. In this test we check that | 3651 // package_name (not hash) specified as id. In this test we check that |
3614 // by hash we can determine that appropriate package was set by policy. | 3652 // by hash we can determine that appropriate package was set by policy. |
3615 base::ListValue policy_value; | 3653 base::ListValue policy_value; |
3616 InsertPrefValue(&policy_value, 0, appinfo.package_name); | 3654 InsertPrefValue(&policy_value, 0, appinfo.package_name); |
3617 profile()->GetTestingPrefService()->SetManagedPref( | 3655 profile()->GetTestingPrefService()->SetManagedPref( |
3618 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); | 3656 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); |
3619 | 3657 |
3620 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 3658 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
3621 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, | 3659 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
3622 GetPinnableForAppID(app_id, profile())); | 3660 GetPinnableForAppID(app_id, profile())); |
3623 } | 3661 } |
3624 | 3662 |
3625 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) { | 3663 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) { |
| 3664 // TODO(victorhsieh): Implement opt-in and opt-out. |
| 3665 if (arc::ShouldArcAlwaysStart()) |
| 3666 return; |
| 3667 |
3626 extension_service_->AddExtension(arc_support_host_.get()); | 3668 extension_service_->AddExtension(arc_support_host_.get()); |
3627 // Test enables ARC, so turn it off for initial values. | 3669 // Test enables ARC, so turn it off for initial values. |
3628 EnableArc(false); | 3670 EnablePlayStore(false); |
3629 | 3671 |
3630 InitLauncherController(); | 3672 InitLauncherController(); |
3631 | 3673 |
3632 // To prevent import legacy pins each time. | 3674 // To prevent import legacy pins each time. |
3633 // Initially pins are imported from legacy pref based model. | 3675 // Initially pins are imported from legacy pref based model. |
3634 StartPrefSyncService(syncer::SyncDataList()); | 3676 StartPrefSyncService(syncer::SyncDataList()); |
3635 | 3677 |
3636 // Inject |launcher_controller_| as ShelfDelegate to verify the behavior | 3678 // Inject |launcher_controller_| as ShelfDelegate to verify the behavior |
3637 // of removing pinned icon in ArcSessionManager::OnOptInPreferenceChanged(). | 3679 // of removing pinned icon in ArcSessionManager::OnOptInPreferenceChanged(). |
3638 SetShelfDelegate(); | 3680 SetShelfDelegate(); |
(...skipping 19 matching lines...) Expand all Loading... |
3658 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, | 3700 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, |
3659 "AppList, Chrome"); | 3701 "AppList, Chrome"); |
3660 | 3702 |
3661 // ARC is not managed and disabled, Play Store pin should be available. | 3703 // ARC is not managed and disabled, Play Store pin should be available. |
3662 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); | 3704 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); |
3663 base::RunLoop().RunUntilIdle(); | 3705 base::RunLoop().RunUntilIdle(); |
3664 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3706 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
3665 "AppList, Chrome, Play Store"); | 3707 "AppList, Chrome, Play Store"); |
3666 | 3708 |
3667 // ARC is not managed and enabled, Play Store pin should be available. | 3709 // ARC is not managed and enabled, Play Store pin should be available. |
3668 EnableArc(true); | 3710 EnablePlayStore(true); |
3669 ValidateArcState(true, false, | 3711 ValidateArcState(true, false, |
3670 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 3712 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
3671 "AppList, Chrome, Play Store"); | 3713 "AppList, Chrome, Play Store"); |
3672 | 3714 |
3673 // User disables ARC. ARC is not managed and disabled, Play Store pin should | 3715 // User disables ARC. ARC is not managed and disabled, Play Store pin should |
3674 // be automatically removed. | 3716 // be automatically removed. |
3675 EnableArc(false); | 3717 EnablePlayStore(false); |
3676 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3718 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
3677 "AppList, Chrome"); | 3719 "AppList, Chrome"); |
3678 | 3720 |
3679 // Even if re-enable it again, Play Store pin does not appear automatically. | 3721 // Even if re-enable it again, Play Store pin does not appear automatically. |
3680 EnableArc(true); | 3722 EnablePlayStore(true); |
3681 ValidateArcState(true, false, | 3723 ValidateArcState(true, false, |
3682 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 3724 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
3683 "AppList, Chrome"); | 3725 "AppList, Chrome"); |
3684 } | 3726 } |
3685 | 3727 |
3686 namespace { | 3728 namespace { |
3687 | 3729 |
3688 class ChromeLauncherControllerOrientationTest | 3730 class ChromeLauncherControllerOrientationTest |
3689 : public ChromeLauncherControllerImplWithArcTest { | 3731 : public ChromeLauncherControllerImplWithArcTest { |
3690 public: | 3732 public: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3752 | 3794 |
3753 views::Widget* window_none_ = nullptr; | 3795 views::Widget* window_none_ = nullptr; |
3754 views::Widget* window_landscape_ = nullptr; | 3796 views::Widget* window_landscape_ = nullptr; |
3755 views::Widget* window_portrait_ = nullptr; | 3797 views::Widget* window_portrait_ = nullptr; |
3756 views::Widget* window_current_ = nullptr; | 3798 views::Widget* window_current_ = nullptr; |
3757 | 3799 |
3758 private: | 3800 private: |
3759 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); | 3801 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); |
3760 }; | 3802 }; |
3761 | 3803 |
| 3804 INSTANTIATE_TEST_CASE_P(, |
| 3805 ChromeLauncherControllerOrientationTest, |
| 3806 ::testing::Bool()); |
| 3807 |
3762 class ChromeLauncherControllerArcDefaultAppsTest | 3808 class ChromeLauncherControllerArcDefaultAppsTest |
3763 : public ChromeLauncherControllerImplTest { | 3809 : public ChromeLauncherControllerImplTest, |
| 3810 public ::testing::WithParamInterface<bool> { |
3764 public: | 3811 public: |
3765 ChromeLauncherControllerArcDefaultAppsTest() {} | 3812 ChromeLauncherControllerArcDefaultAppsTest() {} |
3766 ~ChromeLauncherControllerArcDefaultAppsTest() override {} | 3813 ~ChromeLauncherControllerArcDefaultAppsTest() override {} |
3767 | 3814 |
3768 protected: | 3815 protected: |
3769 void SetUp() override { | 3816 void SetUp() override { |
| 3817 if (GetParam()) |
| 3818 arc::SetArcAlwaysStartForTesting(); |
3770 ArcDefaultAppList::UseTestAppsDirectory(); | 3819 ArcDefaultAppList::UseTestAppsDirectory(); |
3771 ChromeLauncherControllerImplTest::SetUp(); | 3820 ChromeLauncherControllerImplTest::SetUp(); |
3772 } | 3821 } |
3773 | 3822 |
3774 private: | 3823 private: |
3775 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); | 3824 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); |
3776 }; | 3825 }; |
3777 | 3826 |
| 3827 INSTANTIATE_TEST_CASE_P(, |
| 3828 ChromeLauncherControllerArcDefaultAppsTest, |
| 3829 ::testing::Bool()); |
| 3830 |
3778 } // namespace | 3831 } // namespace |
3779 | 3832 |
3780 TEST_F(ChromeLauncherControllerOrientationTest, | 3833 TEST_P(ChromeLauncherControllerOrientationTest, |
3781 ArcOrientationLockBeforeWindowReady) { | 3834 ArcOrientationLockBeforeWindowReady) { |
3782 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3835 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
3783 | 3836 |
3784 extension_service_->AddExtension(arc_support_host_.get()); | 3837 extension_service_->AddExtension(arc_support_host_.get()); |
3785 EnableArc(true); | 3838 EnablePlayStore(true); |
3786 | 3839 |
3787 InitLauncherController(); | 3840 InitLauncherController(); |
3788 | 3841 |
3789 ash::ScreenOrientationController* controller = | 3842 ash::ScreenOrientationController* controller = |
3790 ash::Shell::GetInstance()->screen_orientation_controller(); | 3843 ash::Shell::GetInstance()->screen_orientation_controller(); |
3791 | 3844 |
3792 std::string app_id1("org.chromium.arc.1"); | 3845 std::string app_id1("org.chromium.arc.1"); |
3793 int task_id1 = 1; | 3846 int task_id1 = 1; |
3794 arc::mojom::AppInfo appinfo1 = | 3847 arc::mojom::AppInfo appinfo1 = |
3795 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); | 3848 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); |
(...skipping 24 matching lines...) Expand all Loading... |
3820 EXPECT_EQ(display::Display::ROTATE_90, | 3873 EXPECT_EQ(display::Display::ROTATE_90, |
3821 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3874 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
3822 | 3875 |
3823 // The screen will be locked when the window is created. | 3876 // The screen will be locked when the window is created. |
3824 CreateArcWindow(app_id2); | 3877 CreateArcWindow(app_id2); |
3825 EXPECT_TRUE(controller->rotation_locked()); | 3878 EXPECT_TRUE(controller->rotation_locked()); |
3826 EXPECT_EQ(display::Display::ROTATE_0, | 3879 EXPECT_EQ(display::Display::ROTATE_0, |
3827 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3880 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
3828 } | 3881 } |
3829 | 3882 |
3830 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { | 3883 TEST_P(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { |
3831 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3884 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
3832 | 3885 |
3833 extension_service_->AddExtension(arc_support_host_.get()); | 3886 extension_service_->AddExtension(arc_support_host_.get()); |
3834 EnableArc(true); | 3887 EnablePlayStore(true); |
3835 EnableTabletMode(true); | 3888 EnableTabletMode(true); |
3836 | 3889 |
3837 InitLauncherController(); | 3890 InitLauncherController(); |
3838 | 3891 |
3839 InitApps(); | 3892 InitApps(); |
3840 ash::ScreenOrientationController* controller = | 3893 ash::ScreenOrientationController* controller = |
3841 ash::Shell::GetInstance()->screen_orientation_controller(); | 3894 ash::Shell::GetInstance()->screen_orientation_controller(); |
3842 | 3895 |
3843 // Activating a window with NON orientation unlocks the screen. | 3896 // Activating a window with NON orientation unlocks the screen. |
3844 window_none_->Activate(); | 3897 window_none_->Activate(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3917 EnableTabletMode(true); | 3970 EnableTabletMode(true); |
3918 EXPECT_TRUE(controller->rotation_locked()); | 3971 EXPECT_TRUE(controller->rotation_locked()); |
3919 EXPECT_EQ(display::Display::ROTATE_90, | 3972 EXPECT_EQ(display::Display::ROTATE_90, |
3920 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3973 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
3921 | 3974 |
3922 // Manually unlock first. | 3975 // Manually unlock first. |
3923 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); | 3976 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); |
3924 EXPECT_FALSE(controller->rotation_locked()); | 3977 EXPECT_FALSE(controller->rotation_locked()); |
3925 } | 3978 } |
3926 | 3979 |
3927 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { | 3980 TEST_P(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { |
3928 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3981 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
3929 | 3982 |
3930 extension_service_->AddExtension(arc_support_host_.get()); | 3983 extension_service_->AddExtension(arc_support_host_.get()); |
3931 EnableArc(true); | 3984 EnablePlayStore(true); |
3932 EnableTabletMode(true); | 3985 EnableTabletMode(true); |
3933 | 3986 |
3934 InitLauncherController(); | 3987 InitLauncherController(); |
3935 | 3988 |
3936 InitApps(); | 3989 InitApps(); |
3937 ash::ScreenOrientationController* controller = | 3990 ash::ScreenOrientationController* controller = |
3938 ash::Shell::GetInstance()->screen_orientation_controller(); | 3991 ash::Shell::GetInstance()->screen_orientation_controller(); |
3939 | 3992 |
3940 // Start with portrait. | 3993 // Start with portrait. |
3941 window_portrait_->Activate(); | 3994 window_portrait_->Activate(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3978 EXPECT_EQ(display::Display::ROTATE_0, | 4031 EXPECT_EQ(display::Display::ROTATE_0, |
3979 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 4032 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
3980 | 4033 |
3981 NotifyOnTaskOrientationLockRequested(task_id_current_, | 4034 NotifyOnTaskOrientationLockRequested(task_id_current_, |
3982 OrientationLock::CURRENT); | 4035 OrientationLock::CURRENT); |
3983 EXPECT_TRUE(controller->rotation_locked()); | 4036 EXPECT_TRUE(controller->rotation_locked()); |
3984 EXPECT_EQ(display::Display::ROTATE_0, | 4037 EXPECT_EQ(display::Display::ROTATE_0, |
3985 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 4038 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
3986 } | 4039 } |
3987 | 4040 |
3988 TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { | 4041 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { |
3989 arc_test_.SetUp(profile()); | 4042 arc_test_.SetUp(profile()); |
3990 InitLauncherController(); | 4043 InitLauncherController(); |
3991 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); | 4044 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); |
3992 | 4045 |
3993 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 4046 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
3994 EnableArc(false); | 4047 EnablePlayStore(false); |
3995 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4048 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
3996 ASSERT_TRUE(prefs->GetAppIds().size()); | 4049 ASSERT_TRUE(prefs->GetAppIds().size()); |
3997 | 4050 |
3998 const std::string app_id = | 4051 const std::string app_id = |
3999 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); | 4052 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
4000 EXPECT_EQ(ash::kInvalidShelfID, | 4053 EXPECT_EQ(ash::kInvalidShelfID, |
4001 launcher_controller_->GetShelfIDForAppID(app_id)); | 4054 launcher_controller_->GetShelfIDForAppID(app_id)); |
4002 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4055 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
4003 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4056 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
4004 EXPECT_NE(ash::kInvalidShelfID, | 4057 EXPECT_NE(ash::kInvalidShelfID, |
4005 launcher_controller_->GetShelfIDForAppID(app_id)); | 4058 launcher_controller_->GetShelfIDForAppID(app_id)); |
4006 | 4059 |
4007 // Stop ARC again. Shelf item should go away. | 4060 // Stop ARC again. Shelf item should go away. |
4008 EnableArc(false); | 4061 EnablePlayStore(false); |
4009 EXPECT_EQ(ash::kInvalidShelfID, | 4062 EXPECT_EQ(ash::kInvalidShelfID, |
4010 launcher_controller_->GetShelfIDForAppID(app_id)); | 4063 launcher_controller_->GetShelfIDForAppID(app_id)); |
4011 | 4064 |
4012 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4065 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
4013 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4066 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
4014 | 4067 |
4015 EXPECT_NE(ash::kInvalidShelfID, | 4068 EXPECT_NE(ash::kInvalidShelfID, |
4016 launcher_controller_->GetShelfIDForAppID(app_id)); | 4069 launcher_controller_->GetShelfIDForAppID(app_id)); |
4017 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 4070 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
4018 | 4071 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4303 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
4251 shelf_controller->auto_hide()); | 4304 shelf_controller->auto_hide()); |
4252 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4305 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
4253 | 4306 |
4254 PrefService* prefs = profile()->GetTestingPrefService(); | 4307 PrefService* prefs = profile()->GetTestingPrefService(); |
4255 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4308 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
4256 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4309 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
4257 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4310 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
4258 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4311 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
4259 } | 4312 } |
OLD | NEW |