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

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

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

Powered by Google App Engine
This is Rietveld 408576698