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 // Ensure that the logic for enabling IDC_OPTIONS is consistent, regardless of |
| 452 // the order of entering fullscreen and forced incognito modes. See |
| 453 // http://crbug.com/694331. |
| 454 TEST_F(BrowserCommandControllerTest, OptionsConsistency) { |
| 455 TestingProfile* profile = browser()->profile()->AsTestingProfile(); |
| 456 // Setup guest session. |
| 457 profile->SetGuestSession(true); |
| 458 // Setup forced incognito mode. |
| 459 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
| 460 IncognitoModePrefs::FORCED); |
| 461 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 462 // Enter fullscreen. |
| 463 browser()->command_controller()->FullscreenStateChanged(); |
| 464 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 465 // Exit fullscreen |
| 466 browser()->command_controller()->FullscreenStateChanged(); |
| 467 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 468 // Reenter incognito mode, this should trigger |
| 469 // UpdateSharedCommandsForIncognitoAvailability() again. |
| 470 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
| 471 IncognitoModePrefs::DISABLED); |
| 472 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
| 473 IncognitoModePrefs::FORCED); |
| 474 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 475 } |
| 476 |
451 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { | 477 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { |
452 // Set up a profile with an off the record profile. | 478 // Set up a profile with an off the record profile. |
453 std::unique_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); | 479 std::unique_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); |
454 Profile* profile2 = profile1->GetOffTheRecordProfile(); | 480 Profile* profile2 = profile1->GetOffTheRecordProfile(); |
455 | 481 |
456 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); | 482 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); |
457 | 483 |
458 // Create a new browser based on the off the record profile. | 484 // Create a new browser based on the off the record profile. |
459 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); | 485 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); |
460 std::unique_ptr<Browser> browser2( | 486 std::unique_ptr<Browser> browser2( |
(...skipping 10 matching lines...) Expand all Loading... |
471 | 497 |
472 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 498 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
473 chrome::BrowserCommandController command_controller(browser()); | 499 chrome::BrowserCommandController command_controller(browser()); |
474 const CommandUpdater* command_updater = command_controller.command_updater(); | 500 const CommandUpdater* command_updater = command_controller.command_updater(); |
475 | 501 |
476 // Check that the SYNC_SETUP command is updated on preference change. | 502 // Check that the SYNC_SETUP command is updated on preference change. |
477 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 503 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
478 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 504 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
479 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 505 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
480 } | 506 } |
OLD | NEW |