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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2790803002: mash: Remove V1 app shelf item locking; monitor running status instead. (Closed)
Patch Set: spelling Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 Extension::NO_FLAGS, "gggggggggggggggggggggggggggggggg", &error); 447 Extension::NO_FLAGS, "gggggggggggggggggggggggggggggggg", &error);
448 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 448 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
449 manifest, Extension::NO_FLAGS, 449 manifest, Extension::NO_FLAGS,
450 ArcSupportHost::kHostAppId, &error); 450 ArcSupportHost::kHostAppId, &error);
451 extension_service_->AddExtension(extension_chrome_.get()); 451 extension_service_->AddExtension(extension_chrome_.get());
452 } 452 }
453 453
454 // Creates a running platform V2 app (not pinned) of type |app_id|. 454 // Creates a running platform V2 app (not pinned) of type |app_id|.
455 virtual void CreateRunningV2App(const std::string& app_id) { 455 virtual void CreateRunningV2App(const std::string& app_id) {
456 DCHECK(!test_controller_); 456 DCHECK(!test_controller_);
457 ash::ShelfID id =
458 launcher_controller_->CreateAppShortcutLauncherItemWithType(
459 ash::AppLaunchId(app_id), model_->item_count(), ash::TYPE_APP);
460 DCHECK(id);
461 // Change the created launcher controller into a V2 app controller. 457 // Change the created launcher controller into a V2 app controller.
462 test_controller_ = new TestV2AppLauncherItemController(app_id, 458 test_controller_ = new TestV2AppLauncherItemController(app_id,
463 launcher_controller_.get()); 459 launcher_controller_.get());
464 launcher_controller_->SetItemController(id, test_controller_); 460 ash::ShelfID id = launcher_controller_->InsertAppLauncherItem(
461 test_controller_, ash::STATUS_RUNNING, model_->item_count(),
462 ash::TYPE_APP);
465 DCHECK(launcher_controller_->IsPlatformApp(id)); 463 DCHECK(launcher_controller_->IsPlatformApp(id));
466 launcher_controller_->SetItemStatus(id, ash::STATUS_RUNNING);
467 } 464 }
468 465
469 // Sets the stage for a multi user test. 466 // Sets the stage for a multi user test.
470 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, 467 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a,
471 syncer::SyncChangeList* user_b) { 468 syncer::SyncChangeList* user_b) {
472 InitLauncherController(); 469 InitLauncherController();
473 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 470 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
474 471
475 // Set an empty pinned pref to begin with. 472 // Set an empty pinned pref to begin with.
476 syncer::SyncChangeList sync_list; 473 syncer::SyncChangeList sync_list;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 private: 1307 private:
1311 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest); 1308 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplMultiProfileWithArcTest);
1312 }; 1309 };
1313 1310
1314 INSTANTIATE_TEST_CASE_P(, 1311 INSTANTIATE_TEST_CASE_P(,
1315 ChromeLauncherControllerImplMultiProfileWithArcTest, 1312 ChromeLauncherControllerImplMultiProfileWithArcTest,
1316 ::testing::Bool()); 1313 ::testing::Bool());
1317 1314
1318 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) { 1315 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) {
1319 InitLauncherController(); 1316 InitLauncherController();
1320 // Model should only contain the browser shortcut and app list items. 1317 // The model should only contain the browser shortcut and app list items.
1321 EXPECT_EQ(2, model_->item_count()); 1318 EXPECT_EQ(2, model_->item_count());
1322 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1319 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1323 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1320 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1324 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1321 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1325 1322
1326 // Installing |extension3_| should add it to the launcher - behind the 1323 // Installing |extension3_| should add it to the launcher - behind the
1327 // chrome icon. 1324 // chrome icon.
1328 extension_service_->AddExtension(extension3_.get()); 1325 extension_service_->AddExtension(extension3_.get());
1329 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1326 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1330 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1327 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 // order. 1492 // order.
1496 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) { 1493 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) {
1497 InitLauncherController(); 1494 InitLauncherController();
1498 1495
1499 syncer::SyncChangeList sync_list; 1496 syncer::SyncChangeList sync_list;
1500 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1497 InsertAddPinChange(&sync_list, 0, extension1_->id());
1501 InsertAddPinChange(&sync_list, 1, extension2_->id()); 1498 InsertAddPinChange(&sync_list, 1, extension2_->id());
1502 InsertAddPinChange(&sync_list, 2, extension3_->id()); 1499 InsertAddPinChange(&sync_list, 2, extension3_->id());
1503 SendPinChanges(sync_list, true); 1500 SendPinChanges(sync_list, true);
1504 1501
1505 // Model should only contain the browser shortcut and app list items. 1502 // The model should only contain the browser shortcut and app list items.
1506 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1503 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1507 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1504 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1508 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1505 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1509 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1506 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1510 1507
1511 // Installing |extension3_| should add it to the shelf - behind the 1508 // Installing |extension3_| should add it to the shelf - behind the
1512 // chrome icon. 1509 // chrome icon.
1513 ash::ShelfItem item; 1510 ash::ShelfItem item;
1514 extension_service_->AddExtension(extension3_.get()); 1511 extension_service_->AddExtension(extension3_.get());
1515 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1512 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 17 matching lines...) Expand all
1533 // order. 1530 // order.
1534 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsRandomOrder) { 1531 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsRandomOrder) {
1535 InitLauncherController(); 1532 InitLauncherController();
1536 1533
1537 syncer::SyncChangeList sync_list; 1534 syncer::SyncChangeList sync_list;
1538 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1535 InsertAddPinChange(&sync_list, 0, extension1_->id());
1539 InsertAddPinChange(&sync_list, 1, extension2_->id()); 1536 InsertAddPinChange(&sync_list, 1, extension2_->id());
1540 InsertAddPinChange(&sync_list, 2, extension3_->id()); 1537 InsertAddPinChange(&sync_list, 2, extension3_->id());
1541 SendPinChanges(sync_list, true); 1538 SendPinChanges(sync_list, true);
1542 1539
1543 // Model should only contain the browser shortcut and app list items. 1540 // The model should only contain the browser shortcut and app list items.
1544 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1541 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1545 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1542 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1546 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1543 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1547 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1544 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1548 1545
1549 // Installing |extension2_| should add it to the launcher - behind the 1546 // Installing |extension2_| should add it to the launcher - behind the
1550 // chrome icon. 1547 // chrome icon.
1551 extension_service_->AddExtension(extension2_.get()); 1548 extension_service_->AddExtension(extension2_.get());
1552 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1549 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1553 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1550 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
(...skipping 18 matching lines...) Expand all
1572 RestoreDefaultAppsRandomOrderChromeMoved) { 1569 RestoreDefaultAppsRandomOrderChromeMoved) {
1573 InitLauncherController(); 1570 InitLauncherController();
1574 1571
1575 syncer::SyncChangeList sync_list; 1572 syncer::SyncChangeList sync_list;
1576 InsertAddPinChange(&sync_list, 0, extension1_->id()); 1573 InsertAddPinChange(&sync_list, 0, extension1_->id());
1577 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId); 1574 InsertAddPinChange(&sync_list, 1, extension_misc::kChromeAppId);
1578 InsertAddPinChange(&sync_list, 2, extension2_->id()); 1575 InsertAddPinChange(&sync_list, 2, extension2_->id());
1579 InsertAddPinChange(&sync_list, 3, extension3_->id()); 1576 InsertAddPinChange(&sync_list, 3, extension3_->id());
1580 SendPinChanges(sync_list, true); 1577 SendPinChanges(sync_list, true);
1581 1578
1582 // Model should only contain the browser shortcut and app list items. 1579 // The model should only contain the browser shortcut and app list items.
1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1580 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1584 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1581 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1585 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1582 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1586 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1583 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1587 1584
1588 // Installing |extension2_| should add it to the shelf - behind the 1585 // Installing |extension2_| should add it to the shelf - behind the
1589 // chrome icon. 1586 // chrome icon.
1590 ash::ShelfItem item; 1587 ash::ShelfItem item;
1591 extension_service_->AddExtension(extension2_.get()); 1588 extension_service_->AddExtension(extension2_.get());
1592 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1589 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 extension_service_->UnloadExtension(extension2_->id(), 1653 extension_service_->UnloadExtension(extension2_->id(),
1657 UnloadedExtensionInfo::REASON_UNINSTALL); 1654 UnloadedExtensionInfo::REASON_UNINSTALL);
1658 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1655 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1659 1656
1660 // Check that an update of an extension does not crash the system. 1657 // Check that an update of an extension does not crash the system.
1661 extension_service_->UnloadExtension(extension3_->id(), 1658 extension_service_->UnloadExtension(extension3_->id(),
1662 UnloadedExtensionInfo::REASON_UPDATE); 1659 UnloadedExtensionInfo::REASON_UPDATE);
1663 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1660 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1664 } 1661 }
1665 1662
1666 // Check that simple locking of an application will 'create' a launcher item. 1663 // Test the V1 app interaction flow: run it, activate it, close it.
1667 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { 1664 TEST_F(ChromeLauncherControllerImplTest, V1AppRunActivateClose) {
1668 InitLauncherController(); 1665 InitLauncherController();
1669 // Model should only contain the browser shortcut and app list items. 1666 // The model should only contain the browser shortcut and app list items.
1670 EXPECT_EQ(2, model_->item_count());
1671 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1672 EXPECT_EQ(ash::kInvalidShelfID,
1673 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1674 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1675 EXPECT_EQ(ash::kInvalidShelfID,
1676 launcher_controller_->GetShelfIDForAppID(extension2_->id()));
1677
1678 launcher_controller_->LockV1AppWithID(extension1_->id());
1679
1680 EXPECT_EQ(3, model_->item_count());
1681 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1682 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1683 EXPECT_NE(ash::kInvalidShelfID,
1684 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1685 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1686 EXPECT_EQ(ash::kInvalidShelfID,
1687 launcher_controller_->GetShelfIDForAppID(extension2_->id()));
1688
1689 launcher_controller_->UnlockV1AppWithID(extension1_->id());
1690
1691 EXPECT_EQ(2, model_->item_count());
1692 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1693 EXPECT_EQ(ash::kInvalidShelfID,
1694 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1695 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1696 EXPECT_EQ(ash::kInvalidShelfID,
1697 launcher_controller_->GetShelfIDForAppID(extension2_->id()));
1698 }
1699
1700 // Check that multiple locks of an application will be properly handled.
1701 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) {
1702 InitLauncherController();
1703 // Model should only contain the browser shortcut and app list items.
1704 EXPECT_EQ(2, model_->item_count()); 1667 EXPECT_EQ(2, model_->item_count());
1705 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1668 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1706 EXPECT_EQ(ash::kInvalidShelfID, 1669 EXPECT_EQ(ash::kInvalidShelfID,
1707 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1670 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1708 1671
1709 for (int i = 0; i < 2; i++) { 1672 // Reporting that the app is running should create a new shelf item.
1710 launcher_controller_->LockV1AppWithID(extension1_->id()); 1673 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1711
1712 EXPECT_EQ(3, model_->item_count());
1713 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1714 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1715 EXPECT_NE(ash::kInvalidShelfID,
1716 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1717 }
1718
1719 launcher_controller_->UnlockV1AppWithID(extension1_->id());
1720
1721 EXPECT_EQ(3, model_->item_count()); 1674 EXPECT_EQ(3, model_->item_count());
1722 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); 1675 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1676 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1723 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1677 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1724 EXPECT_NE(ash::kInvalidShelfID, 1678 EXPECT_NE(ash::kInvalidShelfID,
1725 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1679 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1726 1680
1727 launcher_controller_->UnlockV1AppWithID(extension1_->id()); 1681 // Reporting an active status should just update the existing item.
1682 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_ACTIVE);
1683 EXPECT_EQ(3, model_->item_count());
1684 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[2].status);
1728 1685
1686 // Reporting that the app is closed should remove its shelf item.
1687 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1688 EXPECT_EQ(2, model_->item_count());
1689 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1690 EXPECT_EQ(ash::kInvalidShelfID,
1691 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1692
1693 // Reporting that the app is closed again should have no effect.
1694 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1695 EXPECT_EQ(2, model_->item_count());
1696 }
1697
1698 // Test the V1 app interaction flow: pin it, run it, close it, unpin it.
1699 TEST_F(ChromeLauncherControllerImplTest, V1AppPinRunCloseUnpin) {
1700 InitLauncherController();
1701 // The model should only contain the browser shortcut and app list items.
1702 EXPECT_EQ(2, model_->item_count());
1703 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1704 EXPECT_EQ(ash::kInvalidShelfID,
1705 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1706
1707 // Pinning the app should create a new shelf item.
1708 launcher_controller_->PinAppWithID(extension1_->id());
1709 EXPECT_EQ(3, model_->item_count());
1710 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1711 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1712 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1713 EXPECT_NE(ash::kInvalidShelfID,
1714 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1715
1716 // Reporting that the app is running should just update the existing item.
1717 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1718 EXPECT_EQ(3, model_->item_count());
1719 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1720 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1721 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1722 EXPECT_NE(ash::kInvalidShelfID,
1723 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1724
1725 // Reporting that the app is closed should just update the existing item.
1726 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1727 EXPECT_EQ(3, model_->item_count());
1728 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1729 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1730 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1731 EXPECT_NE(ash::kInvalidShelfID,
1732 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1733
1734 // Unpinning the app should remove its shelf item.
1735 launcher_controller_->UnpinAppWithID(extension1_->id());
1729 EXPECT_EQ(2, model_->item_count()); 1736 EXPECT_EQ(2, model_->item_count());
1730 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1737 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1731 EXPECT_EQ(ash::kInvalidShelfID, 1738 EXPECT_EQ(ash::kInvalidShelfID,
1732 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1739 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1733 } 1740 }
1734 1741
1735 // Check that already pinned items are not effected by locks. 1742 // Test the V1 app interaction flow: run it, pin it, close it, unpin it.
1736 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { 1743 TEST_F(ChromeLauncherControllerImplTest, V1AppRunPinCloseUnpin) {
1737 InitLauncherController(); 1744 InitLauncherController();
1738 // Model should only contain the browser shortcut and app list items. 1745 // The model should only contain the browser shortcut and app list items.
1739 EXPECT_EQ(2, model_->item_count()); 1746 EXPECT_EQ(2, model_->item_count());
1740 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1747 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1741 EXPECT_EQ(ash::kInvalidShelfID, 1748 EXPECT_EQ(ash::kInvalidShelfID,
1742 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1749 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1743 1750
1751 // Reporting that the app is running should create a new shelf item.
1752 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1753 EXPECT_EQ(3, model_->item_count());
1754 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1755 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1756 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1757 EXPECT_NE(ash::kInvalidShelfID,
1758 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1759
1760 // Pinning the app should just update the existing item.
1744 launcher_controller_->PinAppWithID(extension1_->id()); 1761 launcher_controller_->PinAppWithID(extension1_->id());
1745
1746 EXPECT_EQ(3, model_->item_count()); 1762 EXPECT_EQ(3, model_->item_count());
1747 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1763 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1764 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1748 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1765 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1749 EXPECT_NE(ash::kInvalidShelfID, 1766 EXPECT_NE(ash::kInvalidShelfID,
1750 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1767 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1751 1768
1752 launcher_controller_->LockV1AppWithID(extension1_->id()); 1769 // Reporting that the app is closed should just update the existing item.
1753 1770 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1754 EXPECT_EQ(3, model_->item_count()); 1771 EXPECT_EQ(3, model_->item_count());
1755 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1772 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1773 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1756 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1774 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1757 EXPECT_NE(ash::kInvalidShelfID, 1775 EXPECT_NE(ash::kInvalidShelfID,
1758 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1776 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1759 1777
1760 launcher_controller_->UnlockV1AppWithID(extension1_->id()); 1778 // Unpinning the app should remove its shelf item.
1761
1762 EXPECT_EQ(3, model_->item_count());
1763 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1764 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1765 EXPECT_NE(ash::kInvalidShelfID,
1766 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1767
1768 launcher_controller_->UnpinAppWithID(extension1_->id()); 1779 launcher_controller_->UnpinAppWithID(extension1_->id());
1769
1770 EXPECT_EQ(2, model_->item_count()); 1780 EXPECT_EQ(2, model_->item_count());
1771 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1781 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1772 EXPECT_EQ(ash::kInvalidShelfID, 1782 EXPECT_EQ(ash::kInvalidShelfID,
1773 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1783 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1774 } 1784 }
1775 1785
1776 // Check that already pinned items which get locked stay after unpinning. 1786 // Test the V1 app interaction flow: pin it, run it, unpin it, close it.
1777 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { 1787 TEST_F(ChromeLauncherControllerImplTest, V1AppPinRunUnpinClose) {
1778 InitLauncherController(); 1788 InitLauncherController();
1779 // Model should only contain the browser shortcut and app list items. 1789 // The model should only contain the browser shortcut and app list items.
1780 EXPECT_EQ(2, model_->item_count()); 1790 EXPECT_EQ(2, model_->item_count());
1781 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1791 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1782 EXPECT_EQ(ash::kInvalidShelfID, 1792 EXPECT_EQ(ash::kInvalidShelfID,
1783 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1793 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1784 1794
1795 // Pinning the app should create a new shelf item.
1785 launcher_controller_->PinAppWithID(extension1_->id()); 1796 launcher_controller_->PinAppWithID(extension1_->id());
1786
1787 EXPECT_EQ(3, model_->item_count()); 1797 EXPECT_EQ(3, model_->item_count());
1788 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1798 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1799 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1789 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1800 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1790 EXPECT_NE(ash::kInvalidShelfID, 1801 EXPECT_NE(ash::kInvalidShelfID,
1791 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1802 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1792 1803
1793 launcher_controller_->LockV1AppWithID(extension1_->id()); 1804 // Reporting that the app is running should just update the existing item.
1794 1805 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1795 EXPECT_EQ(3, model_->item_count()); 1806 EXPECT_EQ(3, model_->item_count());
1796 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1807 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1808 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1797 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1809 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1798 EXPECT_NE(ash::kInvalidShelfID, 1810 EXPECT_NE(ash::kInvalidShelfID,
1799 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1811 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1800 1812
1813 // Unpinning the app should just update the existing item.
1801 launcher_controller_->UnpinAppWithID(extension1_->id()); 1814 launcher_controller_->UnpinAppWithID(extension1_->id());
1802
1803 EXPECT_EQ(3, model_->item_count()); 1815 EXPECT_EQ(3, model_->item_count());
1804 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); 1816 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1817 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1805 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1818 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1806 EXPECT_NE(ash::kInvalidShelfID, 1819 EXPECT_NE(ash::kInvalidShelfID,
1807 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1820 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1808 1821
1809 launcher_controller_->UnlockV1AppWithID(extension1_->id()); 1822 // Reporting that the app is closed should remove its shelf item.
1810 1823 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1811 EXPECT_EQ(2, model_->item_count()); 1824 EXPECT_EQ(2, model_->item_count());
1812 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1825 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1813 EXPECT_EQ(ash::kInvalidShelfID, 1826 EXPECT_EQ(ash::kInvalidShelfID,
1814 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1827 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
1815 } 1828 }
1816 1829
1817 // Check that running applications wich are not pinned get properly restored 1830 // Ensure unpinned V1 app ordering is properly restored after user changes.
1818 // upon user change. 1831 TEST_F(ChromeLauncherControllerImplTest, CheckRunningV1AppOrder) {
1819 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) {
1820 InitLauncherController(); 1832 InitLauncherController();
1821 // Model should only contain the browser shortcut and app list items. 1833 // The model should only contain the browser shortcut and app list items.
1822 EXPECT_EQ(2, model_->item_count()); 1834 EXPECT_EQ(2, model_->item_count());
1823 1835
1824 // Add a few running applications. 1836 // Add a few running applications.
1825 launcher_controller_->LockV1AppWithID(extension1_->id()); 1837 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1826 launcher_controller_->LockV1AppWithID(extension2_->id()); 1838 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_RUNNING);
1827 launcher_controller_->LockV1AppWithID(extension3_->id()); 1839 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_RUNNING);
1828 EXPECT_EQ(5, model_->item_count()); 1840 EXPECT_EQ(5, model_->item_count());
1829 // Note that this not only checks the order of applications but also the 1841 // Note that this not only checks the order of applications but also the
1830 // running type. 1842 // running type.
1831 EXPECT_EQ("AppList, Chrome, app1, app2, app3", GetPinnedAppStatus()); 1843 EXPECT_EQ("AppList, Chrome, app1, app2, app3", GetPinnedAppStatus());
1832 1844
1833 // Remember the current order of applications for the current user. 1845 // Remember the current order of applications for the current user.
1834 const AccountId& current_account_id = 1846 const AccountId& current_account_id =
1835 multi_user_util::GetAccountIdFromProfile(profile()); 1847 multi_user_util::GetAccountIdFromProfile(profile());
1836 RememberUnpinnedRunningApplicationOrder(); 1848 RememberUnpinnedRunningApplicationOrder();
1837 1849
1838 // Switch some items and check that restoring a user which was not yet 1850 // Switch some items and check that restoring a user which was not yet
1839 // remembered changes nothing. 1851 // remembered changes nothing.
1840 model_->Move(2, 3); 1852 model_->Move(2, 3);
1841 EXPECT_EQ("AppList, Chrome, app2, app1, app3", GetPinnedAppStatus()); 1853 EXPECT_EQ("AppList, Chrome, app2, app1, app3", GetPinnedAppStatus());
1842 const AccountId second_fake_account_id( 1854 const AccountId second_fake_account_id(
1843 AccountId::FromUserEmail("second-fake-user@fake.com")); 1855 AccountId::FromUserEmail("second-fake-user@fake.com"));
1844 RestoreUnpinnedRunningApplicationOrder(second_fake_account_id); 1856 RestoreUnpinnedRunningApplicationOrder(second_fake_account_id);
1845 EXPECT_EQ("AppList, Chrome, app2, app1, app3", GetPinnedAppStatus()); 1857 EXPECT_EQ("AppList, Chrome, app2, app1, app3", GetPinnedAppStatus());
1846 1858
1847 // Restoring the stored user should however do the right thing. 1859 // Restoring the stored user should however do the right thing.
1848 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1860 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1849 EXPECT_EQ("AppList, Chrome, app1, app2, app3", GetPinnedAppStatus()); 1861 EXPECT_EQ("AppList, Chrome, app1, app2, app3", GetPinnedAppStatus());
1850 1862
1851 // Switch again some items and even delete one - making sure that the missing 1863 // Switch again some items and even delete one - making sure that the missing
1852 // item gets properly handled. 1864 // item gets properly handled.
1853 model_->Move(3, 4); 1865 model_->Move(3, 4);
1854 launcher_controller_->UnlockV1AppWithID(extension1_->id()); 1866 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1855 EXPECT_EQ("AppList, Chrome, app3, app2", GetPinnedAppStatus()); 1867 EXPECT_EQ("AppList, Chrome, app3, app2", GetPinnedAppStatus());
1856 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1868 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1857 EXPECT_EQ("AppList, Chrome, app2, app3", GetPinnedAppStatus()); 1869 EXPECT_EQ("AppList, Chrome, app2, app3", GetPinnedAppStatus());
1858 1870
1859 // Check that removing more items does not crash and changes nothing. 1871 // Check that removing more items does not crash and changes nothing.
1860 launcher_controller_->UnlockV1AppWithID(extension2_->id()); 1872 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_CLOSED);
1861 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1873 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1862 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); 1874 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus());
1863 launcher_controller_->UnlockV1AppWithID(extension3_->id()); 1875 launcher_controller_->SetV1AppStatus(extension3_->id(), ash::STATUS_CLOSED);
1864 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1876 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1865 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1877 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1866 } 1878 }
1867 1879
1868 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) { 1880 TEST_P(ChromeLauncherControllerImplWithArcTest, ArcDeferredLaunch) {
1869 RecreateChromeLauncher(); 1881 RecreateChromeLauncher();
1870 1882
1871 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1883 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1872 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1884 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1873 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1885 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 2479
2468 // Transfer the window to another user's desktop and check that activating it 2480 // Transfer the window to another user's desktop and check that activating it
2469 // does pull it back to that user. 2481 // does pull it back to that user.
2470 manager->ShowWindowForUser( 2482 manager->ShowWindowForUser(
2471 window, multi_user_util::GetAccountIdFromProfile(profile2)); 2483 window, multi_user_util::GetAccountIdFromProfile(profile2));
2472 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2484 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user));
2473 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); 2485 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false);
2474 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2486 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user));
2475 } 2487 }
2476 2488
2477 // Check that lock -> pin -> unlock -> unpin does properly transition. 2489 // Check that a running windowed V1 application will be properly pinned and
2478 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { 2490 // unpinned when the order gets changed through a profile / policy change.
2479 InitLauncherController();
2480 // Model should only contain the browser shortcut and app list items.
2481 EXPECT_EQ(2, model_->item_count());
2482 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2483 EXPECT_EQ(ash::kInvalidShelfID,
2484 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
2485
2486 launcher_controller_->LockV1AppWithID(extension1_->id());
2487
2488 EXPECT_EQ(3, model_->item_count());
2489 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
2490 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2491 EXPECT_NE(ash::kInvalidShelfID,
2492 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
2493
2494 launcher_controller_->PinAppWithID(extension1_->id());
2495
2496 EXPECT_EQ(3, model_->item_count());
2497 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
2498 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2499 EXPECT_NE(ash::kInvalidShelfID,
2500 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
2501
2502 launcher_controller_->UnlockV1AppWithID(extension1_->id());
2503
2504 EXPECT_EQ(3, model_->item_count());
2505 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
2506 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
2507 EXPECT_NE(ash::kInvalidShelfID,
2508 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
2509
2510 launcher_controller_->UnpinAppWithID(extension1_->id());
2511
2512 EXPECT_EQ(2, model_->item_count());
2513 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2514 EXPECT_EQ(ash::kInvalidShelfID,
2515 launcher_controller_->GetShelfIDForAppID(extension1_->id()));
2516 }
2517
2518 // Check that a locked (windowed V1 application) will be properly converted
2519 // between locked and pinned when the order gets changed through a profile /
2520 // policy change.
2521 TEST_F(ChromeLauncherControllerImplTest, 2491 TEST_F(ChromeLauncherControllerImplTest,
2522 RestoreDefaultAndLockedAppsResyncOrder) { 2492 RestoreDefaultAndRunningV1AppsResyncOrder) {
2523 InitLauncherController(); 2493 InitLauncherController();
2524 2494
2525 syncer::SyncChangeList sync_list; 2495 syncer::SyncChangeList sync_list;
2526 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2496 InsertAddPinChange(&sync_list, 0, extension1_->id());
2527 InsertAddPinChange(&sync_list, 1, extension3_->id()); 2497 InsertAddPinChange(&sync_list, 1, extension3_->id());
2528 SendPinChanges(sync_list, true); 2498 SendPinChanges(sync_list, true);
2529 2499
2530 // The shelf layout has always one static item at the beginning (App List). 2500 // The shelf layout has always one static item at the beginning (App List).
2531 extension_service_->AddExtension(extension1_.get()); 2501 extension_service_->AddExtension(extension1_.get());
2532 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 2502 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
2533 extension_service_->AddExtension(extension2_.get()); 2503 extension_service_->AddExtension(extension2_.get());
2534 // No new app icon will be generated. 2504 // No new app icon will be generated.
2535 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 2505 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
2536 2506
2537 // Add the app as locked app which will add it (un-pinned). 2507 // Set the app status as running, which will add an unpinned item.
2538 launcher_controller_->LockV1AppWithID(extension2_->id()); 2508 launcher_controller_->SetV1AppStatus(extension2_->id(), ash::STATUS_RUNNING);
2539 EXPECT_EQ("AppList, Chrome, App1, app2", GetPinnedAppStatus()); 2509 EXPECT_EQ("AppList, Chrome, App1, app2", GetPinnedAppStatus());
2540 extension_service_->AddExtension(extension3_.get()); 2510 extension_service_->AddExtension(extension3_.get());
2541 EXPECT_EQ("AppList, Chrome, App1, App3, app2", GetPinnedAppStatus()); 2511 EXPECT_EQ("AppList, Chrome, App1, App3, app2", GetPinnedAppStatus());
2542 2512
2543 // Now request to pin all items which should convert the locked item into a 2513 // Now request to pin all items, which will pin the running unpinned items.
2544 // pinned item.
2545 syncer::SyncChangeList sync_list1; 2514 syncer::SyncChangeList sync_list1;
2546 InsertAddPinChange(&sync_list1, 0, extension3_->id()); 2515 InsertAddPinChange(&sync_list1, 0, extension3_->id());
2547 InsertAddPinChange(&sync_list1, 1, extension2_->id()); 2516 InsertAddPinChange(&sync_list1, 1, extension2_->id());
2548 InsertAddPinChange(&sync_list1, 2, extension1_->id()); 2517 InsertAddPinChange(&sync_list1, 2, extension1_->id());
2549 SendPinChanges(sync_list1, true); 2518 SendPinChanges(sync_list1, true);
2550 EXPECT_EQ("AppList, Chrome, App3, App2, App1", GetPinnedAppStatus()); 2519 EXPECT_EQ("AppList, Chrome, App3, App2, App1", GetPinnedAppStatus());
2551 2520
2552 // Going back to a status where there is no requirement for app 2 to be pinned 2521 // Removing the requirement for app 2 to be pinned should convert it back to
2553 // should convert it back to locked but not pinned and state. The position 2522 // running but not pinned. It should move towards the end of the shelf, after
2554 // is determined by the |ShelfModel|'s weight system and since running 2523 // the pinned items, as determined by the |ShelfModel|'s weight system.
2555 // applications are not allowed to be mixed with shortcuts, it should show up
2556 // at the end of the list.
2557 syncer::SyncChangeList sync_list2; 2524 syncer::SyncChangeList sync_list2;
2558 InsertAddPinChange(&sync_list2, 0, extension3_->id()); 2525 InsertAddPinChange(&sync_list2, 0, extension3_->id());
2559 InsertAddPinChange(&sync_list2, 1, extension1_->id()); 2526 InsertAddPinChange(&sync_list2, 1, extension1_->id());
2560 SendPinChanges(sync_list2, true); 2527 SendPinChanges(sync_list2, true);
2561 EXPECT_EQ("AppList, Chrome, App3, App1, app2", GetPinnedAppStatus()); 2528 EXPECT_EQ("AppList, Chrome, App3, App1, app2", GetPinnedAppStatus());
2562 2529
2563 // Removing an item should simply close it and everything should shift. 2530 // Removing an item should simply close it and everything should shift.
2564 SendPinChanges(syncer::SyncChangeList(), true); 2531 SendPinChanges(syncer::SyncChangeList(), true);
2565 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus()); 2532 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus());
2566 } 2533 }
2567 2534
2568 // Check that a running and not pinned V2 application will be properly converted 2535 // Check that a running unpinned V2 application will be properly pinned and
2569 // between locked and pinned when the order gets changed through a profile / 2536 // unpinned when the order gets changed through a profile / policy change.
2570 // policy change.
2571 TEST_F(ChromeLauncherControllerImplTest, 2537 TEST_F(ChromeLauncherControllerImplTest,
2572 RestoreDefaultAndRunningV2AppsResyncOrder) { 2538 RestoreDefaultAndRunningV2AppsResyncOrder) {
2573 InitLauncherController(); 2539 InitLauncherController();
2574 syncer::SyncChangeList sync_list0; 2540 syncer::SyncChangeList sync_list0;
2575 InsertAddPinChange(&sync_list0, 0, extension1_->id()); 2541 InsertAddPinChange(&sync_list0, 0, extension1_->id());
2576 InsertAddPinChange(&sync_list0, 1, extension3_->id()); 2542 InsertAddPinChange(&sync_list0, 1, extension3_->id());
2577 SendPinChanges(sync_list0, true); 2543 SendPinChanges(sync_list0, true);
2578 // The shelf layout has always one static item at the beginning (app List). 2544 // The shelf layout has always one static item at the beginning (app List).
2579 extension_service_->AddExtension(extension1_.get()); 2545 extension_service_->AddExtension(extension1_.get());
2580 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 2546 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
2581 extension_service_->AddExtension(extension_platform_app_.get()); 2547 extension_service_->AddExtension(extension_platform_app_.get());
2582 // No new app icon will be generated. 2548 // No new app icon will be generated.
2583 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 2549 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
2584 // Add an unpinned but running V2 app. 2550 // Add an unpinned but running V2 app.
2585 CreateRunningV2App(extension_platform_app_->id()); 2551 CreateRunningV2App(extension_platform_app_->id());
2586 EXPECT_EQ("AppList, Chrome, App1, *platform_app", GetPinnedAppStatus()); 2552 EXPECT_EQ("AppList, Chrome, App1, *platform_app", GetPinnedAppStatus());
2587 extension_service_->AddExtension(extension3_.get()); 2553 extension_service_->AddExtension(extension3_.get());
2588 EXPECT_EQ("AppList, Chrome, App1, App3, *platform_app", GetPinnedAppStatus()); 2554 EXPECT_EQ("AppList, Chrome, App1, App3, *platform_app", GetPinnedAppStatus());
2589 2555
2590 // Now request to pin all items which should convert the locked item into a 2556 // Now request to pin all items, which should pin the running unpinned item.
2591 // pinned item.
2592 syncer::SyncChangeList sync_list1; 2557 syncer::SyncChangeList sync_list1;
2593 InsertAddPinChange(&sync_list1, 0, extension3_->id()); 2558 InsertAddPinChange(&sync_list1, 0, extension3_->id());
2594 InsertAddPinChange(&sync_list1, 1, extension_platform_app_->id()); 2559 InsertAddPinChange(&sync_list1, 1, extension_platform_app_->id());
2595 InsertAddPinChange(&sync_list1, 2, extension1_->id()); 2560 InsertAddPinChange(&sync_list1, 2, extension1_->id());
2596 SendPinChanges(sync_list1, true); 2561 SendPinChanges(sync_list1, true);
2597 EXPECT_EQ("AppList, Chrome, App3, *Platform_App, App1", GetPinnedAppStatus()); 2562 EXPECT_EQ("AppList, Chrome, App3, *Platform_App, App1", GetPinnedAppStatus());
2598 2563
2599 // Going back to a status where there is no requirement for the V2 app to be 2564 // Removing the requirement for app 2 to be pinned should convert it back to
2600 // pinned should convert it back to running V2 app. Since the position is 2565 // running but not pinned. It should move towards the end of the shelf, after
2601 // determined by the |ShelfModel|'s weight system, it will be after last 2566 // the pinned items, as determined by the |ShelfModel|'s weight system.
2602 // pinned item.
2603 syncer::SyncChangeList sync_list2; 2567 syncer::SyncChangeList sync_list2;
2604 InsertAddPinChange(&sync_list2, 0, extension3_->id()); 2568 InsertAddPinChange(&sync_list2, 0, extension3_->id());
2605 InsertAddPinChange(&sync_list2, 1, extension1_->id()); 2569 InsertAddPinChange(&sync_list2, 1, extension1_->id());
2606 SendPinChanges(sync_list2, true); 2570 SendPinChanges(sync_list2, true);
2607 EXPECT_EQ("AppList, Chrome, App3, App1, *platform_app", GetPinnedAppStatus()); 2571 EXPECT_EQ("AppList, Chrome, App3, App1, *platform_app", GetPinnedAppStatus());
2608 2572
2609 // Removing an item should simply close it and everything should shift. 2573 // Removing an item should simply close it and everything should shift.
2610 syncer::SyncChangeList sync_list3; 2574 syncer::SyncChangeList sync_list3;
2611 InsertAddPinChange(&sync_list3, 0, extension3_->id()); 2575 InsertAddPinChange(&sync_list3, 0, extension3_->id());
2612 SendPinChanges(sync_list3, true); 2576 SendPinChanges(sync_list3, true);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 // Check that V1 apps are correctly reflected in the launcher menu using the 2973 // Check that V1 apps are correctly reflected in the launcher menu using the
3010 // refocus logic. 2974 // refocus logic.
3011 // Note that the extension matching logic is tested by the extension system 2975 // Note that the extension matching logic is tested by the extension system
3012 // and does not need a separate test here. 2976 // and does not need a separate test here.
3013 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) { 2977 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) {
3014 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2978 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
3015 EXPECT_EQ(0, browser()->tab_strip_model()->count()); 2979 EXPECT_EQ(0, browser()->tab_strip_model()->count());
3016 2980
3017 InitLauncherControllerWithBrowser(); 2981 InitLauncherControllerWithBrowser();
3018 2982
3019 // Model should only contain the browser shortcut and app list items. 2983 // The model should only contain the browser shortcut and app list items.
3020 EXPECT_EQ(2, model_->item_count()); 2984 EXPECT_EQ(2, model_->item_count());
3021 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2985 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
3022 2986
3023 // Installing |extension3_| adds it to the launcher. 2987 // Installing |extension3_| adds it to the launcher.
3024 ash::ShelfID gmail_id = model_->next_id(); 2988 ash::ShelfID gmail_id = model_->next_id();
3025 extension_service_->AddExtension(extension3_.get()); 2989 extension_service_->AddExtension(extension3_.get());
3026 EXPECT_EQ(3, model_->item_count()); 2990 EXPECT_EQ(3, model_->item_count());
3027 int gmail_index = model_->ItemIndexByID(gmail_id); 2991 int gmail_index = model_->ItemIndexByID(gmail_id);
3028 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 2992 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3029 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 2993 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4431 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4395 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4432 shelf_controller->auto_hide()); 4396 shelf_controller->auto_hide());
4433 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4397 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4434 4398
4435 PrefService* prefs = profile()->GetTestingPrefService(); 4399 PrefService* prefs = profile()->GetTestingPrefService();
4436 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4400 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4437 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4401 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4438 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4402 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4439 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4403 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4440 } 4404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698