Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: chrome/browser/ui/browser_command_controller_unittest.cc

Issue 2689383002: Commands should have consistent behaviors across different modes
Patch Set: Resolve review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
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));
170
171 chrome::BrowserCommandController
172 ::UpdateSharedCommandsForIncognitoAvailability(
173 browser()->command_controller()->command_updater(), testprofile, true);
174 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
175 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
176 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
177 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW));
178 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW));
168 179
169 testprofile->SetGuestSession(false); 180 testprofile->SetGuestSession(false);
170 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), 181 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(),
171 IncognitoModePrefs::FORCED); 182 IncognitoModePrefs::FORCED);
172 chrome::BrowserCommandController 183 chrome::BrowserCommandController
173 ::UpdateSharedCommandsForIncognitoAvailability( 184 ::UpdateSharedCommandsForIncognitoAvailability(
174 browser()->command_controller()->command_updater(), testprofile); 185 browser()->command_controller()->command_updater(), testprofile, false);
175 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 186 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
176 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 187 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
177 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); 188 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
189 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW));
190 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW));
191
192 chrome::BrowserCommandController
193 ::UpdateSharedCommandsForIncognitoAvailability(
194 browser()->command_controller()->command_updater(), testprofile, true);
195 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
196 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
197 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
198 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_INCOGNITO_WINDOW));
199 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_NEW_WINDOW));
178 } 200 }
179 201
180 TEST_F(BrowserCommandControllerTest, AppFullScreen) { 202 TEST_F(BrowserCommandControllerTest, AppFullScreen) {
181 // Enable for tabbed browser. 203 // Enable for tabbed browser.
182 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 204 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
183 205
184 // Enabled for app windows. 206 // Enabled for app windows.
185 browser()->app_name_ = "app"; 207 browser()->app_name_ = "app";
186 ASSERT_TRUE(browser()->is_app()); 208 ASSERT_TRUE(browser()->is_app());
187 browser()->command_controller()->FullscreenStateChanged(); 209 browser()->command_controller()->FullscreenStateChanged();
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 460
439 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 461 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
440 chrome::BrowserCommandController command_controller(browser()); 462 chrome::BrowserCommandController command_controller(browser());
441 const CommandUpdater* command_updater = command_controller.command_updater(); 463 const CommandUpdater* command_updater = command_controller.command_updater();
442 464
443 // Check that the SYNC_SETUP command is updated on preference change. 465 // Check that the SYNC_SETUP command is updated on preference change.
444 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 466 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
445 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 467 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
446 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 468 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
447 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698