| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 arc_test_.app_instance()->RefreshAppList(); | 817 arc_test_.app_instance()->RefreshAppList(); |
| 817 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); | 818 arc_test_.app_instance()->SendRefreshAppList(arc_test_.fake_apps()); |
| 818 } | 819 } |
| 819 | 820 |
| 820 void UninstallArcApps() { | 821 void UninstallArcApps() { |
| 821 arc_test_.app_instance()->RefreshAppList(); | 822 arc_test_.app_instance()->RefreshAppList(); |
| 822 arc_test_.app_instance()->SendRefreshAppList( | 823 arc_test_.app_instance()->SendRefreshAppList( |
| 823 std::vector<arc::mojom::AppInfo>()); | 824 std::vector<arc::mojom::AppInfo>()); |
| 824 } | 825 } |
| 825 | 826 |
| 826 void EnableArc(bool enabled) { | 827 // TODO(victorhsieh): Add test coverage for Persistent ARC |
| 828 void EnablePlay(bool enabled) { |
| 827 arc_test_.arc_session_manager()->SetArcPlayStoreEnabled(enabled); | 829 arc_test_.arc_session_manager()->SetArcPlayStoreEnabled(enabled); |
| 828 base::RunLoop().RunUntilIdle(); | 830 base::RunLoop().RunUntilIdle(); |
| 829 } | 831 } |
| 830 | 832 |
| 831 void EnableTabletMode(bool enable) { | 833 void EnableTabletMode(bool enable) { |
| 832 ash::MaximizeModeController* controller = | 834 ash::MaximizeModeController* controller = |
| 833 ash::WmShell::Get()->maximize_mode_controller(); | 835 ash::WmShell::Get()->maximize_mode_controller(); |
| 834 controller->EnableMaximizeModeWindowManager(enable); | 836 controller->EnableMaximizeModeWindowManager(enable); |
| 835 } | 837 } |
| 836 | 838 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 aura::client::ParentWindowWithContext(window.get(), GetContext(), | 939 aura::client::ParentWindowWithContext(window.get(), GetContext(), |
| 938 gfx::Rect(200, 200)); | 940 gfx::Rect(200, 200)); |
| 939 | 941 |
| 940 return new TestBrowserWindowAura(std::move(window)); | 942 return new TestBrowserWindowAura(std::move(window)); |
| 941 } | 943 } |
| 942 | 944 |
| 943 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); | 945 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest); |
| 944 }; | 946 }; |
| 945 | 947 |
| 946 class ChromeLauncherControllerImplWithArcTest | 948 class ChromeLauncherControllerImplWithArcTest |
| 947 : public ChromeLauncherControllerImplTest { | 949 : public ChromeLauncherControllerImplTest, |
| 950 public ::testing::WithParamInterface<bool> { |
| 948 protected: | 951 protected: |
| 949 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; } | 952 ChromeLauncherControllerImplWithArcTest() { auto_start_arc_test_ = true; } |
| 950 ~ChromeLauncherControllerImplWithArcTest() override {} | 953 ~ChromeLauncherControllerImplWithArcTest() override {} |
| 951 | 954 |
| 955 void SetUp() override { |
| 956 if (GetParam()) |
| 957 arc::SetArcAlwaysStartForTesting(); |
| 958 ChromeLauncherControllerImplTest::SetUp(); |
| 959 } |
| 960 |
| 952 private: | 961 private: |
| 953 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest); | 962 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplWithArcTest); |
| 954 }; | 963 }; |
| 955 | 964 |
| 965 INSTANTIATE_TEST_CASE_P(, |
| 966 ChromeLauncherControllerImplWithArcTest, |
| 967 ::testing::Bool()); |
| 968 |
| 956 // Watches WebContents and blocks until it is destroyed. This is needed for | 969 // Watches WebContents and blocks until it is destroyed. This is needed for |
| 957 // the destruction of a V2 application. | 970 // the destruction of a V2 application. |
| 958 class WebContentsDestroyedWatcher : public content::WebContentsObserver { | 971 class WebContentsDestroyedWatcher : public content::WebContentsObserver { |
| 959 public: | 972 public: |
| 960 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) | 973 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) |
| 961 : content::WebContentsObserver(web_contents), | 974 : content::WebContentsObserver(web_contents), |
| 962 message_loop_runner_(new content::MessageLoopRunner) { | 975 message_loop_runner_(new content::MessageLoopRunner) { |
| 963 EXPECT_TRUE(web_contents != NULL); | 976 EXPECT_TRUE(web_contents != NULL); |
| 964 } | 977 } |
| 965 ~WebContentsDestroyedWatcher() override {} | 978 ~WebContentsDestroyedWatcher() override {} |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 | 1237 |
| 1225 ash::test::TestShellDelegate* shell_delegate_; | 1238 ash::test::TestShellDelegate* shell_delegate_; |
| 1226 | 1239 |
| 1227 ProfileToNameMap created_profiles_; | 1240 ProfileToNameMap created_profiles_; |
| 1228 | 1241 |
| 1229 DISALLOW_COPY_AND_ASSIGN( | 1242 DISALLOW_COPY_AND_ASSIGN( |
| 1230 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); | 1243 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest); |
| 1231 }; | 1244 }; |
| 1232 | 1245 |
| 1233 class ChromeLauncherControllerImplMultiProfileWithArcTest | 1246 class ChromeLauncherControllerImplMultiProfileWithArcTest |
| 1234 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
{ // NOLINT(whitespace/line_length) | 1247 : public MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
, // NOLINT(whitespace/line_length) |
| 1248 public ::testing::WithParamInterface<bool> { |
| 1235 protected: | 1249 protected: |
| 1236 ChromeLauncherControllerImplMultiProfileWithArcTest() { | 1250 ChromeLauncherControllerImplMultiProfileWithArcTest() { |
| 1237 auto_start_arc_test_ = true; | 1251 auto_start_arc_test_ = true; |
| 1238 } | 1252 } |
| 1239 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} | 1253 ~ChromeLauncherControllerImplMultiProfileWithArcTest() override {} |
| 1240 | 1254 |
| 1255 void SetUp() override { |
| 1256 if (GetParam()) |
| 1257 arc::SetArcAlwaysStartForTesting(); |
| 1258 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest:: |
| 1259 SetUp(); |
| 1260 } |
| 1261 |
| 1241 private: | 1262 private: |
| 1242 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); | 1263 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); |
| 1243 }; | 1264 }; |
| 1244 | 1265 |
| 1266 INSTANTIATE_TEST_CASE_P(, |
| 1267 ChromeLauncherControllerImplMultiProfileWithArcTest, |
| 1268 ::testing::Bool()); |
| 1269 |
| 1245 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { | 1270 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { |
| 1246 InitLauncherController(); | 1271 InitLauncherController(); |
| 1247 // Model should only contain the browser shortcut and app list items. | 1272 // Model should only contain the browser shortcut and app list items. |
| 1248 EXPECT_EQ(2, model_->item_count()); | 1273 EXPECT_EQ(2, model_->item_count()); |
| 1249 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1274 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1250 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1275 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1251 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 1276 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1252 | 1277 |
| 1253 // Installing |extension3_| should add it to the launcher - behind the | 1278 // Installing |extension3_| should add it to the launcher - behind the |
| 1254 // chrome icon. | 1279 // chrome icon. |
| 1255 extension_service_->AddExtension(extension3_.get()); | 1280 extension_service_->AddExtension(extension3_.get()); |
| 1256 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1281 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 1257 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1282 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1258 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1283 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1259 } | 1284 } |
| 1260 | 1285 |
| 1261 TEST_F(ChromeLauncherControllerImplWithArcTest, | 1286 TEST_P(ChromeLauncherControllerImplWithArcTest, |
| 1262 ArcAppPinCrossPlatformWorkflow) { | 1287 ArcAppPinCrossPlatformWorkflow) { |
| 1263 // Work on ARC disabled platform first. | 1288 // Work on ARC disabled platform first. |
| 1264 const std::string arc_app_id1 = | 1289 const std::string arc_app_id1 = |
| 1265 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1290 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1266 const std::string arc_app_id2 = | 1291 const std::string arc_app_id2 = |
| 1267 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1292 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1268 const std::string arc_app_id3 = | 1293 const std::string arc_app_id3 = |
| 1269 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); | 1294 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); |
| 1270 | 1295 |
| 1271 InitLauncherController(); | 1296 InitLauncherController(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); | 1354 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); |
| 1330 | 1355 |
| 1331 launcher_controller_.reset(); | 1356 launcher_controller_.reset(); |
| 1332 ResetPinModel(); | 1357 ResetPinModel(); |
| 1333 | 1358 |
| 1334 SendPinChanges(syncer::SyncChangeList(), true); | 1359 SendPinChanges(syncer::SyncChangeList(), true); |
| 1335 StopAppSyncService(); | 1360 StopAppSyncService(); |
| 1336 EXPECT_EQ(0U, app_service_->sync_items().size()); | 1361 EXPECT_EQ(0U, app_service_->sync_items().size()); |
| 1337 | 1362 |
| 1338 // Move back to ARC disabled platform. | 1363 // Move back to ARC disabled platform. |
| 1339 EnableArc(false); | 1364 // TODO(victorhsieh): Implement opt-out. |
| 1365 if (arc::ShouldArcAlwaysStart()) |
| 1366 return; |
| 1367 EnablePlay(false); |
| 1340 StartAppSyncService(copy_sync_list); | 1368 StartAppSyncService(copy_sync_list); |
| 1341 RecreateChromeLauncher(); | 1369 RecreateChromeLauncher(); |
| 1342 | 1370 |
| 1343 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1371 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1344 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1372 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1345 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 1373 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1346 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1374 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1347 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1375 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1348 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1376 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1349 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); | 1377 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); |
| 1350 | 1378 |
| 1351 // Now move/remove pins on ARC disabled platform. | 1379 // Now move/remove pins on ARC disabled platform. |
| 1352 model_->Move(4, 2); | 1380 model_->Move(4, 2); |
| 1353 launcher_controller_->UnpinAppWithID(extension2_->id()); | 1381 launcher_controller_->UnpinAppWithID(extension2_->id()); |
| 1354 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); | 1382 EXPECT_EQ("AppList, App3, Chrome, App1", GetPinnedAppStatus()); |
| 1355 EnableArc(true); | 1383 EnablePlay(true); |
| 1356 | 1384 |
| 1357 SendListOfArcApps(); | 1385 SendListOfArcApps(); |
| 1358 | 1386 |
| 1359 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1387 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1360 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1388 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1361 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1389 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1362 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1390 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1363 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1391 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1364 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1392 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1365 EXPECT_EQ("AppList, Fake App 1, App3, Chrome, App1, Fake App 0", | 1393 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... |
| 1782 | 1810 |
| 1783 // Check that removing more items does not crash and changes nothing. | 1811 // Check that removing more items does not crash and changes nothing. |
| 1784 launcher_controller_->UnlockV1AppWithID(extension2_->id()); | 1812 launcher_controller_->UnlockV1AppWithID(extension2_->id()); |
| 1785 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1813 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1786 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); | 1814 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); |
| 1787 launcher_controller_->UnlockV1AppWithID(extension3_->id()); | 1815 launcher_controller_->UnlockV1AppWithID(extension3_->id()); |
| 1788 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1816 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1789 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 1817 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 1790 } | 1818 } |
| 1791 | 1819 |
| 1792 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { | 1820 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { |
| 1793 RecreateChromeLauncher(); | 1821 RecreateChromeLauncher(); |
| 1794 | 1822 |
| 1795 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1823 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
| 1796 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1824 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1797 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1825 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1798 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1826 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1799 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1827 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1800 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1828 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1801 | 1829 |
| 1802 SendListOfArcApps(); | 1830 SendListOfArcApps(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 | 1885 |
| 1858 const arc::FakeAppInstance::Request* request1 = | 1886 const arc::FakeAppInstance::Request* request1 = |
| 1859 arc_test_.app_instance()->launch_requests()[0].get(); | 1887 arc_test_.app_instance()->launch_requests()[0].get(); |
| 1860 const arc::FakeAppInstance::Request* request2 = | 1888 const arc::FakeAppInstance::Request* request2 = |
| 1861 arc_test_.app_instance()->launch_requests()[1].get(); | 1889 arc_test_.app_instance()->launch_requests()[1].get(); |
| 1862 | 1890 |
| 1863 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1891 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1864 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1892 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| 1865 } | 1893 } |
| 1866 | 1894 |
| 1867 TEST_F(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { | 1895 TEST_P(ChromeLauncherControllerImplMultiProfileWithArcTest, ArcMultiUser) { |
| 1868 SendListOfArcApps(); | 1896 SendListOfArcApps(); |
| 1869 | 1897 |
| 1870 InitLauncherController(); | 1898 InitLauncherController(); |
| 1871 SetLauncherControllerHelper(new TestLauncherControllerHelper); | 1899 SetLauncherControllerHelper(new TestLauncherControllerHelper); |
| 1872 | 1900 |
| 1873 // App1 exists all the time. | 1901 // App1 exists all the time. |
| 1874 // App2 is created when primary user is active and destroyed when secondary | 1902 // App2 is created when primary user is active and destroyed when secondary |
| 1875 // user is active. | 1903 // user is active. |
| 1876 // App3 created when secondary user is active. | 1904 // App3 created when secondary user is active. |
| 1877 | 1905 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 EXPECT_EQ(ash::kInvalidShelfID, | 1957 EXPECT_EQ(ash::kInvalidShelfID, |
| 1930 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1958 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1931 EXPECT_NE(ash::kInvalidShelfID, | 1959 EXPECT_NE(ash::kInvalidShelfID, |
| 1932 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1960 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1933 | 1961 |
| 1934 // Close active window to let test passes. | 1962 // Close active window to let test passes. |
| 1935 arc_window1->CloseNow(); | 1963 arc_window1->CloseNow(); |
| 1936 arc_window3->CloseNow(); | 1964 arc_window3->CloseNow(); |
| 1937 } | 1965 } |
| 1938 | 1966 |
| 1939 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { | 1967 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { |
| 1940 InitLauncherController(); | 1968 InitLauncherController(); |
| 1941 | 1969 |
| 1942 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1970 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1943 SendListOfArcApps(); | 1971 SendListOfArcApps(); |
| 1944 EXPECT_EQ(ash::kInvalidShelfID, | 1972 EXPECT_EQ(ash::kInvalidShelfID, |
| 1945 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1973 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1946 | 1974 |
| 1947 // Normal flow, create/destroy tasks. | 1975 // Normal flow, create/destroy tasks. |
| 1948 std::string window_app_id1("org.chromium.arc.1"); | 1976 std::string window_app_id1("org.chromium.arc.1"); |
| 1949 std::string window_app_id2("org.chromium.arc.2"); | 1977 std::string window_app_id2("org.chromium.arc.2"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1972 EXPECT_NE(ash::kInvalidShelfID, | 2000 EXPECT_NE(ash::kInvalidShelfID, |
| 1973 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2001 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1974 arc_test_.StopArcInstance(); | 2002 arc_test_.StopArcInstance(); |
| 1975 base::RunLoop().RunUntilIdle(); | 2003 base::RunLoop().RunUntilIdle(); |
| 1976 EXPECT_EQ(ash::kInvalidShelfID, | 2004 EXPECT_EQ(ash::kInvalidShelfID, |
| 1977 launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2005 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1978 } | 2006 } |
| 1979 | 2007 |
| 1980 // Test race creation/deletion of ARC app. | 2008 // Test race creation/deletion of ARC app. |
| 1981 // TODO(khmel): Remove after moving everything to wayland protocol. | 2009 // TODO(khmel): Remove after moving everything to wayland protocol. |
| 1982 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { | 2010 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { |
| 1983 InitLauncherController(); | 2011 InitLauncherController(); |
| 1984 | 2012 |
| 1985 const std::string arc_app_id1 = | 2013 const std::string arc_app_id1 = |
| 1986 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2014 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1987 const std::string arc_app_id2 = | 2015 const std::string arc_app_id2 = |
| 1988 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2016 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1989 SendListOfArcApps(); | 2017 SendListOfArcApps(); |
| 1990 | 2018 |
| 1991 // ARC window created before and closed after mojom notification. | 2019 // ARC window created before and closed after mojom notification. |
| 1992 std::string window_app_id1("org.chromium.arc.1"); | 2020 std::string window_app_id1("org.chromium.arc.1"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2019 arc_window->Close(); | 2047 arc_window->Close(); |
| 2020 base::RunLoop().RunUntilIdle(); | 2048 base::RunLoop().RunUntilIdle(); |
| 2021 // Closing window does not close shelf item. It is closed on task destroy. | 2049 // Closing window does not close shelf item. It is closed on task destroy. |
| 2022 EXPECT_NE(ash::kInvalidShelfID, | 2050 EXPECT_NE(ash::kInvalidShelfID, |
| 2023 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2051 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 2024 arc_test_.app_instance()->SendTaskDestroyed(2); | 2052 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 2025 EXPECT_EQ(ash::kInvalidShelfID, | 2053 EXPECT_EQ(ash::kInvalidShelfID, |
| 2026 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 2054 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 2027 } | 2055 } |
| 2028 | 2056 |
| 2029 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { | 2057 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { |
| 2030 InitLauncherController(); | 2058 InitLauncherController(); |
| 2031 | 2059 |
| 2032 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2060 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2033 SendListOfArcApps(); | 2061 SendListOfArcApps(); |
| 2034 | 2062 |
| 2035 std::string window_app_id("org.chromium.arc.1"); | 2063 std::string window_app_id("org.chromium.arc.1"); |
| 2036 views::Widget* arc_window = CreateArcWindow(window_app_id); | 2064 views::Widget* arc_window = CreateArcWindow(window_app_id); |
| 2037 ASSERT_TRUE(arc_window); | 2065 ASSERT_TRUE(arc_window); |
| 2038 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], | 2066 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], |
| 2039 std::string()); | 2067 std::string()); |
| 2040 const ash::ShelfID shelf_id = | 2068 const ash::ShelfID shelf_id = |
| 2041 launcher_controller_->GetShelfIDForAppID(arc_app_id); | 2069 launcher_controller_->GetShelfIDForAppID(arc_app_id); |
| 2042 EXPECT_NE(ash::kInvalidShelfID, shelf_id); | 2070 EXPECT_NE(ash::kInvalidShelfID, shelf_id); |
| 2043 | 2071 |
| 2044 for (int i = 0; i < 3; ++i) { | 2072 for (int i = 0; i < 3; ++i) { |
| 2045 arc_window->Close(); | 2073 arc_window->Close(); |
| 2046 base::RunLoop().RunUntilIdle(); | 2074 base::RunLoop().RunUntilIdle(); |
| 2047 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2075 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 2048 | 2076 |
| 2049 arc_window = CreateArcWindow(window_app_id); | 2077 arc_window = CreateArcWindow(window_app_id); |
| 2050 ASSERT_TRUE(arc_window); | 2078 ASSERT_TRUE(arc_window); |
| 2051 base::RunLoop().RunUntilIdle(); | 2079 base::RunLoop().RunUntilIdle(); |
| 2052 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2080 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 2053 } | 2081 } |
| 2054 } | 2082 } |
| 2055 | 2083 |
| 2056 // Validate that ARC app is pinned correctly and pin is removed automatically | 2084 // Validate that ARC app is pinned correctly and pin is removed automatically |
| 2057 // once app is uninstalled. | 2085 // once app is uninstalled. |
| 2058 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { | 2086 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPin) { |
| 2059 InitLauncherController(); | 2087 InitLauncherController(); |
| 2060 | 2088 |
| 2061 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2089 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2062 | 2090 |
| 2063 SendListOfArcApps(); | 2091 SendListOfArcApps(); |
| 2064 extension_service_->AddExtension(extension1_.get()); | 2092 extension_service_->AddExtension(extension1_.get()); |
| 2065 extension_service_->AddExtension(extension2_.get()); | 2093 extension_service_->AddExtension(extension2_.get()); |
| 2066 | 2094 |
| 2067 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2095 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2068 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); | 2096 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2069 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 2097 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2070 | 2098 |
| 2071 launcher_controller_->PinAppWithID(extension1_->id()); | 2099 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2072 launcher_controller_->PinAppWithID(arc_app_id); | 2100 launcher_controller_->PinAppWithID(arc_app_id); |
| 2073 launcher_controller_->PinAppWithID(extension2_->id()); | 2101 launcher_controller_->PinAppWithID(extension2_->id()); |
| 2074 | 2102 |
| 2075 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2103 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2076 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); | 2104 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2077 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2105 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2078 | 2106 |
| 2079 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); | 2107 EXPECT_EQ("AppList, Chrome, App1, Fake App 0, App2", GetPinnedAppStatus()); |
| 2108 // In opt-out mode, only system apps are available and can't be uninstalled. |
| 2109 // Skip the rest of the test. |
| 2110 if (arc::ShouldArcAlwaysStart()) |
| 2111 return; |
| 2080 UninstallArcApps(); | 2112 UninstallArcApps(); |
| 2113 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2081 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2114 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2082 SendListOfArcApps(); | 2115 SendListOfArcApps(); |
| 2116 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id)); |
| 2083 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2117 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2084 | 2118 |
| 2085 // Disable/Enable ARC should persist pin state. | 2119 // Disable/Enable ARC should persist pin state. |
| 2086 launcher_controller_->PinAppWithID(arc_app_id); | 2120 launcher_controller_->PinAppWithID(arc_app_id); |
| 2087 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2121 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 2088 arc::ArcSessionManager::Get()->Shutdown(); | 2122 arc::ArcSessionManager::Get()->Shutdown(); |
| 2089 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2123 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 2090 arc::ArcSessionManager::Get()->OnPrimaryUserProfilePrepared(profile()); | 2124 arc::ArcSessionManager::Get()->OnPrimaryUserProfilePrepared(profile()); |
| 2091 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2125 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 2092 | 2126 |
| 2093 // Opt-Out/Opt-In remove item from the shelf. | 2127 // Opt-Out/Opt-In remove item from the shelf. |
| 2094 EnableArc(false); | 2128 EnablePlay(false); |
| 2095 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2129 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2096 EnableArc(true); | 2130 EnablePlay(true); |
| 2097 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2131 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2098 SendListOfArcApps(); | 2132 SendListOfArcApps(); |
| 2099 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); | 2133 EXPECT_EQ("AppList, Chrome, App1, App2, Fake App 0", GetPinnedAppStatus()); |
| 2100 } | 2134 } |
| 2101 | 2135 |
| 2102 // Validates that ARC app pins persist across OptOut/OptIn. | 2136 // Validates that ARC app pins persist across OptOut/OptIn. |
| 2103 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { | 2137 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinOptOutOptIn) { |
| 2104 InitLauncherController(); | 2138 InitLauncherController(); |
| 2105 | 2139 |
| 2106 const std::string arc_app_id1 = | 2140 const std::string arc_app_id1 = |
| 2107 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 2141 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 2108 const std::string arc_app_id2 = | 2142 const std::string arc_app_id2 = |
| 2109 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 2143 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 2110 | 2144 |
| 2111 SendListOfArcApps(); | 2145 SendListOfArcApps(); |
| 2112 extension_service_->AddExtension(extension1_.get()); | 2146 extension_service_->AddExtension(extension1_.get()); |
| 2113 extension_service_->AddExtension(extension2_.get()); | 2147 extension_service_->AddExtension(extension2_.get()); |
| 2114 | 2148 |
| 2115 launcher_controller_->PinAppWithID(extension1_->id()); | 2149 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2116 launcher_controller_->PinAppWithID(arc_app_id2); | 2150 launcher_controller_->PinAppWithID(arc_app_id2); |
| 2117 launcher_controller_->PinAppWithID(extension2_->id()); | 2151 launcher_controller_->PinAppWithID(extension2_->id()); |
| 2118 launcher_controller_->PinAppWithID(arc_app_id1); | 2152 launcher_controller_->PinAppWithID(arc_app_id1); |
| 2119 | 2153 |
| 2120 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2154 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2121 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2155 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2122 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2156 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2123 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2157 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2124 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2158 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 2125 GetPinnedAppStatus()); | 2159 GetPinnedAppStatus()); |
| 2126 | 2160 |
| 2127 EnableArc(false); | 2161 // TODO(victorhsieh): Implement opt-out. |
| 2162 if (arc::ShouldArcAlwaysStart()) |
| 2163 return; |
| 2164 EnablePlay(false); |
| 2128 | 2165 |
| 2129 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 2166 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 2130 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2167 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2131 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2168 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2132 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2169 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2133 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2170 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2134 | 2171 |
| 2135 EnableArc(true); | 2172 EnablePlay(true); |
| 2136 SendListOfArcApps(); | 2173 SendListOfArcApps(); |
| 2137 base::RunLoop().RunUntilIdle(); | 2174 base::RunLoop().RunUntilIdle(); |
| 2138 | 2175 |
| 2139 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2176 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2140 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 2177 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 2141 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 2178 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 2142 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 2179 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 2143 | 2180 |
| 2144 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", | 2181 EXPECT_EQ("AppList, Chrome, App1, Fake App 1, App2, Fake App 0", |
| 2145 GetPinnedAppStatus()); | 2182 GetPinnedAppStatus()); |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3585 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3549 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3586 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3550 | 3587 |
| 3551 launcher_controller_->CloseLauncherItem(shelfId3); | 3588 launcher_controller_->CloseLauncherItem(shelfId3); |
| 3552 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3589 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3553 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3590 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
| 3554 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3591 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3555 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 3592 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
| 3556 } | 3593 } |
| 3557 | 3594 |
| 3558 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { | 3595 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcAppPinPolicy) { |
| 3559 InitLauncherControllerWithBrowser(); | 3596 InitLauncherControllerWithBrowser(); |
| 3560 arc::mojom::AppInfo appinfo = CreateAppInfo( | 3597 arc::mojom::AppInfo appinfo = CreateAppInfo( |
| 3561 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); | 3598 "Some App", "SomeActivity", "com.example.app", OrientationLock::NONE); |
| 3562 const std::string app_id = AddArcAppAndShortcut(appinfo); | 3599 const std::string app_id = AddArcAppAndShortcut(appinfo); |
| 3563 | 3600 |
| 3564 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app | 3601 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app |
| 3565 // package_name (not hash) specified as id. In this test we check that | 3602 // package_name (not hash) specified as id. In this test we check that |
| 3566 // by hash we can determine that appropriate package was set by policy. | 3603 // by hash we can determine that appropriate package was set by policy. |
| 3567 base::ListValue policy_value; | 3604 base::ListValue policy_value; |
| 3568 InsertPrefValue(&policy_value, 0, appinfo.package_name); | 3605 InsertPrefValue(&policy_value, 0, appinfo.package_name); |
| 3569 profile()->GetTestingPrefService()->SetManagedPref( | 3606 profile()->GetTestingPrefService()->SetManagedPref( |
| 3570 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); | 3607 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); |
| 3571 | 3608 |
| 3572 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 3609 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 3573 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, | 3610 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
| 3574 GetPinnableForAppID(app_id, profile())); | 3611 GetPinnableForAppID(app_id, profile())); |
| 3575 } | 3612 } |
| 3576 | 3613 |
| 3577 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) { | 3614 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) { |
| 3615 // TODO(victorhsieh): Implement opt-in and opt-out. |
| 3616 if (arc::ShouldArcAlwaysStart()) |
| 3617 return; |
| 3618 |
| 3578 extension_service_->AddExtension(arc_support_host_.get()); | 3619 extension_service_->AddExtension(arc_support_host_.get()); |
| 3579 // Test enables ARC, so turn it off for initial values. | 3620 // Test enables ARC, so turn it off for initial values. |
| 3580 EnableArc(false); | 3621 EnablePlay(false); |
| 3581 | 3622 |
| 3582 InitLauncherController(); | 3623 InitLauncherController(); |
| 3583 | 3624 |
| 3584 // To prevent import legacy pins each time. | 3625 // To prevent import legacy pins each time. |
| 3585 // Initially pins are imported from legacy pref based model. | 3626 // Initially pins are imported from legacy pref based model. |
| 3586 StartPrefSyncService(syncer::SyncDataList()); | 3627 StartPrefSyncService(syncer::SyncDataList()); |
| 3587 | 3628 |
| 3588 arc::ArcSessionManager::SetShelfDelegateForTesting( | 3629 arc::ArcSessionManager::SetShelfDelegateForTesting( |
| 3589 launcher_controller_.get()); | 3630 launcher_controller_.get()); |
| 3590 | 3631 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3609 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, | 3650 ValidateArcState(false, true, arc::ArcSessionManager::State::STOPPED, |
| 3610 "AppList, Chrome"); | 3651 "AppList, Chrome"); |
| 3611 | 3652 |
| 3612 // ARC is not managed and disabled, Play Store pin should be available. | 3653 // ARC is not managed and disabled, Play Store pin should be available. |
| 3613 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); | 3654 profile()->GetTestingPrefService()->RemoveManagedPref(prefs::kArcEnabled); |
| 3614 base::RunLoop().RunUntilIdle(); | 3655 base::RunLoop().RunUntilIdle(); |
| 3615 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3656 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
| 3616 "AppList, Chrome, Play Store"); | 3657 "AppList, Chrome, Play Store"); |
| 3617 | 3658 |
| 3618 // ARC is not managed and enabled, Play Store pin should be available. | 3659 // ARC is not managed and enabled, Play Store pin should be available. |
| 3619 EnableArc(true); | 3660 EnablePlay(true); |
| 3620 ValidateArcState(true, false, | 3661 ValidateArcState(true, false, |
| 3621 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 3662 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 3622 "AppList, Chrome, Play Store"); | 3663 "AppList, Chrome, Play Store"); |
| 3623 | 3664 |
| 3624 // User disables ARC. ARC is not managed and disabled, Play Store pin should | 3665 // User disables ARC. ARC is not managed and disabled, Play Store pin should |
| 3625 // be automatically removed. | 3666 // be automatically removed. |
| 3626 EnableArc(false); | 3667 EnablePlay(false); |
| 3627 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3668 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
| 3628 "AppList, Chrome"); | 3669 "AppList, Chrome"); |
| 3629 | 3670 |
| 3630 // Even if re-enable it again, Play Store pin does not appear automatically. | 3671 // Even if re-enable it again, Play Store pin does not appear automatically. |
| 3631 EnableArc(true); | 3672 EnablePlay(true); |
| 3632 ValidateArcState(true, false, | 3673 ValidateArcState(true, false, |
| 3633 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 3674 arc::ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 3634 "AppList, Chrome"); | 3675 "AppList, Chrome"); |
| 3635 } | 3676 } |
| 3636 | 3677 |
| 3637 namespace { | 3678 namespace { |
| 3638 | 3679 |
| 3639 class ChromeLauncherControllerOrientationTest | 3680 class ChromeLauncherControllerOrientationTest |
| 3640 : public ChromeLauncherControllerImplWithArcTest { | 3681 : public ChromeLauncherControllerImplWithArcTest { |
| 3641 public: | 3682 public: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 | 3744 |
| 3704 views::Widget* window_none_ = nullptr; | 3745 views::Widget* window_none_ = nullptr; |
| 3705 views::Widget* window_landscape_ = nullptr; | 3746 views::Widget* window_landscape_ = nullptr; |
| 3706 views::Widget* window_portrait_ = nullptr; | 3747 views::Widget* window_portrait_ = nullptr; |
| 3707 views::Widget* window_current_ = nullptr; | 3748 views::Widget* window_current_ = nullptr; |
| 3708 | 3749 |
| 3709 private: | 3750 private: |
| 3710 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); | 3751 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); |
| 3711 }; | 3752 }; |
| 3712 | 3753 |
| 3754 INSTANTIATE_TEST_CASE_P(, |
| 3755 ChromeLauncherControllerOrientationTest, |
| 3756 ::testing::Bool()); |
| 3757 |
| 3713 class ChromeLauncherControllerArcDefaultAppsTest | 3758 class ChromeLauncherControllerArcDefaultAppsTest |
| 3714 : public ChromeLauncherControllerImplTest { | 3759 : public ChromeLauncherControllerImplTest, |
| 3760 public ::testing::WithParamInterface<bool> { |
| 3715 public: | 3761 public: |
| 3716 ChromeLauncherControllerArcDefaultAppsTest() {} | 3762 ChromeLauncherControllerArcDefaultAppsTest() {} |
| 3717 ~ChromeLauncherControllerArcDefaultAppsTest() override {} | 3763 ~ChromeLauncherControllerArcDefaultAppsTest() override {} |
| 3718 | 3764 |
| 3719 protected: | 3765 protected: |
| 3720 void SetUp() override { | 3766 void SetUp() override { |
| 3767 if (GetParam()) |
| 3768 arc::SetArcAlwaysStartForTesting(); |
| 3721 ArcDefaultAppList::UseTestAppsDirectory(); | 3769 ArcDefaultAppList::UseTestAppsDirectory(); |
| 3722 ChromeLauncherControllerImplTest::SetUp(); | 3770 ChromeLauncherControllerImplTest::SetUp(); |
| 3723 } | 3771 } |
| 3724 | 3772 |
| 3725 private: | 3773 private: |
| 3726 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); | 3774 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); |
| 3727 }; | 3775 }; |
| 3728 | 3776 |
| 3777 INSTANTIATE_TEST_CASE_P(, |
| 3778 ChromeLauncherControllerArcDefaultAppsTest, |
| 3779 ::testing::Bool()); |
| 3780 |
| 3729 } // namespace | 3781 } // namespace |
| 3730 | 3782 |
| 3731 TEST_F(ChromeLauncherControllerOrientationTest, | 3783 TEST_P(ChromeLauncherControllerOrientationTest, |
| 3732 ArcOrientationLockBeforeWindowReady) { | 3784 ArcOrientationLockBeforeWindowReady) { |
| 3733 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3785 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3734 | 3786 |
| 3735 extension_service_->AddExtension(arc_support_host_.get()); | 3787 extension_service_->AddExtension(arc_support_host_.get()); |
| 3736 EnableArc(true); | 3788 EnablePlay(true); |
| 3737 | 3789 |
| 3738 InitLauncherController(); | 3790 InitLauncherController(); |
| 3739 arc::ArcSessionManager::SetShelfDelegateForTesting( | 3791 arc::ArcSessionManager::SetShelfDelegateForTesting( |
| 3740 launcher_controller_.get()); | 3792 launcher_controller_.get()); |
| 3741 | 3793 |
| 3742 ash::ScreenOrientationController* controller = | 3794 ash::ScreenOrientationController* controller = |
| 3743 ash::Shell::GetInstance()->screen_orientation_controller(); | 3795 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3744 | 3796 |
| 3745 std::string app_id1("org.chromium.arc.1"); | 3797 std::string app_id1("org.chromium.arc.1"); |
| 3746 int task_id1 = 1; | 3798 int task_id1 = 1; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3773 EXPECT_EQ(display::Display::ROTATE_90, | 3825 EXPECT_EQ(display::Display::ROTATE_90, |
| 3774 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3826 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3775 | 3827 |
| 3776 // The screen will be locked when the window is created. | 3828 // The screen will be locked when the window is created. |
| 3777 CreateArcWindow(app_id2); | 3829 CreateArcWindow(app_id2); |
| 3778 EXPECT_TRUE(controller->rotation_locked()); | 3830 EXPECT_TRUE(controller->rotation_locked()); |
| 3779 EXPECT_EQ(display::Display::ROTATE_0, | 3831 EXPECT_EQ(display::Display::ROTATE_0, |
| 3780 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3832 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3781 } | 3833 } |
| 3782 | 3834 |
| 3783 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { | 3835 TEST_P(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { |
| 3784 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3836 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3785 | 3837 |
| 3786 extension_service_->AddExtension(arc_support_host_.get()); | 3838 extension_service_->AddExtension(arc_support_host_.get()); |
| 3787 EnableArc(true); | 3839 EnablePlay(true); |
| 3788 EnableTabletMode(true); | 3840 EnableTabletMode(true); |
| 3789 | 3841 |
| 3790 InitLauncherController(); | 3842 InitLauncherController(); |
| 3791 arc::ArcSessionManager::SetShelfDelegateForTesting( | 3843 arc::ArcSessionManager::SetShelfDelegateForTesting( |
| 3792 launcher_controller_.get()); | 3844 launcher_controller_.get()); |
| 3793 | 3845 |
| 3794 InitApps(); | 3846 InitApps(); |
| 3795 ash::ScreenOrientationController* controller = | 3847 ash::ScreenOrientationController* controller = |
| 3796 ash::Shell::GetInstance()->screen_orientation_controller(); | 3848 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3797 | 3849 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3872 EnableTabletMode(true); | 3924 EnableTabletMode(true); |
| 3873 EXPECT_TRUE(controller->rotation_locked()); | 3925 EXPECT_TRUE(controller->rotation_locked()); |
| 3874 EXPECT_EQ(display::Display::ROTATE_90, | 3926 EXPECT_EQ(display::Display::ROTATE_90, |
| 3875 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3927 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3876 | 3928 |
| 3877 // Manually unlock first. | 3929 // Manually unlock first. |
| 3878 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); | 3930 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); |
| 3879 EXPECT_FALSE(controller->rotation_locked()); | 3931 EXPECT_FALSE(controller->rotation_locked()); |
| 3880 } | 3932 } |
| 3881 | 3933 |
| 3882 TEST_F(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { | 3934 TEST_P(ChromeLauncherControllerOrientationTest, CurrentWithLandscapeDisplay) { |
| 3883 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3935 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3884 | 3936 |
| 3885 extension_service_->AddExtension(arc_support_host_.get()); | 3937 extension_service_->AddExtension(arc_support_host_.get()); |
| 3886 EnableArc(true); | 3938 EnablePlay(true); |
| 3887 EnableTabletMode(true); | 3939 EnableTabletMode(true); |
| 3888 | 3940 |
| 3889 InitLauncherController(); | 3941 InitLauncherController(); |
| 3890 arc::ArcSessionManager::SetShelfDelegateForTesting( | 3942 arc::ArcSessionManager::SetShelfDelegateForTesting( |
| 3891 launcher_controller_.get()); | 3943 launcher_controller_.get()); |
| 3892 | 3944 |
| 3893 InitApps(); | 3945 InitApps(); |
| 3894 ash::ScreenOrientationController* controller = | 3946 ash::ScreenOrientationController* controller = |
| 3895 ash::Shell::GetInstance()->screen_orientation_controller(); | 3947 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 3896 | 3948 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3935 EXPECT_EQ(display::Display::ROTATE_0, | 3987 EXPECT_EQ(display::Display::ROTATE_0, |
| 3936 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3988 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3937 | 3989 |
| 3938 NotifyOnTaskOrientationLockRequested(task_id_current_, | 3990 NotifyOnTaskOrientationLockRequested(task_id_current_, |
| 3939 OrientationLock::CURRENT); | 3991 OrientationLock::CURRENT); |
| 3940 EXPECT_TRUE(controller->rotation_locked()); | 3992 EXPECT_TRUE(controller->rotation_locked()); |
| 3941 EXPECT_EQ(display::Display::ROTATE_0, | 3993 EXPECT_EQ(display::Display::ROTATE_0, |
| 3942 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3994 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3943 } | 3995 } |
| 3944 | 3996 |
| 3945 TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { | 3997 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { |
| 3946 arc_test_.SetUp(profile()); | 3998 arc_test_.SetUp(profile()); |
| 3947 InitLauncherController(); | 3999 InitLauncherController(); |
| 3948 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); | 4000 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); |
| 3949 arc::ArcSessionManager::SetShelfDelegateForTesting( | 4001 arc::ArcSessionManager::SetShelfDelegateForTesting( |
| 3950 launcher_controller_.get()); | 4002 launcher_controller_.get()); |
| 3951 | 4003 |
| 3952 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 4004 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 3953 EnableArc(false); | 4005 EnablePlay(false); |
| 3954 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); | 4006 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); |
| 3955 ASSERT_TRUE(prefs->GetAppIds().size()); | 4007 ASSERT_TRUE(prefs->GetAppIds().size()); |
| 3956 | 4008 |
| 3957 const std::string app_id = | 4009 const std::string app_id = |
| 3958 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); | 4010 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
| 3959 EXPECT_EQ(ash::kInvalidShelfID, | 4011 EXPECT_EQ(ash::kInvalidShelfID, |
| 3960 launcher_controller_->GetShelfIDForAppID(app_id)); | 4012 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3961 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4013 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
| 3962 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); | 4014 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); |
| 3963 EXPECT_NE(ash::kInvalidShelfID, | 4015 EXPECT_NE(ash::kInvalidShelfID, |
| 3964 launcher_controller_->GetShelfIDForAppID(app_id)); | 4016 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3965 | 4017 |
| 3966 // Stop ARC again. Shelf item should go away. | 4018 // Stop ARC again. Shelf item should go away. |
| 3967 EnableArc(false); | 4019 EnablePlay(false); |
| 3968 EXPECT_EQ(ash::kInvalidShelfID, | 4020 EXPECT_EQ(ash::kInvalidShelfID, |
| 3969 launcher_controller_->GetShelfIDForAppID(app_id)); | 4021 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3970 | 4022 |
| 3971 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); | 4023 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); |
| 3972 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); | 4024 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcPlayStoreEnabled()); |
| 3973 | 4025 |
| 3974 EXPECT_NE(ash::kInvalidShelfID, | 4026 EXPECT_NE(ash::kInvalidShelfID, |
| 3975 launcher_controller_->GetShelfIDForAppID(app_id)); | 4027 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3976 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 4028 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3977 | 4029 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4209 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4261 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4210 shelf_controller->auto_hide()); | 4262 shelf_controller->auto_hide()); |
| 4211 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4263 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4212 | 4264 |
| 4213 PrefService* prefs = profile()->GetTestingPrefService(); | 4265 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4214 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4266 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4215 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4267 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4216 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4268 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4217 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4269 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4218 } | 4270 } |
| OLD | NEW |