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

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

Issue 1307093004: Remove references to IsNewAvatarMenu since the flag was removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback Created 5 years, 2 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Enable for tabbed browser. 166 // Enable for tabbed browser.
167 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 167 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
168 168
169 // Enabled for app windows. 169 // Enabled for app windows.
170 browser()->app_name_ = "app"; 170 browser()->app_name_ = "app";
171 ASSERT_TRUE(browser()->is_app()); 171 ASSERT_TRUE(browser()->is_app());
172 browser()->command_controller()->FullscreenStateChanged(); 172 browser()->command_controller()->FullscreenStateChanged();
173 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 173 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
174 } 174 }
175 175
176 TEST_F(BrowserCommandControllerTest, OldAvatarMenuEnabledForOneOrMoreProfiles) { 176 TEST_F(BrowserCommandControllerTest, AvatarAcceleratorEnabledOnDesktop) {
177 if (!profiles::IsMultipleProfilesEnabled()) 177 if (!profiles::IsMultipleProfilesEnabled())
178 return; 178 return;
179 179
180 // The command line is reset at the end of every test by the test suite.
181 switches::DisableNewAvatarMenuForTesting(
182 base::CommandLine::ForCurrentProcess());
183 ASSERT_FALSE(switches::IsNewAvatarMenu());
184
185 TestingProfileManager testing_profile_manager( 180 TestingProfileManager testing_profile_manager(
186 TestingBrowserProcess::GetGlobal()); 181 TestingBrowserProcess::GetGlobal());
187 ASSERT_TRUE(testing_profile_manager.SetUp()); 182 ASSERT_TRUE(testing_profile_manager.SetUp());
188 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); 183 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
189 184
190 chrome::BrowserCommandController command_controller(browser()); 185 chrome::BrowserCommandController command_controller(browser());
191 const CommandUpdater* command_updater = command_controller.command_updater(); 186 const CommandUpdater* command_updater = command_controller.command_updater();
192 187
193 bool enabled = true; 188 bool enabled = true;
194 #if defined(OS_CHROMEOS) 189 #if defined(OS_CHROMEOS)
195 // Chrome OS uses system tray menu to handle multi-profiles. 190 // Chrome OS uses system tray menu to handle multi-profiles.
196 enabled = false; 191 enabled = false;
197 #endif 192 #endif
198 193
199 testing_profile_manager.CreateTestingProfile("p1"); 194 testing_profile_manager.CreateTestingProfile("p1");
200 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); 195 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
201 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 196 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
202 197
203 testing_profile_manager.CreateTestingProfile("p2"); 198 testing_profile_manager.CreateTestingProfile("p2");
204 ASSERT_EQ(2U, profile_manager->GetNumberOfProfiles()); 199 ASSERT_EQ(2U, profile_manager->GetNumberOfProfiles());
205 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 200 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
206 201
207 testing_profile_manager.DeleteTestingProfile("p1"); 202 testing_profile_manager.DeleteTestingProfile("p1");
208 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); 203 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
209 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 204 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
210 205
211 testing_profile_manager.DeleteTestingProfile("p2"); 206 testing_profile_manager.DeleteTestingProfile("p2");
212 } 207 }
213 208
214 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) {
215 if (!profiles::IsMultipleProfilesEnabled())
216 return;
217
218 // The command line is reset at the end of every test by the test suite.
219 switches::EnableNewAvatarMenuForTesting(
220 base::CommandLine::ForCurrentProcess());
221
222 TestingProfileManager testing_profile_manager(
223 TestingBrowserProcess::GetGlobal());
224 ASSERT_TRUE(testing_profile_manager.SetUp());
225 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
226
227 chrome::BrowserCommandController command_controller(browser());
228 const CommandUpdater* command_updater = command_controller.command_updater();
229
230 testing_profile_manager.CreateTestingProfile("p1");
231 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
232 #if defined(OS_CHROMEOS)
233 // Chrome OS uses system tray menu to handle multi-profiles.
234 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
235 #else
236 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
237 #endif
238 testing_profile_manager.DeleteTestingProfile("p1");
239 }
240
241 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { 209 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) {
242 if (!profiles::IsMultipleProfilesEnabled()) 210 if (!profiles::IsMultipleProfilesEnabled())
243 return; 211 return;
244 212
245 // Set up a profile with an off the record profile. 213 // Set up a profile with an off the record profile.
246 TestingProfile::Builder normal_builder; 214 TestingProfile::Builder normal_builder;
247 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); 215 scoped_ptr<TestingProfile> original_profile = normal_builder.Build();
248 216
249 // Create a new browser based on the off the record profile. 217 // Create a new browser based on the off the record profile.
250 Browser::CreateParams profile_params( 218 Browser::CreateParams profile_params(
251 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); 219 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop());
252 scoped_ptr<Browser> otr_browser( 220 scoped_ptr<Browser> otr_browser(
253 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); 221 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
254 222
255 chrome::BrowserCommandController command_controller(otr_browser.get()); 223 chrome::BrowserCommandController command_controller(otr_browser.get());
256 const CommandUpdater* command_updater = command_controller.command_updater(); 224 const CommandUpdater* command_updater = command_controller.command_updater();
257 225
258 // Both the old style and the new style avatar menu should be disabled. 226 // The avatar menu should be disabled.
259 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
260 if (switches::IsNewAvatarMenu()) {
261 switches::DisableNewAvatarMenuForTesting(
262 base::CommandLine::ForCurrentProcess());
263 } else {
264 switches::EnableNewAvatarMenuForTesting(
265 base::CommandLine::ForCurrentProcess());
266 }
267 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 227 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
268 // The command line is reset at the end of every test by the test suite. 228 // The command line is reset at the end of every test by the test suite.
269 } 229 }
270 230
271 ////////////////////////////////////////////////////////////////////////////// 231 //////////////////////////////////////////////////////////////////////////////
272 class BrowserCommandControllerFullscreenTest; 232 class BrowserCommandControllerFullscreenTest;
273 233
274 // A test browser window that can toggle fullscreen state. 234 // A test browser window that can toggle fullscreen state.
275 class FullscreenTestBrowserWindow : public TestBrowserWindow, 235 class FullscreenTestBrowserWindow : public TestBrowserWindow,
276 ExclusiveAccessContext { 236 ExclusiveAccessContext {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 406
447 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 407 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
448 chrome::BrowserCommandController command_controller(browser()); 408 chrome::BrowserCommandController command_controller(browser());
449 const CommandUpdater* command_updater = command_controller.command_updater(); 409 const CommandUpdater* command_updater = command_controller.command_updater();
450 410
451 // Check that the SYNC_SETUP command is updated on preference change. 411 // Check that the SYNC_SETUP command is updated on preference change.
452 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 412 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
453 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 413 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
454 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 414 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
455 } 415 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller_browsertest.cc ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698