OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_command_controller.h" | 5 #include "chrome/browser/ui/browser_command_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 | 245 |
246 ////////////////////////////////////////////////////////////////////////////// | 246 ////////////////////////////////////////////////////////////////////////////// |
247 class BrowserCommandControllerFullscreenTest; | 247 class BrowserCommandControllerFullscreenTest; |
248 | 248 |
249 // A test browser window that can toggle fullscreen state. | 249 // A test browser window that can toggle fullscreen state. |
250 class FullscreenTestBrowserWindow : public TestBrowserWindow, | 250 class FullscreenTestBrowserWindow : public TestBrowserWindow, |
251 ExclusiveAccessContext { | 251 ExclusiveAccessContext { |
252 public: | 252 public: |
253 FullscreenTestBrowserWindow( | 253 FullscreenTestBrowserWindow( |
254 BrowserCommandControllerFullscreenTest* test_browser) | 254 BrowserCommandControllerFullscreenTest* test_browser) |
255 : fullscreen_(false), test_browser_(test_browser) {} | 255 : fullscreen_(false), |
256 toolbar_showing_(false), | |
257 test_browser_(test_browser) {} | |
256 | 258 |
257 ~FullscreenTestBrowserWindow() override {} | 259 ~FullscreenTestBrowserWindow() override {} |
258 | 260 |
259 // TestBrowserWindow overrides: | 261 // TestBrowserWindow overrides: |
260 bool ShouldHideUIForFullscreen() const override { return fullscreen_; } | 262 bool ShouldHideUIForFullscreen() const override { return fullscreen_; } |
261 bool IsFullscreen() const override { return fullscreen_; } | 263 bool IsFullscreen() const override { return fullscreen_; } |
262 void EnterFullscreen(const GURL& url, | 264 void EnterFullscreen(const GURL& url, |
263 ExclusiveAccessBubbleType type) override { | 265 ExclusiveAccessBubbleType type) override { |
264 fullscreen_ = true; | 266 fullscreen_ = true; |
265 } | 267 } |
266 void ExitFullscreen() override { fullscreen_ = false; } | 268 void ExitFullscreen() override { fullscreen_ = false; } |
269 bool IsToolbarShowing() const override { return toolbar_showing_; } | |
267 | 270 |
268 ExclusiveAccessContext* GetExclusiveAccessContext() override { return this; } | 271 ExclusiveAccessContext* GetExclusiveAccessContext() override { return this; } |
269 | 272 |
270 // Exclusive access interface: | 273 // Exclusive access interface: |
271 Profile* GetProfile() override; | 274 Profile* GetProfile() override; |
272 content::WebContents* GetActiveWebContents() override; | 275 content::WebContents* GetActiveWebContents() override; |
273 void HideDownloadShelf() override {} | 276 void HideDownloadShelf() override {} |
274 void UnhideDownloadShelf() override {} | 277 void UnhideDownloadShelf() override {} |
275 void UpdateExclusiveAccessExitBubbleContent( | 278 void UpdateExclusiveAccessExitBubbleContent( |
276 const GURL& url, | 279 const GURL& url, |
277 ExclusiveAccessBubbleType bubble_type) override {} | 280 ExclusiveAccessBubbleType bubble_type) override {} |
278 void OnExclusiveAccessUserInput() override {} | 281 void OnExclusiveAccessUserInput() override {} |
279 | 282 |
283 // Setters | |
msw
2017/04/04 22:46:39
nit: remove this comment, it doesn't help.
Hzj_jie
2017/04/05 18:09:16
Done.
| |
284 void ShowToolbar() { toolbar_showing_ = true; } | |
msw
2017/04/04 22:46:39
nit: make this set_toolbar_showing(bool showing) {
Hzj_jie
2017/04/05 18:09:17
Done.
| |
285 | |
280 private: | 286 private: |
281 bool fullscreen_; | 287 bool fullscreen_; |
288 bool toolbar_showing_; | |
282 BrowserCommandControllerFullscreenTest* test_browser_; | 289 BrowserCommandControllerFullscreenTest* test_browser_; |
283 | 290 |
284 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); | 291 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); |
285 }; | 292 }; |
286 | 293 |
287 // Test that uses FullscreenTestBrowserWindow for its window. | 294 // Test that uses FullscreenTestBrowserWindow for its window. |
288 class BrowserCommandControllerFullscreenTest | 295 class BrowserCommandControllerFullscreenTest |
289 : public BrowserWithTestWindowTest { | 296 : public BrowserWithTestWindowTest { |
290 public: | 297 public: |
291 BrowserCommandControllerFullscreenTest() {} | 298 BrowserCommandControllerFullscreenTest() {} |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | 332 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); |
326 #if defined(GOOGLE_CHROME_BUILD) | 333 #if defined(GOOGLE_CHROME_BUILD) |
327 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | 334 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); |
328 #endif | 335 #endif |
329 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 336 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
330 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 337 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
331 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | 338 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); |
332 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | 339 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); |
333 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | 340 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); |
334 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | 341 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); |
335 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 342 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
msw
2017/04/04 22:46:39
Test IDC_EXIT (and others) here?
Hzj_jie
2017/04/05 18:09:16
Done.
| |
336 | 343 |
337 // Simulate going fullscreen. | 344 // Simulate going fullscreen. |
338 chrome::ToggleFullscreenMode(browser()); | 345 chrome::ToggleFullscreenMode(browser()); |
339 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 346 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
340 browser()->command_controller()->FullscreenStateChanged(); | 347 browser()->command_controller()->FullscreenStateChanged(); |
341 | 348 |
342 // Most commands are disabled in fullscreen. | 349 // Most commands are disabled in fullscreen. |
343 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | 350 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); |
344 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | 351 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); |
345 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | 352 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); |
346 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | 353 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); |
347 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | 354 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); |
348 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | 355 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); |
349 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | 356 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); |
350 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | 357 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); |
351 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | 358 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); |
352 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | 359 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); |
353 #if defined(GOOGLE_CHROME_BUILD) | 360 #if defined(GOOGLE_CHROME_BUILD) |
354 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | 361 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); |
355 #endif | 362 #endif |
356 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 363 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
357 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 364 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
358 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | 365 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); |
359 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | 366 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); |
360 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | 367 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); |
361 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | 368 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); |
362 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 369 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
msw
2017/04/04 22:46:39
Test IDC_EXIT (and others) here?
Hzj_jie
2017/04/05 18:09:17
Done.
| |
363 | 370 |
371 // In fullscreen, only the exit fullscreen commands are reserved. All other | |
372 // shortcuts should be delivered to the web page. See https://goo.gl/4tJ32G. | |
msw
2017/04/04 22:46:39
Ditto, use the full url, or a crbug.com/# addy.
Hzj_jie
2017/04/05 18:09:17
Done.
| |
373 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
msw
2017/04/04 22:46:39
nit: it would be nice to reduce the boilerplate fo
Hzj_jie
2017/04/05 18:09:16
Done.
| |
374 IDC_CLOSE_TAB, | |
375 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
376 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
377 IDC_CLOSE_WINDOW, | |
378 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
379 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
380 IDC_NEW_INCOGNITO_WINDOW, | |
381 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
382 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
383 IDC_NEW_TAB, | |
384 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
385 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
386 IDC_NEW_WINDOW, | |
387 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
388 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
389 IDC_SELECT_NEXT_TAB, | |
390 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
391 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
392 IDC_SELECT_PREVIOUS_TAB, | |
393 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
394 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
395 IDC_EXIT, | |
msw
2017/04/04 22:46:39
Test IDC_FULLSCREEN here?
Hzj_jie
2017/04/05 18:09:16
Done.
| |
396 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
397 | |
398 // Exit fullscreen. | |
msw
2017/04/04 22:46:39
If this block is just a duplicate of the one at th
Hzj_jie
2017/04/05 18:09:17
Yes, updated.
| |
399 chrome::ToggleFullscreenMode(browser()); | |
400 ASSERT_FALSE(browser()->window()->IsFullscreen()); | |
401 browser()->command_controller()->FullscreenStateChanged(); | |
402 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
403 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | |
404 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | |
405 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
406 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | |
407 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | |
408 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | |
409 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | |
410 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | |
411 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | |
412 #if defined(GOOGLE_CHROME_BUILD) | |
413 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | |
414 #endif | |
415 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
416 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | |
417 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | |
418 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | |
419 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
420 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | |
421 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | |
422 | |
364 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 423 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
365 IDC_CLOSE_TAB, | 424 IDC_CLOSE_TAB, |
366 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 425 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); |
426 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
427 IDC_CLOSE_WINDOW, | |
428 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
429 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
430 IDC_NEW_INCOGNITO_WINDOW, | |
431 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
432 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
433 IDC_NEW_TAB, | |
434 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
435 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
436 IDC_NEW_WINDOW, | |
437 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
438 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
439 IDC_SELECT_NEXT_TAB, | |
440 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
441 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
442 IDC_SELECT_PREVIOUS_TAB, | |
443 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
444 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
445 IDC_EXIT, | |
446 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
447 | |
448 // Guest Profiles disallow some options. | |
449 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); | |
450 EXPECT_TRUE(testprofile); | |
451 testprofile->SetGuestSession(true); | |
452 | |
453 browser()->command_controller()->FullscreenStateChanged(); | |
454 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
455 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | |
456 } | |
457 | |
458 #if defined(OS_MACOSX) | |
459 TEST_F(BrowserCommandControllerFullscreenTest, | |
460 TabShortcutsShouldBePreservedOnMacOSX) { | |
461 static_cast<FullscreenTestBrowserWindow*>(window())->ShowToolbar(); | |
462 | |
463 // Defaults for a tabbed browser. | |
msw
2017/04/04 22:46:39
If this is a duplicate of the top of UpdateCommand
Hzj_jie
2017/04/05 18:09:17
Merged into the previous test.
| |
464 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
465 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | |
466 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | |
467 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
468 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | |
469 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | |
470 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | |
471 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | |
472 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | |
473 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | |
474 #if defined(GOOGLE_CHROME_BUILD) | |
475 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | |
476 #endif | |
477 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
478 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | |
479 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | |
480 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | |
481 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
482 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | |
483 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | |
484 | |
485 // Simulate going fullscreen. | |
486 chrome::ToggleFullscreenMode(browser()); | |
487 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
488 browser()->command_controller()->FullscreenStateChanged(); | |
489 | |
490 // Most commands are disabled in fullscreen. | |
491 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
492 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | |
493 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | |
494 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
495 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | |
496 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | |
497 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | |
498 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | |
499 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | |
500 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | |
501 #if defined(GOOGLE_CHROME_BUILD) | |
502 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | |
503 #endif | |
504 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
505 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | |
506 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | |
507 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | |
508 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
509 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | |
510 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | |
511 | |
512 // In fullscreen, once the toolbar is visible, browser shortcuts should still | |
513 // be reserved. See http://crbug.com/702251. | |
514 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
515 IDC_CLOSE_TAB, | |
516 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
367 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 517 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
368 IDC_CLOSE_WINDOW, | 518 IDC_CLOSE_WINDOW, |
369 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 519 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); |
370 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 520 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
371 IDC_NEW_INCOGNITO_WINDOW, | 521 IDC_NEW_INCOGNITO_WINDOW, |
372 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 522 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); |
373 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 523 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
374 IDC_NEW_TAB, | 524 IDC_NEW_TAB, |
375 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 525 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); |
376 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 526 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 | 588 |
439 // Guest Profiles disallow some options. | 589 // Guest Profiles disallow some options. |
440 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); | 590 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); |
441 EXPECT_TRUE(testprofile); | 591 EXPECT_TRUE(testprofile); |
442 testprofile->SetGuestSession(true); | 592 testprofile->SetGuestSession(true); |
443 | 593 |
444 browser()->command_controller()->FullscreenStateChanged(); | 594 browser()->command_controller()->FullscreenStateChanged(); |
445 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 595 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
446 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 596 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
447 } | 597 } |
598 #endif | |
448 | 599 |
449 // Ensure that the logic for enabling IDC_OPTIONS is consistent, regardless of | 600 // Ensure that the logic for enabling IDC_OPTIONS is consistent, regardless of |
450 // the order of entering fullscreen and forced incognito modes. See | 601 // the order of entering fullscreen and forced incognito modes. See |
451 // http://crbug.com/694331. | 602 // http://crbug.com/694331. |
452 TEST_F(BrowserCommandControllerTest, OptionsConsistency) { | 603 TEST_F(BrowserCommandControllerTest, OptionsConsistency) { |
453 TestingProfile* profile = browser()->profile()->AsTestingProfile(); | 604 TestingProfile* profile = browser()->profile()->AsTestingProfile(); |
454 // Setup guest session. | 605 // Setup guest session. |
455 profile->SetGuestSession(true); | 606 profile->SetGuestSession(true); |
456 // Setup forced incognito mode. | 607 // Setup forced incognito mode. |
457 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | 608 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 647 |
497 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 648 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
498 chrome::BrowserCommandController command_controller(browser()); | 649 chrome::BrowserCommandController command_controller(browser()); |
499 const CommandUpdater* command_updater = command_controller.command_updater(); | 650 const CommandUpdater* command_updater = command_controller.command_updater(); |
500 | 651 |
501 // Check that the SYNC_SETUP command is updated on preference change. | 652 // Check that the SYNC_SETUP command is updated on preference change. |
502 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 653 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
503 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 654 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
504 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 655 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
505 } | 656 } |
OLD | NEW |