Chromium Code Reviews| 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/shelf/shelf.h" | 7 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_item_types.h" | 8 #include "ash/shelf/shelf_item_types.h" |
| 9 #include "ash/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 14 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" | |
|
stevenjb
2016/04/07 18:58:12
cros only?
lgcheng
2016/04/07 19:40:51
Done.
| |
| 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 17 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" | 18 #include "chrome/browser/ui/ash/launcher/desktop_shell_launcher_context_menu.h" |
| 18 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" | 19 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 20 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 22 | 23 |
| 23 class LauncherContextMenuTest : public ash::test::AshTestBase { | 24 class LauncherContextMenuTest : public ash::test::AshTestBase { |
| 24 protected: | 25 protected: |
| 25 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { | 26 static bool IsItemPresentInMenu(LauncherContextMenu* menu, int command_id) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 46 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); | 47 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); |
| 47 return LauncherContextMenu::Create(controller_.get(), &item, shelf); | 48 return LauncherContextMenu::Create(controller_.get(), &item, shelf); |
| 48 } | 49 } |
| 49 | 50 |
| 50 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { | 51 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell() { |
| 51 ash::ShelfItem* item = nullptr; | 52 ash::ShelfItem* item = nullptr; |
| 52 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); | 53 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); |
| 53 return LauncherContextMenu::Create(controller_.get(), item, shelf); | 54 return LauncherContextMenu::Create(controller_.get(), item, shelf); |
| 54 } | 55 } |
| 55 | 56 |
| 57 #if defined(OS_CHROMEOS) | |
| 58 LauncherContextMenu* CreateLauncherContextMenuForArcApp() { | |
| 59 ash::ShelfItem item; | |
| 60 item.id = 1; // dummy id | |
| 61 ash::Shelf* shelf = ash::Shelf::ForWindow(CurrentContext()); | |
| 62 return new ArcLauncherContextMenu(controller_.get(), &item, shelf); | |
| 63 } | |
| 64 #endif | |
| 65 | |
| 56 Profile* profile() { return profile_.get(); } | 66 Profile* profile() { return profile_.get(); } |
| 57 | 67 |
| 58 private: | 68 private: |
| 59 scoped_ptr<TestingProfile> profile_; | 69 scoped_ptr<TestingProfile> profile_; |
| 60 ash::ShelfModel shelf_model_; | 70 ash::ShelfModel shelf_model_; |
| 61 scoped_ptr<ChromeLauncherController> controller_; | 71 scoped_ptr<ChromeLauncherController> controller_; |
| 62 | 72 |
| 63 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); | 73 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); |
| 64 }; | 74 }; |
| 65 | 75 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 132 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
| 123 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
| 124 // By default, screen is not locked and ChangeWallPaper item is added in | 134 // By default, screen is not locked and ChangeWallPaper item is added in |
| 125 // menu. ChangeWallPaper item is not enabled in default mode. | 135 // menu. ChangeWallPaper item is not enabled in default mode. |
| 126 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 136 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
| 127 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 137 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 128 EXPECT_FALSE( | 138 EXPECT_FALSE( |
| 129 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 139 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
| 130 #endif | 140 #endif |
| 131 } | 141 } |
| 142 | |
| 143 // Verifies contextmenu items for Arc app | |
| 144 #if defined(OS_CHROMEOS) | |
| 145 TEST_F(LauncherContextMenuTest, ArcLauncherContextMenuItemCheck) { | |
| 146 scoped_ptr<LauncherContextMenu> menu(CreateLauncherContextMenuForArcApp()); | |
| 147 EXPECT_TRUE( | |
| 148 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | |
| 149 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); | |
| 150 EXPECT_TRUE( | |
| 151 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); | |
| 152 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); | |
| 153 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | |
| 154 LauncherContextMenu::MENU_ALIGNMENT_MENU)); | |
| 155 EXPECT_TRUE( | |
| 156 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | |
| 157 // By default, screen is not locked and ChangeWallPaper item is added in | |
| 158 // menu. ChangeWallPaper item is not enabled in default mode. | |
| 159 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | |
| 160 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | |
| 161 EXPECT_FALSE( | |
| 162 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | |
| 163 } | |
| 164 #endif | |
| OLD | NEW |