| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 165 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
| 166 | 166 |
| 167 // Enabled for app windows. | 167 // Enabled for app windows. |
| 168 browser()->app_name_ = "app"; | 168 browser()->app_name_ = "app"; |
| 169 ASSERT_TRUE(browser()->is_app()); | 169 ASSERT_TRUE(browser()->is_app()); |
| 170 browser()->command_controller()->FullscreenStateChanged(); | 170 browser()->command_controller()->FullscreenStateChanged(); |
| 171 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 171 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_F(BrowserCommandControllerTest, OldAvatarMenuEnabledForOneOrMoreProfiles) { | 174 TEST_F(BrowserCommandControllerTest, OldAvatarMenuEnabledForOneOrMoreProfiles) { |
| 175 #if defined(OS_CHROMEOS) | |
| 176 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by | |
| 177 // default on CrOS. http://crbug.com/351655 | |
| 178 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); | |
| 179 #endif | |
| 180 | |
| 181 if (!profiles::IsMultipleProfilesEnabled()) | 175 if (!profiles::IsMultipleProfilesEnabled()) |
| 182 return; | 176 return; |
| 183 | 177 |
| 184 EXPECT_FALSE(switches::IsNewProfileManagement()); | 178 EXPECT_FALSE(switches::IsNewProfileManagement()); |
| 185 | 179 |
| 186 TestingProfileManager testing_profile_manager( | 180 TestingProfileManager testing_profile_manager( |
| 187 TestingBrowserProcess::GetGlobal()); | 181 TestingBrowserProcess::GetGlobal()); |
| 188 ASSERT_TRUE(testing_profile_manager.SetUp()); | 182 ASSERT_TRUE(testing_profile_manager.SetUp()); |
| 189 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); | 183 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); |
| 190 | 184 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 200 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 207 | 201 |
| 208 testing_profile_manager.DeleteTestingProfile("p1"); | 202 testing_profile_manager.DeleteTestingProfile("p1"); |
| 209 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); | 203 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); |
| 210 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 204 EXPECT_EQ(enabled, command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 211 | 205 |
| 212 testing_profile_manager.DeleteTestingProfile("p2"); | 206 testing_profile_manager.DeleteTestingProfile("p2"); |
| 213 } | 207 } |
| 214 | 208 |
| 215 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) { | 209 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) { |
| 216 #if defined(OS_CHROMEOS) | |
| 217 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by | |
| 218 // default on CrOS. http://crbug.com/351655 | |
| 219 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); | |
| 220 #endif | |
| 221 | |
| 222 if (!profiles::IsMultipleProfilesEnabled()) | 210 if (!profiles::IsMultipleProfilesEnabled()) |
| 223 return; | 211 return; |
| 224 | 212 |
| 225 // 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. |
| 226 CommandLine::ForCurrentProcess()->AppendSwitch( | 214 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 227 switches::kNewProfileManagement); | 215 switches::kNewProfileManagement); |
| 228 EXPECT_TRUE(switches::IsNewProfileManagement()); | 216 EXPECT_TRUE(switches::IsNewProfileManagement()); |
| 229 | 217 |
| 230 TestingProfileManager testing_profile_manager( | 218 TestingProfileManager testing_profile_manager( |
| 231 TestingBrowserProcess::GetGlobal()); | 219 TestingBrowserProcess::GetGlobal()); |
| 232 ASSERT_TRUE(testing_profile_manager.SetUp()); | 220 ASSERT_TRUE(testing_profile_manager.SetUp()); |
| 233 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); | 221 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); |
| 234 | 222 |
| 235 chrome::BrowserCommandController command_controller(browser()); | 223 chrome::BrowserCommandController command_controller(browser()); |
| 236 const CommandUpdater* command_updater = command_controller.command_updater(); | 224 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 237 | 225 |
| 238 testing_profile_manager.CreateTestingProfile("p1"); | 226 testing_profile_manager.CreateTestingProfile("p1"); |
| 239 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); | 227 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); |
| 240 #if defined(OS_CHROMEOS) | 228 #if defined(OS_CHROMEOS) |
| 241 // Chrome OS uses system tray menu to handle multi-profiles. | 229 // Chrome OS uses system tray menu to handle multi-profiles. |
| 242 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 230 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 243 #else | 231 #else |
| 244 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 232 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 245 #endif | 233 #endif |
| 246 testing_profile_manager.DeleteTestingProfile("p1"); | 234 testing_profile_manager.DeleteTestingProfile("p1"); |
| 247 } | 235 } |
| 248 | 236 |
| 249 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) { | 237 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) { |
| 250 #if defined(OS_CHROMEOS) | |
| 251 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by | |
| 252 // default on CrOS. http://crbug.com/351655 | |
| 253 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); | |
| 254 #endif | |
| 255 | |
| 256 if (!profiles::IsMultipleProfilesEnabled()) | 238 if (!profiles::IsMultipleProfilesEnabled()) |
| 257 return; | 239 return; |
| 258 | 240 |
| 259 // The command line is reset at the end of every test by the test suite. | 241 // The command line is reset at the end of every test by the test suite. |
| 260 CommandLine::ForCurrentProcess()->AppendSwitch( | 242 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 261 switches::kNewProfileManagement); | 243 switches::kNewProfileManagement); |
| 262 EXPECT_TRUE(switches::IsNewProfileManagement()); | 244 EXPECT_TRUE(switches::IsNewProfileManagement()); |
| 263 | 245 |
| 264 TestingProfileManager testing_profile_manager( | 246 TestingProfileManager testing_profile_manager( |
| 265 TestingBrowserProcess::GetGlobal()); | 247 TestingBrowserProcess::GetGlobal()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 283 const CommandUpdater* command_updater = command_controller.command_updater(); | 265 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 284 #if defined(OS_CHROMEOS) | 266 #if defined(OS_CHROMEOS) |
| 285 // Chrome OS uses system tray menu to handle multi-profiles. | 267 // Chrome OS uses system tray menu to handle multi-profiles. |
| 286 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 268 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 287 #else | 269 #else |
| 288 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 270 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 289 #endif | 271 #endif |
| 290 } | 272 } |
| 291 | 273 |
| 292 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { | 274 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { |
| 293 #if defined(OS_CHROMEOS) | |
| 294 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by | |
| 295 // default on CrOS. http://crbug.com/351655 | |
| 296 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); | |
| 297 #endif | |
| 298 | |
| 299 if (!profiles::IsMultipleProfilesEnabled()) | 275 if (!profiles::IsMultipleProfilesEnabled()) |
| 300 return; | 276 return; |
| 301 | 277 |
| 302 // Set up a profile with an off the record profile. | 278 // Set up a profile with an off the record profile. |
| 303 TestingProfile::Builder normal_builder; | 279 TestingProfile::Builder normal_builder; |
| 304 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); | 280 scoped_ptr<TestingProfile> original_profile = normal_builder.Build(); |
| 305 | 281 |
| 306 // Create a new browser based on the off the record profile. | 282 // Create a new browser based on the off the record profile. |
| 307 Browser::CreateParams profile_params( | 283 Browser::CreateParams profile_params( |
| 308 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); | 284 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 459 |
| 484 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 460 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 485 chrome::BrowserCommandController command_controller(browser()); | 461 chrome::BrowserCommandController command_controller(browser()); |
| 486 const CommandUpdater* command_updater = command_controller.command_updater(); | 462 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 487 | 463 |
| 488 // Check that the SYNC_SETUP command is updated on preference change. | 464 // Check that the SYNC_SETUP command is updated on preference change. |
| 489 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 465 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 490 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 466 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 491 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 467 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 492 } | 468 } |
| OLD | NEW |