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

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

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 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
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/browser_commands.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/command_updater.h" 10 #include "chrome/browser/command_updater.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 ASSERT_TRUE(browser()->is_app()); 169 ASSERT_TRUE(browser()->is_app());
170 browser()->command_controller()->FullscreenStateChanged(); 170 browser()->command_controller()->FullscreenStateChanged();
171 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 171 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
172 } 172 }
173 173
174 TEST_F(BrowserCommandControllerTest, OldAvatarMenuEnabledForOneOrMoreProfiles) { 174 TEST_F(BrowserCommandControllerTest, OldAvatarMenuEnabledForOneOrMoreProfiles) {
175 if (!profiles::IsMultipleProfilesEnabled()) 175 if (!profiles::IsMultipleProfilesEnabled())
176 return; 176 return;
177 177
178 // The command line is reset at the end of every test by the test suite. 178 // The command line is reset at the end of every test by the test suite.
179 switches::DisableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); 179 switches::DisableNewAvatarMenuForTesting(
180 base::CommandLine::ForCurrentProcess());
180 ASSERT_FALSE(switches::IsNewAvatarMenu()); 181 ASSERT_FALSE(switches::IsNewAvatarMenu());
181 182
182 TestingProfileManager testing_profile_manager( 183 TestingProfileManager testing_profile_manager(
183 TestingBrowserProcess::GetGlobal()); 184 TestingBrowserProcess::GetGlobal());
184 ASSERT_TRUE(testing_profile_manager.SetUp()); 185 ASSERT_TRUE(testing_profile_manager.SetUp());
185 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); 186 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
186 187
187 chrome::BrowserCommandController command_controller(browser()); 188 chrome::BrowserCommandController command_controller(browser());
188 const CommandUpdater* command_updater = command_controller.command_updater(); 189 const CommandUpdater* command_updater = command_controller.command_updater();
189 190
(...skipping 16 matching lines...) Expand all
206 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 207 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
207 208
208 testing_profile_manager.DeleteTestingProfile("p2"); 209 testing_profile_manager.DeleteTestingProfile("p2");
209 } 210 }
210 211
211 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) { 212 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) {
212 if (!profiles::IsMultipleProfilesEnabled()) 213 if (!profiles::IsMultipleProfilesEnabled())
213 return; 214 return;
214 215
215 // The command line is reset at the end of every test by the test suite. 216 // The command line is reset at the end of every test by the test suite.
216 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); 217 switches::EnableNewAvatarMenuForTesting(
218 base::CommandLine::ForCurrentProcess());
217 219
218 TestingProfileManager testing_profile_manager( 220 TestingProfileManager testing_profile_manager(
219 TestingBrowserProcess::GetGlobal()); 221 TestingBrowserProcess::GetGlobal());
220 ASSERT_TRUE(testing_profile_manager.SetUp()); 222 ASSERT_TRUE(testing_profile_manager.SetUp());
221 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); 223 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
222 224
223 chrome::BrowserCommandController command_controller(browser()); 225 chrome::BrowserCommandController command_controller(browser());
224 const CommandUpdater* command_updater = command_controller.command_updater(); 226 const CommandUpdater* command_updater = command_controller.command_updater();
225 227
226 testing_profile_manager.CreateTestingProfile("p1"); 228 testing_profile_manager.CreateTestingProfile("p1");
227 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); 229 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
228 #if defined(OS_CHROMEOS) 230 #if defined(OS_CHROMEOS)
229 // Chrome OS uses system tray menu to handle multi-profiles. 231 // Chrome OS uses system tray menu to handle multi-profiles.
230 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 232 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
231 #else 233 #else
232 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 234 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
233 #endif 235 #endif
234 testing_profile_manager.DeleteTestingProfile("p1"); 236 testing_profile_manager.DeleteTestingProfile("p1");
235 } 237 }
236 238
237 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) { 239 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) {
238 if (!profiles::IsMultipleProfilesEnabled()) 240 if (!profiles::IsMultipleProfilesEnabled())
239 return; 241 return;
240 242
241 // The command line is reset at the end of every test by the test suite. 243 // The command line is reset at the end of every test by the test suite.
242 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); 244 switches::EnableNewAvatarMenuForTesting(
245 base::CommandLine::ForCurrentProcess());
243 246
244 TestingProfileManager testing_profile_manager( 247 TestingProfileManager testing_profile_manager(
245 TestingBrowserProcess::GetGlobal()); 248 TestingBrowserProcess::GetGlobal());
246 ASSERT_TRUE(testing_profile_manager.SetUp()); 249 ASSERT_TRUE(testing_profile_manager.SetUp());
247 250
248 // Set up guest a profile. 251 // Set up guest a profile.
249 scoped_ptr<TestingProfile> original_profile = 252 scoped_ptr<TestingProfile> original_profile =
250 TestingProfile::Builder().Build(); 253 TestingProfile::Builder().Build();
251 TestingProfile::Builder guest_builder; 254 TestingProfile::Builder guest_builder;
252 guest_builder.SetGuestSession(); 255 guest_builder.SetGuestSession();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); 288 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop());
286 scoped_ptr<Browser> otr_browser( 289 scoped_ptr<Browser> otr_browser(
287 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); 290 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
288 291
289 chrome::BrowserCommandController command_controller(otr_browser.get()); 292 chrome::BrowserCommandController command_controller(otr_browser.get());
290 const CommandUpdater* command_updater = command_controller.command_updater(); 293 const CommandUpdater* command_updater = command_controller.command_updater();
291 294
292 // Both the old style and the new style avatar menu should be disabled. 295 // Both the old style and the new style avatar menu should be disabled.
293 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 296 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
294 if (switches::IsNewAvatarMenu()) { 297 if (switches::IsNewAvatarMenu()) {
295 switches::DisableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); 298 switches::DisableNewAvatarMenuForTesting(
299 base::CommandLine::ForCurrentProcess());
296 } else { 300 } else {
297 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); 301 switches::EnableNewAvatarMenuForTesting(
302 base::CommandLine::ForCurrentProcess());
298 } 303 }
299 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 304 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
300 // The command line is reset at the end of every test by the test suite. 305 // The command line is reset at the end of every test by the test suite.
301 } 306 }
302 307
303 ////////////////////////////////////////////////////////////////////////////// 308 //////////////////////////////////////////////////////////////////////////////
304 309
305 // A test browser window that can toggle fullscreen state. 310 // A test browser window that can toggle fullscreen state.
306 class FullscreenTestBrowserWindow : public TestBrowserWindow { 311 class FullscreenTestBrowserWindow : public TestBrowserWindow {
307 public: 312 public:
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 455
451 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 456 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
452 chrome::BrowserCommandController command_controller(browser()); 457 chrome::BrowserCommandController command_controller(browser());
453 const CommandUpdater* command_updater = command_controller.command_updater(); 458 const CommandUpdater* command_updater = command_controller.command_updater();
454 459
455 // Check that the SYNC_SETUP command is updated on preference change. 460 // Check that the SYNC_SETUP command is updated on preference change.
456 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 461 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
457 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 462 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
458 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 463 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
459 } 464 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/browser_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698