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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 TEST_F(BrowserCommandControllerTest, IncognitoCommands) { | 154 TEST_F(BrowserCommandControllerTest, IncognitoCommands) { |
| 155 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 155 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 156 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 156 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
| 157 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); | 157 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); |
| 158 | 158 |
| 159 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); | 159 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); |
| 160 EXPECT_TRUE(testprofile); | 160 EXPECT_TRUE(testprofile); |
| 161 testprofile->SetGuestSession(true); | 161 testprofile->SetGuestSession(true); |
| 162 chrome::BrowserCommandController | 162 chrome::BrowserCommandController |
| 163 ::UpdateSharedCommandsForIncognitoAvailability( | 163 ::UpdateSharedCommandsForIncognitoAvailability( |
| 164 browser()->command_controller()->command_updater(), testprofile); | 164 browser()->command_controller()->command_updater(), testprofile, false); |
|
msw
2017/02/14 22:34:50
If we keep this flag, we should have test coverage
Hzj_jie
2017/02/15 02:00:49
Sure, more test cases are added.
| |
| 165 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 165 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 166 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 166 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
| 167 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); | 167 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); |
| 168 | 168 |
| 169 testprofile->SetGuestSession(false); | 169 testprofile->SetGuestSession(false); |
| 170 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | 170 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
| 171 IncognitoModePrefs::FORCED); | 171 IncognitoModePrefs::FORCED); |
| 172 chrome::BrowserCommandController | 172 chrome::BrowserCommandController |
| 173 ::UpdateSharedCommandsForIncognitoAvailability( | 173 ::UpdateSharedCommandsForIncognitoAvailability( |
| 174 browser()->command_controller()->command_updater(), testprofile); | 174 browser()->command_controller()->command_updater(), testprofile, false); |
| 175 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 175 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 176 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 176 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
| 177 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); | 177 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST_F(BrowserCommandControllerTest, AppFullScreen) { | 180 TEST_F(BrowserCommandControllerTest, AppFullScreen) { |
| 181 // Enable for tabbed browser. | 181 // Enable for tabbed browser. |
| 182 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 182 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
| 183 | 183 |
| 184 // Enabled for app windows. | 184 // Enabled for app windows. |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 | 438 |
| 439 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 439 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 440 chrome::BrowserCommandController command_controller(browser()); | 440 chrome::BrowserCommandController command_controller(browser()); |
| 441 const CommandUpdater* command_updater = command_controller.command_updater(); | 441 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 442 | 442 |
| 443 // Check that the SYNC_SETUP command is updated on preference change. | 443 // Check that the SYNC_SETUP command is updated on preference change. |
| 444 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 444 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 445 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 445 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 446 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 446 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 447 } | 447 } |
| OLD | NEW |