| 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_lookup.h" | 8 #include "ash/common/wm_lookup.h" |
| 9 #include "ash/common/wm_root_window_controller.h" | 9 #include "ash/common/wm_root_window_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // Verifies contextmenu items for Arc app | 184 // Verifies contextmenu items for Arc app |
| 185 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { | 185 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { |
| 186 arc_test().app_instance()->RefreshAppList(); | 186 arc_test().app_instance()->RefreshAppList(); |
| 187 arc_test().app_instance()->SendRefreshAppList( | 187 arc_test().app_instance()->SendRefreshAppList( |
| 188 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), | 188 std::vector<arc::mojom::AppInfo>(arc_test().fake_apps().begin(), |
| 189 arc_test().fake_apps().begin() + 1)); | 189 arc_test().fake_apps().begin() + 1)); |
| 190 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); | 190 const std::string app_id = ArcAppTest::GetAppId(arc_test().fake_apps()[0]); |
| 191 | 191 |
| 192 controller()->PinAppWithID(app_id); | 192 controller()->PinAppWithID(app_id); |
| 193 | 193 |
| 194 ash::ShelfItem item; | 194 const ash::ShelfID item_id = controller()->GetShelfIDForAppID(app_id); |
| 195 item.id = controller()->GetShelfIDForAppID(app_id); | 195 const ash::ShelfItem* item = controller()->GetItem(item_id); |
| 196 ASSERT_TRUE(item); |
| 196 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 197 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 197 ash::WmShelf* wm_shelf = GetWmShelf(primary_id); | 198 ash::WmShelf* wm_shelf = GetWmShelf(primary_id); |
| 198 | 199 |
| 199 std::unique_ptr<LauncherContextMenu> menu( | 200 std::unique_ptr<LauncherContextMenu> menu( |
| 200 new ArcLauncherContextMenu(controller(), &item, wm_shelf)); | 201 new ArcLauncherContextMenu(controller(), item, wm_shelf)); |
| 201 | 202 |
| 202 // Arc app is pinned but not running. | 203 // Arc app is pinned but not running. |
| 203 EXPECT_TRUE( | 204 EXPECT_TRUE( |
| 204 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 205 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 205 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); | 206 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); |
| 206 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 207 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 207 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); | 208 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); |
| 208 EXPECT_FALSE( | 209 EXPECT_FALSE( |
| 209 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 210 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 210 | 211 |
| 211 EXPECT_TRUE( | 212 EXPECT_TRUE( |
| 212 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); | 213 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); |
| 213 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); | 214 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); |
| 214 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 215 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 215 LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 216 LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 216 EXPECT_TRUE( | 217 EXPECT_TRUE( |
| 217 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 218 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 218 // By default, screen is not locked and ChangeWallPaper item is added in | 219 // By default, screen is not locked and ChangeWallPaper item is added in |
| 219 // menu. ChangeWallPaper item is not enabled in default mode. | 220 // menu. ChangeWallPaper item is not enabled in default mode. |
| 220 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 221 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 221 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 222 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 222 EXPECT_FALSE( | 223 EXPECT_FALSE( |
| 223 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 224 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 224 | 225 |
| 225 // Arc app is running. | 226 // Arc app is running. |
| 226 std::string window_app_id1("org.chromium.arc.1"); | 227 std::string window_app_id1("org.chromium.arc.1"); |
| 227 CreateArcWindow(window_app_id1); | 228 CreateArcWindow(window_app_id1); |
| 228 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0], | 229 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0], |
| 229 std::string()); | 230 std::string()); |
| 230 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); | 231 menu.reset(new ArcLauncherContextMenu(controller(), item, wm_shelf)); |
| 231 | 232 |
| 232 EXPECT_FALSE( | 233 EXPECT_FALSE( |
| 233 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 234 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 234 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 235 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 235 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); | 236 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); |
| 236 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 237 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 237 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 238 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 238 | 239 |
| 239 // Arc non-launchable app is running. | 240 // Arc non-launchable app is running. |
| 240 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]); | 241 const std::string app_id2 = ArcAppTest::GetAppId(arc_test().fake_apps()[1]); |
| 241 std::string window_app_id2("org.chromium.arc.2"); | 242 std::string window_app_id2("org.chromium.arc.2"); |
| 242 CreateArcWindow(window_app_id2); | 243 CreateArcWindow(window_app_id2); |
| 243 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], | 244 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], |
| 244 std::string()); | 245 std::string()); |
| 245 item.id = controller()->GetShelfIDForAppID(app_id2); | 246 const ash::ShelfID item_id2 = controller()->GetShelfIDForAppID(app_id2); |
| 246 ASSERT_TRUE(item.id); | 247 const ash::ShelfItem* item2 = controller()->GetItem(item_id2); |
| 247 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); | 248 ASSERT_TRUE(item2); |
| 249 menu.reset(new ArcLauncherContextMenu(controller(), item2, wm_shelf)); |
| 248 | 250 |
| 249 EXPECT_FALSE( | 251 EXPECT_FALSE( |
| 250 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 252 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 251 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 253 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 252 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 254 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 253 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 255 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 254 | 256 |
| 255 // Shelf group context menu. | 257 // Shelf group context menu. |
| 256 std::vector<arc::mojom::ShortcutInfo> shortcuts = arc_test().fake_shortcuts(); | 258 std::vector<arc::mojom::ShortcutInfo> shortcuts = arc_test().fake_shortcuts(); |
| 257 shortcuts[0].intent_uri += | 259 shortcuts[0].intent_uri += |
| 258 ";S.org.chromium.arc.shelf_group_id=arc_test_shelf_group;end"; | 260 ";S.org.chromium.arc.shelf_group_id=arc_test_shelf_group;end"; |
| 259 arc_test().app_instance()->SendInstallShortcuts(shortcuts); | 261 arc_test().app_instance()->SendInstallShortcuts(shortcuts); |
| 260 const std::string app_id3 = | 262 const std::string app_id3 = |
| 261 arc::ArcAppShelfId("arc_test_shelf_group", | 263 arc::ArcAppShelfId("arc_test_shelf_group", |
| 262 ArcAppTest::GetAppId(arc_test().fake_apps()[2])) | 264 ArcAppTest::GetAppId(arc_test().fake_apps()[2])) |
| 263 .ToString(); | 265 .ToString(); |
| 264 std::string window_app_id3("org.chromium.arc.3"); | 266 std::string window_app_id3("org.chromium.arc.3"); |
| 265 CreateArcWindow(window_app_id3); | 267 CreateArcWindow(window_app_id3); |
| 266 arc_test().app_instance()->SendTaskCreated(3, arc_test().fake_apps()[2], | 268 arc_test().app_instance()->SendTaskCreated(3, arc_test().fake_apps()[2], |
| 267 shortcuts[0].intent_uri); | 269 shortcuts[0].intent_uri); |
| 268 item.id = controller()->GetShelfIDForAppID(app_id3); | 270 const ash::ShelfID item_id3 = controller()->GetShelfIDForAppID(app_id3); |
| 269 ASSERT_TRUE(item.id); | 271 const ash::ShelfItem* item3 = controller()->GetItem(item_id3); |
| 270 menu.reset(new ArcLauncherContextMenu(controller(), &item, wm_shelf)); | 272 ASSERT_TRUE(item3); |
| 273 menu.reset(new ArcLauncherContextMenu(controller(), item3, wm_shelf)); |
| 271 | 274 |
| 272 EXPECT_FALSE( | 275 EXPECT_FALSE( |
| 273 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 276 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
| 274 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 277 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
| 275 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 278 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
| 276 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 279 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
| 277 } | 280 } |
| 278 | 281 |
| 279 // Tests that fullscreen which makes "Autohide shelf" option disappeared on | 282 // Tests that fullscreen which makes "Autohide shelf" option disappeared on |
| 280 // shelf is a per-display setting (crbug.com/496681). | 283 // shelf is a per-display setting (crbug.com/496681). |
| (...skipping 15 matching lines...) Expand all Loading... |
| 296 widget->SetFullscreen(true); | 299 widget->SetFullscreen(true); |
| 297 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( | 300 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( |
| 298 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 301 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); |
| 299 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( | 302 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( |
| 300 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); | 303 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); |
| 301 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), | 304 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), |
| 302 LauncherContextMenu::MENU_AUTO_HIDE)); | 305 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 303 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), | 306 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), |
| 304 LauncherContextMenu::MENU_AUTO_HIDE)); | 307 LauncherContextMenu::MENU_AUTO_HIDE)); |
| 305 } | 308 } |
| OLD | NEW |