| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #include "chrome/common/chrome_constants.h" | 75 #include "chrome/common/chrome_constants.h" |
| 76 #include "chrome/common/chrome_switches.h" | 76 #include "chrome/common/chrome_switches.h" |
| 77 #include "chrome/common/extensions/extension_constants.h" | 77 #include "chrome/common/extensions/extension_constants.h" |
| 78 #include "chrome/common/pref_names.h" | 78 #include "chrome/common/pref_names.h" |
| 79 #include "chrome/test/base/browser_with_test_window_test.h" | 79 #include "chrome/test/base/browser_with_test_window_test.h" |
| 80 #include "chrome/test/base/test_browser_window_aura.h" | 80 #include "chrome/test/base/test_browser_window_aura.h" |
| 81 #include "chrome/test/base/testing_browser_process.h" | 81 #include "chrome/test/base/testing_browser_process.h" |
| 82 #include "chrome/test/base/testing_profile.h" | 82 #include "chrome/test/base/testing_profile.h" |
| 83 #include "chrome/test/base/testing_profile_manager.h" | 83 #include "chrome/test/base/testing_profile_manager.h" |
| 84 #include "chromeos/chromeos_switches.h" | 84 #include "chromeos/chromeos_switches.h" |
| 85 #include "components/arc/arc_util.h" |
| 85 #include "components/arc/common/app.mojom.h" | 86 #include "components/arc/common/app.mojom.h" |
| 86 #include "components/arc/test/fake_app_instance.h" | 87 #include "components/arc/test/fake_app_instance.h" |
| 87 #include "components/exo/shell_surface.h" | 88 #include "components/exo/shell_surface.h" |
| 88 #include "components/prefs/pref_notifier_impl.h" | 89 #include "components/prefs/pref_notifier_impl.h" |
| 89 #include "components/signin/core/account_id/account_id.h" | 90 #include "components/signin/core/account_id/account_id.h" |
| 90 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" | 91 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" |
| 91 #include "components/sync/model/fake_sync_change_processor.h" | 92 #include "components/sync/model/fake_sync_change_processor.h" |
| 92 #include "components/sync/model/sync_error_factory_mock.h" | 93 #include "components/sync/model/sync_error_factory_mock.h" |
| 93 #include "components/sync/protocol/sync.pb.h" | 94 #include "components/sync/protocol/sync.pb.h" |
| 94 #include "components/sync_preferences/pref_model_associator.h" | 95 #include "components/sync_preferences/pref_model_associator.h" |
| (...skipping 775 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 | 1284 |
| 1271 ash::test::TestShellDelegate* shell_delegate_; | 1285 ash::test::TestShellDelegate* shell_delegate_; |
| 1272 | 1286 |
| 1273 ProfileToNameMap created_profiles_; | 1287 ProfileToNameMap created_profiles_; |
| 1274 | 1288 |
| 1275 DISALLOW_COPY_AND_ASSIGN( | 1289 DISALLOW_COPY_AND_ASSIGN( |
| 1276 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); | 1290 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); |
| 1277 }; | 1291 }; |
| 1278 | 1292 |
| 1279 class ChromeLauncherControllerImplMultiProfileWithArcTest | 1293 class ChromeLauncherControllerImplMultiProfileWithArcTest |
| 1280 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
{ // NOLINT(whitespace/line_length) | 1294 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
, // NOLINT(whitespace/line_length) |
| 1295 public ::testing::WithParamInterface<bool> { |
| 1281 protected: | 1296 protected: |
| 1282 ChromeLauncherControllerImplMultiProfileWithArcTest() { | 1297 ChromeLauncherControllerImplMultiProfileWithArcTest() { |
| 1283 auto_start_arc_test_ = true; | 1298 auto_start_arc_test_ = true; |
| 1284 } | 1299 } |
| 1285 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} | 1300 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} |
| 1286 | 1301 |
| 1302 void SetUp() override { |
| 1303 if (GetParam()) |
| 1304 arc::SetArcAlwaysStartForTesting(); |
| 1305 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest:: |
| 1306 SetUp(); |
| 1307 } |
| 1308 |
| 1287 private: | 1309 private: |
| 1288 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); | 1310 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); |
| 1289 }; | 1311 }; |
| 1290 | 1312 |
| 1313 INSTANTIATE_TEST_CASE_P(, |
| 1314 ChromeLauncherControllerImplMultiProfileWithArcTest, |
| 1315 ::testing::Bool()); |
| 1316 |
| 1291 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { | 1317 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { |
| 1292 InitLauncherController(); | 1318 InitLauncherController(); |
| 1293 // Model should only contain the browser shortcut and app list items. | 1319 // Model should only contain the browser shortcut and app list items. |
| 1294 EXPECT_EQ(2, model_->item_count()); | 1320 EXPECT_EQ(2, model_->item_count()); |
| 1295 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1321 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1296 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1322 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1297 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 1323 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1298 | 1324 |
| 1299 // Installing |extension3_| should add it to the launcher - behind the | 1325 // Installing |extension3_| should add it to the launcher - behind the |
| 1300 // chrome icon. | 1326 // chrome icon. |
| 1301 extension_service_->AddExtension(extension3_.get()); | 1327 extension_service_->AddExtension(extension3_.get()); |
| 1302 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1328 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 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 } | 1331 } |
| 1306 | 1332 |
| 1307 TEST_F(ChromeLauncherControllerImplWithArcTest, | 1333 TEST_P(ChromeLauncherControllerImplWithArcTest, |
| 1308 ArcAppPinCrossPlatformWorkflow) { | 1334 ArcAppPinCrossPlatformWorkflow) { |
| 1309 // Work on ARC disabled platform first. | 1335 // Work on ARC disabled platform first. |
| 1310 const std::string arc_app_id1 = | 1336 const std::string arc_app_id1 = |
| 1311 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1337 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1312 const std::string arc_app_id2 = | 1338 const std::string arc_app_id2 = |
| 1313 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1339 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1314 const std::string arc_app_id3 = | 1340 const std::string arc_app_id3 = |
| 1315 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); | 1341 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); |
| 1316 | 1342 |
| 1317 InitLauncherController(); | 1343 InitLauncherController(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); | 1401 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); |
| 1376 | 1402 |
| 1377 launcher_controller_.reset(); | 1403 launcher_controller_.reset(); |
| 1378 ResetPinModel(); | 1404 ResetPinModel(); |
| 1379 | 1405 |
| 1380 SendPinChanges(syncer::SyncChangeList(), true); | 1406 SendPinChanges(syncer::SyncChangeList(), true); |
| 1381 StopAppSyncService(); | 1407 StopAppSyncService(); |
| 1382 EXPECT_EQ(0U, app_service_->sync_items().size()); | 1408 EXPECT_EQ(0U, app_service_->sync_items().size()); |
| 1383 | 1409 |
| 1384 // Move back to ARC disabled platform. | 1410 // Move back to ARC disabled platform. |
| 1385 EnableArc(false); | 1411 // TODO(victorhsieh): Implement opt-out. |
| 1412 if (arc::ShouldArcAlwaysStart()) |
| 1413 return; |
| 1414 EnablePlayStore(false); |
| 1386 StartAppSyncService(copy_sync_list); | 1415 StartAppSyncService(copy_sync_list); |
| 1387 RecreateChromeLauncher(); | 1416 RecreateChromeLauncher(); |
| 1388 | 1417 |
| 1389 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1418 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1390 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1419 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1391 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 1420 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1392 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1421 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1393 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1422 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1394 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1423 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1395 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); | 1424 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); |
| 1396 | 1425 |
| 1397 // Now move/remove pins on ARC disabled platform. | 1426 // Now move/remove pins on ARC disabled platform. |
| 1398 model_->Move(4, 2); | 1427 model_->Move(4, 2); |
| 1399 launcher_controller_->UnpinAppWithID(extension2_->id()); | 1428 launcher_controller_->UnpinAppWithID(extension2_->id()); |
| 1400 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); | 1429 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); |
| 1401 EnableArc(true); | 1430 EnablePlayStore(true); |
| 1402 | 1431 |
| 1403 SendListOfArcApps(); | 1432 SendListOfArcApps(); |
| 1404 | 1433 |
| 1405 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1434 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1406 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1435 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1407 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1436 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1408 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1437 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1409 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1438 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1410 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1439 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1411 EXPECT_EQ("AppList, Fake App 1, App3, Chrome, App1, Fake App 0", | 1440 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... |
| 1828 | 1857 |
| 1829 // Check that removing more items does not crash and changes nothing. | 1858 // Check that removing more items does not crash and changes nothing. |
| 1830 launcher_controller_->UnlockV1AppWithID(extension2_->id()); | 1859 launcher_controller_->UnlockV1AppWithID(extension2_->id()); |
| 1831 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1860 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1832 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); | 1861 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); |
| 1833 launcher_controller_->UnlockV1AppWithID(extension3_->id()); | 1862 launcher_controller_->UnlockV1AppWithID(extension3_->id()); |
| 1834 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1863 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1835 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 1864 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 1836 } | 1865 } |
| 1837 | 1866 |
| 1838 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { | 1867 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { |
| 1839 RecreateChromeLauncher(); | 1868 RecreateChromeLauncher(); |
| 1840 | 1869 |
| 1841 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1870 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
| 1842 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1871 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1843 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1872 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1844 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1873 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1845 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1874 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1846 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1875 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1847 | 1876 |
| 1848 SendListOfArcApps(); | 1877 SendListOfArcApps(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 | 1932 |
| 1904 const arc::FakeAppInstance::Request* request1 = | 1933 const arc::FakeAppInstance::Request* request1 = |
| 1905 arc_test_.app_instance()->launch_requests()[0].get(); | 1934 arc_test_.app_instance()->launch_requests()[0].get(); |
| 1906 const arc::FakeAppInstance::Request* request2 = | 1935 const arc::FakeAppInstance::Request* request2 = |
| 1907 arc_test_.app_instance()->launch_requests()[1].get(); | 1936 arc_test_.app_instance()->launch_requests()[1].get(); |
| 1908 | 1937 |
| 1909 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1938 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1910 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1939 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| 1911 } | 1940 } |
| 1912 | 1941 |
| 1913 TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { | 1942 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { |
| 1914 SendListOfArcApps(); | 1943 SendListOfArcApps(); |
| 1915 | 1944 |
| 1916 InitLauncherController(); | 1945 InitLauncherController(); |
| 1917 SetLauncherControllerHelper(new TestLauncherControllerHelper); | 1946 SetLauncherControllerHelper(new TestLauncherControllerHelper); |
| 1918 | 1947 |
| 1919 // App1 exists all the time. | 1948 // App1 exists all the time. |
| 1920 // App2 is created when primary user is active and destroyed when secondary | 1949 // App2 is created when primary user is active and destroyed when secondary |
| 1921 // user is active. | 1950 // user is active. |
| 1922 // App3 created when secondary user is active. | 1951 // App3 created when secondary user is active. |
| 1923 | 1952 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 EXPECT_EQ(ash::kInvalidShelfID, | 2004 EXPECT_EQ(ash::kInvalidShelfID, |
| 1976 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2005 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1977 EXPECT_NE(ash::kInvalidShelfID, | 2006 EXPECT_NE(ash::kInvalidShelfID, |
| 1978 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 2007 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1979 | 2008 |
| 1980 // Close active window to let test passes. | 2009 // Close active window to let test passes. |
| 1981 arc_window1->CloseNow(); | 2010 arc_window1->CloseNow(); |
| 1982 arc_window3->CloseNow(); | 2011 arc_window3->CloseNow(); |
| 1983 } | 2012 } |
| 1984 | 2013 |
| 1985 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { | 2014 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { |
| 1986 InitLauncherController(); | 2015 InitLauncherController(); |
| 1987 | 2016 |
| 1988 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2017 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1989 SendListOfArcApps(); | 2018 SendListOfArcApps(); |
| 1990 EXPECT_EQ(ash::kInvalidShelfID, | 2019 EXPECT_EQ(ash::kInvalidShelfID, |
| 1991 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2020 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1992 | 2021 |
| 1993 // Normal flow, create/destroy tasks. | 2022 // Normal flow, create/destroy tasks. |
| 1994 std::string window_app_id1("org.chromium.arc.1"); | 2023 std::string window_app_id1("org.chromium.arc.1"); |
| 1995 std::string window_app_id2("org.chromium.arc.2"); | 2024 std::string window_app_id2("org.chromium.arc.2"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2018 EXPECT_NE(ash::kInvalidShelfID, | 2047 EXPECT_NE(ash::kInvalidShelfID, |
| 2019 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2048 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 2020 arc_test_.StopArcInstance(); | 2049 arc_test_.StopArcInstance(); |
| 2021 base::RunLoop().RunUntilIdle(); | 2050 base::RunLoop().RunUntilIdle(); |
| 2022 EXPECT_EQ(ash::kInvalidShelfID, | 2051 EXPECT_EQ(ash::kInvalidShelfID, |
| 2023 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2052 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 2024 } | 2053 } |
| 2025 | 2054 |
| 2026 // Test race creation/deletion of ARC app. | 2055 // Test race creation/deletion of ARC app. |
| 2027 // TODO(khmel): Remove after moving everything to wayland protocol. | 2056 // TODO(khmel): Remove after moving everything to wayland protocol. |
| 2028 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { | 2057 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { |
| 2029 InitLauncherController(); | 2058 InitLauncherController(); |
| 2030 | 2059 |
| 2031 const std::string arc_app_id1 = | 2060 const std::string arc_app_id1 = |
| 2032 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2061 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2033 const std::string arc_app_id2 = | 2062 const std::string arc_app_id2 = |
| 2034 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2063 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 2035 SendListOfArcApps(); | 2064 SendListOfArcApps(); |
| 2036 | 2065 |
| 2037 // ARC window created before and closed after mojom notification. | 2066 // ARC window created before and closed after mojom notification. |
| 2038 std::string window_app_id1("org.chromium.arc.1"); | 2067 std::string window_app_id1("org.chromium.arc.1"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2065 arc_window->Close(); | 2094 arc_window->Close(); |
| 2066 base::RunLoop().RunUntilIdle(); | 2095 base::RunLoop().RunUntilIdle(); |
| 2067 // Closing window does not close shelf item. It is closed on task destroy. | 2096 // Closing window does not close shelf item. It is closed on task destroy. |
| 2068 EXPECT_NE(ash::kInvalidShelfID, | 2097 EXPECT_NE(ash::kInvalidShelfID, |
| 2069 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2098 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 2070 arc_test_.app_instance()->SendTaskDestroyed(2); | 2099 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 2071 EXPECT_EQ(ash::kInvalidShelfID, | 2100 EXPECT_EQ(ash::kInvalidShelfID, |
| 2072 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2101 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 2073 } | 2102 } |
| 2074 | 2103 |
| 2075 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { | 2104 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { |
| 2076 InitLauncherController(); | 2105 InitLauncherController(); |
| 2077 | 2106 |
| 2078 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2107 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2079 SendListOfArcApps(); | 2108 SendListOfArcApps(); |
| 2080 | 2109 |
| 2081 std::string window_app_id("org.chromium.arc.1"); | 2110 std::string window_app_id("org.chromium.arc.1"); |
| 2082 views::Widget* arc_window = CreateArcWindow(window_app_id); | 2111 views::Widget* arc_window = CreateArcWindow(window_app_id); |
| 2083 ASSERT_TRUE(arc_window); | 2112 ASSERT_TRUE(arc_window); |
| 2084 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2113 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2085 std::string()); | 2114 std::string()); |
| 2086 const ash::ShelfID shelf_id = | 2115 const ash::ShelfID shelf_id = |
| 2087 launcher_controller_->GetShelfIDForAppID(arc_app_id); | 2116 launcher_controller_->GetShelfIDForAppID(arc_app_id); |
| 2088 EXPECT_NE(ash::kInvalidShelfID, shelf_id); | 2117 EXPECT_NE(ash::kInvalidShelfID, shelf_id); |
| 2089 | 2118 |
| 2090 for (int i = 0; i < 3; ++i) { | 2119 for (int i = 0; i < 3; ++i) { |
| 2091 arc_window->Close(); | 2120 arc_window->Close(); |
| 2092 base::RunLoop().RunUntilIdle(); | 2121 base::RunLoop().RunUntilIdle(); |
| 2093 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2122 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 2094 | 2123 |
| 2095 arc_window = CreateArcWindow(window_app_id); | 2124 arc_window = CreateArcWindow(window_app_id); |
| 2096 ASSERT_TRUE(arc_window); | 2125 ASSERT_TRUE(arc_window); |
| 2097 base::RunLoop().RunUntilIdle(); | 2126 base::RunLoop().RunUntilIdle(); |
| 2098 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2127 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 2099 } | 2128 } |
| 2100 } | 2129 } |
| 2101 | 2130 |
| 2102 // Validate that ARC app is pinned correctly and pin is removed automatically | 2131 // Validate that ARC app is pinned correctly and pin is removed automatically |
| 2103 // once app is uninstalled. | 2132 // once app is uninstalled. |
| 2104 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { | 2133 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { |
| 2105 InitLauncherController(); | 2134 InitLauncherController(); |
| 2106 | 2135 |
| 2107 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2136 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2108 | 2137 |
| 2109 SendListOfArcApps(); | 2138 SendListOfArcApps(); |
| 2110 extension_service_->AddExtension(extension1_.get()); | 2139 extension_service_->AddExtension(extension1_.get()); |
| 2111 extension_service_->AddExtension(extension2_.get()); | 2140 extension_service_->AddExtension(extension2_.get()); |
| 2112 | 2141 |
| 2113 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2142 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2114 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); | 2143 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2115 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 2144 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2116 | 2145 |
| 2117 launcher_controller_->PinAppWithID(extension1_->id()); | 2146 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2118 launcher_controller_->PinAppWithID(arc_app_id); | 2147 launcher_controller_->PinAppWithID(arc_app_id); |
| 2119 launcher_controller_->PinAppWithID(extension2_->id()); | 2148 launcher_controller_->PinAppWithID(extension2_->id()); |
| 2120 | 2149 |
| 2121 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2150 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2122 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); | 2151 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2123 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2152 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2124 | 2153 |
| 2125 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); | 2154 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); |
| 2155 // In opt-out mode, only system apps are available and can't be uninstalled. |
| 2156 // Skip the rest of the test. |
| 2157 if (arc::ShouldArcAlwaysStart()) |
| 2158 return; |
| 2126 UninstallArcApps(); | 2159 UninstallArcApps(); |
| 2160 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2127 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2161 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2128 SendListOfArcApps(); | 2162 SendListOfArcApps(); |
| 2163 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2129 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2164 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2130 | 2165 |
| 2131 // Opt-Out/Opt-In remove item from the shelf. | 2166 // Opt-Out/Opt-In remove item from the shelf. |
| 2132 launcher_controller_->PinAppWithID(arc_app_id); | 2167 launcher_controller_->PinAppWithID(arc_app_id); |
| 2133 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2168 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 2134 EnableArc(false); | 2169 EnablePlayStore(false); |
| 2135 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2170 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2136 EnableArc(true); | 2171 EnablePlayStore(true); |
| 2137 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2172 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2138 SendListOfArcApps(); | 2173 SendListOfArcApps(); |
| 2139 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2174 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 2140 } | 2175 } |
| 2141 | 2176 |
| 2142 // Validates that ARC app pins persist across OptOut/OptIn. | 2177 // Validates that ARC app pins persist across OptOut/OptIn. |
| 2143 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { | 2178 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { |
| 2144 InitLauncherController(); | 2179 InitLauncherController(); |
| 2145 | 2180 |
| 2146 const std::string arc_app_id1 = | 2181 const std::string arc_app_id1 = |
| 2147 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2182 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2148 const std::string arc_app_id2 = | 2183 const std::string arc_app_id2 = |
| 2149 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2184 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 2150 | 2185 |
| 2151 SendListOfArcApps(); | 2186 SendListOfArcApps(); |
| 2152 extension_service_->AddExtension(extension1_.get()); | 2187 extension_service_->AddExtension(extension1_.get()); |
| 2153 extension_service_->AddExtension(extension2_.get()); | 2188 extension_service_->AddExtension(extension2_.get()); |
| 2154 | 2189 |
| 2155 launcher_controller_->PinAppWithID(extension1_->id()); | 2190 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2156 launcher_controller_->PinAppWithID(arc_app_id2); | 2191 launcher_controller_->PinAppWithID(arc_app_id2); |
| 2157 launcher_controller_->PinAppWithID(extension2_->id()); | 2192 launcher_controller_->PinAppWithID(extension2_->id()); |
| 2158 launcher_controller_->PinAppWithID(arc_app_id1); | 2193 launcher_controller_->PinAppWithID(arc_app_id1); |
| 2159 | 2194 |
| 2160 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2195 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2161 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2196 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2162 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2197 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2163 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2198 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2164 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2199 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 2165 GetPinnedAppStatus()); | 2200 GetPinnedAppStatus()); |
| 2166 | 2201 |
| 2167 EnableArc(false); | 2202 // TODO(victorhsieh): Implement opt-out. |
| 2203 if (arc::ShouldArcAlwaysStart()) |
| 2204 return; |
| 2205 EnablePlayStore(false); |
| 2168 | 2206 |
| 2169 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2207 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2170 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2208 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2171 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2209 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2172 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2210 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2173 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2211 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2174 | 2212 |
| 2175 EnableArc(true); | 2213 EnablePlayStore(true); |
| 2176 SendListOfArcApps(); | 2214 SendListOfArcApps(); |
| 2177 base::RunLoop().RunUntilIdle(); | 2215 base::RunLoop().RunUntilIdle(); |
| 2178 | 2216 |
| 2179 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2217 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2180 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2218 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2181 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2219 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2182 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2220 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2183 | 2221 |
| 2184 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2222 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 2185 GetPinnedAppStatus()); | 2223 GetPinnedAppStatus()); |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3603 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3641 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3604 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3642 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3605 | 3643 |
| 3606 launcher_controller_->CloseLauncherItem(shelfId3); | 3644 launcher_controller_->CloseLauncherItem(shelfId3); |
| 3607 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3645 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3608 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3646 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 3609 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3647 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3610 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3648 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3611 } | 3649 } |
| 3612 | 3650 |
| 3613 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { | 3651 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { |
| 3614 InitLauncherControllerWithBrowser(); | 3652 InitLauncherControllerWithBrowser(); |
| 3615 arc::mojom::AppInfo appinfo = CreateAppInfo( | 3653 arc::mojom::AppInfo appinfo = CreateAppInfo( |
| 3616 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); | 3654 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); |
| 3617 const std::string app_id = AddArcAppAndShortcut(appinfo); | 3655 const std::string app_id = AddArcAppAndShortcut(appinfo); |
| 3618 | 3656 |
| 3619 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app | 3657 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app |
| 3620 // package_name (not hash) specified as id. In this test we check that | 3658 // package_name (not hash) specified as id. In this test we check that |
| 3621 // by hash we can determine that appropriate package was set by policy. | 3659 // by hash we can determine that appropriate package was set by policy. |
| 3622 base::ListValue policy_value; | 3660 base::ListValue policy_value; |
| 3623 InsertPrefValue(&policy_value, 0, appinfo.package_name); | 3661 InsertPrefValue(&policy_value, 0, appinfo.package_name); |
| 3624 profile()->GetTestingPrefService()->SetManagedPref( | 3662 profile()->GetTestingPrefService()->SetManagedPref( |
| 3625 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); | 3663 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); |
| 3626 | 3664 |
| 3627 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 3665 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 3628 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, | 3666 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
| 3629 GetPinnableForAppID(app_id, profile())); | 3667 GetPinnableForAppID(app_id, profile())); |
| 3630 } | 3668 } |
| 3631 | 3669 |
| 3632 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) { | 3670 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) { |
| 3671 // TODO(victorhsieh): Implement opt-in and opt-out. |
| 3672 if (arc::ShouldArcAlwaysStart()) |
| 3673 return; |
| 3674 |
| 3633 extension_service_->AddExtension(arc_support_host_.get()); | 3675 extension_service_->AddExtension(arc_support_host_.get()); |
| 3634 // Test enables ARC, so turn it off for initial values. | 3676 // Test enables ARC, so turn it off for initial values. |
| 3635 EnableArc(false); | 3677 EnablePlayStore(false); |
| 3636 | 3678 |
| 3637 InitLauncherController(); | 3679 InitLauncherController(); |
| 3638 | 3680 |
| 3639 // To prevent import legacy pins each time. | 3681 // To prevent import legacy pins each time. |
| 3640 // Initially pins are imported from legacy pref based model. | 3682 // Initially pins are imported from legacy pref based model. |
| 3641 StartPrefSyncService(syncer::SyncDataList()); | 3683 StartPrefSyncService(syncer::SyncDataList()); |
| 3642 | 3684 |
| 3643 // Inject |launcher_controller_| as ShelfDelegate to verify the behavior | 3685 // Inject |launcher_controller_| as ShelfDelegate to verify the behavior |
| 3644 // of removing pinned icon in ArcSessionManager::OnOptInPreferenceChanged(). | 3686 // of removing pinned icon in ArcSessionManager::OnOptInPreferenceChanged(). |
| 3645 SetShelfDelegate(); | 3687 SetShelfDelegate(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3665 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, | 3707 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, |
| 3666 "AppList, Chrome"); | 3708 "AppList, Chrome"); |
| 3667 | 3709 |
| 3668 // ARC is not managed and disabled, Play Store pin should be available. | 3710 // ARC is not managed and disabled, Play Store pin should be available. |
| 3669 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); | 3711 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); |
| 3670 base::RunLoop().RunUntilIdle(); | 3712 base::RunLoop().RunUntilIdle(); |
| 3671 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3713 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
| 3672 "AppList, Chrome, Play Store"); | 3714 "AppList, Chrome, Play Store"); |
| 3673 | 3715 |
| 3674 // ARC is not managed and enabled, Play Store pin should be available. | 3716 // ARC is not managed and enabled, Play Store pin should be available. |
| 3675 EnableArc(true); | 3717 EnablePlayStore(true); |
| 3676 ValidateArcState(true, false, | 3718 ValidateArcState(true, false, |
| 3677 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 3719 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 3678 "AppList, Chrome, Play Store"); | 3720 "AppList, Chrome, Play Store"); |
| 3679 | 3721 |
| 3680 // User disables ARC. ARC is not managed and disabled, Play Store pin should | 3722 // User disables ARC. ARC is not managed and disabled, Play Store pin should |
| 3681 // be automatically removed. | 3723 // be automatically removed. |
| 3682 EnableArc(false); | 3724 EnablePlayStore(false); |
| 3683 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3725 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
| 3684 "AppList, Chrome"); | 3726 "AppList, Chrome"); |
| 3685 | 3727 |
| 3686 // Even if re-enable it again, Play Store pin does not appear automatically. | 3728 // Even if re-enable it again, Play Store pin does not appear automatically. |
| 3687 EnableArc(true); | 3729 EnablePlayStore(true); |
| 3688 ValidateArcState(true, false, | 3730 ValidateArcState(true, false, |
| 3689 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 3731 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 3690 "AppList, Chrome"); | 3732 "AppList, Chrome"); |
| 3691 } | 3733 } |
| 3692 | 3734 |
| 3693 namespace { | 3735 namespace { |
| 3694 | 3736 |
| 3695 class ChromeLauncherControllerOrientationTest | 3737 class ChromeLauncherControllerOrientationTest |
| 3696 : public ChromeLauncherControllerImplWithArcTest { | 3738 : public ChromeLauncherControllerImplWithArcTest { |
| 3697 public: | 3739 public: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3759 | 3801 |
| 3760 views::Widget* window_none_ = nullptr; | 3802 views::Widget* window_none_ = nullptr; |
| 3761 views::Widget* window_landscape_ = nullptr; | 3803 views::Widget* window_landscape_ = nullptr; |
| 3762 views::Widget* window_portrait_ = nullptr; | 3804 views::Widget* window_portrait_ = nullptr; |
| 3763 views::Widget* window_current_ = nullptr; | 3805 views::Widget* window_current_ = nullptr; |
| 3764 | 3806 |
| 3765 private: | 3807 private: |
| 3766 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); | 3808 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); |
| 3767 }; | 3809 }; |
| 3768 | 3810 |
| 3811 INSTANTIATE_TEST_CASE_P(, |
| 3812 ChromeLauncherControllerOrientationTest, |
| 3813 ::testing::Bool()); |
| 3814 |
| 3769 class ChromeLauncherControllerArcDefaultAppsTest | 3815 class ChromeLauncherControllerArcDefaultAppsTest |
| 3770 : public ChromeLauncherControllerImplTest { | 3816 : public ChromeLauncherControllerImplTest, |
| 3817 public ::testing::WithParamInterface<bool> { |
| 3771 public: | 3818 public: |
| 3772 ChromeLauncherControllerArcDefaultAppsTest() {} | 3819 ChromeLauncherControllerArcDefaultAppsTest() {} |
| 3773 ~ChromeLauncherControllerArcDefaultAppsTest() override {} | 3820 ~ChromeLauncherControllerArcDefaultAppsTest() override {} |
| 3774 | 3821 |
| 3775 protected: | 3822 protected: |
| 3776 void SetUp() override { | 3823 void SetUp() override { |
| 3824 if (GetParam()) |
| 3825 arc::SetArcAlwaysStartForTesting(); |
| 3777 ArcDefaultAppList::UseTestAppsDirectory(); | 3826 ArcDefaultAppList::UseTestAppsDirectory(); |
| 3778 ChromeLauncherControllerImplTest::SetUp(); | 3827 ChromeLauncherControllerImplTest::SetUp(); |
| 3779 } | 3828 } |
| 3780 | 3829 |
| 3781 private: | 3830 private: |
| 3782 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); | 3831 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); |
| 3783 }; | 3832 }; |
| 3784 | 3833 |
| 3834 INSTANTIATE_TEST_CASE_P(, |
| 3835 ChromeLauncherControllerArcDefaultAppsTest, |
| 3836 ::testing::Bool()); |
| 3837 |
| 3785 } // namespace | 3838 } // namespace |
| 3786 | 3839 |
| 3787 TEST_F(ChromeLauncherControllerOrientationTest, | 3840 TEST_P(ChromeLauncherControllerOrientationTest, |
| 3788 ArcOrientationLockBeforeWindowReady) { | 3841 ArcOrientationLockBeforeWindowReady) { |
| 3789 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3842 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3790 | 3843 |
| 3791 extension_service_->AddExtension(arc_support_host_.get()); | 3844 extension_service_->AddExtension(arc_support_host_.get()); |
| 3792 EnableArc(true); | 3845 EnablePlayStore(true); |
| 3793 | 3846 |
| 3794 InitLauncherController(); | 3847 InitLauncherController(); |
| 3795 | 3848 |
| 3796 ash::ScreenOrientationController* controller = | 3849 ash::ScreenOrientationController* controller = |
| 3797 ash::Shell::GetInstance()->screen_orientation_controller(); | 3850 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3798 | 3851 |
| 3799 std::string app_id1("org.chromium.arc.1"); | 3852 std::string app_id1("org.chromium.arc.1"); |
| 3800 int task_id1 = 1; | 3853 int task_id1 = 1; |
| 3801 arc::mojom::AppInfo appinfo1 = | 3854 arc::mojom::AppInfo appinfo1 = |
| 3802 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); | 3855 CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3827 EXPECT_EQ(display::Display::ROTATE_90, | 3880 EXPECT_EQ(display::Display::ROTATE_90, |
| 3828 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3881 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3829 | 3882 |
| 3830 // The screen will be locked when the window is created. | 3883 // The screen will be locked when the window is created. |
| 3831 CreateArcWindow(app_id2); | 3884 CreateArcWindow(app_id2); |
| 3832 EXPECT_TRUE(controller->rotation_locked()); | 3885 EXPECT_TRUE(controller->rotation_locked()); |
| 3833 EXPECT_EQ(display::Display::ROTATE_0, | 3886 EXPECT_EQ(display::Display::ROTATE_0, |
| 3834 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3887 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3835 } | 3888 } |
| 3836 | 3889 |
| 3837 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { | 3890 TEST_P(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { |
| 3838 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3891 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3839 | 3892 |
| 3840 extension_service_->AddExtension(arc_support_host_.get()); | 3893 extension_service_->AddExtension(arc_support_host_.get()); |
| 3841 EnableArc(true); | 3894 EnablePlayStore(true); |
| 3842 EnableTabletMode(true); | 3895 EnableTabletMode(true); |
| 3843 | 3896 |
| 3844 InitLauncherController(); | 3897 InitLauncherController(); |
| 3845 | 3898 |
| 3846 InitApps(); | 3899 InitApps(); |
| 3847 ash::ScreenOrientationController* controller = | 3900 ash::ScreenOrientationController* controller = |
| 3848 ash::Shell::GetInstance()->screen_orientation_controller(); | 3901 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3849 | 3902 |
| 3850 // Activating a window with NON orientation unlocks the screen. | 3903 // Activating a window with NON orientation unlocks the screen. |
| 3851 window_none_->Activate(); | 3904 window_none_->Activate(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3924 EnableTabletMode(true); | 3977 EnableTabletMode(true); |
| 3925 EXPECT_TRUE(controller->rotation_locked()); | 3978 EXPECT_TRUE(controller->rotation_locked()); |
| 3926 EXPECT_EQ(display::Display::ROTATE_90, | 3979 EXPECT_EQ(display::Display::ROTATE_90, |
| 3927 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3980 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3928 | 3981 |
| 3929 // Manually unlock first. | 3982 // Manually unlock first. |
| 3930 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); | 3983 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); |
| 3931 EXPECT_FALSE(controller->rotation_locked()); | 3984 EXPECT_FALSE(controller->rotation_locked()); |
| 3932 } | 3985 } |
| 3933 | 3986 |
| 3934 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { | 3987 TEST_P(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { |
| 3935 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3988 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3936 | 3989 |
| 3937 extension_service_->AddExtension(arc_support_host_.get()); | 3990 extension_service_->AddExtension(arc_support_host_.get()); |
| 3938 EnableArc(true); | 3991 EnablePlayStore(true); |
| 3939 EnableTabletMode(true); | 3992 EnableTabletMode(true); |
| 3940 | 3993 |
| 3941 InitLauncherController(); | 3994 InitLauncherController(); |
| 3942 | 3995 |
| 3943 InitApps(); | 3996 InitApps(); |
| 3944 ash::ScreenOrientationController* controller = | 3997 ash::ScreenOrientationController* controller = |
| 3945 ash::Shell::GetInstance()->screen_orientation_controller(); | 3998 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3946 | 3999 |
| 3947 // Start with portrait. | 4000 // Start with portrait. |
| 3948 window_portrait_->Activate(); | 4001 window_portrait_->Activate(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3985 EXPECT_EQ(display::Display::ROTATE_0, | 4038 EXPECT_EQ(display::Display::ROTATE_0, |
| 3986 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 4039 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3987 | 4040 |
| 3988 NotifyOnTaskOrientationLockRequested(task_id_current_, | 4041 NotifyOnTaskOrientationLockRequested(task_id_current_, |
| 3989 OrientationLock::CURRENT); | 4042 OrientationLock::CURRENT); |
| 3990 EXPECT_TRUE(controller->rotation_locked()); | 4043 EXPECT_TRUE(controller->rotation_locked()); |
| 3991 EXPECT_EQ(display::Display::ROTATE_0, | 4044 EXPECT_EQ(display::Display::ROTATE_0, |
| 3992 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 4045 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3993 } | 4046 } |
| 3994 | 4047 |
| 3995 TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { | 4048 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { |
| 3996 arc_test_.SetUp(profile()); | 4049 arc_test_.SetUp(profile()); |
| 3997 InitLauncherController(); | 4050 InitLauncherController(); |
| 3998 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); | 4051 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); |
| 3999 | 4052 |
| 4000 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 4053 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 4001 EnableArc(false); | 4054 EnablePlayStore(false); |
| 4002 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4055 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4003 ASSERT_TRUE(prefs->GetAppIds().size()); | 4056 ASSERT_TRUE(prefs->GetAppIds().size()); |
| 4004 | 4057 |
| 4005 const std::string app_id = | 4058 const std::string app_id = |
| 4006 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); | 4059 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
| 4007 EXPECT_EQ(ash::kInvalidShelfID, | 4060 EXPECT_EQ(ash::kInvalidShelfID, |
| 4008 launcher_controller_->GetShelfIDForAppID(app_id)); | 4061 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 4009 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4062 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
| 4010 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4063 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4011 EXPECT_NE(ash::kInvalidShelfID, | 4064 EXPECT_NE(ash::kInvalidShelfID, |
| 4012 launcher_controller_->GetShelfIDForAppID(app_id)); | 4065 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 4013 | 4066 |
| 4014 // Stop ARC again. Shelf item should go away. | 4067 // Stop ARC again. Shelf item should go away. |
| 4015 EnableArc(false); | 4068 EnablePlayStore(false); |
| 4016 EXPECT_EQ(ash::kInvalidShelfID, | 4069 EXPECT_EQ(ash::kInvalidShelfID, |
| 4017 launcher_controller_->GetShelfIDForAppID(app_id)); | 4070 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 4018 | 4071 |
| 4019 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4072 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
| 4020 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4073 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4021 | 4074 |
| 4022 EXPECT_NE(ash::kInvalidShelfID, | 4075 EXPECT_NE(ash::kInvalidShelfID, |
| 4023 launcher_controller_->GetShelfIDForAppID(app_id)); | 4076 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 4024 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 4077 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 4025 | 4078 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4257 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4310 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4258 shelf_controller->auto_hide()); | 4311 shelf_controller->auto_hide()); |
| 4259 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4312 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4260 | 4313 |
| 4261 PrefService* prefs = profile()->GetTestingPrefService(); | 4314 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4262 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4315 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4263 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4316 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4264 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4317 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4265 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4318 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4266 } | 4319 } |
| OLD | NEW |