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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { | 224 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { |
225 if (!profiles::IsMultipleProfilesEnabled()) | 225 if (!profiles::IsMultipleProfilesEnabled()) |
226 return; | 226 return; |
227 | 227 |
228 // Set up a profile with an off the record profile. | 228 // Set up a profile with an off the record profile. |
229 TestingProfile::Builder normal_builder; | 229 TestingProfile::Builder normal_builder; |
230 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); | 230 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); |
231 | 231 |
232 // Create a new browser based on the off the record profile. | 232 // Create a new browser based on the off the record profile. |
233 Browser::CreateParams profile_params( | 233 Browser::CreateParams profile_params( |
234 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); | 234 original_profile->GetOffTheRecordProfile()); |
235 scoped_ptr<Browser> otr_browser( | 235 scoped_ptr<Browser> otr_browser( |
236 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); | 236 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); |
237 | 237 |
238 chrome::BrowserCommandController command_controller(otr_browser.get()); | 238 chrome::BrowserCommandController command_controller(otr_browser.get()); |
239 const CommandUpdater* command_updater = command_controller.command_updater(); | 239 const CommandUpdater* command_updater = command_controller.command_updater(); |
240 | 240 |
241 // The avatar menu should be disabled. | 241 // The avatar menu should be disabled. |
242 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 242 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
243 // 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. |
244 } | 244 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 399 } |
400 | 400 |
401 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { | 401 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { |
402 // Set up a profile with an off the record profile. | 402 // Set up a profile with an off the record profile. |
403 scoped_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); | 403 scoped_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); |
404 Profile* profile2 = profile1->GetOffTheRecordProfile(); | 404 Profile* profile2 = profile1->GetOffTheRecordProfile(); |
405 | 405 |
406 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); | 406 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); |
407 | 407 |
408 // Create a new browser based on the off the record profile. | 408 // Create a new browser based on the off the record profile. |
409 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(), | 409 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile()); |
410 chrome::GetActiveDesktop()); | |
411 scoped_ptr<Browser> browser2( | 410 scoped_ptr<Browser> browser2( |
412 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); | 411 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); |
413 | 412 |
414 chrome::BrowserCommandController command_controller(browser2.get()); | 413 chrome::BrowserCommandController command_controller(browser2.get()); |
415 const CommandUpdater* command_updater = command_controller.command_updater(); | 414 const CommandUpdater* command_updater = command_controller.command_updater(); |
416 | 415 |
417 // Check that the SYNC_SETUP command is updated on preference change. | 416 // Check that the SYNC_SETUP command is updated on preference change. |
418 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 417 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
419 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 418 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
420 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 419 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
421 } | 420 } |
422 | 421 |
423 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 422 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
424 chrome::BrowserCommandController command_controller(browser()); | 423 chrome::BrowserCommandController command_controller(browser()); |
425 const CommandUpdater* command_updater = command_controller.command_updater(); | 424 const CommandUpdater* command_updater = command_controller.command_updater(); |
426 | 425 |
427 // Check that the SYNC_SETUP command is updated on preference change. | 426 // Check that the SYNC_SETUP command is updated on preference change. |
428 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 427 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
429 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 428 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
430 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 429 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
431 } | 430 } |
OLD | NEW |