Chromium Code Reviews| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 manifest, Extension::NO_FLAGS, | 404 manifest, Extension::NO_FLAGS, |
| 405 ArcSupportHost::kHostAppId, &error); | 405 ArcSupportHost::kHostAppId, &error); |
| 406 } | 406 } |
| 407 | 407 |
| 408 // Creates a running V2 app (not pinned) of type |app_id|. | 408 // Creates a running V2 app (not pinned) of type |app_id|. |
| 409 virtual void CreateRunningV2App(const std::string& app_id) { | 409 virtual void CreateRunningV2App(const std::string& app_id) { |
| 410 DCHECK(!test_controller_); | 410 DCHECK(!test_controller_); |
| 411 ash::ShelfID id = | 411 ash::ShelfID id = |
| 412 launcher_controller_->CreateAppShortcutLauncherItemWithType( | 412 launcher_controller_->CreateAppShortcutLauncherItemWithType( |
| 413 ash::launcher::AppLauncherId(app_id), model_->item_count(), | 413 ash::launcher::AppLauncherId(app_id), model_->item_count(), |
| 414 ash::TYPE_PLATFORM_APP); | 414 ash::TYPE_APP); |
| 415 DCHECK(id); | 415 DCHECK(id); |
| 416 // Change the created launcher controller into a V2 app controller. | 416 // Change the created launcher controller into a V2 app controller. |
| 417 test_controller_ = new TestV2AppLauncherItemController(app_id, | 417 test_controller_ = new TestV2AppLauncherItemController(app_id, |
| 418 launcher_controller_.get()); | 418 launcher_controller_.get()); |
| 419 launcher_controller_->SetItemController(id, test_controller_); | 419 launcher_controller_->SetItemController(id, test_controller_); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Sets the stage for a multi user test. | 422 // Sets the stage for a multi user test. |
| 423 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, | 423 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, |
| 424 syncer::SyncChangeList* user_b) { | 424 syncer::SyncChangeList* user_b) { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 // Get the setup of the currently shown launcher items in one string. | 676 // Get the setup of the currently shown launcher items in one string. |
| 677 // Each pinned element will start with a big letter, each running but not | 677 // Each pinned element will start with a big letter, each running but not |
| 678 // pinned V1 app will start with a small letter and each running but not | 678 // pinned V1 app will start with a small letter and each running but not |
| 679 // pinned V2 app will start with a '*' + small letter. | 679 // pinned V2 app will start with a '*' + small letter. |
| 680 std::string GetPinnedAppStatus() { | 680 std::string GetPinnedAppStatus() { |
| 681 std::string result; | 681 std::string result; |
| 682 for (int i = 0; i < model_->item_count(); i++) { | 682 for (int i = 0; i < model_->item_count(); i++) { |
| 683 if (!result.empty()) | 683 if (!result.empty()) |
| 684 result.append(", "); | 684 result.append(", "); |
| 685 switch (model_->items()[i].type) { | 685 switch (model_->items()[i].type) { |
| 686 case ash::TYPE_PLATFORM_APP: | 686 case ash::TYPE_APP: { |
| 687 result += "*"; | 687 if (controller()->IsPlatformApp(item().id)) |
| 688 // FALLTHROUGH | 688 result += "*"; |
| 689 case ash::TYPE_WINDOWED_APP: { | |
| 690 const std::string& app = | 689 const std::string& app = |
| 691 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | 690 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); |
| 692 if (app == extension1_->id()) { | 691 EXPECT_FALSE(launcher_controller_->IsAppPinned(app)); |
| 693 result += "app1"; | 692 if (app == extension1_->id()) { |
| 694 EXPECT_FALSE( | 693 result += "app1"; |
| 695 launcher_controller_->IsAppPinned(extension1_->id())); | 694 } else if (app == extension2_->id()) { |
| 696 } else if (app == extension2_->id()) { | 695 result += "app2"; |
| 697 result += "app2"; | 696 } else if (app == extension3_->id()) { |
| 698 EXPECT_FALSE( | 697 result += "app3"; |
| 699 launcher_controller_->IsAppPinned(extension2_->id())); | 698 } else if (app == extension4_->id()) { |
| 700 } else if (app == extension3_->id()) { | 699 result += "app4"; |
| 701 result += "app3"; | 700 } else if (app == extension5_->id()) { |
| 702 EXPECT_FALSE( | 701 result += "app5"; |
| 703 launcher_controller_->IsAppPinned(extension3_->id())); | 702 } else if (app == extension6_->id()) { |
| 704 } else if (app == extension4_->id()) { | 703 result += "app6"; |
| 705 result += "app4"; | 704 } else if (app == extension7_->id()) { |
| 706 EXPECT_FALSE( | 705 result += "app7"; |
| 707 launcher_controller_->IsAppPinned(extension4_->id())); | 706 } else if (app == extension8_->id()) { |
| 708 } else if (app == extension5_->id()) { | 707 result += "app8"; |
| 709 result += "app5"; | 708 } else { |
| 710 EXPECT_FALSE( | 709 result += "unknown"; |
| 711 launcher_controller_->IsAppPinned(extension5_->id())); | |
| 712 } else if (app == extension6_->id()) { | |
| 713 result += "app6"; | |
| 714 EXPECT_FALSE( | |
| 715 launcher_controller_->IsAppPinned(extension6_->id())); | |
| 716 } else if (app == extension7_->id()) { | |
| 717 result += "app7"; | |
| 718 EXPECT_FALSE( | |
| 719 launcher_controller_->IsAppPinned(extension7_->id())); | |
| 720 } else if (app == extension8_->id()) { | |
| 721 result += "app8"; | |
| 722 EXPECT_FALSE( | |
| 723 launcher_controller_->IsAppPinned(extension8_->id())); | |
| 724 } else { | |
| 725 result += "unknown"; | |
| 726 } | |
| 727 break; | |
| 728 } | 710 } |
| 711 break; | |
| 712 } | |
| 729 case ash::TYPE_APP_SHORTCUT: { | 713 case ash::TYPE_APP_SHORTCUT: { |
| 730 const std::string& app = | 714 const std::string& app = |
| 731 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | 715 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); |
| 732 if (app == extension1_->id()) { | 716 EXPECT_TRUE(launcher_controller_->IsAppPinned(app)); |
| 733 result += "App1"; | 717 if (app == extension1_->id()) { |
| 734 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 718 result += "App1"; |
| 735 } else if (app == extension2_->id()) { | 719 } else if (app == extension2_->id()) { |
| 736 result += "App2"; | 720 result += "App2"; |
| 737 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 721 } else if (app == extension3_->id()) { |
| 738 } else if (app == extension3_->id()) { | 722 result += "App3"; |
| 739 result += "App3"; | 723 } else if (app == extension4_->id()) { |
| 740 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 724 result += "App4"; |
| 741 } else if (app == extension4_->id()) { | 725 } else if (app == extension5_->id()) { |
| 742 result += "App4"; | 726 result += "App5"; |
| 743 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); | 727 } else if (app == extension6_->id()) { |
| 744 } else if (app == extension5_->id()) { | 728 result += "App6"; |
| 745 result += "App5"; | 729 } else if (app == extension7_->id()) { |
| 746 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension5_->id())); | 730 result += "App7"; |
| 747 } else if (app == extension6_->id()) { | 731 } else if (app == extension8_->id()) { |
| 748 result += "App6"; | 732 result += "App8"; |
| 749 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension6_->id())); | 733 } else if (app == arc_support_host_->id()) { |
| 750 } else if (app == extension7_->id()) { | 734 result += "Play Store"; |
| 751 result += "App7"; | 735 } else { |
| 752 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension7_->id())); | 736 bool arc_app_found = false; |
| 753 } else if (app == extension8_->id()) { | 737 for (const auto& arc_app : arc_test_.fake_apps()) { |
| 754 result += "App8"; | 738 if (app == ArcAppTest::GetAppId(arc_app)) { |
| 755 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension8_->id())); | 739 result += arc_app.name; |
| 756 } else if (app == arc_support_host_->id()) { | 740 arc_app_found = true; |
| 757 result += "Play Store"; | 741 break; |
| 758 EXPECT_TRUE( | |
| 759 launcher_controller_->IsAppPinned(arc_support_host_->id())); | |
| 760 } else { | |
| 761 bool arc_app_found = false; | |
| 762 for (const auto& arc_app : arc_test_.fake_apps()) { | |
| 763 if (app == ArcAppTest::GetAppId(arc_app)) { | |
| 764 result += arc_app.name; | |
| 765 arc_app_found = true; | |
| 766 break; | |
| 767 } | |
| 768 } | 742 } |
| 769 if (!arc_app_found) | |
| 770 result += "unknown"; | |
| 771 } | 743 } |
| 772 break; | 744 if (!arc_app_found) |
| 745 result += "unknown"; | |
| 773 } | 746 } |
| 747 break; | |
| 748 } | |
| 774 case ash::TYPE_BROWSER_SHORTCUT: | 749 case ash::TYPE_BROWSER_SHORTCUT: |
| 775 result += "Chrome"; | 750 result += "Chrome"; |
| 776 break; | 751 break; |
| 777 case ash::TYPE_APP_LIST: | 752 case ash::TYPE_APP_LIST: |
| 778 result += "AppList"; | 753 result += "AppList"; |
| 779 break; | 754 break; |
| 780 default: | 755 default: |
| 781 result += "Unknown"; | 756 result += "Unknown"; |
| 782 break; | 757 break; |
| 783 } | 758 } |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1571 UnloadedExtensionInfo::REASON_UPDATE); | 1546 UnloadedExtensionInfo::REASON_UPDATE); |
| 1572 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1547 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 1573 } | 1548 } |
| 1574 | 1549 |
| 1575 // Check that simple locking of an application will 'create' a launcher item. | 1550 // Check that simple locking of an application will 'create' a launcher item. |
| 1576 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { | 1551 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { |
| 1577 InitLauncherController(); | 1552 InitLauncherController(); |
| 1578 // Model should only contain the browser shortcut and app list items. | 1553 // Model should only contain the browser shortcut and app list items. |
| 1579 EXPECT_EQ(2, model_->item_count()); | 1554 EXPECT_EQ(2, model_->item_count()); |
| 1580 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1555 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1581 EXPECT_FALSE( | 1556 EXPECT_EQ(ash::kInvalidShelfID, GetShelfIDForAppID(extension1_->id())); |
| 1582 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1557 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1584 EXPECT_FALSE( | 1558 EXPECT_EQ(ash::kInvalidShelfID, GetShelfIDForAppID(extension2_->id())); |
| 1585 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | |
| 1586 | 1559 |
| 1587 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1560 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1588 | 1561 |
| 1589 EXPECT_EQ(3, model_->item_count()); | 1562 EXPECT_EQ(3, model_->item_count()); |
| 1590 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1563 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1591 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1564 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1592 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1565 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1593 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1566 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1594 EXPECT_FALSE( | 1567 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1595 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | |
| 1596 | 1568 |
| 1597 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1569 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1598 | 1570 |
| 1599 EXPECT_EQ(2, model_->item_count()); | 1571 EXPECT_EQ(2, model_->item_count()); |
| 1600 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1572 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1601 EXPECT_FALSE( | 1573 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1602 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1603 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1574 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1604 EXPECT_FALSE( | 1575 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1605 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | |
| 1606 } | 1576 } |
| 1607 | 1577 |
| 1608 // Check that multiple locks of an application will be properly handled. | 1578 // Check that multiple locks of an application will be properly handled. |
| 1609 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) { | 1579 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) { |
| 1610 InitLauncherController(); | 1580 InitLauncherController(); |
| 1611 // Model should only contain the browser shortcut and app list items. | 1581 // Model should only contain the browser shortcut and app list items. |
| 1612 EXPECT_EQ(2, model_->item_count()); | 1582 EXPECT_EQ(2, model_->item_count()); |
| 1613 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1614 EXPECT_FALSE( | 1584 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1615 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1616 | 1585 |
| 1617 for (int i = 0; i < 2; i++) { | 1586 for (int i = 0; i < 2; i++) { |
| 1618 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1587 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1619 | 1588 |
| 1620 EXPECT_EQ(3, model_->item_count()); | 1589 EXPECT_EQ(3, model_->item_count()); |
| 1621 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1590 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1622 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1591 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1623 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( | 1592 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1624 extension1_->id())); | |
| 1625 } | 1593 } |
| 1626 | 1594 |
| 1627 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1595 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1628 | 1596 |
| 1629 EXPECT_EQ(3, model_->item_count()); | 1597 EXPECT_EQ(3, model_->item_count()); |
| 1630 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1598 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1631 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1599 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1632 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1600 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1633 | 1601 |
| 1634 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1602 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1635 | 1603 |
| 1636 EXPECT_EQ(2, model_->item_count()); | 1604 EXPECT_EQ(2, model_->item_count()); |
| 1637 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1605 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1638 EXPECT_FALSE( | 1606 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1639 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1640 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | |
| 1641 EXPECT_FALSE( | |
| 1642 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1643 } | 1607 } |
| 1644 | 1608 |
| 1645 // Check that already pinned items are not effected by locks. | 1609 // Check that already pinned items are not effected by locks. |
| 1646 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { | 1610 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { |
| 1647 InitLauncherController(); | 1611 InitLauncherController(); |
| 1648 // Model should only contain the browser shortcut and app list items. | 1612 // Model should only contain the browser shortcut and app list items. |
| 1649 EXPECT_EQ(2, model_->item_count()); | 1613 EXPECT_EQ(2, model_->item_count()); |
| 1650 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1614 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1651 EXPECT_FALSE( | 1615 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1652 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1653 | 1616 |
| 1654 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1655 launcher_controller_->PinAppWithID(extension1_->id()); | 1617 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1656 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | |
|
Mr4D (OOO till 08-26)
2016/11/23 23:11:51
Hmmm. Why did you remove this test? After pinning
msw
2016/11/24 00:00:55
This is redundant with line 1621, right?
Mr4D (OOO till 08-26)
2016/11/24 02:21:33
Yes. There it is. Never mind.
| |
| 1657 | 1618 |
| 1658 EXPECT_EQ(3, model_->item_count()); | 1619 EXPECT_EQ(3, model_->item_count()); |
| 1659 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1620 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1660 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1621 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1661 EXPECT_FALSE( | 1622 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1662 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1663 | 1623 |
| 1664 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1624 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1665 | 1625 |
| 1666 EXPECT_EQ(3, model_->item_count()); | 1626 EXPECT_EQ(3, model_->item_count()); |
| 1667 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1627 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1668 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1628 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1669 EXPECT_FALSE( | 1629 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1670 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1671 | 1630 |
| 1672 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1631 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1673 | 1632 |
| 1674 EXPECT_EQ(3, model_->item_count()); | 1633 EXPECT_EQ(3, model_->item_count()); |
| 1675 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1634 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1676 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1635 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1677 EXPECT_FALSE( | 1636 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1678 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1679 | 1637 |
| 1680 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1638 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1681 | 1639 |
| 1682 EXPECT_EQ(2, model_->item_count()); | 1640 EXPECT_EQ(2, model_->item_count()); |
| 1641 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
|
Mr4D (OOO till 08-26)
2016/11/23 23:11:51
Note: that you also test for not being pinned afte
msw
2016/11/24 00:00:55
Would you like me to add a comment here, like "Ens
Mr4D (OOO till 08-26)
2016/11/24 02:21:33
No need, that was meant for the comment above whic
| |
| 1642 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); | |
| 1683 } | 1643 } |
| 1684 | 1644 |
| 1685 // Check that already pinned items which get locked stay after unpinning. | 1645 // Check that already pinned items which get locked stay after unpinning. |
| 1686 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { | 1646 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { |
| 1687 InitLauncherController(); | 1647 InitLauncherController(); |
| 1688 // Model should only contain the browser shortcut and app list items. | 1648 // Model should only contain the browser shortcut and app list items. |
| 1689 EXPECT_EQ(2, model_->item_count()); | 1649 EXPECT_EQ(2, model_->item_count()); |
| 1690 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1650 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1691 EXPECT_FALSE( | 1651 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1692 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1693 | 1652 |
| 1694 launcher_controller_->PinAppWithID(extension1_->id()); | 1653 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1695 | 1654 |
| 1696 EXPECT_EQ(3, model_->item_count()); | 1655 EXPECT_EQ(3, model_->item_count()); |
| 1697 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1656 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1698 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1657 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1699 EXPECT_FALSE( | 1658 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1700 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1701 | 1659 |
| 1702 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1660 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1703 | 1661 |
| 1704 EXPECT_EQ(3, model_->item_count()); | 1662 EXPECT_EQ(3, model_->item_count()); |
| 1705 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1663 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1706 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1664 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1707 EXPECT_FALSE( | 1665 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1708 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1709 | 1666 |
| 1710 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1667 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1711 | 1668 |
| 1712 EXPECT_EQ(3, model_->item_count()); | 1669 EXPECT_EQ(3, model_->item_count()); |
| 1713 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1670 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1714 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1671 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1715 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1672 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1716 | 1673 |
| 1717 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1674 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1718 | 1675 |
| 1719 EXPECT_EQ(2, model_->item_count()); | 1676 EXPECT_EQ(2, model_->item_count()); |
| 1677 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1678 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); | |
| 1720 } | 1679 } |
| 1721 | 1680 |
| 1722 // Check that running applications wich are not pinned get properly restored | 1681 // Check that running applications wich are not pinned get properly restored |
| 1723 // upon user change. | 1682 // upon user change. |
| 1724 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) { | 1683 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) { |
| 1725 InitLauncherController(); | 1684 InitLauncherController(); |
| 1726 // Model should only contain the browser shortcut and app list items. | 1685 // Model should only contain the browser shortcut and app list items. |
| 1727 EXPECT_EQ(2, model_->item_count()); | 1686 EXPECT_EQ(2, model_->item_count()); |
| 1728 | 1687 |
| 1729 // Add a few running applications. | 1688 // Add a few running applications. |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2274 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); | 2233 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); |
| 2275 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 2234 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 2276 } | 2235 } |
| 2277 | 2236 |
| 2278 // Check that lock -> pin -> unlock -> unpin does properly transition. | 2237 // Check that lock -> pin -> unlock -> unpin does properly transition. |
| 2279 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { | 2238 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { |
| 2280 InitLauncherController(); | 2239 InitLauncherController(); |
| 2281 // Model should only contain the browser shortcut and app list items. | 2240 // Model should only contain the browser shortcut and app list items. |
| 2282 EXPECT_EQ(2, model_->item_count()); | 2241 EXPECT_EQ(2, model_->item_count()); |
| 2283 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2242 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2284 EXPECT_FALSE( | 2243 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2285 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 2286 | 2244 |
| 2287 launcher_controller_->LockV1AppWithID(extension1_->id()); | 2245 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 2288 | 2246 |
| 2289 EXPECT_EQ(3, model_->item_count()); | 2247 EXPECT_EQ(3, model_->item_count()); |
| 2290 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 2248 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 2291 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2249 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2292 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 2250 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2293 | 2251 |
| 2294 launcher_controller_->PinAppWithID(extension1_->id()); | 2252 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2295 | 2253 |
| 2296 EXPECT_EQ(3, model_->item_count()); | 2254 EXPECT_EQ(3, model_->item_count()); |
| 2297 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2255 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2298 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2256 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2299 EXPECT_FALSE( | 2257 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2300 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 2301 | 2258 |
| 2302 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 2259 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 2303 | 2260 |
| 2304 EXPECT_EQ(3, model_->item_count()); | 2261 EXPECT_EQ(3, model_->item_count()); |
| 2305 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2262 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2306 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2263 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2307 EXPECT_FALSE( | 2264 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2308 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 2309 | 2265 |
| 2310 launcher_controller_->UnpinAppWithID(extension1_->id()); | 2266 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 2311 | 2267 |
| 2312 EXPECT_EQ(2, model_->item_count()); | 2268 EXPECT_EQ(2, model_->item_count()); |
| 2269 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 2270 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); | |
| 2313 } | 2271 } |
| 2314 | 2272 |
| 2315 // Check that a locked (windowed V1 application) will be properly converted | 2273 // Check that a locked (windowed V1 application) will be properly converted |
| 2316 // between locked and pinned when the order gets changed through a profile / | 2274 // between locked and pinned when the order gets changed through a profile / |
| 2317 // policy change. | 2275 // policy change. |
| 2318 TEST_F(ChromeLauncherControllerImplTest, | 2276 TEST_F(ChromeLauncherControllerImplTest, |
| 2319 RestoreDefaultAndLockedAppsResyncOrder) { | 2277 RestoreDefaultAndLockedAppsResyncOrder) { |
| 2320 InitLauncherController(); | 2278 InitLauncherController(); |
| 2321 | 2279 |
| 2322 syncer::SyncChangeList sync_list; | 2280 syncer::SyncChangeList sync_list; |
| (...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4030 | 3988 |
| 4031 // Pinned state should not change. | 3989 // Pinned state should not change. |
| 4032 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 3990 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4033 launcher_controller_->UnpinAppWithID(extension2_->id()); | 3991 launcher_controller_->UnpinAppWithID(extension2_->id()); |
| 4034 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 3992 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 4035 | 3993 |
| 4036 // Resume syncing and sync information overrides local copy. | 3994 // Resume syncing and sync information overrides local copy. |
| 4037 StartAppSyncService(copy_sync_list); | 3995 StartAppSyncService(copy_sync_list); |
| 4038 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 3996 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4039 } | 3997 } |
| OLD | NEW |