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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 // Guest Profiles disallow some options. | 441 // Guest Profiles disallow some options. |
442 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); | 442 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); |
443 EXPECT_TRUE(testprofile); | 443 EXPECT_TRUE(testprofile); |
444 testprofile->SetGuestSession(true); | 444 testprofile->SetGuestSession(true); |
445 | 445 |
446 browser()->command_controller()->FullscreenStateChanged(); | 446 browser()->command_controller()->FullscreenStateChanged(); |
447 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 447 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
448 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 448 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
449 } | 449 } |
450 | 450 |
451 // Code defect is tracked by bug, http://crbug.com/694331. | |
msw
2017/02/23 19:07:28
nit: replace this comment with something like: "En
Hzj_jie
2017/02/23 22:00:09
Done.
| |
452 TEST_F(BrowserCommandControllerTest, OptionsConsistency) { | |
453 TestingProfile* profile = browser()->profile()->AsTestingProfile(); | |
454 // Setup guest session. | |
455 profile->SetGuestSession(true); | |
456 // Setup forced incognito mode. | |
457 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | |
458 IncognitoModePrefs::FORCED); | |
459 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
460 // Enter fullscreen. | |
461 browser()->command_controller()->FullscreenStateChanged(); | |
462 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
463 // Exit fullscreen | |
464 browser()->command_controller()->FullscreenStateChanged(); | |
465 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
466 // Reenter incognito mode, this should trigger | |
467 // UpdateSharedCommandsForIncognitoAvailability() again. | |
468 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | |
469 IncognitoModePrefs::DISABLED); | |
470 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | |
471 IncognitoModePrefs::FORCED); | |
472 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
473 } | |
474 | |
451 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { | 475 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { |
452 // Set up a profile with an off the record profile. | 476 // Set up a profile with an off the record profile. |
453 std::unique_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); | 477 std::unique_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); |
454 Profile* profile2 = profile1->GetOffTheRecordProfile(); | 478 Profile* profile2 = profile1->GetOffTheRecordProfile(); |
455 | 479 |
456 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); | 480 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); |
457 | 481 |
458 // Create a new browser based on the off the record profile. | 482 // Create a new browser based on the off the record profile. |
459 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); | 483 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); |
460 std::unique_ptr<Browser> browser2( | 484 std::unique_ptr<Browser> browser2( |
(...skipping 10 matching lines...) Expand all Loading... | |
471 | 495 |
472 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 496 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
473 chrome::BrowserCommandController command_controller(browser()); | 497 chrome::BrowserCommandController command_controller(browser()); |
474 const CommandUpdater* command_updater = command_controller.command_updater(); | 498 const CommandUpdater* command_updater = command_controller.command_updater(); |
475 | 499 |
476 // Check that the SYNC_SETUP command is updated on preference change. | 500 // Check that the SYNC_SETUP command is updated on preference change. |
477 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 501 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
478 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 502 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
479 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 503 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
480 } | 504 } |
OLD | NEW |