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 "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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); | 229 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); |
230 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
231 // Chrome OS uses system tray menu to handle multi-profiles. | 231 // Chrome OS uses system tray menu to handle multi-profiles. |
232 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 232 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
233 #else | 233 #else |
234 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 234 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
235 #endif | 235 #endif |
236 testing_profile_manager.DeleteTestingProfile("p1"); | 236 testing_profile_manager.DeleteTestingProfile("p1"); |
237 } | 237 } |
238 | 238 |
239 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) { | |
240 if (!profiles::IsMultipleProfilesEnabled()) | |
241 return; | |
242 | |
243 // The command line is reset at the end of every test by the test suite. | |
244 switches::EnableNewAvatarMenuForTesting( | |
245 base::CommandLine::ForCurrentProcess()); | |
246 | |
247 TestingProfileManager testing_profile_manager( | |
248 TestingBrowserProcess::GetGlobal()); | |
249 ASSERT_TRUE(testing_profile_manager.SetUp()); | |
250 | |
251 // Set up guest a profile. | |
252 scoped_ptr<TestingProfile> original_profile = | |
253 TestingProfile::Builder().Build(); | |
254 TestingProfile::Builder guest_builder; | |
255 guest_builder.SetGuestSession(); | |
256 guest_builder.SetPath(ProfileManager::GetGuestProfilePath()); | |
257 // Browsers in Guest mode must be off the record profiles. | |
258 TestingProfile* guest_profile = | |
259 guest_builder.BuildIncognito(original_profile.get()); | |
260 | |
261 ASSERT_TRUE(guest_profile->IsGuestSession()); | |
262 | |
263 // Create a new browser based on the guest profile. | |
264 Browser::CreateParams profile_params(guest_profile, | |
265 chrome::GetActiveDesktop()); | |
266 scoped_ptr<Browser> guest_browser( | |
267 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); | |
268 chrome::BrowserCommandController command_controller(guest_browser.get()); | |
269 const CommandUpdater* command_updater = command_controller.command_updater(); | |
270 #if defined(OS_CHROMEOS) | |
271 // Chrome OS uses system tray menu to handle multi-profiles. | |
272 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | |
273 #else | |
274 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | |
275 #endif | |
276 } | |
277 | |
278 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { | 239 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { |
279 if (!profiles::IsMultipleProfilesEnabled()) | 240 if (!profiles::IsMultipleProfilesEnabled()) |
280 return; | 241 return; |
281 | 242 |
282 // Set up a profile with an off the record profile. | 243 // Set up a profile with an off the record profile. |
283 TestingProfile::Builder normal_builder; | 244 TestingProfile::Builder normal_builder; |
284 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); | 245 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); |
285 | 246 |
286 // Create a new browser based on the off the record profile. | 247 // Create a new browser based on the off the record profile. |
287 Browser::CreateParams profile_params( | 248 Browser::CreateParams profile_params( |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 416 |
456 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 417 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
457 chrome::BrowserCommandController command_controller(browser()); | 418 chrome::BrowserCommandController command_controller(browser()); |
458 const CommandUpdater* command_updater = command_controller.command_updater(); | 419 const CommandUpdater* command_updater = command_controller.command_updater(); |
459 | 420 |
460 // Check that the SYNC_SETUP command is updated on preference change. | 421 // Check that the SYNC_SETUP command is updated on preference change. |
461 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 422 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
462 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 423 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
463 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 424 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
464 } | 425 } |
OLD | NEW |