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

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

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Restore AppLaunchId class via using ShelfID = AppLaunchId; cleanup. Created 3 years, 7 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.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.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>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "ash/display/display_configuration_controller.h" 17 #include "ash/display/display_configuration_controller.h"
18 #include "ash/display/screen_orientation_controller_chromeos.h" 18 #include "ash/display/screen_orientation_controller_chromeos.h"
19 #include "ash/public/cpp/app_launch_id.h"
20 #include "ash/public/cpp/shelf_item.h" 19 #include "ash/public/cpp/shelf_item.h"
21 #include "ash/public/cpp/shelf_item_delegate.h" 20 #include "ash/public/cpp/shelf_item_delegate.h"
22 #include "ash/shelf/shelf_application_menu_model.h" 21 #include "ash/shelf/shelf_application_menu_model.h"
23 #include "ash/shelf/shelf_constants.h" 22 #include "ash/shelf/shelf_constants.h"
24 #include "ash/shelf/shelf_controller.h" 23 #include "ash/shelf/shelf_controller.h"
25 #include "ash/shelf/shelf_model.h" 24 #include "ash/shelf/shelf_model.h"
26 #include "ash/shelf/shelf_model_observer.h" 25 #include "ash/shelf/shelf_model_observer.h"
27 #include "ash/shell.h" 26 #include "ash/shell.h"
28 #include "ash/test/ash_test_helper.h" 27 #include "ash/test/ash_test_helper.h"
29 #include "ash/test/shell_test_api.h" 28 #include "ash/test/shell_test_api.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 247
249 TabToStringMap tab_id_map_; 248 TabToStringMap tab_id_map_;
250 249
251 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); 250 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper);
252 }; 251 };
253 252
254 // Test implementation of a V2 app launcher item controller. 253 // Test implementation of a V2 app launcher item controller.
255 class TestV2AppLauncherItemController : public ash::ShelfItemDelegate { 254 class TestV2AppLauncherItemController : public ash::ShelfItemDelegate {
256 public: 255 public:
257 explicit TestV2AppLauncherItemController(const std::string& app_id) 256 explicit TestV2AppLauncherItemController(const std::string& app_id)
258 : ash::ShelfItemDelegate(ash::AppLaunchId(app_id)) {} 257 : ash::ShelfItemDelegate(ash::ShelfID(app_id)) {}
259 258
260 ~TestV2AppLauncherItemController() override {} 259 ~TestV2AppLauncherItemController() override {}
261 260
262 // Override for ash::ShelfItemDelegate: 261 // Override for ash::ShelfItemDelegate:
263 void ItemSelected(std::unique_ptr<ui::Event> event, 262 void ItemSelected(std::unique_ptr<ui::Event> event,
264 int64_t display_id, 263 int64_t display_id,
265 ash::ShelfLaunchSource source, 264 ash::ShelfLaunchSource source,
266 const ItemSelectedCallback& callback) override { 265 const ItemSelectedCallback& callback) override {
267 callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt); 266 callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt);
268 } 267 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile( 588 std::unique_ptr<Browser> CreateBrowserWithTestWindowForProfile(
590 Profile* profile) { 589 Profile* profile) {
591 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura(); 590 TestBrowserWindow* browser_window = CreateTestBrowserWindowAura();
592 new TestBrowserWindowOwner(browser_window); 591 new TestBrowserWindowOwner(browser_window);
593 return base::WrapUnique( 592 return base::WrapUnique(
594 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window)); 593 CreateBrowser(profile, Browser::TYPE_TABBED, false, browser_window));
595 } 594 }
596 595
597 void AddAppListLauncherItem() { 596 void AddAppListLauncherItem() {
598 ash::ShelfItem app_list; 597 ash::ShelfItem app_list;
598 app_list.id = ash::ShelfID("AppList");
James Cook 2017/05/04 16:38:49 ditto
msw 2017/05/04 19:05:58 Done.
599 app_list.type = ash::TYPE_APP_LIST; 599 app_list.type = ash::TYPE_APP_LIST;
600 model_->Add(app_list); 600 model_->Add(app_list);
601 } 601 }
602 602
603 // Create a launcher controller instance, owned by the test shell delegate. 603 // Create a launcher controller instance, owned by the test shell delegate.
604 // Returns a pointer to the uninitialized controller. 604 // Returns a pointer to the uninitialized controller.
605 ChromeLauncherController* CreateLauncherController() { 605 ChromeLauncherController* CreateLauncherController() {
606 launcher_controller_ = shell_delegate_->CreateLauncherController(profile()); 606 launcher_controller_ = shell_delegate_->CreateLauncherController(profile());
607 return launcher_controller_; 607 return launcher_controller_;
608 } 608 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 FROM_HERE, syncer::SyncChange::ACTION_UPDATE, sync_data)); 820 FROM_HERE, syncer::SyncChange::ACTION_UPDATE, sync_data));
821 app_service_->ProcessSyncChanges(FROM_HERE, sync_list); 821 app_service_->ProcessSyncChanges(FROM_HERE, sync_list);
822 } 822 }
823 823
824 // Gets the IDs of the currently pinned app items. 824 // Gets the IDs of the currently pinned app items.
825 void GetPinnedAppIds(ChromeLauncherController* controller, 825 void GetPinnedAppIds(ChromeLauncherController* controller,
826 std::vector<std::string>* app_ids) { 826 std::vector<std::string>* app_ids) {
827 app_ids->clear(); 827 app_ids->clear();
828 for (const auto& item : model_->items()) { 828 for (const auto& item : model_->items()) {
829 if (item.type == ash::TYPE_PINNED_APP) 829 if (item.type == ash::TYPE_PINNED_APP)
830 app_ids->push_back(item.app_launch_id.app_id()); 830 app_ids->push_back(item.id.app_id());
831 } 831 }
832 } 832 }
833 833
834 // Get the setup of the currently shown launcher items in one string. 834 // Get the setup of the currently shown launcher items in one string.
835 // Each pinned element will start with a big letter, each running but not 835 // Each pinned element will start with a big letter, each running but not
836 // pinned V1 app will start with a small letter and each running but not 836 // pinned V1 app will start with a small letter and each running but not
837 // pinned V2 app will start with a '*' + small letter. 837 // pinned V2 app will start with a '*' + small letter.
838 std::string GetPinnedAppStatus() { 838 std::string GetPinnedAppStatus() {
839 std::string result; 839 std::string result;
840 for (int i = 0; i < model_->item_count(); i++) { 840 for (int i = 0; i < model_->item_count(); i++) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 UnloadedExtensionReason::UPDATE); 1692 UnloadedExtensionReason::UPDATE);
1693 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1693 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1694 } 1694 }
1695 1695
1696 // Test the V1 app interaction flow: run it, activate it, close it. 1696 // Test the V1 app interaction flow: run it, activate it, close it.
1697 TEST_F(ChromeLauncherControllerTest, V1AppRunActivateClose) { 1697 TEST_F(ChromeLauncherControllerTest, V1AppRunActivateClose) {
1698 InitLauncherController(); 1698 InitLauncherController();
1699 // The model should only contain the browser shortcut and app list items. 1699 // The model should only contain the browser shortcut and app list items.
1700 EXPECT_EQ(2, model_->item_count()); 1700 EXPECT_EQ(2, model_->item_count());
1701 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1701 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1702 EXPECT_EQ(ash::kInvalidShelfID, 1702 EXPECT_TRUE(
1703 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1703 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1704 1704
1705 // Reporting that the app is running should create a new shelf item. 1705 // Reporting that the app is running should create a new shelf item.
1706 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1706 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1707 EXPECT_EQ(3, model_->item_count()); 1707 EXPECT_EQ(3, model_->item_count());
1708 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); 1708 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1709 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); 1709 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1710 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1710 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1711 EXPECT_NE(ash::kInvalidShelfID, 1711 EXPECT_FALSE(
1712 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1712 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1713 1713
1714 // Reporting an active status should just update the existing item. 1714 // Reporting an active status should just update the existing item.
1715 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_ACTIVE); 1715 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_ACTIVE);
1716 EXPECT_EQ(3, model_->item_count()); 1716 EXPECT_EQ(3, model_->item_count());
1717 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[2].status); 1717 EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[2].status);
1718 1718
1719 // Reporting that the app is closed should remove its shelf item. 1719 // Reporting that the app is closed should remove its shelf item.
1720 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1720 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1721 EXPECT_EQ(2, model_->item_count()); 1721 EXPECT_EQ(2, model_->item_count());
1722 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1722 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1723 EXPECT_EQ(ash::kInvalidShelfID, 1723 EXPECT_TRUE(
1724 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1724 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1725 1725
1726 // Reporting that the app is closed again should have no effect. 1726 // Reporting that the app is closed again should have no effect.
1727 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1727 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1728 EXPECT_EQ(2, model_->item_count()); 1728 EXPECT_EQ(2, model_->item_count());
1729 } 1729 }
1730 1730
1731 // Test the V1 app interaction flow: pin it, run it, close it, unpin it. 1731 // Test the V1 app interaction flow: pin it, run it, close it, unpin it.
1732 TEST_F(ChromeLauncherControllerTest, V1AppPinRunCloseUnpin) { 1732 TEST_F(ChromeLauncherControllerTest, V1AppPinRunCloseUnpin) {
1733 InitLauncherController(); 1733 InitLauncherController();
1734 // The model should only contain the browser shortcut and app list items. 1734 // The model should only contain the browser shortcut and app list items.
1735 EXPECT_EQ(2, model_->item_count()); 1735 EXPECT_EQ(2, model_->item_count());
1736 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1736 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1737 EXPECT_EQ(ash::kInvalidShelfID, 1737 EXPECT_TRUE(
1738 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1738 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1739 1739
1740 // Pinning the app should create a new shelf item. 1740 // Pinning the app should create a new shelf item.
1741 launcher_controller_->PinAppWithID(extension1_->id()); 1741 launcher_controller_->PinAppWithID(extension1_->id());
1742 EXPECT_EQ(3, model_->item_count()); 1742 EXPECT_EQ(3, model_->item_count());
1743 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1743 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1744 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); 1744 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1745 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1745 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1746 EXPECT_NE(ash::kInvalidShelfID, 1746 EXPECT_FALSE(
1747 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1747 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1748 1748
1749 // Reporting that the app is running should just update the existing item. 1749 // Reporting that the app is running should just update the existing item.
1750 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1750 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1751 EXPECT_EQ(3, model_->item_count()); 1751 EXPECT_EQ(3, model_->item_count());
1752 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1752 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1753 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); 1753 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1754 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1754 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1755 EXPECT_NE(ash::kInvalidShelfID, 1755 EXPECT_FALSE(
1756 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1756 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1757 1757
1758 // Reporting that the app is closed should just update the existing item. 1758 // Reporting that the app is closed should just update the existing item.
1759 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1759 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1760 EXPECT_EQ(3, model_->item_count()); 1760 EXPECT_EQ(3, model_->item_count());
1761 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1761 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1762 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); 1762 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1763 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1763 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1764 EXPECT_NE(ash::kInvalidShelfID, 1764 EXPECT_FALSE(
1765 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1765 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1766 1766
1767 // Unpinning the app should remove its shelf item. 1767 // Unpinning the app should remove its shelf item.
1768 launcher_controller_->UnpinAppWithID(extension1_->id()); 1768 launcher_controller_->UnpinAppWithID(extension1_->id());
1769 EXPECT_EQ(2, model_->item_count()); 1769 EXPECT_EQ(2, model_->item_count());
1770 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1770 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1771 EXPECT_EQ(ash::kInvalidShelfID, 1771 EXPECT_TRUE(
1772 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1772 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1773 } 1773 }
1774 1774
1775 // Test the V1 app interaction flow: run it, pin it, close it, unpin it. 1775 // Test the V1 app interaction flow: run it, pin it, close it, unpin it.
1776 TEST_F(ChromeLauncherControllerTest, V1AppRunPinCloseUnpin) { 1776 TEST_F(ChromeLauncherControllerTest, V1AppRunPinCloseUnpin) {
1777 InitLauncherController(); 1777 InitLauncherController();
1778 // The model should only contain the browser shortcut and app list items. 1778 // The model should only contain the browser shortcut and app list items.
1779 EXPECT_EQ(2, model_->item_count()); 1779 EXPECT_EQ(2, model_->item_count());
1780 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1780 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1781 EXPECT_EQ(ash::kInvalidShelfID, 1781 EXPECT_TRUE(
1782 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1782 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1783 1783
1784 // Reporting that the app is running should create a new shelf item. 1784 // Reporting that the app is running should create a new shelf item.
1785 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1785 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1786 EXPECT_EQ(3, model_->item_count()); 1786 EXPECT_EQ(3, model_->item_count());
1787 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); 1787 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1788 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); 1788 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1789 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1789 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1790 EXPECT_NE(ash::kInvalidShelfID, 1790 EXPECT_FALSE(
1791 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1791 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1792 1792
1793 // Pinning the app should just update the existing item. 1793 // Pinning the app should just update the existing item.
1794 launcher_controller_->PinAppWithID(extension1_->id()); 1794 launcher_controller_->PinAppWithID(extension1_->id());
1795 EXPECT_EQ(3, model_->item_count()); 1795 EXPECT_EQ(3, model_->item_count());
1796 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1796 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1797 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); 1797 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1798 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1798 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1799 EXPECT_NE(ash::kInvalidShelfID, 1799 EXPECT_FALSE(
1800 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1800 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1801 1801
1802 // Reporting that the app is closed should just update the existing item. 1802 // Reporting that the app is closed should just update the existing item.
1803 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1803 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1804 EXPECT_EQ(3, model_->item_count()); 1804 EXPECT_EQ(3, model_->item_count());
1805 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1805 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1806 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); 1806 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1807 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1807 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1808 EXPECT_NE(ash::kInvalidShelfID, 1808 EXPECT_FALSE(
1809 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1809 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1810 1810
1811 // Unpinning the app should remove its shelf item. 1811 // Unpinning the app should remove its shelf item.
1812 launcher_controller_->UnpinAppWithID(extension1_->id()); 1812 launcher_controller_->UnpinAppWithID(extension1_->id());
1813 EXPECT_EQ(2, model_->item_count()); 1813 EXPECT_EQ(2, model_->item_count());
1814 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1814 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1815 EXPECT_EQ(ash::kInvalidShelfID, 1815 EXPECT_TRUE(
1816 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1816 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1817 } 1817 }
1818 1818
1819 // Test the V1 app interaction flow: pin it, run it, unpin it, close it. 1819 // Test the V1 app interaction flow: pin it, run it, unpin it, close it.
1820 TEST_F(ChromeLauncherControllerTest, V1AppPinRunUnpinClose) { 1820 TEST_F(ChromeLauncherControllerTest, V1AppPinRunUnpinClose) {
1821 InitLauncherController(); 1821 InitLauncherController();
1822 // The model should only contain the browser shortcut and app list items. 1822 // The model should only contain the browser shortcut and app list items.
1823 EXPECT_EQ(2, model_->item_count()); 1823 EXPECT_EQ(2, model_->item_count());
1824 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1824 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1825 EXPECT_EQ(ash::kInvalidShelfID, 1825 EXPECT_TRUE(
1826 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1826 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1827 1827
1828 // Pinning the app should create a new shelf item. 1828 // Pinning the app should create a new shelf item.
1829 launcher_controller_->PinAppWithID(extension1_->id()); 1829 launcher_controller_->PinAppWithID(extension1_->id());
1830 EXPECT_EQ(3, model_->item_count()); 1830 EXPECT_EQ(3, model_->item_count());
1831 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1831 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1832 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status); 1832 EXPECT_EQ(ash::STATUS_CLOSED, model_->items()[2].status);
1833 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1833 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1834 EXPECT_NE(ash::kInvalidShelfID, 1834 EXPECT_FALSE(
1835 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1835 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1836 1836
1837 // Reporting that the app is running should just update the existing item. 1837 // Reporting that the app is running should just update the existing item.
1838 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1838 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
1839 EXPECT_EQ(3, model_->item_count()); 1839 EXPECT_EQ(3, model_->item_count());
1840 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type); 1840 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[2].type);
1841 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); 1841 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1842 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1842 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1843 EXPECT_NE(ash::kInvalidShelfID, 1843 EXPECT_FALSE(
1844 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1844 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1845 1845
1846 // Unpinning the app should just update the existing item. 1846 // Unpinning the app should just update the existing item.
1847 launcher_controller_->UnpinAppWithID(extension1_->id()); 1847 launcher_controller_->UnpinAppWithID(extension1_->id());
1848 EXPECT_EQ(3, model_->item_count()); 1848 EXPECT_EQ(3, model_->item_count());
1849 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); 1849 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type);
1850 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status); 1850 EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[2].status);
1851 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1851 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1852 EXPECT_NE(ash::kInvalidShelfID, 1852 EXPECT_FALSE(
1853 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1853 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1854 1854
1855 // Reporting that the app is closed should remove its shelf item. 1855 // Reporting that the app is closed should remove its shelf item.
1856 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED); 1856 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_CLOSED);
1857 EXPECT_EQ(2, model_->item_count()); 1857 EXPECT_EQ(2, model_->item_count());
1858 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1858 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1859 EXPECT_EQ(ash::kInvalidShelfID, 1859 EXPECT_TRUE(
1860 launcher_controller_->GetShelfIDForAppID(extension1_->id())); 1860 launcher_controller_->GetShelfIDForAppID(extension1_->id()).IsEmpty());
1861 } 1861 }
1862 1862
1863 // Ensure unpinned V1 app ordering is properly restored after user changes. 1863 // Ensure unpinned V1 app ordering is properly restored after user changes.
1864 TEST_F(ChromeLauncherControllerTest, CheckRunningV1AppOrder) { 1864 TEST_F(ChromeLauncherControllerTest, CheckRunningV1AppOrder) {
1865 InitLauncherController(); 1865 InitLauncherController();
1866 // The model should only contain the browser shortcut and app list items. 1866 // The model should only contain the browser shortcut and app list items.
1867 EXPECT_EQ(2, model_->item_count()); 1867 EXPECT_EQ(2, model_->item_count());
1868 1868
1869 // Add a few running applications. 1869 // Add a few running applications.
1870 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING); 1870 launcher_controller_->SetV1AppStatus(extension1_->id(), ash::STATUS_RUNNING);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1920 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1921 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1921 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1922 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1922 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1923 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut); 1923 const std::string arc_shortcut_id = ArcAppTest::GetAppId(shortcut);
1924 1924
1925 SendListOfArcApps(); 1925 SendListOfArcApps();
1926 SendListOfArcShortcuts(); 1926 SendListOfArcShortcuts();
1927 1927
1928 arc_test_.StopArcInstance(); 1928 arc_test_.StopArcInstance();
1929 1929
1930 EXPECT_EQ(ash::kInvalidShelfID, 1930 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
1931 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1931 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
1932 EXPECT_EQ(ash::kInvalidShelfID, 1932 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsEmpty());
1933 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1933 EXPECT_TRUE(
1934 EXPECT_EQ(ash::kInvalidShelfID, 1934 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id).IsEmpty());
1935 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1936 EXPECT_EQ(ash::kInvalidShelfID,
1937 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id));
1938 1935
1939 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); 1936 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1940 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON); 1937 arc::LaunchApp(profile(), arc_app_id1, ui::EF_LEFT_MOUSE_BUTTON);
1941 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON); 1938 arc::LaunchApp(profile(), arc_app_id2, ui::EF_LEFT_MOUSE_BUTTON);
1942 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON); 1939 arc::LaunchApp(profile(), arc_app_id3, ui::EF_LEFT_MOUSE_BUTTON);
1943 arc::LaunchApp(profile(), arc_shortcut_id, ui::EF_LEFT_MOUSE_BUTTON); 1940 arc::LaunchApp(profile(), arc_shortcut_id, ui::EF_LEFT_MOUSE_BUTTON);
1944 1941
1945 const ash::ShelfID shelf_id_app_1 = 1942 const ash::ShelfID shelf_id_app_1 =
1946 launcher_controller_->GetShelfIDForAppID(arc_app_id1); 1943 launcher_controller_->GetShelfIDForAppID(arc_app_id1);
1947 const ash::ShelfID shelf_id_app_2 = 1944 const ash::ShelfID shelf_id_app_2 =
1948 launcher_controller_->GetShelfIDForAppID(arc_app_id2); 1945 launcher_controller_->GetShelfIDForAppID(arc_app_id2);
1949 const ash::ShelfID shelf_id_app_3 = 1946 const ash::ShelfID shelf_id_app_3 =
1950 launcher_controller_->GetShelfIDForAppID(arc_app_id3); 1947 launcher_controller_->GetShelfIDForAppID(arc_app_id3);
1951 const ash::ShelfID shelf_id_shortcut = 1948 const ash::ShelfID shelf_id_shortcut =
1952 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id); 1949 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id);
1953 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); 1950 EXPECT_FALSE(shelf_id_app_1.IsEmpty());
1954 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); 1951 EXPECT_FALSE(shelf_id_app_2.IsEmpty());
1955 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); 1952 EXPECT_FALSE(shelf_id_app_3.IsEmpty());
1956 EXPECT_NE(ash::kInvalidShelfID, shelf_id_shortcut); 1953 EXPECT_FALSE(shelf_id_shortcut.IsEmpty());
1957 1954
1958 // We activated arc_app_id1 twice but expect one close for item controller 1955 // We activated arc_app_id1 twice but expect one close for item controller
1959 // stops launching request. 1956 // stops launching request.
1960 ash::ShelfItemDelegate* item_delegate = 1957 ash::ShelfItemDelegate* item_delegate =
1961 model_->GetShelfItemDelegate(shelf_id_app_1); 1958 model_->GetShelfItemDelegate(shelf_id_app_1);
1962 ASSERT_NE(nullptr, item_delegate); 1959 ASSERT_NE(nullptr, item_delegate);
1963 item_delegate->Close(); 1960 item_delegate->Close();
1964 base::RunLoop().RunUntilIdle(); 1961 base::RunLoop().RunUntilIdle();
1965 1962
1966 EXPECT_EQ(ash::kInvalidShelfID, 1963 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
1967 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1968 EXPECT_EQ(shelf_id_app_2, 1964 EXPECT_EQ(shelf_id_app_2,
1969 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1965 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1970 EXPECT_EQ(shelf_id_app_3, 1966 EXPECT_EQ(shelf_id_app_3,
1971 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1967 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1972 1968
1973 arc_test_.RestartArcInstance(); 1969 arc_test_.RestartArcInstance();
1974 SendListOfArcApps(); 1970 SendListOfArcApps();
1975 1971
1976 base::RunLoop().RunUntilIdle(); 1972 base::RunLoop().RunUntilIdle();
1977 1973
1978 // Now deferred contollers should go away together with shelf items and ARC 1974 // Now deferred contollers should go away together with shelf items and ARC
1979 // app instance should receive request for launching apps and shortcuts. 1975 // app instance should receive request for launching apps and shortcuts.
1980 EXPECT_EQ(ash::kInvalidShelfID, 1976 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
1981 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1977 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
1982 EXPECT_EQ(ash::kInvalidShelfID, 1978 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsEmpty());
1983 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1984 EXPECT_EQ(ash::kInvalidShelfID,
1985 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
1986 1979
1987 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); 1980 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size());
1988 ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size()); 1981 ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size());
1989 1982
1990 const arc::FakeAppInstance::Request* request1 = 1983 const arc::FakeAppInstance::Request* request1 =
1991 arc_test_.app_instance()->launch_requests()[0].get(); 1984 arc_test_.app_instance()->launch_requests()[0].get();
1992 const arc::FakeAppInstance::Request* request2 = 1985 const arc::FakeAppInstance::Request* request2 =
1993 arc_test_.app_instance()->launch_requests()[1].get(); 1986 arc_test_.app_instance()->launch_requests()[1].get();
1994 1987
1995 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1988 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
1996 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1989 (request1->IsForApp(app3) && request2->IsForApp(app2)));
1997 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), 1990 EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(),
1998 shortcut.intent_uri); 1991 shortcut.intent_uri);
1999 } 1992 }
2000 1993
2001 // Ensure the deferred controller does not override the active app controller 1994 // Ensure the deferred controller does not override the active app controller
2002 // (crbug.com/701152). 1995 // (crbug.com/701152).
2003 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunchForActiveApp) { 1996 TEST_P(ChromeLauncherControllerWithArcTest, ArcDeferredLaunchForActiveApp) {
2004 InitLauncherController(); 1997 InitLauncherController();
2005 SendListOfArcApps(); 1998 SendListOfArcApps();
2006 arc_test_.StopArcInstance(); 1999 arc_test_.StopArcInstance();
2007 2000
2008 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0]; 2001 const arc::mojom::AppInfo& app = arc_test_.fake_apps()[0];
2009 const std::string app_id = ArcAppTest::GetAppId(app); 2002 const std::string app_id = ArcAppTest::GetAppId(app);
2010 2003
2011 launcher_controller_->PinAppWithID(app_id); 2004 launcher_controller_->PinAppWithID(app_id);
2012 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 2005 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
2013 const ash::ShelfID shelf_id = 2006 const ash::ShelfID shelf_id =
2014 launcher_controller_->GetShelfIDForAppID(app_id); 2007 launcher_controller_->GetShelfIDForAppID(app_id);
2015 EXPECT_NE(ash::kInvalidShelfID, shelf_id); 2008 EXPECT_FALSE(shelf_id.IsEmpty());
2016 2009
2017 int item_index = model_->ItemIndexByID(shelf_id); 2010 int item_index = model_->ItemIndexByID(shelf_id);
2018 ASSERT_GE(item_index, 0); 2011 ASSERT_GE(item_index, 0);
2019 2012
2020 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); 2013 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED);
2021 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); 2014 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP);
2022 2015
2023 // Play Store app is ARC app that might be represented by native Chrome 2016 // Play Store app is ARC app that might be represented by native Chrome
2024 // platform app. 2017 // platform app.
2025 model_->SetShelfItemDelegate( 2018 model_->SetShelfItemDelegate(
2026 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>( 2019 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>(
2027 ash::AppLaunchId(app_id))); 2020 ash::ShelfID(app_id)));
2028 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 2021 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
2029 2022
2030 // This launch request should be ignored in case of active app. 2023 // This launch request should be ignored in case of active app.
2031 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 2024 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
2032 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 2025 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
2033 2026
2034 // Close app but shortcut should exist. 2027 // Close app but shortcut should exist.
2035 launcher_controller_->CloseLauncherItem(shelf_id); 2028 launcher_controller_->CloseLauncherItem(shelf_id);
2036 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id)); 2029 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(app_id));
2037 2030
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2064 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2072 const std::string arc_app_id2 = 2065 const std::string arc_app_id2 =
2073 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2066 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2074 const std::string arc_app_id3 = 2067 const std::string arc_app_id3 =
2075 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); 2068 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]);
2076 2069
2077 std::string window_app_id1("org.chromium.arc.1"); 2070 std::string window_app_id1("org.chromium.arc.1");
2078 views::Widget* arc_window1 = CreateArcWindow(window_app_id1); 2071 views::Widget* arc_window1 = CreateArcWindow(window_app_id1);
2079 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 2072 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2080 std::string()); 2073 std::string());
2081 EXPECT_NE(ash::kInvalidShelfID, 2074 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2082 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2083 2075
2084 std::string window_app_id2("org.chromium.arc.2"); 2076 std::string window_app_id2("org.chromium.arc.2");
2085 views::Widget* arc_window2 = CreateArcWindow(window_app_id2); 2077 views::Widget* arc_window2 = CreateArcWindow(window_app_id2);
2086 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], 2078 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1],
2087 std::string()); 2079 std::string());
2088 EXPECT_NE(ash::kInvalidShelfID, 2080 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2089 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2090 2081
2091 launcher_controller_->SetProfileForTest(profile2); 2082 launcher_controller_->SetProfileForTest(profile2);
2092 SwitchActiveUser(account_id2); 2083 SwitchActiveUser(account_id2);
2093 2084
2094 EXPECT_EQ(ash::kInvalidShelfID, 2085 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2095 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 2086 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2096 EXPECT_EQ(ash::kInvalidShelfID,
2097 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2098 2087
2099 std::string window_app_id3("org.chromium.arc.3"); 2088 std::string window_app_id3("org.chromium.arc.3");
2100 views::Widget* arc_window3 = CreateArcWindow(window_app_id3); 2089 views::Widget* arc_window3 = CreateArcWindow(window_app_id3);
2101 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[2], 2090 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[2],
2102 std::string()); 2091 std::string());
2103 EXPECT_EQ(ash::kInvalidShelfID, 2092 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsEmpty());
2104 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
2105 2093
2106 arc_window2->CloseNow(); 2094 arc_window2->CloseNow();
2107 arc_test_.app_instance()->SendTaskDestroyed(2); 2095 arc_test_.app_instance()->SendTaskDestroyed(2);
2108 2096
2109 launcher_controller_->SetProfileForTest(profile()); 2097 launcher_controller_->SetProfileForTest(profile());
2110 SwitchActiveUser(account_id); 2098 SwitchActiveUser(account_id);
2111 2099
2112 EXPECT_NE(ash::kInvalidShelfID, 2100 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2113 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 2101 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2114 EXPECT_EQ(ash::kInvalidShelfID, 2102 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id3).IsEmpty());
2115 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2116 EXPECT_NE(ash::kInvalidShelfID,
2117 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
2118 2103
2119 // Close active window to let test passes. 2104 // Close active window to let test passes.
2120 arc_window1->CloseNow(); 2105 arc_window1->CloseNow();
2121 arc_window3->CloseNow(); 2106 arc_window3->CloseNow();
2122 } 2107 }
2123 2108
2124 TEST_P(ChromeLauncherControllerWithArcTest, ArcRunningApp) { 2109 TEST_P(ChromeLauncherControllerWithArcTest, ArcRunningApp) {
2125 InitLauncherController(); 2110 InitLauncherController();
2126 2111
2127 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2112 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2128 SendListOfArcApps(); 2113 SendListOfArcApps();
2129 EXPECT_EQ(ash::kInvalidShelfID, 2114 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2130 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2131 2115
2132 // Normal flow, create/destroy tasks. 2116 // Normal flow, create/destroy tasks.
2133 std::string window_app_id1("org.chromium.arc.1"); 2117 std::string window_app_id1("org.chromium.arc.1");
2134 std::string window_app_id2("org.chromium.arc.2"); 2118 std::string window_app_id2("org.chromium.arc.2");
2135 std::string window_app_id3("org.chromium.arc.3"); 2119 std::string window_app_id3("org.chromium.arc.3");
2136 CreateArcWindow(window_app_id1); 2120 CreateArcWindow(window_app_id1);
2137 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 2121 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2138 std::string()); 2122 std::string());
2139 EXPECT_NE(ash::kInvalidShelfID, 2123 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2140 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2141 CreateArcWindow(window_app_id2); 2124 CreateArcWindow(window_app_id2);
2142 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0], 2125 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0],
2143 std::string()); 2126 std::string());
2144 EXPECT_NE(ash::kInvalidShelfID, 2127 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2145 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2146 arc_test_.app_instance()->SendTaskDestroyed(1); 2128 arc_test_.app_instance()->SendTaskDestroyed(1);
2147 EXPECT_NE(ash::kInvalidShelfID, 2129 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2148 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2149 arc_test_.app_instance()->SendTaskDestroyed(2); 2130 arc_test_.app_instance()->SendTaskDestroyed(2);
2150 EXPECT_EQ(ash::kInvalidShelfID, 2131 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2151 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2152 2132
2153 // Stopping bridge removes apps. 2133 // Stopping bridge removes apps.
2154 CreateArcWindow(window_app_id3); 2134 CreateArcWindow(window_app_id3);
2155 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0], 2135 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0],
2156 std::string()); 2136 std::string());
2157 EXPECT_NE(ash::kInvalidShelfID, 2137 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2158 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2159 arc_test_.StopArcInstance(); 2138 arc_test_.StopArcInstance();
2160 base::RunLoop().RunUntilIdle(); 2139 base::RunLoop().RunUntilIdle();
2161 EXPECT_EQ(ash::kInvalidShelfID, 2140 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id).IsEmpty());
2162 launcher_controller_->GetShelfIDForAppID(arc_app_id));
2163 } 2141 }
2164 2142
2165 // Test race creation/deletion of ARC app. 2143 // Test race creation/deletion of ARC app.
2166 // TODO(khmel): Remove after moving everything to wayland protocol. 2144 // TODO(khmel): Remove after moving everything to wayland protocol.
2167 TEST_P(ChromeLauncherControllerWithArcTest, ArcRaceCreateClose) { 2145 TEST_P(ChromeLauncherControllerWithArcTest, ArcRaceCreateClose) {
2168 InitLauncherController(); 2146 InitLauncherController();
2169 2147
2170 const std::string arc_app_id1 = 2148 const std::string arc_app_id1 =
2171 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2149 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2172 const std::string arc_app_id2 = 2150 const std::string arc_app_id2 =
2173 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); 2151 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]);
2174 SendListOfArcApps(); 2152 SendListOfArcApps();
2175 2153
2176 // ARC window created before and closed after mojom notification. 2154 // ARC window created before and closed after mojom notification.
2177 std::string window_app_id1("org.chromium.arc.1"); 2155 std::string window_app_id1("org.chromium.arc.1");
2178 views::Widget* arc_window = CreateArcWindow(window_app_id1); 2156 views::Widget* arc_window = CreateArcWindow(window_app_id1);
2179 EXPECT_EQ(ash::kInvalidShelfID, 2157 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2180 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2181 ASSERT_TRUE(arc_window); 2158 ASSERT_TRUE(arc_window);
2182 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 2159 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2183 std::string()); 2160 std::string());
2184 EXPECT_NE(ash::kInvalidShelfID, 2161 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2185 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2186 arc_test_.app_instance()->SendTaskDestroyed(1); 2162 arc_test_.app_instance()->SendTaskDestroyed(1);
2187 EXPECT_EQ(ash::kInvalidShelfID, 2163 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2188 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2189 arc_window->Close(); 2164 arc_window->Close();
2190 base::RunLoop().RunUntilIdle(); 2165 base::RunLoop().RunUntilIdle();
2191 EXPECT_EQ(ash::kInvalidShelfID, 2166 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id1).IsEmpty());
2192 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
2193 2167
2194 // ARC window created after and closed before mojom notification. 2168 // ARC window created after and closed before mojom notification.
2195 std::string window_app_id2("org.chromium.arc.2"); 2169 std::string window_app_id2("org.chromium.arc.2");
2196 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1], 2170 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1],
2197 std::string()); 2171 std::string());
2198 EXPECT_NE(ash::kInvalidShelfID, 2172 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2199 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2200 arc_window = CreateArcWindow(window_app_id2); 2173 arc_window = CreateArcWindow(window_app_id2);
2201 ASSERT_TRUE(arc_window); 2174 ASSERT_TRUE(arc_window);
2202 EXPECT_NE(ash::kInvalidShelfID, 2175 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2203 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2204 arc_window->Close(); 2176 arc_window->Close();
2205 base::RunLoop().RunUntilIdle(); 2177 base::RunLoop().RunUntilIdle();
2206 // Closing window does not close shelf item. It is closed on task destroy. 2178 // Closing window does not close shelf item. It is closed on task destroy.
2207 EXPECT_NE(ash::kInvalidShelfID, 2179 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2208 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2209 arc_test_.app_instance()->SendTaskDestroyed(2); 2180 arc_test_.app_instance()->SendTaskDestroyed(2);
2210 EXPECT_EQ(ash::kInvalidShelfID, 2181 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(arc_app_id2).IsEmpty());
2211 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
2212 } 2182 }
2213 2183
2214 TEST_P(ChromeLauncherControllerWithArcTest, ArcWindowRecreation) { 2184 TEST_P(ChromeLauncherControllerWithArcTest, ArcWindowRecreation) {
2215 InitLauncherController(); 2185 InitLauncherController();
2216 2186
2217 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 2187 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
2218 SendListOfArcApps(); 2188 SendListOfArcApps();
2219 2189
2220 std::string window_app_id("org.chromium.arc.1"); 2190 std::string window_app_id("org.chromium.arc.1");
2221 views::Widget* arc_window = CreateArcWindow(window_app_id); 2191 views::Widget* arc_window = CreateArcWindow(window_app_id);
2222 ASSERT_TRUE(arc_window); 2192 ASSERT_TRUE(arc_window);
2223 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0], 2193 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0],
2224 std::string()); 2194 std::string());
2225 const ash::ShelfID shelf_id = 2195 const ash::ShelfID shelf_id =
2226 launcher_controller_->GetShelfIDForAppID(arc_app_id); 2196 launcher_controller_->GetShelfIDForAppID(arc_app_id);
2227 EXPECT_NE(ash::kInvalidShelfID, shelf_id); 2197 EXPECT_FALSE(shelf_id.IsEmpty());
2228 2198
2229 for (int i = 0; i < 3; ++i) { 2199 for (int i = 0; i < 3; ++i) {
2230 arc_window->Close(); 2200 arc_window->Close();
2231 base::RunLoop().RunUntilIdle(); 2201 base::RunLoop().RunUntilIdle();
2232 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2202 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
2233 2203
2234 arc_window = CreateArcWindow(window_app_id); 2204 arc_window = CreateArcWindow(window_app_id);
2235 ASSERT_TRUE(arc_window); 2205 ASSERT_TRUE(arc_window);
2236 base::RunLoop().RunUntilIdle(); 2206 base::RunLoop().RunUntilIdle();
2237 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 2207 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id));
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2983 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
3014 EXPECT_EQ(0, browser()->tab_strip_model()->count()); 2984 EXPECT_EQ(0, browser()->tab_strip_model()->count());
3015 2985
3016 InitLauncherControllerWithBrowser(); 2986 InitLauncherControllerWithBrowser();
3017 2987
3018 // The model should only contain the browser shortcut and app list items. 2988 // The model should only contain the browser shortcut and app list items.
3019 EXPECT_EQ(2, model_->item_count()); 2989 EXPECT_EQ(2, model_->item_count());
3020 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2990 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
3021 2991
3022 // Installing |extension3_| adds it to the launcher. 2992 // Installing |extension3_| adds it to the launcher.
3023 ash::ShelfID gmail_id = model_->next_id(); 2993 const ash::ShelfID gmail_id(extension3_->id());
3024 extension_service_->AddExtension(extension3_.get()); 2994 extension_service_->AddExtension(extension3_.get());
3025 EXPECT_EQ(3, model_->item_count()); 2995 EXPECT_EQ(3, model_->item_count());
3026 int gmail_index = model_->ItemIndexByID(gmail_id); 2996 int gmail_index = model_->ItemIndexByID(gmail_id);
3027 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 2997 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3028 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 2998 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3029 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 2999 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3030 3000
3031 // Check the menu content. 3001 // Check the menu content.
3032 ash::ShelfItem item_browser; 3002 ash::ShelfItem item_browser;
3033 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 3003 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 } 3043 }
3074 3044
3075 // Check the multi profile case where only user related apps should show up. 3045 // Check the multi profile case where only user related apps should show up.
3076 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 3046 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
3077 V1AppMenuGenerationTwoUsers) { 3047 V1AppMenuGenerationTwoUsers) {
3078 // Create a browser item in the LauncherController. 3048 // Create a browser item in the LauncherController.
3079 InitLauncherController(); 3049 InitLauncherController();
3080 chrome::NewTab(browser()); 3050 chrome::NewTab(browser());
3081 3051
3082 // Installing |extension3_| adds it to the launcher. 3052 // Installing |extension3_| adds it to the launcher.
3083 ash::ShelfID gmail_id = model_->next_id(); 3053 const ash::ShelfID gmail_id(extension3_->id());
3084 extension_service_->AddExtension(extension3_.get()); 3054 extension_service_->AddExtension(extension3_.get());
3085 EXPECT_EQ(3, model_->item_count()); 3055 EXPECT_EQ(3, model_->item_count());
3086 int gmail_index = model_->ItemIndexByID(gmail_id); 3056 int gmail_index = model_->ItemIndexByID(gmail_id);
3087 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3057 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3088 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3058 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3089 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3059 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3090 3060
3091 // Check the menu content. 3061 // Check the menu content.
3092 ash::ShelfItem item_browser; 3062 ash::ShelfItem item_browser;
3093 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 3063 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 EXPECT_EQ(2, model_->item_count()); 3309 EXPECT_EQ(2, model_->item_count());
3340 } 3310 }
3341 } 3311 }
3342 3312
3343 // Checks that the generated menu list properly activates items. 3313 // Checks that the generated menu list properly activates items.
3344 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) { 3314 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) {
3345 InitLauncherControllerWithBrowser(); 3315 InitLauncherControllerWithBrowser();
3346 3316
3347 // Add |extension3_| to the launcher and add two items. 3317 // Add |extension3_| to the launcher and add two items.
3348 GURL gmail = GURL("https://mail.google.com/mail/u"); 3318 GURL gmail = GURL("https://mail.google.com/mail/u");
3349 ash::ShelfID gmail_id = model_->next_id(); 3319 const ash::ShelfID gmail_id(extension3_->id());
3350 extension_service_->AddExtension(extension3_.get()); 3320 extension_service_->AddExtension(extension3_.get());
3351 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3321 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3352 base::string16 title1 = ASCIIToUTF16("Test1"); 3322 base::string16 title1 = ASCIIToUTF16("Test1");
3353 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3323 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3354 chrome::NewTab(browser()); 3324 chrome::NewTab(browser());
3355 base::string16 title2 = ASCIIToUTF16("Test2"); 3325 base::string16 title2 = ASCIIToUTF16("Test2");
3356 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); 3326 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
3357 3327
3358 // Check that the menu is properly set. 3328 // Check that the menu is properly set.
3359 ash::ShelfItem item_gmail; 3329 ash::ShelfItem item_gmail;
(...skipping 27 matching lines...) Expand all
3387 } 3357 }
3388 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 3358 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
3389 } 3359 }
3390 3360
3391 // Checks that the generated menu list properly deletes items. 3361 // Checks that the generated menu list properly deletes items.
3392 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { 3362 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) {
3393 InitLauncherControllerWithBrowser(); 3363 InitLauncherControllerWithBrowser();
3394 3364
3395 // Add |extension3_| to the launcher and add two items. 3365 // Add |extension3_| to the launcher and add two items.
3396 GURL gmail = GURL("https://mail.google.com/mail/u"); 3366 GURL gmail = GURL("https://mail.google.com/mail/u");
3397 ash::ShelfID gmail_id = model_->next_id(); 3367 const ash::ShelfID gmail_id(extension3_->id());
3398 extension_service_->AddExtension(extension3_.get()); 3368 extension_service_->AddExtension(extension3_.get());
3399 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 3369 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
3400 base::string16 title1 = ASCIIToUTF16("Test1"); 3370 base::string16 title1 = ASCIIToUTF16("Test1");
3401 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 3371 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
3402 chrome::NewTab(browser()); 3372 chrome::NewTab(browser());
3403 base::string16 title2 = ASCIIToUTF16("Test2"); 3373 base::string16 title2 = ASCIIToUTF16("Test2");
3404 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); 3374 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
3405 3375
3406 // Check that the menu is properly set. 3376 // Check that the menu is properly set.
3407 ash::ShelfItem item_gmail; 3377 ash::ShelfItem item_gmail;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. 3415 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher.
3446 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( 3416 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>(
3447 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); 3417 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL);
3448 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); 3418 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible());
3449 int panel_index = model_observer_->last_index(); 3419 int panel_index = model_observer_->last_index();
3450 EXPECT_EQ(1, model_observer_->added()); 3420 EXPECT_EQ(1, model_observer_->added());
3451 EXPECT_EQ(1, app_icon_loader->fetch_count()); 3421 EXPECT_EQ(1, app_icon_loader->fetch_count());
3452 model_observer_->clear_counts(); 3422 model_observer_->clear_counts();
3453 3423
3454 // App panels should have a separate identifier than the app id 3424 // App panels should have a separate identifier than the app id
3455 EXPECT_EQ(ash::kInvalidShelfID, 3425 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(app_id).IsEmpty());
3456 launcher_controller_->GetShelfIDForAppID(app_id));
3457 3426
3458 // Setting the app image should not change the panel, which has a window icon. 3427 // Setting the app image should not change the panel, which has a window icon.
3459 gfx::ImageSkia image; 3428 gfx::ImageSkia image;
3460 launcher_controller_->OnAppImageUpdated(app_id, image); 3429 launcher_controller_->OnAppImageUpdated(app_id, image);
3461 EXPECT_EQ(0, model_observer_->changed()); 3430 EXPECT_EQ(0, model_observer_->changed());
3462 model_observer_->clear_counts(); 3431 model_observer_->clear_counts();
3463 3432
3464 // Make a second app panel and verify that it gets the same index as the first 3433 // Make a second app panel and verify that it gets the same index as the first
3465 // panel, being added to the left of the existing panel. 3434 // panel, being added to the left of the existing panel.
3466 std::unique_ptr<V2App> app_panel2 = base::MakeUnique<V2App>( 3435 std::unique_ptr<V2App> app_panel2 = base::MakeUnique<V2App>(
(...skipping 16 matching lines...) Expand all
3483 chrome::NewTab(browser()); 3452 chrome::NewTab(browser());
3484 base::string16 title = ASCIIToUTF16("Test"); 3453 base::string16 title = ASCIIToUTF16("Test");
3485 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); 3454 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title);
3486 content::WebContents* content = 3455 content::WebContents* content =
3487 browser()->tab_strip_model()->GetActiveWebContents(); 3456 browser()->tab_strip_model()->GetActiveWebContents();
3488 3457
3489 // Check that the launcher controller does not recognize the running app. 3458 // Check that the launcher controller does not recognize the running app.
3490 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 3459 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
3491 3460
3492 // Installing |extension3_| adds it to the launcher. 3461 // Installing |extension3_| adds it to the launcher.
3493 ash::ShelfID gmail_id = model_->next_id(); 3462 const ash::ShelfID gmail_id(extension3_->id());
3494 extension_service_->AddExtension(extension3_.get()); 3463 extension_service_->AddExtension(extension3_.get());
3495 EXPECT_EQ(3, model_->item_count()); 3464 EXPECT_EQ(3, model_->item_count());
3496 int gmail_index = model_->ItemIndexByID(gmail_id); 3465 int gmail_index = model_->ItemIndexByID(gmail_id);
3497 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3466 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3498 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3467 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3499 3468
3500 // Check that it is now handled. 3469 // Check that it is now handled.
3501 EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 3470 EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
3502 3471
3503 // Check also that the app has detected that properly. 3472 // Check also that the app has detected that properly.
(...skipping 10 matching lines...) Expand all
3514 3483
3515 // Create a Gmail browser tab. 3484 // Create a Gmail browser tab.
3516 chrome::NewTab(browser()); 3485 chrome::NewTab(browser());
3517 base::string16 title = ASCIIToUTF16("Test"); 3486 base::string16 title = ASCIIToUTF16("Test");
3518 NavigateAndCommitActiveTabWithTitle(browser(), GURL(offline_gmail_url), 3487 NavigateAndCommitActiveTabWithTitle(browser(), GURL(offline_gmail_url),
3519 title); 3488 title);
3520 content::WebContents* content = 3489 content::WebContents* content =
3521 browser()->tab_strip_model()->GetActiveWebContents(); 3490 browser()->tab_strip_model()->GetActiveWebContents();
3522 3491
3523 // Installing |extension3_| adds it to the launcher. 3492 // Installing |extension3_| adds it to the launcher.
3524 ash::ShelfID gmail_id = model_->next_id(); 3493 const ash::ShelfID gmail_id(extension3_->id());
3525 extension_service_->AddExtension(extension3_.get()); 3494 extension_service_->AddExtension(extension3_.get());
3526 EXPECT_EQ(3, model_->item_count()); 3495 EXPECT_EQ(3, model_->item_count());
3527 int gmail_index = model_->ItemIndexByID(gmail_id); 3496 int gmail_index = model_->ItemIndexByID(gmail_id);
3528 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type); 3497 EXPECT_EQ(ash::TYPE_PINNED_APP, model_->items()[gmail_index].type);
3529 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 3498 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
3530 3499
3531 // The content should not be able to be handled by the app. 3500 // The content should not be able to be handled by the app.
3532 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 3501 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
3533 } 3502 }
3534 3503
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 // ChromeLauncherController. 3607 // ChromeLauncherController.
3639 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3608 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3640 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3609 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3641 app_icon_loader1->AddSupportedApp(app_id1); 3610 app_icon_loader1->AddSupportedApp(app_id1);
3642 app_icon_loader2->AddSupportedApp(app_id2); 3611 app_icon_loader2->AddSupportedApp(app_id2);
3643 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3612 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3644 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3613 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3645 3614
3646 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( 3615 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem(
3647 base::MakeUnique<ExtensionAppWindowLauncherItemController>( 3616 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3648 ash::AppLaunchId(app_id3)), 3617 ash::ShelfID(app_id3)),
3649 ash::STATUS_RUNNING); 3618 ash::STATUS_RUNNING);
3650 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3619 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3651 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3620 EXPECT_EQ(0, app_icon_loader1->clear_count());
3652 EXPECT_EQ(0, app_icon_loader2->fetch_count()); 3621 EXPECT_EQ(0, app_icon_loader2->fetch_count());
3653 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3622 EXPECT_EQ(0, app_icon_loader2->clear_count());
3654 3623
3655 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( 3624 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem(
3656 base::MakeUnique<ExtensionAppWindowLauncherItemController>( 3625 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3657 ash::AppLaunchId(app_id2)), 3626 ash::ShelfID(app_id2)),
3658 ash::STATUS_RUNNING); 3627 ash::STATUS_RUNNING);
3659 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3628 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3660 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3629 EXPECT_EQ(0, app_icon_loader1->clear_count());
3661 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3630 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3662 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3631 EXPECT_EQ(0, app_icon_loader2->clear_count());
3663 3632
3664 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( 3633 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem(
3665 base::MakeUnique<ExtensionAppWindowLauncherItemController>( 3634 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3666 ash::AppLaunchId(app_id1)), 3635 ash::ShelfID(app_id1)),
3667 ash::STATUS_RUNNING); 3636 ash::STATUS_RUNNING);
3668 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3637 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3669 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3638 EXPECT_EQ(0, app_icon_loader1->clear_count());
3670 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3639 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3671 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3640 EXPECT_EQ(0, app_icon_loader2->clear_count());
3672 3641
3673 launcher_controller_->CloseLauncherItem(shelfId1); 3642 launcher_controller_->CloseLauncherItem(shelfId1);
3674 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3643 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3675 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3644 EXPECT_EQ(1, app_icon_loader1->clear_count());
3676 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3645 EXPECT_EQ(1, app_icon_loader2->fetch_count());
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
4087 // Prevent safe decoding which requires IPC. 4056 // Prevent safe decoding which requires IPC.
4088 ArcAppIcon::DisableSafeDecodingForTesting(); 4057 ArcAppIcon::DisableSafeDecodingForTesting();
4089 4058
4090 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 4059 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
4091 EnablePlayStore(false); 4060 EnablePlayStore(false);
4092 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile())); 4061 EXPECT_FALSE(arc::IsArcPlayStoreEnabledForProfile(profile()));
4093 ASSERT_TRUE(prefs->GetAppIds().size()); 4062 ASSERT_TRUE(prefs->GetAppIds().size());
4094 4063
4095 const std::string app_id = 4064 const std::string app_id =
4096 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); 4065 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]);
4097 EXPECT_EQ(ash::kInvalidShelfID, 4066 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(app_id).IsEmpty());
4098 launcher_controller_->GetShelfIDForAppID(app_id));
4099 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 4067 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
4100 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); 4068 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
4101 EXPECT_NE(ash::kInvalidShelfID, 4069 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(app_id).IsEmpty());
4102 launcher_controller_->GetShelfIDForAppID(app_id));
4103 4070
4104 // Stop ARC again. Shelf item should go away. 4071 // Stop ARC again. Shelf item should go away.
4105 EnablePlayStore(false); 4072 EnablePlayStore(false);
4106 EXPECT_EQ(ash::kInvalidShelfID, 4073 EXPECT_TRUE(launcher_controller_->GetShelfIDForAppID(app_id).IsEmpty());
4107 launcher_controller_->GetShelfIDForAppID(app_id));
4108 4074
4109 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON)); 4075 EXPECT_TRUE(arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON));
4110 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); 4076 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
4111 4077
4112 EXPECT_NE(ash::kInvalidShelfID, 4078 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(app_id).IsEmpty());
4113 launcher_controller_->GetShelfIDForAppID(app_id));
4114 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 4079 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
4115 4080
4116 std::string window_app_id("org.chromium.arc.1"); 4081 std::string window_app_id("org.chromium.arc.1");
4117 CreateArcWindow(window_app_id); 4082 CreateArcWindow(window_app_id);
4118 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_default_apps()[0], 4083 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_default_apps()[0],
4119 std::string()); 4084 std::string());
4120 4085
4121 EXPECT_NE(ash::kInvalidShelfID, 4086 EXPECT_FALSE(launcher_controller_->GetShelfIDForAppID(app_id).IsEmpty());
4122 launcher_controller_->GetShelfIDForAppID(app_id));
4123 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 4087 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
4124 } 4088 }
4125 4089
4126 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, PlayStoreDeferredLaunch) { 4090 TEST_P(ChromeLauncherControllerArcDefaultAppsTest, PlayStoreDeferredLaunch) {
4127 // Add ARC host app to enable Play Store default app. 4091 // Add ARC host app to enable Play Store default app.
4128 extension_service_->AddExtension(arc_support_host_.get()); 4092 extension_service_->AddExtension(arc_support_host_.get());
4129 arc_test_.SetUp(profile()); 4093 arc_test_.SetUp(profile());
4130 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 4094 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
4131 EXPECT_TRUE(prefs->IsRegistered(arc::kPlayStoreAppId)); 4095 EXPECT_TRUE(prefs->IsRegistered(arc::kPlayStoreAppId));
4132 4096
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4292 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4256 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4293 shelf_controller->auto_hide()); 4257 shelf_controller->auto_hide());
4294 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4258 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4295 4259
4296 PrefService* prefs = profile()->GetTestingPrefService(); 4260 PrefService* prefs = profile()->GetTestingPrefService();
4297 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4261 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4298 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4262 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4299 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4263 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4300 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4264 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4301 } 4265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698