Chromium Code Reviews| 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 TEST_F(BrowserCommandControllerTest, DISABLED_OptionsConsistency) { | |
|
msw
2017/02/20 01:01:12
File a bug, add a comment here that cites the bug
Hzj_jie
2017/02/20 21:15:40
Done.
| |
| 452 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); | |
|
msw
2017/02/20 01:01:12
nit: |profile| or |test_profile| to fit naming con
Hzj_jie
2017/02/20 21:15:40
Done.
| |
| 453 // Setup guest session | |
| 454 testprofile->SetGuestSession(true); | |
| 455 // Setup forced incognito mode | |
| 456 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | |
| 457 IncognitoModePrefs::FORCED); | |
| 458 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
| 459 // Enter fullscreen | |
| 460 browser()->command_controller()->FullscreenStateChanged(); | |
| 461 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
| 462 // Exit fullscreen | |
| 463 browser()->command_controller()->FullscreenStateChanged(); | |
| 464 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
| 465 // Reenter incognito mode, this should trigger | |
| 466 // UpdateSharedCommandsForIncognitoAvailability() again. | |
| 467 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | |
| 468 IncognitoModePrefs::DISABLED); | |
| 469 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | |
| 470 IncognitoModePrefs::FORCED); | |
| 471 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
|
msw
2017/02/20 01:01:12
So, this check fails if you enabled the test right
Hzj_jie
2017/02/20 21:15:40
Yes, the two EXPECT_TRUEs fail because of the code
| |
| 472 } | |
| 473 | |
| 451 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { | 474 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { |
| 452 // Set up a profile with an off the record profile. | 475 // Set up a profile with an off the record profile. |
| 453 std::unique_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); | 476 std::unique_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); |
| 454 Profile* profile2 = profile1->GetOffTheRecordProfile(); | 477 Profile* profile2 = profile1->GetOffTheRecordProfile(); |
| 455 | 478 |
| 456 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); | 479 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); |
| 457 | 480 |
| 458 // Create a new browser based on the off the record profile. | 481 // Create a new browser based on the off the record profile. |
| 459 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); | 482 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); |
| 460 std::unique_ptr<Browser> browser2( | 483 std::unique_ptr<Browser> browser2( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 471 | 494 |
| 472 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 495 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 473 chrome::BrowserCommandController command_controller(browser()); | 496 chrome::BrowserCommandController command_controller(browser()); |
| 474 const CommandUpdater* command_updater = command_controller.command_updater(); | 497 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 475 | 498 |
| 476 // Check that the SYNC_SETUP command is updated on preference change. | 499 // Check that the SYNC_SETUP command is updated on preference change. |
| 477 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 500 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 478 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 501 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 479 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 502 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 480 } | 503 } |
| OLD | NEW |