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

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

Issue 1198313003: Fix the browser match rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_ptr<Browser> instead. Created 5 years, 5 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 "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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (!profiles::IsMultipleProfilesEnabled()) 242 if (!profiles::IsMultipleProfilesEnabled())
243 return; 243 return;
244 244
245 // Set up a profile with an off the record profile. 245 // Set up a profile with an off the record profile.
246 TestingProfile::Builder normal_builder; 246 TestingProfile::Builder normal_builder;
247 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); 247 scoped_ptr<TestingProfile> original_profile = normal_builder.Build();
248 248
249 // Create a new browser based on the off the record profile. 249 // Create a new browser based on the off the record profile.
250 Browser::CreateParams profile_params( 250 Browser::CreateParams profile_params(
251 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); 251 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop());
252 scoped_ptr<Browser> otr_browser( 252 scoped_ptr<Browser> otr_browser =
253 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); 253 chrome::CreateBrowserWithTestWindowForParams(&profile_params);
254 254
255 chrome::BrowserCommandController command_controller(otr_browser.get()); 255 chrome::BrowserCommandController command_controller(otr_browser.get());
256 const CommandUpdater* command_updater = command_controller.command_updater(); 256 const CommandUpdater* command_updater = command_controller.command_updater();
257 257
258 // Both the old style and the new style avatar menu should be disabled. 258 // Both the old style and the new style avatar menu should be disabled.
259 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 259 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
260 if (switches::IsNewAvatarMenu()) { 260 if (switches::IsNewAvatarMenu()) {
261 switches::DisableNewAvatarMenuForTesting( 261 switches::DisableNewAvatarMenuForTesting(
262 base::CommandLine::ForCurrentProcess()); 262 base::CommandLine::ForCurrentProcess());
263 } else { 263 } else {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) { 425 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) {
426 // Set up a profile with an off the record profile. 426 // Set up a profile with an off the record profile.
427 scoped_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build(); 427 scoped_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build();
428 Profile* profile2 = profile1->GetOffTheRecordProfile(); 428 Profile* profile2 = profile1->GetOffTheRecordProfile();
429 429
430 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get()); 430 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get());
431 431
432 // Create a new browser based on the off the record profile. 432 // Create a new browser based on the off the record profile.
433 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(), 433 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(),
434 chrome::GetActiveDesktop()); 434 chrome::GetActiveDesktop());
435 scoped_ptr<Browser> browser2( 435 scoped_ptr<Browser> browser2 =
436 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); 436 chrome::CreateBrowserWithTestWindowForParams(&profile_params);
437 437
438 chrome::BrowserCommandController command_controller(browser2.get()); 438 chrome::BrowserCommandController command_controller(browser2.get());
439 const CommandUpdater* command_updater = command_controller.command_updater(); 439 const CommandUpdater* command_updater = command_controller.command_updater();
440 440
441 // Check that the SYNC_SETUP command is updated on preference change. 441 // Check that the SYNC_SETUP command is updated on preference change.
442 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 442 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
443 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 443 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
444 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 444 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
445 } 445 }
446 446
447 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 447 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
448 chrome::BrowserCommandController command_controller(browser()); 448 chrome::BrowserCommandController command_controller(browser());
449 const CommandUpdater* command_updater = command_controller.command_updater(); 449 const CommandUpdater* command_updater = command_controller.command_updater();
450 450
451 // Check that the SYNC_SETUP command is updated on preference change. 451 // Check that the SYNC_SETUP command is updated on preference change.
452 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 452 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
453 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 453 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
454 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 454 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
455 } 455 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698