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

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

Issue 323133005: Enable consistent identity on android platform by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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 | Annotate | Revision Log
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 204 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
205 205
206 testing_profile_manager.DeleteTestingProfile("p2"); 206 testing_profile_manager.DeleteTestingProfile("p2");
207 } 207 }
208 208
209 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) { 209 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) {
210 if (!profiles::IsMultipleProfilesEnabled()) 210 if (!profiles::IsMultipleProfilesEnabled())
211 return; 211 return;
212 212
213 // The command line is reset at the end of every test by the test suite. 213 // The command line is reset at the end of every test by the test suite.
214 CommandLine::ForCurrentProcess()->AppendSwitch( 214 switches::EnableNewProfileManagementForTesting(
215 switches::kNewProfileManagement); 215 CommandLine::ForCurrentProcess());
216 EXPECT_TRUE(switches::IsNewProfileManagement());
217 216
218 TestingProfileManager testing_profile_manager( 217 TestingProfileManager testing_profile_manager(
219 TestingBrowserProcess::GetGlobal()); 218 TestingBrowserProcess::GetGlobal());
220 ASSERT_TRUE(testing_profile_manager.SetUp()); 219 ASSERT_TRUE(testing_profile_manager.SetUp());
221 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); 220 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
222 221
223 chrome::BrowserCommandController command_controller(browser()); 222 chrome::BrowserCommandController command_controller(browser());
224 const CommandUpdater* command_updater = command_controller.command_updater(); 223 const CommandUpdater* command_updater = command_controller.command_updater();
225 224
226 testing_profile_manager.CreateTestingProfile("p1"); 225 testing_profile_manager.CreateTestingProfile("p1");
227 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); 226 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
228 #if defined(OS_CHROMEOS) 227 #if defined(OS_CHROMEOS)
229 // Chrome OS uses system tray menu to handle multi-profiles. 228 // Chrome OS uses system tray menu to handle multi-profiles.
230 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 229 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
231 #else 230 #else
232 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 231 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
233 #endif 232 #endif
234 testing_profile_manager.DeleteTestingProfile("p1"); 233 testing_profile_manager.DeleteTestingProfile("p1");
235 } 234 }
236 235
237 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) { 236 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) {
238 if (!profiles::IsMultipleProfilesEnabled()) 237 if (!profiles::IsMultipleProfilesEnabled())
239 return; 238 return;
240 239
241 // The command line is reset at the end of every test by the test suite. 240 // The command line is reset at the end of every test by the test suite.
242 CommandLine::ForCurrentProcess()->AppendSwitch( 241 switches::EnableNewProfileManagementForTesting(
243 switches::kNewProfileManagement); 242 CommandLine::ForCurrentProcess());
244 EXPECT_TRUE(switches::IsNewProfileManagement());
245 243
246 TestingProfileManager testing_profile_manager( 244 TestingProfileManager testing_profile_manager(
247 TestingBrowserProcess::GetGlobal()); 245 TestingBrowserProcess::GetGlobal());
248 ASSERT_TRUE(testing_profile_manager.SetUp()); 246 ASSERT_TRUE(testing_profile_manager.SetUp());
249 247
250 // Set up guest a profile. 248 // Set up guest a profile.
251 TestingProfile::Builder guest_builder; 249 TestingProfile::Builder guest_builder;
252 guest_builder.SetIncognito(); // Guest profiles are off the record. 250 guest_builder.SetIncognito(); // Guest profiles are off the record.
253 guest_builder.SetGuestSession(); 251 guest_builder.SetGuestSession();
254 guest_builder.SetPath(ProfileManager::GetGuestProfilePath()); 252 guest_builder.SetPath(ProfileManager::GetGuestProfilePath());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 285
288 chrome::BrowserCommandController command_controller(otr_browser.get()); 286 chrome::BrowserCommandController command_controller(otr_browser.get());
289 const CommandUpdater* command_updater = command_controller.command_updater(); 287 const CommandUpdater* command_updater = command_controller.command_updater();
290 288
291 // The old style avatar menu should be disabled. 289 // The old style avatar menu should be disabled.
292 EXPECT_FALSE(switches::IsNewProfileManagement()); 290 EXPECT_FALSE(switches::IsNewProfileManagement());
293 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 291 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
294 292
295 // The new style avatar menu should also be disabled. 293 // The new style avatar menu should also be disabled.
296 // The command line is reset at the end of every test by the test suite. 294 // The command line is reset at the end of every test by the test suite.
297 CommandLine::ForCurrentProcess()->AppendSwitch( 295 switches::EnableNewProfileManagementForTesting(
298 switches::kNewProfileManagement); 296 CommandLine::ForCurrentProcess());
299 EXPECT_TRUE(switches::IsNewProfileManagement());
300 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 297 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
301 } 298 }
302 299
303 ////////////////////////////////////////////////////////////////////////////// 300 //////////////////////////////////////////////////////////////////////////////
304 301
305 // A test browser window that can toggle fullscreen state. 302 // A test browser window that can toggle fullscreen state.
306 class FullscreenTestBrowserWindow : public TestBrowserWindow { 303 class FullscreenTestBrowserWindow : public TestBrowserWindow {
307 public: 304 public:
308 FullscreenTestBrowserWindow() : fullscreen_(false) {} 305 FullscreenTestBrowserWindow() : fullscreen_(false) {}
309 virtual ~FullscreenTestBrowserWindow() {} 306 virtual ~FullscreenTestBrowserWindow() {}
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 456
460 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 457 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
461 chrome::BrowserCommandController command_controller(browser()); 458 chrome::BrowserCommandController command_controller(browser());
462 const CommandUpdater* command_updater = command_controller.command_updater(); 459 const CommandUpdater* command_updater = command_controller.command_updater();
463 460
464 // Check that the SYNC_SETUP command is updated on preference change. 461 // Check that the SYNC_SETUP command is updated on preference change.
465 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 462 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
466 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 463 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
467 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 464 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
468 } 465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698