| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/public/cpp/shelf_item.h" | 9 #include "ash/public/cpp/shelf_item.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 ash::RootWindowController* root_window_controller = | 83 ash::RootWindowController* root_window_controller = |
| 84 ash::Shell::GetRootWindowControllerWithDisplayId(display_id); | 84 ash::Shell::GetRootWindowControllerWithDisplayId(display_id); |
| 85 EXPECT_NE(nullptr, root_window_controller); | 85 EXPECT_NE(nullptr, root_window_controller); |
| 86 return root_window_controller->GetShelf(); | 86 return root_window_controller->GetShelf(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 LauncherContextMenu* CreateLauncherContextMenu( | 89 LauncherContextMenu* CreateLauncherContextMenu( |
| 90 ash::ShelfItemType shelf_item_type, | 90 ash::ShelfItemType shelf_item_type, |
| 91 ash::WmShelf* wm_shelf) { | 91 ash::WmShelf* wm_shelf) { |
| 92 ash::ShelfItem item; | 92 ash::ShelfItem item; |
| 93 item.id = ash::ShelfID("dummy id"); | 93 item.id = ash::ShelfID("idmockidmockidmockidmockidmockid"); |
| 94 item.type = shelf_item_type; | 94 item.type = shelf_item_type; |
| 95 return LauncherContextMenu::Create(controller(), &item, wm_shelf); | 95 return LauncherContextMenu::Create(controller(), &item, wm_shelf); |
| 96 } | 96 } |
| 97 | 97 |
| 98 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell( | 98 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell( |
| 99 ash::WmShelf* wm_shelf) { | 99 ash::WmShelf* wm_shelf) { |
| 100 return LauncherContextMenu::Create(controller(), nullptr, wm_shelf); | 100 return LauncherContextMenu::Create(controller(), nullptr, wm_shelf); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Creates app window and set optional ARC application id. | 103 // Creates app window and set optional ARC application id. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Verifies contextmenu items for ARC app | 213 // Verifies contextmenu items for ARC app |
| 214 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { | 214 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { |
| 215 arc_test().app_instance()->RefreshAppList(); | 215 arc_test().app_instance()->RefreshAppList(); |
| 216 arc_test().app_instance()->SendRefreshAppList( | 216 arc_test().app_instance()->SendRefreshAppList( |
| 217 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), | 217 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), |
| 218 arc_test().fake_apps().begin() + 1)); | 218 arc_test().fake_apps().begin() + 1)); |
| 219 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); | 219 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); |
| 220 | 220 |
| 221 controller()->PinAppWithID(app_id); | 221 controller()->PinAppWithID(app_id); |
| 222 | 222 |
| 223 const ash::ShelfID item_id = controller()->GetShelfIDForAppID(app_id); | 223 const ash::ShelfItem* item = controller()->GetItem(ash::ShelfID(app_id)); |
| 224 const ash::ShelfItem* item = controller()->GetItem(item_id); | |
| 225 ASSERT_TRUE(item); | 224 ASSERT_TRUE(item); |
| 226 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 225 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 227 ash::WmShelf* wm_shelf = GetWmShelf(primary_id); | 226 ash::WmShelf* wm_shelf = GetWmShelf(primary_id); |
| 228 | 227 |
| 229 std::unique_ptr<LauncherContextMenu> menu( | 228 std::unique_ptr<LauncherContextMenu> menu( |
| 230 new ArcLauncherContextMenu(controller(), item, wm_shelf)); | 229 new ArcLauncherContextMenu(controller(), item, wm_shelf)); |
| 231 | 230 |
| 232 // ARC app is pinned but not running. | 231 // ARC app is pinned but not running. |
| 233 EXPECT_TRUE( | 232 EXPECT_TRUE( |
| 234 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 233 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 265 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); | 264 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); |
| 266 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 265 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 267 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 266 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 268 | 267 |
| 269 // ARC non-launchable app is running. | 268 // ARC non-launchable app is running. |
| 270 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]); | 269 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]); |
| 271 std::string window_app_id2("org.chromium.arc.2"); | 270 std::string window_app_id2("org.chromium.arc.2"); |
| 272 CreateArcWindow(window_app_id2); | 271 CreateArcWindow(window_app_id2); |
| 273 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], | 272 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], |
| 274 std::string()); | 273 std::string()); |
| 275 const ash::ShelfID item_id2 = controller()->GetShelfIDForAppID(app_id2); | 274 const ash::ShelfItem* item2 = controller()->GetItem(ash::ShelfID(app_id2)); |
| 276 const ash::ShelfItem* item2 = controller()->GetItem(item_id2); | |
| 277 ASSERT_TRUE(item2); | 275 ASSERT_TRUE(item2); |
| 278 menu.reset(new ArcLauncherContextMenu(controller(), item2, wm_shelf)); | 276 menu.reset(new ArcLauncherContextMenu(controller(), item2, wm_shelf)); |
| 279 | 277 |
| 280 EXPECT_FALSE( | 278 EXPECT_FALSE( |
| 281 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 279 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 282 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 280 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 283 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 281 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 284 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 282 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 285 | 283 |
| 286 // Shelf group context menu. | 284 // Shelf group context menu. |
| 287 std::vector<arc::mojom::ShortcutInfo> shortcuts = arc_test().fake_shortcuts(); | 285 std::vector<arc::mojom::ShortcutInfo> shortcuts = arc_test().fake_shortcuts(); |
| 288 shortcuts[0].intent_uri += | 286 shortcuts[0].intent_uri += |
| 289 ";S.org.chromium.arc.shelf_group_id=arc_test_shelf_group;end"; | 287 ";S.org.chromium.arc.shelf_group_id=arc_test_shelf_group;end"; |
| 290 arc_test().app_instance()->SendInstallShortcuts(shortcuts); | 288 arc_test().app_instance()->SendInstallShortcuts(shortcuts); |
| 291 const std::string app_id3 = | 289 const std::string app_id3 = |
| 292 arc::ArcAppShelfId("arc_test_shelf_group", | 290 arc::ArcAppShelfId("arc_test_shelf_group", |
| 293 ArcAppTest::GetAppId(arc_test().fake_apps()[2])) | 291 ArcAppTest::GetAppId(arc_test().fake_apps()[2])) |
| 294 .ToString(); | 292 .ToString(); |
| 295 std::string window_app_id3("org.chromium.arc.3"); | 293 std::string window_app_id3("org.chromium.arc.3"); |
| 296 CreateArcWindow(window_app_id3); | 294 CreateArcWindow(window_app_id3); |
| 297 arc_test().app_instance()->SendTaskCreated(3, arc_test().fake_apps()[2], | 295 arc_test().app_instance()->SendTaskCreated(3, arc_test().fake_apps()[2], |
| 298 shortcuts[0].intent_uri); | 296 shortcuts[0].intent_uri); |
| 299 const ash::ShelfID item_id3 = controller()->GetShelfIDForAppID(app_id3); | 297 const ash::ShelfItem* item3 = controller()->GetItem(ash::ShelfID(app_id3)); |
| 300 const ash::ShelfItem* item3 = controller()->GetItem(item_id3); | |
| 301 ASSERT_TRUE(item3); | 298 ASSERT_TRUE(item3); |
| 302 menu.reset(new ArcLauncherContextMenu(controller(), item3, wm_shelf)); | 299 menu.reset(new ArcLauncherContextMenu(controller(), item3, wm_shelf)); |
| 303 | 300 |
| 304 EXPECT_FALSE( | 301 EXPECT_FALSE( |
| 305 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 302 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 306 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 303 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 307 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 304 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 308 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 305 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 309 } | 306 } |
| 310 | 307 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 327 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 324 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); |
| 328 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( | 325 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( |
| 329 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); | 326 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); |
| 330 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), | 327 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), |
| 331 LauncherContextMenu::MENU_AUTO_HIDE)); | 328 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 332 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), | 329 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), |
| 333 LauncherContextMenu::MENU_AUTO_HIDE)); | 330 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 334 } | 331 } |
| 335 | 332 |
| 336 } // namespace | 333 } // namespace |
| OLD | NEW |