| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/launcher_context_menu.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.h" |
| 8 #include "ash/common/wm_root_window_controller.h" | 8 #include "ash/common/wm_root_window_controller.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 DesktopShellLauncherContextMenuVerifyCloseItem) { | 165 DesktopShellLauncherContextMenuVerifyCloseItem) { |
| 166 std::unique_ptr<LauncherContextMenu> menu( | 166 std::unique_ptr<LauncherContextMenu> menu( |
| 167 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); | 167 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT)); |
| 168 ASSERT_FALSE( | 168 ASSERT_FALSE( |
| 169 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 169 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Verifies contextmenu items for Arc app | 172 // Verifies contextmenu items for Arc app |
| 173 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { | 173 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { |
| 174 arc_test().app_instance()->RefreshAppList(); | 174 arc_test().app_instance()->RefreshAppList(); |
| 175 arc_test().app_instance()->SendRefreshAppList(arc_test().fake_apps()); | 175 arc_test().app_instance()->SendRefreshAppList( |
| 176 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), |
| 177 arc_test().fake_apps().begin() + 1)); |
| 176 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); | 178 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); |
| 177 | 179 |
| 178 controller()->PinAppWithID(app_id); | 180 controller()->PinAppWithID(app_id); |
| 179 | 181 |
| 180 ash::ShelfItem item; | 182 ash::ShelfItem item; |
| 181 item.id = controller()->GetShelfIDForAppID(app_id); | 183 item.id = controller()->GetShelfIDForAppID(app_id); |
| 182 ash::WmShelf* wm_shelf = GetWmShelf(); | 184 ash::WmShelf* wm_shelf = GetWmShelf(); |
| 183 | 185 |
| 184 std::unique_ptr<LauncherContextMenu> menu( | 186 std::unique_ptr<LauncherContextMenu> menu( |
| 185 new ArcLauncherContextMenu(controller(), &item, wm_shelf)); | 187 new ArcLauncherContextMenu(controller(), &item, wm_shelf)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 212 CreateArcWindow(window_app_id1); | 214 CreateArcWindow(window_app_id1); |
| 213 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0]); | 215 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0]); |
| 214 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); | 216 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); |
| 215 | 217 |
| 216 EXPECT_FALSE( | 218 EXPECT_FALSE( |
| 217 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 219 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 218 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 220 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 219 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); | 221 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); |
| 220 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 222 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 221 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 223 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 224 |
| 225 // Arc non-launchable app is running. |
| 226 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]); |
| 227 std::string window_app_id2("org.chromium.arc.2"); |
| 228 CreateArcWindow(window_app_id2); |
| 229 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1]); |
| 230 item.id = controller()->GetShelfIDForAppID(app_id2); |
| 231 ASSERT_TRUE(item.id); |
| 232 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); |
| 233 |
| 234 EXPECT_FALSE( |
| 235 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 236 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 237 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 238 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 222 } | 239 } |
| OLD | NEW |