| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 const ItemSelectedCallback& callback) override { | 270 const ItemSelectedCallback& callback) override { |
| 271 callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt); | 271 callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt); |
| 272 } | 272 } |
| 273 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {} | 273 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {} |
| 274 void Close() override {} | 274 void Close() override {} |
| 275 | 275 |
| 276 private: | 276 private: |
| 277 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); | 277 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); |
| 278 }; | 278 }; |
| 279 | 279 |
| 280 // Proxies to ShelfDelegate invocation to the given | |
| 281 // ChromeLauncherControllerImpl instance. Because of ownership management, | |
| 282 // ChromeLauncherControllerImpl instance cannot be injected to WmShell. | |
| 283 // This wraps the instance, so that it can be injected. | |
| 284 class ProxyShelfDelegate : public ash::ShelfDelegate { | |
| 285 public: | |
| 286 explicit ProxyShelfDelegate(ChromeLauncherControllerImpl* controller) | |
| 287 : controller_(controller) {} | |
| 288 ~ProxyShelfDelegate() override = default; | |
| 289 | |
| 290 ash::ShelfID GetShelfIDForAppID(const std::string& app_id) override { | |
| 291 return controller_->GetShelfIDForAppID(app_id); | |
| 292 }; | |
| 293 | |
| 294 ash::ShelfID GetShelfIDForAppIDAndLaunchID( | |
| 295 const std::string& app_id, | |
| 296 const std::string& launch_id) override { | |
| 297 return controller_->GetShelfIDForAppIDAndLaunchID(app_id, launch_id); | |
| 298 } | |
| 299 | |
| 300 const std::string& GetAppIDForShelfID(ash::ShelfID id) override { | |
| 301 return controller_->GetAppIDForShelfID(id); | |
| 302 } | |
| 303 | |
| 304 void PinAppWithID(const std::string& app_id) override { | |
| 305 return controller_->PinAppWithID(app_id); | |
| 306 } | |
| 307 | |
| 308 bool IsAppPinned(const std::string& app_id) override { | |
| 309 return controller_->IsAppPinned(app_id); | |
| 310 } | |
| 311 | |
| 312 void UnpinAppWithID(const std::string& app_id) override { | |
| 313 return controller_->UnpinAppWithID(app_id); | |
| 314 } | |
| 315 | |
| 316 private: | |
| 317 ChromeLauncherControllerImpl* const controller_; | |
| 318 | |
| 319 DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate); | |
| 320 }; | |
| 321 | |
| 322 // A callback that does nothing after shelf item selection handling. | 280 // A callback that does nothing after shelf item selection handling. |
| 323 void NoopCallback(ash::ShelfAction action, base::Optional<ash::MenuItemList>) {} | 281 void NoopCallback(ash::ShelfAction action, base::Optional<ash::MenuItemList>) {} |
| 324 | 282 |
| 325 // Simulates selection of the shelf item. | 283 // Simulates selection of the shelf item. |
| 326 void SelectItem(ash::ShelfItemDelegate* delegate) { | 284 void SelectItem(ash::ShelfItemDelegate* delegate) { |
| 327 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>( | 285 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>( |
| 328 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), | 286 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 329 ui::EF_NONE, 0); | 287 ui::EF_NONE, 0); |
| 330 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, | 288 delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, |
| 331 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); | 289 ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 InsertAddPinChange(user_b, 0, extension6_->id()); | 459 InsertAddPinChange(user_b, 0, extension6_->id()); |
| 502 InsertAddPinChange(user_b, 1, extension7_->id()); | 460 InsertAddPinChange(user_b, 1, extension7_->id()); |
| 503 InsertAddPinChange(user_b, 2, extension8_->id()); | 461 InsertAddPinChange(user_b, 2, extension8_->id()); |
| 504 InsertAddPinChange(user_b, 3, extension_misc::kChromeAppId); | 462 InsertAddPinChange(user_b, 3, extension_misc::kChromeAppId); |
| 505 } | 463 } |
| 506 | 464 |
| 507 void TearDown() override { | 465 void TearDown() override { |
| 508 arc_test_.TearDown(); | 466 arc_test_.TearDown(); |
| 509 model_->RemoveObserver(model_observer_.get()); | 467 model_->RemoveObserver(model_observer_.get()); |
| 510 model_observer_.reset(); | 468 model_observer_.reset(); |
| 511 launcher_controller_.reset(); | 469 launcher_controller_ = nullptr; |
| 512 BrowserWithTestWindowTest::TearDown(); | 470 BrowserWithTestWindowTest::TearDown(); |
| 513 } | 471 } |
| 514 | 472 |
| 515 BrowserWindow* CreateBrowserWindow() override { | 473 BrowserWindow* CreateBrowserWindow() override { |
| 516 return CreateTestBrowserWindowAura(); | 474 return CreateTestBrowserWindowAura(); |
| 517 } | 475 } |
| 518 | 476 |
| 519 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile( | 477 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile( |
| 520 Profile* profile) { | 478 Profile* profile) { |
| 521 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); | 479 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); |
| 522 new TestBrowserWindowOwner(browser_window); | 480 new TestBrowserWindowOwner(browser_window); |
| 523 return base::WrapUnique( | 481 return base::WrapUnique( |
| 524 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); | 482 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); |
| 525 } | 483 } |
| 526 | 484 |
| 527 void AddAppListLauncherItem() { | 485 void AddAppListLauncherItem() { |
| 528 ash::ShelfItem app_list; | 486 ash::ShelfItem app_list; |
| 529 app_list.type = ash::TYPE_APP_LIST; | 487 app_list.type = ash::TYPE_APP_LIST; |
| 530 model_->Add(app_list); | 488 model_->Add(app_list); |
| 531 } | 489 } |
| 532 | 490 |
| 533 void InitLauncherController() { | 491 // Create a launcher controller instance and register it as the ShelfDelegate. |
| 534 launcher_controller_.reset( | 492 // Returns a pointer to the uninitialized controller, which is owned by Shell. |
| 535 new ChromeLauncherControllerImpl(profile(), model_)); | 493 ChromeLauncherControllerImpl* CreateLauncherController() { |
| 536 launcher_controller_->Init(); | 494 // Shell owns ChromeLauncherController as its ShelfDelegate. The lifetime |
| 495 // of this instance should match production behavior as closely as possible. |
| 496 DCHECK(!ChromeLauncherController::instance()); |
| 497 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller = |
| 498 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_); |
| 499 launcher_controller_ = launcher_controller.get(); |
| 500 ash::test::ShellTestApi().SetShelfDelegate(std::move(launcher_controller)); |
| 501 return launcher_controller_; |
| 537 } | 502 } |
| 538 | 503 |
| 504 // Create and initialize the controller. |
| 505 // Returns a pointer to the initialized controller, which is owned by Shell. |
| 506 void InitLauncherController() { CreateLauncherController()->Init(); } |
| 507 |
| 508 // Create and initialize the controller; create a tab and show the browser. |
| 539 void InitLauncherControllerWithBrowser() { | 509 void InitLauncherControllerWithBrowser() { |
| 540 InitLauncherController(); | 510 InitLauncherController(); |
| 541 chrome::NewTab(browser()); | 511 chrome::NewTab(browser()); |
| 542 browser()->window()->Show(); | 512 browser()->window()->Show(); |
| 543 } | 513 } |
| 544 | 514 |
| 545 void RecreateChromeLauncher() { | 515 // Destroy Shell's controller instance and clear the local pointer. |
| 546 // Destroy controller first if it exists. | 516 void ResetLauncherController() { |
| 547 launcher_controller_.reset(); | 517 launcher_controller_ = nullptr; |
| 518 ash::test::ShellTestApi().SetShelfDelegate(nullptr); |
| 519 } |
| 520 |
| 521 // Destroy and recreate the controller; clear and reinitialize the ShelfModel. |
| 522 // Returns a pointer to the uninitialized controller, which is owned by Shell. |
| 523 // TODO(msw): This does not accurately represent ChromeLauncherControllerImpl |
| 524 // lifetime or usage in production, and does not accurately simulate restarts. |
| 525 ChromeLauncherControllerImpl* RecreateLauncherController() { |
| 526 // Destroy any existing controller first; only one may exist at a time. |
| 527 ResetLauncherController(); |
| 548 while (model_->item_count() > 0) | 528 while (model_->item_count() > 0) |
| 549 model_->RemoveItemAt(0); | 529 model_->RemoveItemAt(0); |
| 550 AddAppListLauncherItem(); | 530 AddAppListLauncherItem(); |
| 551 launcher_controller_ = | 531 return CreateLauncherController(); |
| 552 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_); | |
| 553 launcher_controller_->Init(); | |
| 554 } | |
| 555 | |
| 556 // This needs to be called after InitLaunchController(), or its family. | |
| 557 // It is not supported to recreate the instance. | |
| 558 void SetShelfDelegate() { | |
| 559 ash::test::ShellTestApi().SetShelfDelegate( | |
| 560 base::MakeUnique<ProxyShelfDelegate>(launcher_controller_.get())); | |
| 561 } | 532 } |
| 562 | 533 |
| 563 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { | 534 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { |
| 564 app_service_->MergeDataAndStartSyncing( | 535 app_service_->MergeDataAndStartSyncing( |
| 565 syncer::APP_LIST, init_sync_list, | 536 syncer::APP_LIST, init_sync_list, |
| 566 base::MakeUnique<syncer::FakeSyncChangeProcessor>(), | 537 base::MakeUnique<syncer::FakeSyncChangeProcessor>(), |
| 567 base::MakeUnique<syncer::SyncErrorFactoryMock>()); | 538 base::MakeUnique<syncer::SyncErrorFactoryMock>()); |
| 568 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); | 539 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); |
| 569 } | 540 } |
| 570 | 541 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 scoped_refptr<Extension> extension4_; | 939 scoped_refptr<Extension> extension4_; |
| 969 scoped_refptr<Extension> extension5_; | 940 scoped_refptr<Extension> extension5_; |
| 970 scoped_refptr<Extension> extension6_; | 941 scoped_refptr<Extension> extension6_; |
| 971 scoped_refptr<Extension> extension7_; | 942 scoped_refptr<Extension> extension7_; |
| 972 scoped_refptr<Extension> extension8_; | 943 scoped_refptr<Extension> extension8_; |
| 973 scoped_refptr<Extension> extension_platform_app_; | 944 scoped_refptr<Extension> extension_platform_app_; |
| 974 scoped_refptr<Extension> arc_support_host_; | 945 scoped_refptr<Extension> arc_support_host_; |
| 975 | 946 |
| 976 ArcAppTest arc_test_; | 947 ArcAppTest arc_test_; |
| 977 bool auto_start_arc_test_ = false; | 948 bool auto_start_arc_test_ = false; |
| 978 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; | 949 ChromeLauncherControllerImpl* launcher_controller_ = nullptr; |
| 979 std::unique_ptr<TestShelfModelObserver> model_observer_; | 950 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 980 ash::ShelfModel* model_ = nullptr; | 951 ash::ShelfModel* model_ = nullptr; |
| 981 std::unique_ptr<TestingProfileManager> profile_manager_; | 952 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 982 | 953 |
| 983 // |item_delegate_manager_| owns |test_controller_|. | 954 // |item_delegate_manager_| owns |test_controller_|. |
| 984 ash::ShelfItemDelegate* test_controller_ = nullptr; | 955 ash::ShelfItemDelegate* test_controller_ = nullptr; |
| 985 | 956 |
| 986 ExtensionService* extension_service_ = nullptr; | 957 ExtensionService* extension_service_ = nullptr; |
| 987 | 958 |
| 988 app_list::AppListSyncableService* app_service_ = nullptr; | 959 app_list::AppListSyncableService* app_service_ = nullptr; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1309 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1339 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1310 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1340 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1311 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1341 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus()); | 1312 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus()); |
| 1342 | 1313 |
| 1343 // Persist pin state, we don't have active pin for ARC apps yet, but pin | 1314 // Persist pin state, we don't have active pin for ARC apps yet, but pin |
| 1344 // model should have it. | 1315 // model should have it. |
| 1345 syncer::SyncDataList copy_sync_list = | 1316 syncer::SyncDataList copy_sync_list = |
| 1346 app_service_->GetAllSyncData(syncer::APP_LIST); | 1317 app_service_->GetAllSyncData(syncer::APP_LIST); |
| 1347 | 1318 |
| 1348 launcher_controller_.reset(); | 1319 ResetLauncherController(); |
| 1349 SendPinChanges(syncer::SyncChangeList(), true); | 1320 SendPinChanges(syncer::SyncChangeList(), true); |
| 1350 StopAppSyncService(); | 1321 StopAppSyncService(); |
| 1351 EXPECT_EQ(0U, app_service_->sync_items().size()); | 1322 EXPECT_EQ(0U, app_service_->sync_items().size()); |
| 1352 | 1323 |
| 1353 // Move to ARC enabled platform, restart syncing with stored data. | 1324 // Move to ARC enabled platform, restart syncing with stored data. |
| 1354 StartAppSyncService(copy_sync_list); | 1325 StartAppSyncService(copy_sync_list); |
| 1355 RecreateChromeLauncher(); | 1326 RecreateLauncherController()->Init(); |
| 1356 | 1327 |
| 1357 // Pins must be automatically updated. | 1328 // Pins must be automatically updated. |
| 1358 SendListOfArcApps(); | 1329 SendListOfArcApps(); |
| 1359 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1330 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1360 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1331 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1361 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 1332 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1362 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1333 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1363 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1334 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1364 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1335 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1365 | 1336 |
| 1366 EXPECT_EQ("AppList, App1, Chrome, Fake App 0, App2, Fake App 1, App3", | 1337 EXPECT_EQ("AppList, App1, Chrome, Fake App 0, App2, Fake App 1, App3", |
| 1367 GetPinnedAppStatus()); | 1338 GetPinnedAppStatus()); |
| 1368 | 1339 |
| 1369 // Now move pins on ARC enabled platform. | 1340 // Now move pins on ARC enabled platform. |
| 1370 model_->Move(1, 4); | 1341 model_->Move(1, 4); |
| 1371 model_->Move(3, 1); | 1342 model_->Move(3, 1); |
| 1372 model_->Move(3, 5); | 1343 model_->Move(3, 5); |
| 1373 model_->Move(4, 2); | 1344 model_->Move(4, 2); |
| 1374 EXPECT_EQ("AppList, App2, Fake App 1, Chrome, App1, Fake App 0, App3", | 1345 EXPECT_EQ("AppList, App2, Fake App 1, Chrome, App1, Fake App 0, App3", |
| 1375 GetPinnedAppStatus()); | 1346 GetPinnedAppStatus()); |
| 1376 | 1347 |
| 1377 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); | 1348 copy_sync_list = app_service_->GetAllSyncData(syncer::APP_LIST); |
| 1378 | 1349 |
| 1379 launcher_controller_.reset(); | 1350 ResetLauncherController(); |
| 1380 ResetPinModel(); | 1351 ResetPinModel(); |
| 1381 | 1352 |
| 1382 SendPinChanges(syncer::SyncChangeList(), true); | 1353 SendPinChanges(syncer::SyncChangeList(), true); |
| 1383 StopAppSyncService(); | 1354 StopAppSyncService(); |
| 1384 EXPECT_EQ(0U, app_service_->sync_items().size()); | 1355 EXPECT_EQ(0U, app_service_->sync_items().size()); |
| 1385 | 1356 |
| 1386 // Move back to ARC disabled platform. | 1357 // Move back to ARC disabled platform. |
| 1387 // TODO(victorhsieh): Implement opt-out. | 1358 // TODO(victorhsieh): Implement opt-out. |
| 1388 if (arc::ShouldArcAlwaysStart()) | 1359 if (arc::ShouldArcAlwaysStart()) |
| 1389 return; | 1360 return; |
| 1390 EnablePlayStore(false); | 1361 EnablePlayStore(false); |
| 1391 StartAppSyncService(copy_sync_list); | 1362 StartAppSyncService(copy_sync_list); |
| 1392 RecreateChromeLauncher(); | 1363 RecreateLauncherController()->Init(); |
| 1393 | 1364 |
| 1394 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1365 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1395 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); | 1366 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id1)); |
| 1396 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 1367 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1397 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); | 1368 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id2)); |
| 1398 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1369 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1399 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); | 1370 EXPECT_FALSE(launcher_controller_->IsAppPinned(arc_app_id3)); |
| 1400 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); | 1371 EXPECT_EQ("AppList, App2, Chrome, App1, App3", GetPinnedAppStatus()); |
| 1401 | 1372 |
| 1402 // Now move/remove pins on ARC disabled platform. | 1373 // Now move/remove pins on ARC disabled platform. |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 // Check that removing more items does not crash and changes nothing. | 1820 // Check that removing more items does not crash and changes nothing. |
| 1850 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED); | 1821 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED); |
| 1851 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1822 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1852 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); | 1823 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); |
| 1853 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED); | 1824 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED); |
| 1854 RestoreUnpinnedRunningApplicationOrder(current_account_id); | 1825 RestoreUnpinnedRunningApplicationOrder(current_account_id); |
| 1855 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 1826 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 1856 } | 1827 } |
| 1857 | 1828 |
| 1858 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { | 1829 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { |
| 1859 RecreateChromeLauncher(); | 1830 InitLauncherController(); |
| 1860 | 1831 |
| 1861 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; | 1832 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; |
| 1862 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1833 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1863 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1834 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1864 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0]; | 1835 const arc::mojom::ShortcutInfo& shortcut = arc_test_.fake_shortcuts()[0]; |
| 1865 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1836 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1866 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1837 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1867 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1838 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1868 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); | 1839 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); |
| 1869 | 1840 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 | 1910 |
| 1940 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1911 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1941 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1912 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| 1942 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), | 1913 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), |
| 1943 shortcut.intent_uri); | 1914 shortcut.intent_uri); |
| 1944 } | 1915 } |
| 1945 | 1916 |
| 1946 // Ensure the deferred controller does not override the active app controller | 1917 // Ensure the deferred controller does not override the active app controller |
| 1947 // (crbug.com/701152). | 1918 // (crbug.com/701152). |
| 1948 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { | 1919 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunchForActiveApp) { |
| 1949 RecreateChromeLauncher(); | 1920 InitLauncherController(); |
| 1950 SendListOfArcApps(); | 1921 SendListOfArcApps(); |
| 1951 arc_test_.StopArcInstance(); | 1922 arc_test_.StopArcInstance(); |
| 1952 | 1923 |
| 1953 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; | 1924 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; |
| 1954 const std::string app_id = ArcAppTest::GetAppId(app); | 1925 const std::string app_id = ArcAppTest::GetAppId(app); |
| 1955 | 1926 |
| 1956 launcher_controller_->PinAppWithID(app_id); | 1927 launcher_controller_->PinAppWithID(app_id); |
| 1957 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); | 1928 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); |
| 1958 const ash::ShelfID shelf_id = | 1929 const ash::ShelfID shelf_id = |
| 1959 launcher_controller_->GetShelfIDForAppID(app_id); | 1930 launcher_controller_->GetShelfIDForAppID(app_id); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2718 extension_service_->AddExtension(extension4_.get()); | 2689 extension_service_->AddExtension(extension4_.get()); |
| 2719 | 2690 |
| 2720 InitLauncherController(); | 2691 InitLauncherController(); |
| 2721 | 2692 |
| 2722 syncer::SyncChangeList sync_list; | 2693 syncer::SyncChangeList sync_list; |
| 2723 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId); | 2694 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId); |
| 2724 SendPinChanges(sync_list, true); | 2695 SendPinChanges(sync_list, true); |
| 2725 | 2696 |
| 2726 std::vector<std::string> expected_launchers; | 2697 std::vector<std::string> expected_launchers; |
| 2727 std::vector<std::string> actual_launchers; | 2698 std::vector<std::string> actual_launchers; |
| 2728 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2699 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2729 EXPECT_EQ(expected_launchers, actual_launchers); | 2700 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2730 | 2701 |
| 2731 // Unavailable extensions don't create launcher items. | 2702 // Unavailable extensions don't create launcher items. |
| 2732 sync_list.clear(); | 2703 sync_list.clear(); |
| 2733 InsertAddPinChange(&sync_list, 0, extension1_->id()); | 2704 InsertAddPinChange(&sync_list, 0, extension1_->id()); |
| 2734 InsertAddPinChange(&sync_list, 1, extension2_->id()); | 2705 InsertAddPinChange(&sync_list, 1, extension2_->id()); |
| 2735 InsertAddPinChange(&sync_list, 3, extension4_->id()); | 2706 InsertAddPinChange(&sync_list, 3, extension4_->id()); |
| 2736 SendPinChanges(sync_list, false); | 2707 SendPinChanges(sync_list, false); |
| 2737 | 2708 |
| 2738 expected_launchers.push_back(extension2_->id()); | 2709 expected_launchers.push_back(extension2_->id()); |
| 2739 expected_launchers.push_back(extension4_->id()); | 2710 expected_launchers.push_back(extension4_->id()); |
| 2740 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2711 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2741 EXPECT_EQ(expected_launchers, actual_launchers); | 2712 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2742 | 2713 |
| 2743 sync_list.clear(); | 2714 sync_list.clear(); |
| 2744 InsertAddPinChange(&sync_list, 2, extension3_->id()); | 2715 InsertAddPinChange(&sync_list, 2, extension3_->id()); |
| 2745 SendPinChanges(sync_list, false); | 2716 SendPinChanges(sync_list, false); |
| 2746 expected_launchers.insert(expected_launchers.begin() + 1, extension3_->id()); | 2717 expected_launchers.insert(expected_launchers.begin() + 1, extension3_->id()); |
| 2747 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2718 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2748 EXPECT_EQ(expected_launchers, actual_launchers); | 2719 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2749 | 2720 |
| 2750 sync_list.clear(); | 2721 sync_list.clear(); |
| 2751 InsertUpdatePinChange(&sync_list, 0, extension4_->id()); | 2722 InsertUpdatePinChange(&sync_list, 0, extension4_->id()); |
| 2752 InsertUpdatePinChange(&sync_list, 1, extension3_->id()); | 2723 InsertUpdatePinChange(&sync_list, 1, extension3_->id()); |
| 2753 InsertUpdatePinChange(&sync_list, 2, extension2_->id()); | 2724 InsertUpdatePinChange(&sync_list, 2, extension2_->id()); |
| 2754 SendPinChanges(sync_list, false); | 2725 SendPinChanges(sync_list, false); |
| 2755 std::reverse(expected_launchers.begin(), expected_launchers.end()); | 2726 std::reverse(expected_launchers.begin(), expected_launchers.end()); |
| 2756 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2727 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2757 EXPECT_EQ(expected_launchers, actual_launchers); | 2728 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2758 | 2729 |
| 2759 // Sending legacy sync change without pin info should not affect pin model. | 2730 // Sending legacy sync change without pin info should not affect pin model. |
| 2760 sync_list.clear(); | 2731 sync_list.clear(); |
| 2761 InsertLegacyPinChange(&sync_list, extension4_->id()); | 2732 InsertLegacyPinChange(&sync_list, extension4_->id()); |
| 2762 SendPinChanges(sync_list, false); | 2733 SendPinChanges(sync_list, false); |
| 2763 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2734 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2764 EXPECT_EQ(expected_launchers, actual_launchers); | 2735 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2765 | 2736 |
| 2766 sync_list.clear(); | 2737 sync_list.clear(); |
| 2767 InsertRemovePinChange(&sync_list, extension4_->id()); | 2738 InsertRemovePinChange(&sync_list, extension4_->id()); |
| 2768 SendPinChanges(sync_list, false); | 2739 SendPinChanges(sync_list, false); |
| 2769 expected_launchers.erase(expected_launchers.begin()); | 2740 expected_launchers.erase(expected_launchers.begin()); |
| 2770 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2741 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2771 EXPECT_EQ(expected_launchers, actual_launchers); | 2742 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2772 | 2743 |
| 2773 sync_list.clear(); | 2744 sync_list.clear(); |
| 2774 InsertRemovePinChange(&sync_list, extension3_->id()); | 2745 InsertRemovePinChange(&sync_list, extension3_->id()); |
| 2775 InsertRemovePinChange(&sync_list, extension2_->id()); | 2746 InsertRemovePinChange(&sync_list, extension2_->id()); |
| 2776 SendPinChanges(sync_list, false); | 2747 SendPinChanges(sync_list, false); |
| 2777 expected_launchers.clear(); | 2748 expected_launchers.clear(); |
| 2778 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2749 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2779 EXPECT_EQ(expected_launchers, actual_launchers); | 2750 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2780 } | 2751 } |
| 2781 | 2752 |
| 2782 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) { | 2753 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) { |
| 2783 // Note extension3_ is actually Gmail app which is default pinned. | 2754 // Note extension3_ is actually Gmail app which is default pinned. |
| 2784 extension_service_->AddExtension(extension3_.get()); | 2755 extension_service_->AddExtension(extension3_.get()); |
| 2785 InitLauncherController(); | 2756 InitLauncherController(); |
| 2786 | 2757 |
| 2787 // Default pins should contain Gmail. Pref is not syncing now. | 2758 // Default pins should contain Gmail. Pref is not syncing now. |
| 2788 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 2759 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2813 SendPinChanges(sync_list, false); | 2784 SendPinChanges(sync_list, false); |
| 2814 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); | 2785 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); |
| 2815 | 2786 |
| 2816 // At this point changing old pref based model does not affect pin model. | 2787 // At this point changing old pref based model does not affect pin model. |
| 2817 InsertPrefValue(&value, 3, extension5_->id()); | 2788 InsertPrefValue(&value, 3, extension5_->id()); |
| 2818 StopPrefSyncService(); | 2789 StopPrefSyncService(); |
| 2819 StartPrefSyncServiceForPins(value); | 2790 StartPrefSyncServiceForPins(value); |
| 2820 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); | 2791 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); |
| 2821 | 2792 |
| 2822 // Next Chrome start should preserve pins. | 2793 // Next Chrome start should preserve pins. |
| 2823 RecreateChromeLauncher(); | 2794 RecreateLauncherController()->Init(); |
| 2824 StopPrefSyncService(); | 2795 StopPrefSyncService(); |
| 2825 StartPrefSyncService(syncer::SyncDataList()); | 2796 StartPrefSyncService(syncer::SyncDataList()); |
| 2826 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); | 2797 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus()); |
| 2827 } | 2798 } |
| 2828 | 2799 |
| 2829 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) { | 2800 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) { |
| 2830 extension_service_->AddExtension(extension1_.get()); | 2801 extension_service_->AddExtension(extension1_.get()); |
| 2831 extension_service_->AddExtension(extension3_.get()); | 2802 extension_service_->AddExtension(extension3_.get()); |
| 2832 | 2803 |
| 2833 InitLauncherController(); | 2804 InitLauncherController(); |
| 2834 | 2805 |
| 2835 syncer::SyncChangeList sync_list; | 2806 syncer::SyncChangeList sync_list; |
| 2836 InsertAddPinChange(&sync_list, 0, extension1_->id()); | 2807 InsertAddPinChange(&sync_list, 0, extension1_->id()); |
| 2837 InsertAddPinChange(&sync_list, 1, extension2_->id()); | 2808 InsertAddPinChange(&sync_list, 1, extension2_->id()); |
| 2838 InsertAddPinChange(&sync_list, 2, extension3_->id()); | 2809 InsertAddPinChange(&sync_list, 2, extension3_->id()); |
| 2839 SendPinChanges(sync_list, true); | 2810 SendPinChanges(sync_list, true); |
| 2840 | 2811 |
| 2841 std::vector<std::string> expected_launchers; | 2812 std::vector<std::string> expected_launchers; |
| 2842 expected_launchers.push_back(extension1_->id()); | 2813 expected_launchers.push_back(extension1_->id()); |
| 2843 expected_launchers.push_back(extension3_->id()); | 2814 expected_launchers.push_back(extension3_->id()); |
| 2844 std::vector<std::string> actual_launchers; | 2815 std::vector<std::string> actual_launchers; |
| 2845 | 2816 |
| 2846 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2817 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2847 EXPECT_EQ(expected_launchers, actual_launchers); | 2818 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2848 | 2819 |
| 2849 // Install |extension2| and verify it shows up between the other two. | 2820 // Install |extension2| and verify it shows up between the other two. |
| 2850 extension_service_->AddExtension(extension2_.get()); | 2821 extension_service_->AddExtension(extension2_.get()); |
| 2851 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); | 2822 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); |
| 2852 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); | 2823 GetAppLaunchers(launcher_controller_, &actual_launchers); |
| 2853 EXPECT_EQ(expected_launchers, actual_launchers); | 2824 EXPECT_EQ(expected_launchers, actual_launchers); |
| 2854 } | 2825 } |
| 2855 | 2826 |
| 2856 // Ensure |controller| creates the expected menu items for the given shelf item. | 2827 // Ensure |controller| creates the expected menu items for the given shelf item. |
| 2857 void CheckAppMenu(ChromeLauncherControllerImpl* controller, | 2828 void CheckAppMenu(ChromeLauncherControllerImpl* controller, |
| 2858 const ash::ShelfItem& item, | 2829 const ash::ShelfItem& item, |
| 2859 size_t expected_item_count, | 2830 size_t expected_item_count, |
| 2860 base::string16 expected_item_titles[]) { | 2831 base::string16 expected_item_titles[]) { |
| 2861 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item); | 2832 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item); |
| 2862 ASSERT_EQ(expected_item_count, items.size()); | 2833 ASSERT_EQ(expected_item_count, items.size()); |
| 2863 for (size_t i = 0; i < expected_item_count; i++) | 2834 for (size_t i = 0; i < expected_item_count; i++) |
| 2864 EXPECT_EQ(expected_item_titles[i], items[i]->label); | 2835 EXPECT_EQ(expected_item_titles[i], items[i]->label); |
| 2865 } | 2836 } |
| 2866 | 2837 |
| 2867 // Check that browsers get reflected correctly in the launcher menu. | 2838 // Check that browsers get reflected correctly in the launcher menu. |
| 2868 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { | 2839 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) { |
| 2869 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 2840 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
| 2870 chrome::NewTab(browser()); | 2841 chrome::NewTab(browser()); |
| 2871 | 2842 |
| 2872 InitLauncherController(); | 2843 InitLauncherController(); |
| 2873 | 2844 |
| 2874 // Check that the browser list is empty at this time. | 2845 // Check that the browser list is empty at this time. |
| 2875 ash::ShelfItem item_browser; | 2846 ash::ShelfItem item_browser; |
| 2876 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2847 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 2877 item_browser.id = | 2848 item_browser.id = |
| 2878 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 2849 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
| 2879 CheckAppMenu(launcher_controller_.get(), item_browser, 0, nullptr); | 2850 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); |
| 2880 | 2851 |
| 2881 // Now make the created browser() visible by showing its browser window. | 2852 // Now make the created browser() visible by showing its browser window. |
| 2882 browser()->window()->Show(); | 2853 browser()->window()->Show(); |
| 2883 base::string16 title1 = ASCIIToUTF16("Test1"); | 2854 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 2884 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); | 2855 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); |
| 2885 base::string16 one_menu_item[] = { title1 }; | 2856 base::string16 one_menu_item[] = { title1 }; |
| 2886 | 2857 |
| 2887 CheckAppMenu(launcher_controller_.get(), item_browser, 1, one_menu_item); | 2858 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item); |
| 2888 | 2859 |
| 2889 // Create one more browser/window and check that one more was added. | 2860 // Create one more browser/window and check that one more was added. |
| 2890 std::unique_ptr<Browser> browser2( | 2861 std::unique_ptr<Browser> browser2( |
| 2891 CreateBrowserWithTestWindowForProfile(profile())); | 2862 CreateBrowserWithTestWindowForProfile(profile())); |
| 2892 chrome::NewTab(browser2.get()); | 2863 chrome::NewTab(browser2.get()); |
| 2893 browser2->window()->Show(); | 2864 browser2->window()->Show(); |
| 2894 base::string16 title2 = ASCIIToUTF16("Test2"); | 2865 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 2895 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"), | 2866 NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"), |
| 2896 title2); | 2867 title2); |
| 2897 | 2868 |
| 2898 // Check that the list contains now two entries - make furthermore sure that | 2869 // Check that the list contains now two entries - make furthermore sure that |
| 2899 // the active item is the first entry. | 2870 // the active item is the first entry. |
| 2900 base::string16 two_menu_items[] = {title1, title2}; | 2871 base::string16 two_menu_items[] = {title1, title2}; |
| 2901 CheckAppMenu(launcher_controller_.get(), item_browser, 2, two_menu_items); | 2872 CheckAppMenu(launcher_controller_, item_browser, 2, two_menu_items); |
| 2902 | 2873 |
| 2903 // Apparently we have to close all tabs we have. | 2874 // Apparently we have to close all tabs we have. |
| 2904 chrome::CloseTab(browser2.get()); | 2875 chrome::CloseTab(browser2.get()); |
| 2905 } | 2876 } |
| 2906 | 2877 |
| 2907 // Check the multi profile case where only user related browsers should show up. | 2878 // Check the multi profile case where only user related browsers should show up. |
| 2908 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2879 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 2909 BrowserMenuGenerationTwoUsers) { | 2880 BrowserMenuGenerationTwoUsers) { |
| 2910 // Create a browser item in the LauncherController. | 2881 // Create a browser item in the LauncherController. |
| 2911 InitLauncherController(); | 2882 InitLauncherController(); |
| 2912 | 2883 |
| 2913 ash::ShelfItem item_browser; | 2884 ash::ShelfItem item_browser; |
| 2914 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2885 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 2915 item_browser.id = | 2886 item_browser.id = |
| 2916 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 2887 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
| 2917 | 2888 |
| 2918 // Check that the menu is empty. | 2889 // Check that the menu is empty. |
| 2919 chrome::NewTab(browser()); | 2890 chrome::NewTab(browser()); |
| 2920 CheckAppMenu(launcher_controller_.get(), item_browser, 0, nullptr); | 2891 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); |
| 2921 | 2892 |
| 2922 // Show the created |browser()| by showing its window. | 2893 // Show the created |browser()| by showing its window. |
| 2923 browser()->window()->Show(); | 2894 browser()->window()->Show(); |
| 2924 base::string16 title1 = ASCIIToUTF16("Test1"); | 2895 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 2925 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); | 2896 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); |
| 2926 base::string16 one_menu_item1[] = { title1 }; | 2897 base::string16 one_menu_item1[] = { title1 }; |
| 2927 CheckAppMenu(launcher_controller_.get(), item_browser, 1, one_menu_item1); | 2898 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1); |
| 2928 | 2899 |
| 2929 // Create a browser for another user and check that it is not included in the | 2900 // Create a browser for another user and check that it is not included in the |
| 2930 // users running browser list. | 2901 // users running browser list. |
| 2931 std::string user2 = "user2"; | 2902 std::string user2 = "user2"; |
| 2932 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2903 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 2933 const AccountId account_id2( | 2904 const AccountId account_id2( |
| 2934 multi_user_util::GetAccountIdFromProfile(profile2)); | 2905 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 2935 std::unique_ptr<Browser> browser2( | 2906 std::unique_ptr<Browser> browser2( |
| 2936 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); | 2907 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); |
| 2937 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; | 2908 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; |
| 2938 CheckAppMenu(launcher_controller_.get(), item_browser, 1, one_menu_item1); | 2909 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item1); |
| 2939 | 2910 |
| 2940 // Switch to the other user and make sure that only that browser window gets | 2911 // Switch to the other user and make sure that only that browser window gets |
| 2941 // shown. | 2912 // shown. |
| 2942 SwitchActiveUser(account_id2); | 2913 SwitchActiveUser(account_id2); |
| 2943 CheckAppMenu(launcher_controller_.get(), item_browser, 1, one_menu_item2); | 2914 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2); |
| 2944 | 2915 |
| 2945 // Transferred browsers of other users should not show up in the list. | 2916 // Transferred browsers of other users should not show up in the list. |
| 2946 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 2917 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( |
| 2947 browser()->window()->GetNativeWindow(), account_id2); | 2918 browser()->window()->GetNativeWindow(), account_id2); |
| 2948 CheckAppMenu(launcher_controller_.get(), item_browser, 1, one_menu_item2); | 2919 CheckAppMenu(launcher_controller_, item_browser, 1, one_menu_item2); |
| 2949 | 2920 |
| 2950 chrome::CloseTab(browser2.get()); | 2921 chrome::CloseTab(browser2.get()); |
| 2951 } | 2922 } |
| 2952 | 2923 |
| 2953 // Check that V1 apps are correctly reflected in the launcher menu using the | 2924 // Check that V1 apps are correctly reflected in the launcher menu using the |
| 2954 // refocus logic. | 2925 // refocus logic. |
| 2955 // Note that the extension matching logic is tested by the extension system | 2926 // Note that the extension matching logic is tested by the extension system |
| 2956 // and does not need a separate test here. | 2927 // and does not need a separate test here. |
| 2957 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) { | 2928 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) { |
| 2958 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 2929 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2975 | 2946 |
| 2976 // Check the menu content. | 2947 // Check the menu content. |
| 2977 ash::ShelfItem item_browser; | 2948 ash::ShelfItem item_browser; |
| 2978 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2949 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 2979 item_browser.id = | 2950 item_browser.id = |
| 2980 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 2951 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
| 2981 | 2952 |
| 2982 ash::ShelfItem item_gmail; | 2953 ash::ShelfItem item_gmail; |
| 2983 item_gmail.type = ash::TYPE_PINNED_APP; | 2954 item_gmail.type = ash::TYPE_PINNED_APP; |
| 2984 item_gmail.id = gmail_id; | 2955 item_gmail.id = gmail_id; |
| 2985 CheckAppMenu(launcher_controller_.get(), item_gmail, 0, nullptr); | 2956 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 2986 | 2957 |
| 2987 // Set the gmail URL to a new tab. | 2958 // Set the gmail URL to a new tab. |
| 2988 base::string16 title1 = ASCIIToUTF16("Test1"); | 2959 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 2989 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 2960 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); |
| 2990 | 2961 |
| 2991 base::string16 one_menu_item[] = { title1 }; | 2962 base::string16 one_menu_item[] = { title1 }; |
| 2992 CheckAppMenu(launcher_controller_.get(), item_gmail, 1, one_menu_item); | 2963 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); |
| 2993 | 2964 |
| 2994 // Create one empty tab. | 2965 // Create one empty tab. |
| 2995 chrome::NewTab(browser()); | 2966 chrome::NewTab(browser()); |
| 2996 base::string16 title2 = ASCIIToUTF16("Test2"); | 2967 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 2997 NavigateAndCommitActiveTabWithTitle( | 2968 NavigateAndCommitActiveTabWithTitle( |
| 2998 browser(), | 2969 browser(), |
| 2999 GURL("https://bla"), | 2970 GURL("https://bla"), |
| 3000 title2); | 2971 title2); |
| 3001 | 2972 |
| 3002 // and another one with another gmail instance. | 2973 // and another one with another gmail instance. |
| 3003 chrome::NewTab(browser()); | 2974 chrome::NewTab(browser()); |
| 3004 base::string16 title3 = ASCIIToUTF16("Test3"); | 2975 base::string16 title3 = ASCIIToUTF16("Test3"); |
| 3005 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3); | 2976 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3); |
| 3006 base::string16 two_menu_items[] = {title1, title3}; | 2977 base::string16 two_menu_items[] = {title1, title3}; |
| 3007 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); | 2978 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); |
| 3008 | 2979 |
| 3009 // Even though the item is in the V1 app list, it should also be in the | 2980 // Even though the item is in the V1 app list, it should also be in the |
| 3010 // browser list. | 2981 // browser list. |
| 3011 base::string16 browser_menu_item[] = {title3}; | 2982 base::string16 browser_menu_item[] = {title3}; |
| 3012 CheckAppMenu(launcher_controller_.get(), item_browser, 1, browser_menu_item); | 2983 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item); |
| 3013 | 2984 |
| 3014 // Test that closing of (all) the item(s) does work (and all menus get | 2985 // Test that closing of (all) the item(s) does work (and all menus get |
| 3015 // updated properly). | 2986 // updated properly). |
| 3016 launcher_controller_->Close(item_gmail.id); | 2987 launcher_controller_->Close(item_gmail.id); |
| 3017 | 2988 |
| 3018 CheckAppMenu(launcher_controller_.get(), item_gmail, 0, nullptr); | 2989 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3019 base::string16 browser_menu_item2[] = { title2 }; | 2990 base::string16 browser_menu_item2[] = { title2 }; |
| 3020 CheckAppMenu(launcher_controller_.get(), item_browser, 1, browser_menu_item2); | 2991 CheckAppMenu(launcher_controller_, item_browser, 1, browser_menu_item2); |
| 3021 } | 2992 } |
| 3022 | 2993 |
| 3023 // Check the multi profile case where only user related apps should show up. | 2994 // Check the multi profile case where only user related apps should show up. |
| 3024 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 2995 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 3025 V1AppMenuGenerationTwoUsers) { | 2996 V1AppMenuGenerationTwoUsers) { |
| 3026 // Create a browser item in the LauncherController. | 2997 // Create a browser item in the LauncherController. |
| 3027 InitLauncherController(); | 2998 InitLauncherController(); |
| 3028 chrome::NewTab(browser()); | 2999 chrome::NewTab(browser()); |
| 3029 | 3000 |
| 3030 // Installing |extension3_| adds it to the launcher. | 3001 // Installing |extension3_| adds it to the launcher. |
| 3031 ash::ShelfID gmail_id = model_->next_id(); | 3002 ash::ShelfID gmail_id = model_->next_id(); |
| 3032 extension_service_->AddExtension(extension3_.get()); | 3003 extension_service_->AddExtension(extension3_.get()); |
| 3033 EXPECT_EQ(3, model_->item_count()); | 3004 EXPECT_EQ(3, model_->item_count()); |
| 3034 int gmail_index = model_->ItemIndexByID(gmail_id); | 3005 int gmail_index = model_->ItemIndexByID(gmail_id); |
| 3035 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); | 3006 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); |
| 3036 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 3007 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 3037 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); | 3008 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); |
| 3038 | 3009 |
| 3039 // Check the menu content. | 3010 // Check the menu content. |
| 3040 ash::ShelfItem item_browser; | 3011 ash::ShelfItem item_browser; |
| 3041 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 3012 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
| 3042 item_browser.id = | 3013 item_browser.id = |
| 3043 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 3014 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
| 3044 | 3015 |
| 3045 ash::ShelfItem item_gmail; | 3016 ash::ShelfItem item_gmail; |
| 3046 item_gmail.type = ash::TYPE_PINNED_APP; | 3017 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3047 item_gmail.id = gmail_id; | 3018 item_gmail.id = gmail_id; |
| 3048 CheckAppMenu(launcher_controller_.get(), item_gmail, 0, nullptr); | 3019 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3049 | 3020 |
| 3050 // Set the gmail URL to a new tab. | 3021 // Set the gmail URL to a new tab. |
| 3051 base::string16 title1 = ASCIIToUTF16("Test1"); | 3022 base::string16 title1 = ASCIIToUTF16("Test1"); |
| 3052 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3023 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); |
| 3053 | 3024 |
| 3054 base::string16 one_menu_item[] = { title1 }; | 3025 base::string16 one_menu_item[] = { title1 }; |
| 3055 CheckAppMenu(launcher_controller_.get(), item_gmail, 1, one_menu_item); | 3026 CheckAppMenu(launcher_controller_, item_gmail, 1, one_menu_item); |
| 3056 | 3027 |
| 3057 // Create a second profile and switch to that user. | 3028 // Create a second profile and switch to that user. |
| 3058 std::string user2 = "user2"; | 3029 std::string user2 = "user2"; |
| 3059 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 3030 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
| 3060 const AccountId account_id2( | 3031 const AccountId account_id2( |
| 3061 multi_user_util::GetAccountIdFromProfile(profile2)); | 3032 multi_user_util::GetAccountIdFromProfile(profile2)); |
| 3062 SwitchActiveUser(account_id2); | 3033 SwitchActiveUser(account_id2); |
| 3063 | 3034 |
| 3064 // No item should have content yet. | 3035 // No item should have content yet. |
| 3065 CheckAppMenu(launcher_controller_.get(), item_browser, 0, nullptr); | 3036 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); |
| 3066 CheckAppMenu(launcher_controller_.get(), item_gmail, 0, nullptr); | 3037 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3067 | 3038 |
| 3068 // Transfer the browser of the first user - it should still not show up. | 3039 // Transfer the browser of the first user - it should still not show up. |
| 3069 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 3040 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( |
| 3070 browser()->window()->GetNativeWindow(), account_id2); | 3041 browser()->window()->GetNativeWindow(), account_id2); |
| 3071 | 3042 |
| 3072 CheckAppMenu(launcher_controller_.get(), item_browser, 0, nullptr); | 3043 CheckAppMenu(launcher_controller_, item_browser, 0, nullptr); |
| 3073 CheckAppMenu(launcher_controller_.get(), item_gmail, 0, nullptr); | 3044 CheckAppMenu(launcher_controller_, item_gmail, 0, nullptr); |
| 3074 } | 3045 } |
| 3075 | 3046 |
| 3076 // Check that V2 applications are creating items properly in the launcher when | 3047 // Check that V2 applications are creating items properly in the launcher when |
| 3077 // instantiated by the current user. | 3048 // instantiated by the current user. |
| 3078 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, | 3049 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest, |
| 3079 V2AppHandlingTwoUsers) { | 3050 V2AppHandlingTwoUsers) { |
| 3080 InitLauncherController(); | 3051 InitLauncherController(); |
| 3081 // Create a profile for our second user (will be destroyed by the framework). | 3052 // Create a profile for our second user (will be destroyed by the framework). |
| 3082 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 3053 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
| 3083 const AccountId account_id( | 3054 const AccountId account_id( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3301 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3272 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); |
| 3302 chrome::NewTab(browser()); | 3273 chrome::NewTab(browser()); |
| 3303 base::string16 title2 = ASCIIToUTF16("Test2"); | 3274 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3304 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); | 3275 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); |
| 3305 | 3276 |
| 3306 // Check that the menu is properly set. | 3277 // Check that the menu is properly set. |
| 3307 ash::ShelfItem item_gmail; | 3278 ash::ShelfItem item_gmail; |
| 3308 item_gmail.type = ash::TYPE_PINNED_APP; | 3279 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3309 item_gmail.id = gmail_id; | 3280 item_gmail.id = gmail_id; |
| 3310 base::string16 two_menu_items[] = {title1, title2}; | 3281 base::string16 two_menu_items[] = {title1, title2}; |
| 3311 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); | 3282 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); |
| 3312 ash::ShelfItemDelegate* item_delegate = | 3283 ash::ShelfItemDelegate* item_delegate = |
| 3313 launcher_controller_->GetShelfItemDelegate(gmail_id); | 3284 launcher_controller_->GetShelfItemDelegate(gmail_id); |
| 3314 ASSERT_TRUE(item_delegate); | 3285 ASSERT_TRUE(item_delegate); |
| 3315 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 3286 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 3316 // Execute the second item in the menu, after the title and two separators, | 3287 // Execute the second item in the menu, after the title and two separators, |
| 3317 // this shouldn't do anything since that item is already the active tab. | 3288 // this shouldn't do anything since that item is already the active tab. |
| 3318 { | 3289 { |
| 3319 ash::ShelfApplicationMenuModel menu( | 3290 ash::ShelfApplicationMenuModel menu( |
| 3320 base::string16(), | 3291 base::string16(), |
| 3321 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), | 3292 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3349 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); | 3320 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); |
| 3350 chrome::NewTab(browser()); | 3321 chrome::NewTab(browser()); |
| 3351 base::string16 title2 = ASCIIToUTF16("Test2"); | 3322 base::string16 title2 = ASCIIToUTF16("Test2"); |
| 3352 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); | 3323 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); |
| 3353 | 3324 |
| 3354 // Check that the menu is properly set. | 3325 // Check that the menu is properly set. |
| 3355 ash::ShelfItem item_gmail; | 3326 ash::ShelfItem item_gmail; |
| 3356 item_gmail.type = ash::TYPE_PINNED_APP; | 3327 item_gmail.type = ash::TYPE_PINNED_APP; |
| 3357 item_gmail.id = gmail_id; | 3328 item_gmail.id = gmail_id; |
| 3358 base::string16 two_menu_items[] = {title1, title2}; | 3329 base::string16 two_menu_items[] = {title1, title2}; |
| 3359 CheckAppMenu(launcher_controller_.get(), item_gmail, 2, two_menu_items); | 3330 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); |
| 3360 | 3331 |
| 3361 ash::ShelfItemDelegate* item_delegate = | 3332 ash::ShelfItemDelegate* item_delegate = |
| 3362 launcher_controller_->GetShelfItemDelegate(gmail_id); | 3333 launcher_controller_->GetShelfItemDelegate(gmail_id); |
| 3363 ASSERT_TRUE(item_delegate); | 3334 ASSERT_TRUE(item_delegate); |
| 3364 int tabs = browser()->tab_strip_model()->count(); | 3335 int tabs = browser()->tab_strip_model()->count(); |
| 3365 // Activate the proper tab through the menu item. | 3336 // Activate the proper tab through the menu item. |
| 3366 { | 3337 { |
| 3367 ash::MenuItemList items = | 3338 ash::MenuItemList items = |
| 3368 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); | 3339 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); |
| 3369 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_NONE); | 3340 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_NONE); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3509 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 3480 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 3510 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[3].type); | 3481 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[3].type); |
| 3511 | 3482 |
| 3512 // Move browser shortcut item from index 1 to index 3. | 3483 // Move browser shortcut item from index 1 to index 3. |
| 3513 model_->Move(1, 3); | 3484 model_->Move(1, 3); |
| 3514 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); | 3485 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 3515 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type); | 3486 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type); |
| 3516 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 3487 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| 3517 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); | 3488 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
| 3518 | 3489 |
| 3519 launcher_controller_.reset(); | 3490 RecreateLauncherController(); |
| 3520 while (!model_->items().empty()) | |
| 3521 model_->RemoveItemAt(0); | |
| 3522 | |
| 3523 AddAppListLauncherItem(); | |
| 3524 launcher_controller_ = | |
| 3525 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_); | |
| 3526 helper = new TestLauncherControllerHelper(profile()); | 3491 helper = new TestLauncherControllerHelper(profile()); |
| 3527 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 3492 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 3528 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); | 3493 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); |
| 3529 SetLauncherControllerHelper(helper); | 3494 SetLauncherControllerHelper(helper); |
| 3530 launcher_controller_->Init(); | 3495 launcher_controller_->Init(); |
| 3531 | 3496 |
| 3532 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl. | 3497 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl. |
| 3533 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); | 3498 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 3534 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type); | 3499 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[1].type); |
| 3535 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); | 3500 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3556 | 3521 |
| 3557 launcher_controller_->PinAppWithID("1"); | 3522 launcher_controller_->PinAppWithID("1"); |
| 3558 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); | 3523 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); |
| 3559 int app_index = model_->ItemIndexByID(id); | 3524 int app_index = model_->ItemIndexByID(id); |
| 3560 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3525 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 3561 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); | 3526 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[app_index].type); |
| 3562 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 3527 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 3563 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 3528 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 3564 EXPECT_EQ(initial_size + 1, model_->items().size()); | 3529 EXPECT_EQ(initial_size + 1, model_->items().size()); |
| 3565 | 3530 |
| 3566 launcher_controller_.reset(); | 3531 RecreateLauncherController(); |
| 3567 while (!model_->items().empty()) | |
| 3568 model_->RemoveItemAt(0); | |
| 3569 | |
| 3570 AddAppListLauncherItem(); | |
| 3571 launcher_controller_ = | |
| 3572 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_); | |
| 3573 helper = new TestLauncherControllerHelper(profile()); | 3532 helper = new TestLauncherControllerHelper(profile()); |
| 3574 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 3533 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 3575 SetLauncherControllerHelper(helper); | 3534 SetLauncherControllerHelper(helper); |
| 3576 // app_icon_loader is owned by ChromeLauncherControllerImpl. | 3535 // app_icon_loader is owned by ChromeLauncherControllerImpl. |
| 3577 app_icon_loader = new TestAppIconLoaderImpl; | 3536 app_icon_loader = new TestAppIconLoaderImpl; |
| 3578 app_icon_loader->AddSupportedApp("1"); | 3537 app_icon_loader->AddSupportedApp("1"); |
| 3579 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | 3538 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 3580 launcher_controller_->Init(); | 3539 launcher_controller_->Init(); |
| 3581 | 3540 |
| 3582 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3541 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3677 extension_service_->AddExtension(arc_support_host_.get()); | 3636 extension_service_->AddExtension(arc_support_host_.get()); |
| 3678 // Test enables ARC, so turn it off for initial values. | 3637 // Test enables ARC, so turn it off for initial values. |
| 3679 EnablePlayStore(false); | 3638 EnablePlayStore(false); |
| 3680 | 3639 |
| 3681 InitLauncherController(); | 3640 InitLauncherController(); |
| 3682 | 3641 |
| 3683 // To prevent import legacy pins each time. | 3642 // To prevent import legacy pins each time. |
| 3684 // Initially pins are imported from legacy pref based model. | 3643 // Initially pins are imported from legacy pref based model. |
| 3685 StartPrefSyncService(syncer::SyncDataList()); | 3644 StartPrefSyncService(syncer::SyncDataList()); |
| 3686 | 3645 |
| 3687 // Inject |launcher_controller_| as ShelfDelegate to verify the behavior | |
| 3688 // of removing pinned icon in ArcSessionManager::OnOptInPreferenceChanged(). | |
| 3689 SetShelfDelegate(); | |
| 3690 | |
| 3691 // Initial run, ARC is not managed and disabled, Play Store pin should be | 3646 // Initial run, ARC is not managed and disabled, Play Store pin should be |
| 3692 // available. | 3647 // available. |
| 3693 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, | 3648 ValidateArcState(false, false, arc::ArcSessionManager::State::STOPPED, |
| 3694 "AppList, Chrome, Play Store"); | 3649 "AppList, Chrome, Play Store"); |
| 3695 | 3650 |
| 3696 // ARC is managed and enabled, Play Store pin should be available. | 3651 // ARC is managed and enabled, Play Store pin should be available. |
| 3697 // Note: NEGOTIATING_TERMS_OF_SERVICE here means that opt-in flow starts. | 3652 // Note: NEGOTIATING_TERMS_OF_SERVICE here means that opt-in flow starts. |
| 3698 profile()->GetTestingPrefService()->SetManagedPref( | 3653 profile()->GetTestingPrefService()->SetManagedPref( |
| 3699 prefs::kArcEnabled, base::MakeUnique<base::Value>(true)); | 3654 prefs::kArcEnabled, base::MakeUnique<base::Value>(true)); |
| 3700 base::RunLoop().RunUntilIdle(); | 3655 base::RunLoop().RunUntilIdle(); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4041 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3996 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 4042 | 3997 |
| 4043 // Manually unlock first. | 3998 // Manually unlock first. |
| 4044 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); | 3999 NotifyOnTaskOrientationLockRequested(task_id_none_, OrientationLock::NONE); |
| 4045 EXPECT_FALSE(controller->rotation_locked()); | 4000 EXPECT_FALSE(controller->rotation_locked()); |
| 4046 } | 4001 } |
| 4047 | 4002 |
| 4048 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { | 4003 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { |
| 4049 arc_test_.SetUp(profile()); | 4004 arc_test_.SetUp(profile()); |
| 4050 InitLauncherController(); | 4005 InitLauncherController(); |
| 4051 ChromeLauncherController::set_instance_for_test(launcher_controller_.get()); | 4006 // TODO(crbug.com/709297): Fix this workaround to prevent a TearDown crash. |
| 4007 std::vector<std::unique_ptr<AppIconLoader>> no_loaders; |
| 4008 launcher_controller_->SetAppIconLoadersForTest(no_loaders); |
| 4052 | 4009 |
| 4053 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 4010 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 4054 EnablePlayStore(false); | 4011 EnablePlayStore(false); |
| 4055 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 4012 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
| 4056 ASSERT_TRUE(prefs->GetAppIds().size()); | 4013 ASSERT_TRUE(prefs->GetAppIds().size()); |
| 4057 | 4014 |
| 4058 const std::string app_id = | 4015 const std::string app_id = |
| 4059 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); | 4016 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
| 4060 EXPECT_EQ(ash::kInvalidShelfID, | 4017 EXPECT_EQ(ash::kInvalidShelfID, |
| 4061 launcher_controller_->GetShelfIDForAppID(app_id)); | 4018 launcher_controller_->GetShelfIDForAppID(app_id)); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4177 InsertAddPinChange(&sync_list, 1, extension1_->id()); | 4134 InsertAddPinChange(&sync_list, 1, extension1_->id()); |
| 4178 InsertAddPinChange(&sync_list, 1, extension2_->id()); | 4135 InsertAddPinChange(&sync_list, 1, extension2_->id()); |
| 4179 SendPinChanges(sync_list, true); | 4136 SendPinChanges(sync_list, true); |
| 4180 | 4137 |
| 4181 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4138 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4182 | 4139 |
| 4183 syncer::SyncDataList copy_sync_list = | 4140 syncer::SyncDataList copy_sync_list = |
| 4184 app_service_->GetAllSyncData(syncer::APP_LIST); | 4141 app_service_->GetAllSyncData(syncer::APP_LIST); |
| 4185 | 4142 |
| 4186 app_service_->StopSyncing(syncer::APP_LIST); | 4143 app_service_->StopSyncing(syncer::APP_LIST); |
| 4187 RecreateChromeLauncher(); | 4144 RecreateLauncherController()->Init(); |
| 4188 | 4145 |
| 4189 // Pinned state should not change. | 4146 // Pinned state should not change. |
| 4190 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4147 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4191 launcher_controller_->UnpinAppWithID(extension2_->id()); | 4148 launcher_controller_->UnpinAppWithID(extension2_->id()); |
| 4192 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 4149 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 4193 | 4150 |
| 4194 // Resume syncing and sync information overrides local copy. | 4151 // Resume syncing and sync information overrides local copy. |
| 4195 StartAppSyncService(copy_sync_list); | 4152 StartAppSyncService(copy_sync_list); |
| 4196 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4153 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4197 } | 4154 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4338 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 4295 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 4339 shelf_controller->auto_hide()); | 4296 shelf_controller->auto_hide()); |
| 4340 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); | 4297 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); |
| 4341 | 4298 |
| 4342 PrefService* prefs = profile()->GetTestingPrefService(); | 4299 PrefService* prefs = profile()->GetTestingPrefService(); |
| 4343 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); | 4300 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); |
| 4344 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); | 4301 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); |
| 4345 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); | 4302 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); |
| 4346 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); | 4303 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); |
| 4347 } | 4304 } |
| OLD | NEW |