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

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

Issue 2798173002: mash: Remove ChromeLauncherController's |id_to_item_controller_map_|. (Closed)
Patch Set: Address comment; fix browser tests. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override { 155 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override {
156 ++changed_; 156 ++changed_;
157 last_index_ = index; 157 last_index_ = index;
158 } 158 }
159 159
160 void ShelfItemMoved(int start_index, int target_index) override { 160 void ShelfItemMoved(int start_index, int target_index) override {
161 last_index_ = target_index; 161 last_index_ = target_index;
162 } 162 }
163 163
164 void OnSetShelfItemDelegate(ash::ShelfID id,
165 ash::ShelfItemDelegate* item_delegate) override {}
166
167 void clear_counts() { 164 void clear_counts() {
168 added_ = 0; 165 added_ = 0;
169 removed_ = 0; 166 removed_ = 0;
170 changed_ = 0; 167 changed_ = 0;
171 last_index_ = 0; 168 last_index_ = 0;
172 } 169 }
173 170
174 int added() const { return added_; } 171 int added() const { return added_; }
175 int removed() const { return removed_; } 172 int removed() const { return removed_; }
176 int changed() const { return changed_; } 173 int changed() const { return changed_; }
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 app_list_specifics->set_item_id(extension_misc::kChromeAppId); 706 app_list_specifics->set_item_id(extension_misc::kChromeAppId);
710 app_list_specifics->set_item_type(sync_pb::AppListSpecifics::TYPE_APP); 707 app_list_specifics->set_item_type(sync_pb::AppListSpecifics::TYPE_APP);
711 app_list_specifics->set_item_pin_ordinal(chrome_position.ToInternalValue()); 708 app_list_specifics->set_item_pin_ordinal(chrome_position.ToInternalValue());
712 syncer::SyncData sync_data = syncer::SyncData::CreateLocalData( 709 syncer::SyncData sync_data = syncer::SyncData::CreateLocalData(
713 extension_misc::kChromeAppId, "Test", specifics); 710 extension_misc::kChromeAppId, "Test", specifics);
714 sync_list.push_back(syncer::SyncChange( 711 sync_list.push_back(syncer::SyncChange(
715 FROM_HERE, syncer::SyncChange::ACTION_UPDATE, sync_data)); 712 FROM_HERE, syncer::SyncChange::ACTION_UPDATE, sync_data));
716 app_service_->ProcessSyncChanges(FROM_HERE, sync_list); 713 app_service_->ProcessSyncChanges(FROM_HERE, sync_list);
717 } 714 }
718 715
719 // Gets the currently configured app launchers from the controller. 716 // Gets the IDs of the currently pinned app items.
720 void GetAppLaunchers(ChromeLauncherControllerImpl* controller, 717 void GetPinnedAppIds(ChromeLauncherControllerImpl* controller,
721 std::vector<std::string>* launchers) { 718 std::vector<std::string>* app_ids) {
722 launchers->clear(); 719 app_ids->clear();
723 for (ash::ShelfItems::const_iterator iter(model_->items().begin()); 720 for (const auto& item : model_->items()) {
724 iter != model_->items().end(); ++iter) { 721 if (item.type == ash::TYPE_PINNED_APP)
725 ChromeLauncherControllerImpl::IDToItemControllerMap::const_iterator entry( 722 app_ids->push_back(item.app_launch_id.app_id());
726 controller->id_to_item_controller_map_.find(iter->id));
727 if (iter->type == ash::TYPE_PINNED_APP &&
728 entry != controller->id_to_item_controller_map_.end()) {
729 launchers->push_back(entry->second->app_id());
730 }
731 } 723 }
732 } 724 }
733 725
734 // Get the setup of the currently shown launcher items in one string. 726 // Get the setup of the currently shown launcher items in one string.
735 // Each pinned element will start with a big letter, each running but not 727 // Each pinned element will start with a big letter, each running but not
736 // pinned V1 app will start with a small letter and each running but not 728 // pinned V1 app will start with a small letter and each running but not
737 // pinned V2 app will start with a '*' + small letter. 729 // pinned V2 app will start with a '*' + small letter.
738 std::string GetPinnedAppStatus() { 730 std::string GetPinnedAppStatus() {
739 std::string result; 731 std::string result;
740 for (int i = 0; i < model_->item_count(); i++) { 732 for (int i = 0; i < model_->item_count(); i++) {
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 const ash::ShelfID shelf_id_shortcut = 1859 const ash::ShelfID shelf_id_shortcut =
1868 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id); 1860 launcher_controller_->GetShelfIDForAppID(arc_shortcut_id);
1869 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); 1861 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1);
1870 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); 1862 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2);
1871 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); 1863 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3);
1872 EXPECT_NE(ash::kInvalidShelfID, shelf_id_shortcut); 1864 EXPECT_NE(ash::kInvalidShelfID, shelf_id_shortcut);
1873 1865
1874 // We activated arc_app_id1 twice but expect one close for item controller 1866 // We activated arc_app_id1 twice but expect one close for item controller
1875 // stops launching request. 1867 // stops launching request.
1876 ash::ShelfItemDelegate* item_delegate = 1868 ash::ShelfItemDelegate* item_delegate =
1877 launcher_controller_->GetShelfItemDelegate(shelf_id_app_1); 1869 model_->GetShelfItemDelegate(shelf_id_app_1);
1878 ASSERT_NE(nullptr, item_delegate); 1870 ASSERT_NE(nullptr, item_delegate);
1879 item_delegate->Close(); 1871 item_delegate->Close();
1880 base::RunLoop().RunUntilIdle(); 1872 base::RunLoop().RunUntilIdle();
1881 1873
1882 EXPECT_EQ(ash::kInvalidShelfID, 1874 EXPECT_EQ(ash::kInvalidShelfID,
1883 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); 1875 launcher_controller_->GetShelfIDForAppID(arc_app_id1));
1884 EXPECT_EQ(shelf_id_app_2, 1876 EXPECT_EQ(shelf_id_app_2,
1885 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); 1877 launcher_controller_->GetShelfIDForAppID(arc_app_id2));
1886 EXPECT_EQ(shelf_id_app_3, 1878 EXPECT_EQ(shelf_id_app_3,
1887 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); 1879 launcher_controller_->GetShelfIDForAppID(arc_app_id3));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 EXPECT_NE(ash::kInvalidShelfID, shelf_id); 1923 EXPECT_NE(ash::kInvalidShelfID, shelf_id);
1932 1924
1933 int item_index = model_->ItemIndexByID(shelf_id); 1925 int item_index = model_->ItemIndexByID(shelf_id);
1934 ASSERT_GE(item_index, 0); 1926 ASSERT_GE(item_index, 0);
1935 1927
1936 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED); 1928 EXPECT_EQ(model_->items()[item_index].status, ash::STATUS_CLOSED);
1937 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP); 1929 EXPECT_EQ(model_->items()[item_index].type, ash::TYPE_PINNED_APP);
1938 1930
1939 // Play Store app is ARC app that might be represented by native Chrome 1931 // Play Store app is ARC app that might be represented by native Chrome
1940 // platform app. 1932 // platform app.
1941 launcher_controller_->SetShelfItemDelegate( 1933 model_->SetShelfItemDelegate(
1942 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>( 1934 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>(
1943 ash::AppLaunchId(app_id))); 1935 ash::AppLaunchId(app_id)));
1944 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 1936 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
1945 1937
1946 // This launch request should be ignored in case of active app. 1938 // This launch request should be ignored in case of active app.
1947 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 1939 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
1948 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 1940 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
1949 1941
1950 // Close app but shortcut should exist. 1942 // Close app but shortcut should exist.
1951 launcher_controller_->CloseLauncherItem(shelf_id); 1943 launcher_controller_->CloseLauncherItem(shelf_id);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 2401
2410 // Create a second test profile. The first is the one in profile() created in 2402 // Create a second test profile. The first is the one in profile() created in
2411 // BrowserWithTestWindowTest::SetUp(). 2403 // BrowserWithTestWindowTest::SetUp().
2412 // No need to add the profiles to the MultiUserWindowManager here. 2404 // No need to add the profiles to the MultiUserWindowManager here.
2413 // CreateMultiUserProfile() already does that. 2405 // CreateMultiUserProfile() already does that.
2414 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 2406 TestingProfile* profile2 = CreateMultiUserProfile("user2");
2415 const AccountId current_user = 2407 const AccountId current_user =
2416 multi_user_util::GetAccountIdFromProfile(profile()); 2408 multi_user_util::GetAccountIdFromProfile(profile());
2417 2409
2418 // Create a browser window with a native window for the current user. 2410 // Create a browser window with a native window for the current user.
2419 Browser::CreateParams params(profile(), true);
2420 std::unique_ptr<Browser> browser( 2411 std::unique_ptr<Browser> browser(
2421 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, &params)); 2412 CreateBrowserWithTestWindowForProfile(profile()));
2422 BrowserWindow* browser_window = browser->window(); 2413 BrowserWindow* browser_window = browser->window();
2423 aura::Window* window = browser_window->GetNativeWindow(); 2414 aura::Window* window = browser_window->GetNativeWindow();
2424 manager->SetWindowOwner(window, current_user); 2415 manager->SetWindowOwner(window, current_user);
2425 2416
2426 // Check that an activation of the window on its owner's desktop does not 2417 // Check that an activation of the window on its owner's desktop does not
2427 // change the visibility to another user. 2418 // change the visibility to another user.
2428 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); 2419 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false);
2429 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); 2420 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user));
2430 2421
2431 // Transfer the window to another user's desktop and check that activating it 2422 // Transfer the window to another user's desktop and check that activating it
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 extension_service_->AddExtension(extension2_.get()); 2678 extension_service_->AddExtension(extension2_.get());
2688 extension_service_->AddExtension(extension3_.get()); 2679 extension_service_->AddExtension(extension3_.get());
2689 extension_service_->AddExtension(extension4_.get()); 2680 extension_service_->AddExtension(extension4_.get());
2690 2681
2691 InitLauncherController(); 2682 InitLauncherController();
2692 2683
2693 syncer::SyncChangeList sync_list; 2684 syncer::SyncChangeList sync_list;
2694 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId); 2685 InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId);
2695 SendPinChanges(sync_list, true); 2686 SendPinChanges(sync_list, true);
2696 2687
2697 std::vector<std::string> expected_launchers; 2688 std::vector<std::string> expected_pinned_apps;
2698 std::vector<std::string> actual_launchers; 2689 std::vector<std::string> actual_pinned_apps;
2699 GetAppLaunchers(launcher_controller_, &actual_launchers); 2690 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2700 EXPECT_EQ(expected_launchers, actual_launchers); 2691 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2701 2692
2702 // Unavailable extensions don't create launcher items. 2693 // Unavailable extensions don't create launcher items.
2703 sync_list.clear(); 2694 sync_list.clear();
2704 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2695 InsertAddPinChange(&sync_list, 0, extension1_->id());
2705 InsertAddPinChange(&sync_list, 1, extension2_->id()); 2696 InsertAddPinChange(&sync_list, 1, extension2_->id());
2706 InsertAddPinChange(&sync_list, 3, extension4_->id()); 2697 InsertAddPinChange(&sync_list, 3, extension4_->id());
2707 SendPinChanges(sync_list, false); 2698 SendPinChanges(sync_list, false);
2708 2699
2709 expected_launchers.push_back(extension2_->id()); 2700 expected_pinned_apps.push_back(extension2_->id());
2710 expected_launchers.push_back(extension4_->id()); 2701 expected_pinned_apps.push_back(extension4_->id());
2711 GetAppLaunchers(launcher_controller_, &actual_launchers); 2702 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2712 EXPECT_EQ(expected_launchers, actual_launchers); 2703 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2713 2704
2714 sync_list.clear(); 2705 sync_list.clear();
2715 InsertAddPinChange(&sync_list, 2, extension3_->id()); 2706 InsertAddPinChange(&sync_list, 2, extension3_->id());
2716 SendPinChanges(sync_list, false); 2707 SendPinChanges(sync_list, false);
2717 expected_launchers.insert(expected_launchers.begin() + 1, extension3_->id()); 2708 expected_pinned_apps.insert(expected_pinned_apps.begin() + 1,
2718 GetAppLaunchers(launcher_controller_, &actual_launchers); 2709 extension3_->id());
2719 EXPECT_EQ(expected_launchers, actual_launchers); 2710 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2711 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2720 2712
2721 sync_list.clear(); 2713 sync_list.clear();
2722 InsertUpdatePinChange(&sync_list, 0, extension4_->id()); 2714 InsertUpdatePinChange(&sync_list, 0, extension4_->id());
2723 InsertUpdatePinChange(&sync_list, 1, extension3_->id()); 2715 InsertUpdatePinChange(&sync_list, 1, extension3_->id());
2724 InsertUpdatePinChange(&sync_list, 2, extension2_->id()); 2716 InsertUpdatePinChange(&sync_list, 2, extension2_->id());
2725 SendPinChanges(sync_list, false); 2717 SendPinChanges(sync_list, false);
2726 std::reverse(expected_launchers.begin(), expected_launchers.end()); 2718 std::reverse(expected_pinned_apps.begin(), expected_pinned_apps.end());
2727 GetAppLaunchers(launcher_controller_, &actual_launchers); 2719 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2728 EXPECT_EQ(expected_launchers, actual_launchers); 2720 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2729 2721
2730 // Sending legacy sync change without pin info should not affect pin model. 2722 // Sending legacy sync change without pin info should not affect pin model.
2731 sync_list.clear(); 2723 sync_list.clear();
2732 InsertLegacyPinChange(&sync_list, extension4_->id()); 2724 InsertLegacyPinChange(&sync_list, extension4_->id());
2733 SendPinChanges(sync_list, false); 2725 SendPinChanges(sync_list, false);
2734 GetAppLaunchers(launcher_controller_, &actual_launchers); 2726 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2735 EXPECT_EQ(expected_launchers, actual_launchers); 2727 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2736 2728
2737 sync_list.clear(); 2729 sync_list.clear();
2738 InsertRemovePinChange(&sync_list, extension4_->id()); 2730 InsertRemovePinChange(&sync_list, extension4_->id());
2739 SendPinChanges(sync_list, false); 2731 SendPinChanges(sync_list, false);
2740 expected_launchers.erase(expected_launchers.begin()); 2732 expected_pinned_apps.erase(expected_pinned_apps.begin());
2741 GetAppLaunchers(launcher_controller_, &actual_launchers); 2733 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2742 EXPECT_EQ(expected_launchers, actual_launchers); 2734 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2743 2735
2744 sync_list.clear(); 2736 sync_list.clear();
2745 InsertRemovePinChange(&sync_list, extension3_->id()); 2737 InsertRemovePinChange(&sync_list, extension3_->id());
2746 InsertRemovePinChange(&sync_list, extension2_->id()); 2738 InsertRemovePinChange(&sync_list, extension2_->id());
2747 SendPinChanges(sync_list, false); 2739 SendPinChanges(sync_list, false);
2748 expected_launchers.clear(); 2740 expected_pinned_apps.clear();
2749 GetAppLaunchers(launcher_controller_, &actual_launchers); 2741 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2750 EXPECT_EQ(expected_launchers, actual_launchers); 2742 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2751 } 2743 }
2752 2744
2753 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) { 2745 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) {
2754 // Note extension3_ is actually Gmail app which is default pinned. 2746 // Note extension3_ is actually Gmail app which is default pinned.
2755 extension_service_->AddExtension(extension3_.get()); 2747 extension_service_->AddExtension(extension3_.get());
2756 InitLauncherController(); 2748 InitLauncherController();
2757 2749
2758 // Default pins should contain Gmail. Pref is not syncing now. 2750 // Default pins should contain Gmail. Pref is not syncing now.
2759 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 2751 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2760 2752
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 extension_service_->AddExtension(extension3_.get()); 2794 extension_service_->AddExtension(extension3_.get());
2803 2795
2804 InitLauncherController(); 2796 InitLauncherController();
2805 2797
2806 syncer::SyncChangeList sync_list; 2798 syncer::SyncChangeList sync_list;
2807 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2799 InsertAddPinChange(&sync_list, 0, extension1_->id());
2808 InsertAddPinChange(&sync_list, 1, extension2_->id()); 2800 InsertAddPinChange(&sync_list, 1, extension2_->id());
2809 InsertAddPinChange(&sync_list, 2, extension3_->id()); 2801 InsertAddPinChange(&sync_list, 2, extension3_->id());
2810 SendPinChanges(sync_list, true); 2802 SendPinChanges(sync_list, true);
2811 2803
2812 std::vector<std::string> expected_launchers; 2804 std::vector<std::string> expected_pinned_apps;
2813 expected_launchers.push_back(extension1_->id()); 2805 expected_pinned_apps.push_back(extension1_->id());
2814 expected_launchers.push_back(extension3_->id()); 2806 expected_pinned_apps.push_back(extension3_->id());
2815 std::vector<std::string> actual_launchers; 2807 std::vector<std::string> actual_pinned_apps;
2816 2808
2817 GetAppLaunchers(launcher_controller_, &actual_launchers); 2809 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2818 EXPECT_EQ(expected_launchers, actual_launchers); 2810 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2819 2811
2820 // Install |extension2| and verify it shows up between the other two. 2812 // Install |extension2| and verify it shows up between the other two.
2821 extension_service_->AddExtension(extension2_.get()); 2813 extension_service_->AddExtension(extension2_.get());
2822 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); 2814 expected_pinned_apps.insert(expected_pinned_apps.begin() + 1,
2823 GetAppLaunchers(launcher_controller_, &actual_launchers); 2815 extension2_->id());
2824 EXPECT_EQ(expected_launchers, actual_launchers); 2816 GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
2817 EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
2825 } 2818 }
2826 2819
2827 // Ensure |controller| creates the expected menu items for the given shelf item. 2820 // Ensure |controller| creates the expected menu items for the given shelf item.
2828 void CheckAppMenu(ChromeLauncherControllerImpl* controller, 2821 void CheckAppMenu(ChromeLauncherControllerImpl* controller,
2829 const ash::ShelfItem& item, 2822 const ash::ShelfItem& item,
2830 size_t expected_item_count, 2823 size_t expected_item_count,
2831 base::string16 expected_item_titles[]) { 2824 base::string16 expected_item_titles[]) {
2832 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item); 2825 ash::MenuItemList items = controller->GetAppMenuItemsForTesting(item);
2833 ASSERT_EQ(expected_item_count, items.size()); 2826 ASSERT_EQ(expected_item_count, items.size());
2834 for (size_t i = 0; i < expected_item_count; i++) 2827 for (size_t i = 0; i < expected_item_count; i++)
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 base::string16 title2 = ASCIIToUTF16("Test2"); 3267 base::string16 title2 = ASCIIToUTF16("Test2");
3275 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); 3268 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
3276 3269
3277 // Check that the menu is properly set. 3270 // Check that the menu is properly set.
3278 ash::ShelfItem item_gmail; 3271 ash::ShelfItem item_gmail;
3279 item_gmail.type = ash::TYPE_PINNED_APP; 3272 item_gmail.type = ash::TYPE_PINNED_APP;
3280 item_gmail.id = gmail_id; 3273 item_gmail.id = gmail_id;
3281 base::string16 two_menu_items[] = {title1, title2}; 3274 base::string16 two_menu_items[] = {title1, title2};
3282 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); 3275 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items);
3283 ash::ShelfItemDelegate* item_delegate = 3276 ash::ShelfItemDelegate* item_delegate =
3284 launcher_controller_->GetShelfItemDelegate(gmail_id); 3277 model_->GetShelfItemDelegate(gmail_id);
3285 ASSERT_TRUE(item_delegate); 3278 ASSERT_TRUE(item_delegate);
3286 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 3279 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
3287 // Execute the second item in the menu, after the title and two separators, 3280 // Execute the second item in the menu, after the title and two separators,
3288 // this shouldn't do anything since that item is already the active tab. 3281 // this shouldn't do anything since that item is already the active tab.
3289 { 3282 {
3290 ash::ShelfApplicationMenuModel menu( 3283 ash::ShelfApplicationMenuModel menu(
3291 base::string16(), 3284 base::string16(),
3292 launcher_controller_->GetAppMenuItemsForTesting(item_gmail), 3285 launcher_controller_->GetAppMenuItemsForTesting(item_gmail),
3293 item_delegate); 3286 item_delegate);
3294 menu.ActivatedAt(4); 3287 menu.ActivatedAt(4);
(...skipping 28 matching lines...) Expand all
3323 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2); 3316 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
3324 3317
3325 // Check that the menu is properly set. 3318 // Check that the menu is properly set.
3326 ash::ShelfItem item_gmail; 3319 ash::ShelfItem item_gmail;
3327 item_gmail.type = ash::TYPE_PINNED_APP; 3320 item_gmail.type = ash::TYPE_PINNED_APP;
3328 item_gmail.id = gmail_id; 3321 item_gmail.id = gmail_id;
3329 base::string16 two_menu_items[] = {title1, title2}; 3322 base::string16 two_menu_items[] = {title1, title2};
3330 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items); 3323 CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items);
3331 3324
3332 ash::ShelfItemDelegate* item_delegate = 3325 ash::ShelfItemDelegate* item_delegate =
3333 launcher_controller_->GetShelfItemDelegate(gmail_id); 3326 model_->GetShelfItemDelegate(gmail_id);
3334 ASSERT_TRUE(item_delegate); 3327 ASSERT_TRUE(item_delegate);
3335 int tabs = browser()->tab_strip_model()->count(); 3328 int tabs = browser()->tab_strip_model()->count();
3336 // Activate the proper tab through the menu item. 3329 // Activate the proper tab through the menu item.
3337 { 3330 {
3338 ash::MenuItemList items = 3331 ash::MenuItemList items =
3339 launcher_controller_->GetAppMenuItemsForTesting(item_gmail); 3332 launcher_controller_->GetAppMenuItemsForTesting(item_gmail);
3340 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_NONE); 3333 item_delegate->ExecuteCommand(items[1]->command_id, ui::EF_NONE);
3341 EXPECT_EQ(tabs, browser()->tab_strip_model()->count()); 3334 EXPECT_EQ(tabs, browser()->tab_strip_model()->count());
3342 } 3335 }
3343 3336
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 ASSERT_TRUE(window2); 3701 ASSERT_TRUE(window2);
3709 3702
3710 EXPECT_FALSE(window1->IsActive()); 3703 EXPECT_FALSE(window1->IsActive());
3711 EXPECT_TRUE(window2->IsActive()); 3704 EXPECT_TRUE(window2->IsActive());
3712 3705
3713 const std::string app_id = ArcAppTest::GetAppId(appinfo); 3706 const std::string app_id = ArcAppTest::GetAppId(appinfo);
3714 3707
3715 const ash::ShelfID shelf_id = 3708 const ash::ShelfID shelf_id =
3716 launcher_controller_->GetShelfIDForAppID(app_id); 3709 launcher_controller_->GetShelfIDForAppID(app_id);
3717 ash::ShelfItemDelegate* item_delegate = 3710 ash::ShelfItemDelegate* item_delegate =
3718 launcher_controller_->GetShelfItemDelegate(shelf_id); 3711 model_->GetShelfItemDelegate(shelf_id);
3719 ASSERT_TRUE(item_delegate); 3712 ASSERT_TRUE(item_delegate);
3720 3713
3721 // Selecting the item will show its application menu. It does not change the 3714 // Selecting the item will show its application menu. It does not change the
3722 // active window. 3715 // active window.
3723 SelectItem(item_delegate); 3716 SelectItem(item_delegate);
3724 EXPECT_FALSE(window1->IsActive()); 3717 EXPECT_FALSE(window1->IsActive());
3725 EXPECT_TRUE(window2->IsActive()); 3718 EXPECT_TRUE(window2->IsActive());
3726 3719
3727 // Command ids are just app window indices. Note, apps are registered in 3720 // Command ids are just app window indices. Note, apps are registered in
3728 // opposite order. Last created goes in front. 3721 // opposite order. Last created goes in front.
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 4047
4055 EnablePlayStore(true); 4048 EnablePlayStore(true);
4056 4049
4057 // Pin Play Store. It should be pinned but not scheduled for deferred launch. 4050 // Pin Play Store. It should be pinned but not scheduled for deferred launch.
4058 launcher_controller_->PinAppWithID(arc::kPlayStoreAppId); 4051 launcher_controller_->PinAppWithID(arc::kPlayStoreAppId);
4059 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); 4052 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
4060 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp( 4053 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(
4061 arc::kPlayStoreAppId)); 4054 arc::kPlayStoreAppId));
4062 4055
4063 // Simulate click. This should schedule Play Store for deferred launch. 4056 // Simulate click. This should schedule Play Store for deferred launch.
4064 ash::ShelfItemDelegate* item_delegate = 4057 ash::ShelfItemDelegate* item_delegate = model_->GetShelfItemDelegate(
4065 launcher_controller_->GetShelfItemDelegate( 4058 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
4066 launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
4067 EXPECT_TRUE(item_delegate); 4059 EXPECT_TRUE(item_delegate);
4068 SelectItem(item_delegate); 4060 SelectItem(item_delegate);
4069 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId)); 4061 EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));
4070 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp( 4062 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(
4071 arc::kPlayStoreAppId)); 4063 arc::kPlayStoreAppId));
4072 } 4064 }
4073 4065
4074 // Checks the case when several app items have the same ordinal position (which 4066 // Checks the case when several app items have the same ordinal position (which
4075 // is valid case). 4067 // is valid case).
4076 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) { 4068 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4295 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4287 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4296 shelf_controller->auto_hide()); 4288 shelf_controller->auto_hide());
4297 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4289 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4298 4290
4299 PrefService* prefs = profile()->GetTestingPrefService(); 4291 PrefService* prefs = profile()->GetTestingPrefService();
4300 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4292 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4301 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4293 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4302 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4294 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4303 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4295 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4304 } 4296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698