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

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

Issue 2698013004: Revert 3c7af99, but keep only IsReservedCommandOrKey change (Closed)
Patch Set: Resolve review comments Created 3 years, 10 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_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
362 363
363 // In fullscreen, only the exit fullscreen commands are reserved. All other 364 // In fullscreen, only the exit fullscreen commands are reserved. All other
364 // shortcuts are unreserved. See https://goo.gl/4tJ32G. 365 // shortcuts should be delivered to the web page. See https://goo.gl/4tJ32G.
365 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_CLOSE_TAB)); 366 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
366 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_CLOSE_WINDOW)); 367 IDC_CLOSE_TAB,
367 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW)); 368 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
368 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_TAB)); 369 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
369 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW)); 370 IDC_CLOSE_WINDOW,
370 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SELECT_NEXT_TAB)); 371 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
371 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SELECT_PREVIOUS_TAB)); 372 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
372 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EXIT)); 373 IDC_NEW_INCOGNITO_WINDOW,
373 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 374 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
375 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
376 IDC_NEW_TAB,
377 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
378 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
379 IDC_NEW_WINDOW,
380 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
381 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
382 IDC_SELECT_NEXT_TAB,
383 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
384 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
385 IDC_SELECT_PREVIOUS_TAB,
386 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
387 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
388 IDC_EXIT,
389 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
374 390
375 // Exit fullscreen. 391 // Exit fullscreen.
376 chrome::ToggleFullscreenMode(browser()); 392 chrome::ToggleFullscreenMode(browser());
377 ASSERT_FALSE(browser()->window()->IsFullscreen()); 393 ASSERT_FALSE(browser()->window()->IsFullscreen());
378 browser()->command_controller()->FullscreenStateChanged(); 394 browser()->command_controller()->FullscreenStateChanged();
379 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); 395 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
380 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); 396 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB));
381 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); 397 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR));
382 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); 398 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
383 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); 399 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH));
384 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); 400 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR));
385 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); 401 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE));
386 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); 402 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE));
387 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); 403 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS));
388 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); 404 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU));
389 #if defined(GOOGLE_CHROME_BUILD) 405 #if defined(GOOGLE_CHROME_BUILD)
390 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); 406 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK));
391 #endif 407 #endif
392 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 408 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
393 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 409 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
394 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); 410 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES));
395 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); 411 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS));
396 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); 412 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
397 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); 413 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
398 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_CLOSE_TAB));
399 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_CLOSE_WINDOW));
400 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW));
401 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_NEW_TAB));
402 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW));
403 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SELECT_NEXT_TAB));
404 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SELECT_PREVIOUS_TAB));
405 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EXIT));
406 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 414 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
407 415
416 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
417 IDC_CLOSE_TAB,
418 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
419 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
420 IDC_CLOSE_WINDOW,
421 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
422 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
423 IDC_NEW_INCOGNITO_WINDOW,
424 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
425 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
426 IDC_NEW_TAB,
427 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
428 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
429 IDC_NEW_WINDOW,
430 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
431 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
432 IDC_SELECT_NEXT_TAB,
433 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
434 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
435 IDC_SELECT_PREVIOUS_TAB,
436 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
437 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
438 IDC_EXIT,
439 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0)));
440
408 // Guest Profiles disallow some options. 441 // Guest Profiles disallow some options.
409 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); 442 TestingProfile* testprofile = browser()->profile()->AsTestingProfile();
410 EXPECT_TRUE(testprofile); 443 EXPECT_TRUE(testprofile);
411 testprofile->SetGuestSession(true); 444 testprofile->SetGuestSession(true);
412 445
413 browser()->command_controller()->FullscreenStateChanged(); 446 browser()->command_controller()->FullscreenStateChanged();
414 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 447 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
415 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 448 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
416 } 449 }
417 450
(...skipping 20 matching lines...) Expand all
438 471
439 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 472 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
440 chrome::BrowserCommandController command_controller(browser()); 473 chrome::BrowserCommandController command_controller(browser());
441 const CommandUpdater* command_updater = command_controller.command_updater(); 474 const CommandUpdater* command_updater = command_controller.command_updater();
442 475
443 // Check that the SYNC_SETUP command is updated on preference change. 476 // Check that the SYNC_SETUP command is updated on preference change.
444 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 477 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
445 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 478 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
446 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 479 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
447 } 480 }
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