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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 LauncherContextMenuTest() {} | 72 LauncherContextMenuTest() {} |
73 | 73 |
74 void SetUp() override { | 74 void SetUp() override { |
75 arc_test_.SetUp(&profile_); | 75 arc_test_.SetUp(&profile_); |
76 session_manager_ = base::MakeUnique<session_manager::SessionManager>(); | 76 session_manager_ = base::MakeUnique<session_manager::SessionManager>(); |
77 shell_delegate_ = new ChromeLauncherTestShellDelegate(&profile_); | 77 shell_delegate_ = new ChromeLauncherTestShellDelegate(&profile_); |
78 ash_test_helper()->set_test_shell_delegate(shell_delegate_); | 78 ash_test_helper()->set_test_shell_delegate(shell_delegate_); |
79 ash::test::AshTestBase::SetUp(); | 79 ash::test::AshTestBase::SetUp(); |
80 } | 80 } |
81 | 81 |
82 ash::WmShelf* GetWmShelf(int64_t display_id) { | 82 ash::Shelf* GetShelf(int64_t display_id) { |
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::Shelf* shelf) { |
92 ash::ShelfItem item; | 92 ash::ShelfItem item; |
93 item.id = ash::ShelfID("idmockidmockidmockidmockidmockid"); | 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, shelf); |
96 } | 96 } |
97 | 97 |
98 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell( | 98 LauncherContextMenu* CreateLauncherContextMenuForDesktopShell( |
99 ash::WmShelf* wm_shelf) { | 99 ash::Shelf* shelf) { |
100 return LauncherContextMenu::Create(controller(), nullptr, wm_shelf); | 100 return LauncherContextMenu::Create(controller(), nullptr, 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. |
104 views::Widget* CreateArcWindow(std::string& window_app_id) { | 104 views::Widget* CreateArcWindow(std::string& window_app_id) { |
105 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 105 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
106 views::Widget* widget = new views::Widget(); | 106 views::Widget* widget = new views::Widget(); |
107 widget->Init(params); | 107 widget->Init(params); |
108 widget->Show(); | 108 widget->Show(); |
109 widget->Activate(); | 109 widget->Activate(); |
110 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), | 110 exo::ShellSurface::SetApplicationId(widget->GetNativeWindow(), |
(...skipping 18 matching lines...) Expand all Loading... |
129 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); | 129 DISALLOW_COPY_AND_ASSIGN(LauncherContextMenuTest); |
130 }; | 130 }; |
131 | 131 |
132 // Verifies that "New Incognito window" menu item in the launcher context | 132 // Verifies that "New Incognito window" menu item in the launcher context |
133 // menu is disabled when Incognito mode is switched off (by a policy). | 133 // menu is disabled when Incognito mode is switched off (by a policy). |
134 TEST_F(LauncherContextMenuTest, | 134 TEST_F(LauncherContextMenuTest, |
135 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { | 135 NewIncognitoWindowMenuIsDisabledWhenIncognitoModeOff) { |
136 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 136 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
137 // Initially, "New Incognito window" should be enabled. | 137 // Initially, "New Incognito window" should be enabled. |
138 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( | 138 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( |
139 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 139 ash::TYPE_BROWSER_SHORTCUT, GetShelf(primary_id))); |
140 ASSERT_TRUE(IsItemPresentInMenu( | 140 ASSERT_TRUE(IsItemPresentInMenu( |
141 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); | 141 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); |
142 EXPECT_TRUE(menu->IsCommandIdEnabled( | 142 EXPECT_TRUE(menu->IsCommandIdEnabled( |
143 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); | 143 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); |
144 | 144 |
145 // Disable Incognito mode. | 145 // Disable Incognito mode. |
146 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), | 146 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), |
147 IncognitoModePrefs::DISABLED); | 147 IncognitoModePrefs::DISABLED); |
148 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT, | 148 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT, |
149 GetWmShelf(primary_id))); | 149 GetShelf(primary_id))); |
150 // The item should be disabled. | 150 // The item should be disabled. |
151 ASSERT_TRUE(IsItemPresentInMenu( | 151 ASSERT_TRUE(IsItemPresentInMenu( |
152 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); | 152 menu.get(), LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); |
153 EXPECT_FALSE(menu->IsCommandIdEnabled( | 153 EXPECT_FALSE(menu->IsCommandIdEnabled( |
154 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); | 154 LauncherContextMenu::MENU_NEW_INCOGNITO_WINDOW)); |
155 } | 155 } |
156 | 156 |
157 // Verifies that "New window" menu item in the launcher context | 157 // Verifies that "New window" menu item in the launcher context |
158 // menu is disabled when Incognito mode is forced (by a policy). | 158 // menu is disabled when Incognito mode is forced (by a policy). |
159 TEST_F(LauncherContextMenuTest, | 159 TEST_F(LauncherContextMenuTest, |
160 NewWindowMenuIsDisabledWhenIncognitoModeForced) { | 160 NewWindowMenuIsDisabledWhenIncognitoModeForced) { |
161 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 161 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
162 // Initially, "New window" should be enabled. | 162 // Initially, "New window" should be enabled. |
163 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( | 163 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( |
164 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 164 ash::TYPE_BROWSER_SHORTCUT, GetShelf(primary_id))); |
165 ASSERT_TRUE(IsItemPresentInMenu( | 165 ASSERT_TRUE(IsItemPresentInMenu( |
166 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); | 166 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); |
167 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); | 167 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); |
168 | 168 |
169 // Disable Incognito mode. | 169 // Disable Incognito mode. |
170 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), | 170 IncognitoModePrefs::SetAvailability(profile()->GetPrefs(), |
171 IncognitoModePrefs::FORCED); | 171 IncognitoModePrefs::FORCED); |
172 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT, | 172 menu.reset(CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT, |
173 GetWmShelf(primary_id))); | 173 GetShelf(primary_id))); |
174 ASSERT_TRUE(IsItemPresentInMenu( | 174 ASSERT_TRUE(IsItemPresentInMenu( |
175 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); | 175 menu.get(), LauncherContextMenu::MENU_NEW_WINDOW)); |
176 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); | 176 EXPECT_FALSE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_NEW_WINDOW)); |
177 } | 177 } |
178 | 178 |
179 // Verifies status of contextmenu items for desktop shell. | 179 // Verifies status of contextmenu items for desktop shell. |
180 TEST_F(LauncherContextMenuTest, DesktopShellLauncherContextMenuItemCheck) { | 180 TEST_F(LauncherContextMenuTest, DesktopShellLauncherContextMenuItemCheck) { |
181 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 181 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
182 std::unique_ptr<LauncherContextMenu> menu( | 182 std::unique_ptr<LauncherContextMenu> menu( |
183 CreateLauncherContextMenuForDesktopShell(GetWmShelf(primary_id))); | 183 CreateLauncherContextMenuForDesktopShell(GetShelf(primary_id))); |
184 EXPECT_FALSE( | 184 EXPECT_FALSE( |
185 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 185 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
186 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 186 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
187 EXPECT_TRUE( | 187 EXPECT_TRUE( |
188 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); | 188 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); |
189 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); | 189 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); |
190 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 190 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
191 LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 191 LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
192 EXPECT_TRUE( | 192 EXPECT_TRUE( |
193 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 193 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
194 // By default, screen is not locked and ChangeWallPaper item is added in | 194 // By default, screen is not locked and ChangeWallPaper item is added in |
195 // menu. ChangeWallPaper item is not enabled in default mode. | 195 // menu. ChangeWallPaper item is not enabled in default mode. |
196 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 196 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
197 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 197 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
198 EXPECT_FALSE( | 198 EXPECT_FALSE( |
199 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 199 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
200 } | 200 } |
201 | 201 |
202 // Verifies that "Close" is not shown in context menu if no browser window is | 202 // Verifies that "Close" is not shown in context menu if no browser window is |
203 // opened. | 203 // opened. |
204 TEST_F(LauncherContextMenuTest, | 204 TEST_F(LauncherContextMenuTest, |
205 DesktopShellLauncherContextMenuVerifyCloseItem) { | 205 DesktopShellLauncherContextMenuVerifyCloseItem) { |
206 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 206 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
207 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( | 207 std::unique_ptr<LauncherContextMenu> menu(CreateLauncherContextMenu( |
208 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 208 ash::TYPE_BROWSER_SHORTCUT, GetShelf(primary_id))); |
209 ASSERT_FALSE( | 209 ASSERT_FALSE( |
210 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 210 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
211 } | 211 } |
212 | 212 |
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::ShelfItem* item = controller()->GetItem(ash::ShelfID(app_id)); | 223 const ash::ShelfItem* item = controller()->GetItem(ash::ShelfID(app_id)); |
224 ASSERT_TRUE(item); | 224 ASSERT_TRUE(item); |
225 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 225 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
226 ash::WmShelf* wm_shelf = GetWmShelf(primary_id); | 226 ash::Shelf* shelf = GetShelf(primary_id); |
227 | 227 |
228 std::unique_ptr<LauncherContextMenu> menu( | 228 std::unique_ptr<LauncherContextMenu> menu( |
229 new ArcLauncherContextMenu(controller(), item, wm_shelf)); | 229 new ArcLauncherContextMenu(controller(), item, shelf)); |
230 | 230 |
231 // ARC app is pinned but not running. | 231 // ARC app is pinned but not running. |
232 EXPECT_TRUE( | 232 EXPECT_TRUE( |
233 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 233 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
234 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); | 234 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_OPEN_NEW)); |
235 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 235 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
236 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); | 236 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); |
237 EXPECT_FALSE( | 237 EXPECT_FALSE( |
238 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 238 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
239 | 239 |
240 EXPECT_TRUE( | 240 EXPECT_TRUE( |
241 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); | 241 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_AUTO_HIDE)); |
242 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); | 242 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_AUTO_HIDE)); |
243 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 243 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
244 LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 244 LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
245 EXPECT_TRUE( | 245 EXPECT_TRUE( |
246 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); | 246 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_ALIGNMENT_MENU)); |
247 // By default, screen is not locked and ChangeWallPaper item is added in | 247 // By default, screen is not locked and ChangeWallPaper item is added in |
248 // menu. ChangeWallPaper item is not enabled in default mode. | 248 // menu. ChangeWallPaper item is not enabled in default mode. |
249 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), | 249 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), |
250 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 250 LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
251 EXPECT_FALSE( | 251 EXPECT_FALSE( |
252 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); | 252 menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CHANGE_WALLPAPER)); |
253 | 253 |
254 // ARC app is running. | 254 // ARC app is running. |
255 std::string window_app_id1("org.chromium.arc.1"); | 255 std::string window_app_id1("org.chromium.arc.1"); |
256 CreateArcWindow(window_app_id1); | 256 CreateArcWindow(window_app_id1); |
257 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0], | 257 arc_test().app_instance()->SendTaskCreated(1, arc_test().fake_apps()[0], |
258 std::string()); | 258 std::string()); |
259 menu.reset(new ArcLauncherContextMenu(controller(), item, wm_shelf)); | 259 menu.reset(new ArcLauncherContextMenu(controller(), item, shelf)); |
260 | 260 |
261 EXPECT_FALSE( | 261 EXPECT_FALSE( |
262 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 262 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
263 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 263 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
264 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); | 264 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_PIN)); |
265 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 265 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
266 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 266 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
267 | 267 |
268 // ARC non-launchable app is running. | 268 // ARC non-launchable app is running. |
269 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]); |
270 std::string window_app_id2("org.chromium.arc.2"); | 270 std::string window_app_id2("org.chromium.arc.2"); |
271 CreateArcWindow(window_app_id2); | 271 CreateArcWindow(window_app_id2); |
272 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], | 272 arc_test().app_instance()->SendTaskCreated(2, arc_test().fake_apps()[1], |
273 std::string()); | 273 std::string()); |
274 const ash::ShelfItem* item2 = controller()->GetItem(ash::ShelfID(app_id2)); | 274 const ash::ShelfItem* item2 = controller()->GetItem(ash::ShelfID(app_id2)); |
275 ASSERT_TRUE(item2); | 275 ASSERT_TRUE(item2); |
276 menu.reset(new ArcLauncherContextMenu(controller(), item2, wm_shelf)); | 276 menu.reset(new ArcLauncherContextMenu(controller(), item2, shelf)); |
277 | 277 |
278 EXPECT_FALSE( | 278 EXPECT_FALSE( |
279 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 279 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
280 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 280 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
281 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 281 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
282 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 282 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
283 | 283 |
284 // Shelf group context menu. | 284 // Shelf group context menu. |
285 std::vector<arc::mojom::ShortcutInfo> shortcuts = arc_test().fake_shortcuts(); | 285 std::vector<arc::mojom::ShortcutInfo> shortcuts = arc_test().fake_shortcuts(); |
286 shortcuts[0].intent_uri += | 286 shortcuts[0].intent_uri += |
287 ";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"; |
288 arc_test().app_instance()->SendInstallShortcuts(shortcuts); | 288 arc_test().app_instance()->SendInstallShortcuts(shortcuts); |
289 const std::string app_id3 = | 289 const std::string app_id3 = |
290 arc::ArcAppShelfId("arc_test_shelf_group", | 290 arc::ArcAppShelfId("arc_test_shelf_group", |
291 ArcAppTest::GetAppId(arc_test().fake_apps()[2])) | 291 ArcAppTest::GetAppId(arc_test().fake_apps()[2])) |
292 .ToString(); | 292 .ToString(); |
293 std::string window_app_id3("org.chromium.arc.3"); | 293 std::string window_app_id3("org.chromium.arc.3"); |
294 CreateArcWindow(window_app_id3); | 294 CreateArcWindow(window_app_id3); |
295 arc_test().app_instance()->SendTaskCreated(3, arc_test().fake_apps()[2], | 295 arc_test().app_instance()->SendTaskCreated(3, arc_test().fake_apps()[2], |
296 shortcuts[0].intent_uri); | 296 shortcuts[0].intent_uri); |
297 const ash::ShelfItem* item3 = controller()->GetItem(ash::ShelfID(app_id3)); | 297 const ash::ShelfItem* item3 = controller()->GetItem(ash::ShelfID(app_id3)); |
298 ASSERT_TRUE(item3); | 298 ASSERT_TRUE(item3); |
299 menu.reset(new ArcLauncherContextMenu(controller(), item3, wm_shelf)); | 299 menu.reset(new ArcLauncherContextMenu(controller(), item3, shelf)); |
300 | 300 |
301 EXPECT_FALSE( | 301 EXPECT_FALSE( |
302 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); | 302 IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_OPEN_NEW)); |
303 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); | 303 EXPECT_FALSE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_PIN)); |
304 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); | 304 EXPECT_TRUE(IsItemPresentInMenu(menu.get(), LauncherContextMenu::MENU_CLOSE)); |
305 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); | 305 EXPECT_TRUE(menu->IsCommandIdEnabled(LauncherContextMenu::MENU_CLOSE)); |
306 } | 306 } |
307 | 307 |
308 // Tests that fullscreen which makes "Autohide shelf" option disappeared on | 308 // Tests that fullscreen which makes "Autohide shelf" option disappeared on |
309 // shelf is a per-display setting (crbug.com/496681). | 309 // shelf is a per-display setting (crbug.com/496681). |
310 TEST_F(LauncherContextMenuTest, AutohideShelfOptionOnExternalDisplay) { | 310 TEST_F(LauncherContextMenuTest, AutohideShelfOptionOnExternalDisplay) { |
311 UpdateDisplay("940x550,940x550"); | 311 UpdateDisplay("940x550,940x550"); |
312 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 312 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
313 int64_t secondary_id = display_manager()->GetSecondaryDisplay().id(); | 313 int64_t secondary_id = display_manager()->GetSecondaryDisplay().id(); |
314 | 314 |
315 // Create a normal window on primary display. | 315 // Create a normal window on primary display. |
316 views::Widget* widget = new views::Widget; | 316 views::Widget* widget = new views::Widget; |
317 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 317 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
318 params.context = ash::Shell::GetPrimaryRootWindow(); | 318 params.context = ash::Shell::GetPrimaryRootWindow(); |
319 widget->Init(params); | 319 widget->Init(params); |
320 widget->Show(); | 320 widget->Show(); |
321 | 321 |
322 widget->SetFullscreen(true); | 322 widget->SetFullscreen(true); |
323 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( | 323 std::unique_ptr<LauncherContextMenu> primary_menu(CreateLauncherContextMenu( |
324 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(primary_id))); | 324 ash::TYPE_BROWSER_SHORTCUT, GetShelf(primary_id))); |
325 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( | 325 std::unique_ptr<LauncherContextMenu> secondary_menu(CreateLauncherContextMenu( |
326 ash::TYPE_BROWSER_SHORTCUT, GetWmShelf(secondary_id))); | 326 ash::TYPE_BROWSER_SHORTCUT, GetShelf(secondary_id))); |
327 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), | 327 EXPECT_FALSE(IsItemPresentInMenu(primary_menu.get(), |
328 LauncherContextMenu::MENU_AUTO_HIDE)); | 328 LauncherContextMenu::MENU_AUTO_HIDE)); |
329 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), | 329 EXPECT_TRUE(IsItemPresentInMenu(secondary_menu.get(), |
330 LauncherContextMenu::MENU_AUTO_HIDE)); | 330 LauncherContextMenu::MENU_AUTO_HIDE)); |
331 } | 331 } |
332 | 332 |
333 } // namespace | 333 } // namespace |
OLD | NEW |