Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/ui/browser_command_controller_unittest.cc

Issue 2636013002: Disable browser key reservation in fullscreen mode (Closed)
Patch Set: Add test cases Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); 352 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU));
353 #if defined(GOOGLE_CHROME_BUILD) 353 #if defined(GOOGLE_CHROME_BUILD)
354 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); 354 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK));
355 #endif 355 #endif
356 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 356 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
357 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 357 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
358 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); 358 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES));
359 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); 359 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS));
360 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); 360 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
361 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); 361 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
362 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
dominickn 2017/01/30 01:01:19 Nit: add a newline and comment above this saying:
Hzj_jie 2017/02/08 00:24:07 Done.
363 IDC_CLOSE_TAB,
364 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
365 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
366 IDC_CLOSE_WINDOW,
367 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
368 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
369 IDC_NEW_INCOGNITO_WINDOW,
370 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
371 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
372 IDC_NEW_TAB,
373 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
374 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
375 IDC_NEW_WINDOW,
376 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
377 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
378 IDC_SELECT_NEXT_TAB,
379 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
380 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
381 IDC_SELECT_PREVIOUS_TAB,
382 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
383 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
384 IDC_EXIT,
385 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
dominickn 2017/01/30 01:01:19 Can you EXPECT_TRUE that IDC_FULLSCREEN is reserve
Hzj_jie 2017/02/08 00:24:07 Done.
362 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 386 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
363 387
364 // Exit fullscreen. 388 // Exit fullscreen.
365 chrome::ToggleFullscreenMode(browser()); 389 chrome::ToggleFullscreenMode(browser());
366 ASSERT_FALSE(browser()->window()->IsFullscreen()); 390 ASSERT_FALSE(browser()->window()->IsFullscreen());
367 browser()->command_controller()->FullscreenStateChanged(); 391 browser()->command_controller()->FullscreenStateChanged();
368 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); 392 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
369 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); 393 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB));
370 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); 394 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR));
371 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); 395 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
372 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); 396 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH));
373 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); 397 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR));
374 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); 398 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE));
375 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); 399 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE));
376 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); 400 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS));
377 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); 401 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU));
378 #if defined(GOOGLE_CHROME_BUILD) 402 #if defined(GOOGLE_CHROME_BUILD)
379 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); 403 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK));
380 #endif 404 #endif
381 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 405 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
382 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 406 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
383 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); 407 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES));
384 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); 408 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS));
385 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); 409 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
386 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); 410 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
411 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
412 IDC_CLOSE_TAB,
413 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
414 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
415 IDC_CLOSE_WINDOW,
416 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
417 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
418 IDC_NEW_INCOGNITO_WINDOW,
419 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
420 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
421 IDC_NEW_TAB,
422 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
423 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
424 IDC_NEW_WINDOW,
425 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
426 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
427 IDC_SELECT_NEXT_TAB,
428 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
429 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
430 IDC_SELECT_PREVIOUS_TAB,
431 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
432 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
433 IDC_EXIT,
434 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
387 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 435 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
388 436
389 // Guest Profiles disallow some options. 437 // Guest Profiles disallow some options.
390 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); 438 TestingProfile* testprofile = browser()->profile()->AsTestingProfile();
391 EXPECT_TRUE(testprofile); 439 EXPECT_TRUE(testprofile);
392 testprofile->SetGuestSession(true); 440 testprofile->SetGuestSession(true);
393 441
394 browser()->command_controller()->FullscreenStateChanged(); 442 browser()->command_controller()->FullscreenStateChanged();
395 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 443 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
396 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 444 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
(...skipping 22 matching lines...) Expand all
419 467
420 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 468 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
421 chrome::BrowserCommandController command_controller(browser()); 469 chrome::BrowserCommandController command_controller(browser());
422 const CommandUpdater* command_updater = command_controller.command_updater(); 470 const CommandUpdater* command_updater = command_controller.command_updater();
423 471
424 // Check that the SYNC_SETUP command is updated on preference change. 472 // Check that the SYNC_SETUP command is updated on preference change.
425 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 473 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
426 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 474 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
427 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 475 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
428 } 476 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698