Chromium Code Reviews| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, AvatarMenuEnabledForOneOrMoreProfiles) { |
| 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()); | |
|
Peter Kasting
2015/09/25 23:42:51
It's not a problem that we used to force-disable t
Mike Lerman
2015/09/28 15:23:01
I think we can delete this test now. it tested beh
anthonyvd
2015/09/29 20:23:15
It doesn't seem like it's a problem because the te
| |
| 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) { | 209 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) { |
|
Peter Kasting
2015/09/25 23:42:51
Nit: Remove "New"?
Mike Lerman
2015/09/28 15:23:01
I don't think this test is necessary anymore; ther
anthonyvd
2015/09/29 20:23:15
Good point, it's redundant with the test right abo
| |
| 215 if (!profiles::IsMultipleProfilesEnabled()) | 210 if (!profiles::IsMultipleProfilesEnabled()) |
| 216 return; | 211 return; |
| 217 | 212 |
| 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( | 213 TestingProfileManager testing_profile_manager( |
| 223 TestingBrowserProcess::GetGlobal()); | 214 TestingBrowserProcess::GetGlobal()); |
| 224 ASSERT_TRUE(testing_profile_manager.SetUp()); | 215 ASSERT_TRUE(testing_profile_manager.SetUp()); |
| 225 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); | 216 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); |
| 226 | 217 |
| 227 chrome::BrowserCommandController command_controller(browser()); | 218 chrome::BrowserCommandController command_controller(browser()); |
| 228 const CommandUpdater* command_updater = command_controller.command_updater(); | 219 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 229 | 220 |
| 230 testing_profile_manager.CreateTestingProfile("p1"); | 221 testing_profile_manager.CreateTestingProfile("p1"); |
| 231 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); | 222 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 248 | 239 |
| 249 // Create a new browser based on the off the record profile. | 240 // Create a new browser based on the off the record profile. |
| 250 Browser::CreateParams profile_params( | 241 Browser::CreateParams profile_params( |
| 251 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); | 242 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop()); |
| 252 scoped_ptr<Browser> otr_browser( | 243 scoped_ptr<Browser> otr_browser( |
| 253 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); | 244 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); |
| 254 | 245 |
| 255 chrome::BrowserCommandController command_controller(otr_browser.get()); | 246 chrome::BrowserCommandController command_controller(otr_browser.get()); |
| 256 const CommandUpdater* command_updater = command_controller.command_updater(); | 247 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 257 | 248 |
| 258 // Both the old style and the new style avatar menu should be disabled. | 249 // Both the old style and the new style avatar menu should be disabled. |
|
Peter Kasting
2015/09/25 23:42:52
Nit: "The avatar menu should be disabled."?
anthonyvd
2015/09/29 20:23:15
Done.
| |
| 259 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 250 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)); | |
| 268 // The command line is reset at the end of every test by the test suite. | 251 // The command line is reset at the end of every test by the test suite. |
| 269 } | 252 } |
| 270 | 253 |
| 271 ////////////////////////////////////////////////////////////////////////////// | 254 ////////////////////////////////////////////////////////////////////////////// |
| 272 class BrowserCommandControllerFullscreenTest; | 255 class BrowserCommandControllerFullscreenTest; |
| 273 | 256 |
| 274 // A test browser window that can toggle fullscreen state. | 257 // A test browser window that can toggle fullscreen state. |
| 275 class FullscreenTestBrowserWindow : public TestBrowserWindow, | 258 class FullscreenTestBrowserWindow : public TestBrowserWindow, |
| 276 ExclusiveAccessContext { | 259 ExclusiveAccessContext { |
| 277 public: | 260 public: |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 | 429 |
| 447 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 430 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 448 chrome::BrowserCommandController command_controller(browser()); | 431 chrome::BrowserCommandController command_controller(browser()); |
| 449 const CommandUpdater* command_updater = command_controller.command_updater(); | 432 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 450 | 433 |
| 451 // Check that the SYNC_SETUP command is updated on preference change. | 434 // Check that the SYNC_SETUP command is updated on preference change. |
| 452 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 435 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 453 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 436 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 454 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 437 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 455 } | 438 } |
| OLD | NEW |