| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 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); |
| 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 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 169 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW)); |
| 168 | 170 |
| 169 testprofile->SetGuestSession(false); | 171 testprofile->SetGuestSession(false); |
| 170 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | 172 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
| 171 IncognitoModePrefs::FORCED); | 173 IncognitoModePrefs::FORCED); |
| 172 chrome::BrowserCommandController | 174 chrome::BrowserCommandController:: |
| 173 ::UpdateSharedCommandsForIncognitoAvailability( | 175 UpdateSharedCommandsForIncognitoAvailability( |
| 174 browser()->command_controller()->command_updater(), testprofile); | 176 browser()->command_controller()->command_updater(), testprofile); |
| 175 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 177 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 176 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 178 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
| 177 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); | 179 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); |
| 180 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 181 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW)); |
| 178 } | 182 } |
| 179 | 183 |
| 180 TEST_F(BrowserCommandControllerTest, AppFullScreen) { | 184 TEST_F(BrowserCommandControllerTest, AppFullScreen) { |
| 181 // Enable for tabbed browser. | 185 // Enable for tabbed browser. |
| 182 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 186 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
| 183 | 187 |
| 184 // Enabled for app windows. | 188 // Enabled for app windows. |
| 185 browser()->app_name_ = "app"; | 189 browser()->app_name_ = "app"; |
| 186 ASSERT_TRUE(browser()->is_app()); | 190 ASSERT_TRUE(browser()->is_app()); |
| 187 browser()->command_controller()->FullscreenStateChanged(); | 191 browser()->command_controller()->FullscreenStateChanged(); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 442 |
| 439 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 443 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 440 chrome::BrowserCommandController command_controller(browser()); | 444 chrome::BrowserCommandController command_controller(browser()); |
| 441 const CommandUpdater* command_updater = command_controller.command_updater(); | 445 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 442 | 446 |
| 443 // Check that the SYNC_SETUP command is updated on preference change. | 447 // Check that the SYNC_SETUP command is updated on preference change. |
| 444 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 448 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 445 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 449 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 446 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 450 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 447 } | 451 } |
| OLD | NEW |