| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); | 299 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); |
| 300 // The command line is reset at the end of every test by the test suite. | 300 // The command line is reset at the end of every test by the test suite. |
| 301 } | 301 } |
| 302 | 302 |
| 303 ////////////////////////////////////////////////////////////////////////////// | 303 ////////////////////////////////////////////////////////////////////////////// |
| 304 | 304 |
| 305 // A test browser window that can toggle fullscreen state. | 305 // A test browser window that can toggle fullscreen state. |
| 306 class FullscreenTestBrowserWindow : public TestBrowserWindow { | 306 class FullscreenTestBrowserWindow : public TestBrowserWindow { |
| 307 public: | 307 public: |
| 308 FullscreenTestBrowserWindow() : fullscreen_(false) {} | 308 FullscreenTestBrowserWindow() : fullscreen_(false) {} |
| 309 virtual ~FullscreenTestBrowserWindow() {} | 309 ~FullscreenTestBrowserWindow() override {} |
| 310 | 310 |
| 311 // TestBrowserWindow overrides: | 311 // TestBrowserWindow overrides: |
| 312 virtual bool ShouldHideUIForFullscreen() const override { | 312 bool ShouldHideUIForFullscreen() const override { return fullscreen_; } |
| 313 return fullscreen_; | 313 bool IsFullscreen() const override { return fullscreen_; } |
| 314 } | 314 void EnterFullscreen(const GURL& url, |
| 315 virtual bool IsFullscreen() const override { | 315 FullscreenExitBubbleType type) override { |
| 316 return fullscreen_; | |
| 317 } | |
| 318 virtual void EnterFullscreen( | |
| 319 const GURL& url, FullscreenExitBubbleType type) override { | |
| 320 fullscreen_ = true; | 316 fullscreen_ = true; |
| 321 } | 317 } |
| 322 virtual void ExitFullscreen() override { | 318 void ExitFullscreen() override { fullscreen_ = false; } |
| 323 fullscreen_ = false; | |
| 324 } | |
| 325 | 319 |
| 326 private: | 320 private: |
| 327 bool fullscreen_; | 321 bool fullscreen_; |
| 328 | 322 |
| 329 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); | 323 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); |
| 330 }; | 324 }; |
| 331 | 325 |
| 332 // Test that uses FullscreenTestBrowserWindow for its window. | 326 // Test that uses FullscreenTestBrowserWindow for its window. |
| 333 class BrowserCommandControllerFullscreenTest | 327 class BrowserCommandControllerFullscreenTest |
| 334 : public BrowserWithTestWindowTest { | 328 : public BrowserWithTestWindowTest { |
| 335 public: | 329 public: |
| 336 BrowserCommandControllerFullscreenTest() {} | 330 BrowserCommandControllerFullscreenTest() {} |
| 337 virtual ~BrowserCommandControllerFullscreenTest() {} | 331 virtual ~BrowserCommandControllerFullscreenTest() {} |
| 338 | 332 |
| 339 // BrowserWithTestWindowTest overrides: | 333 // BrowserWithTestWindowTest overrides: |
| 340 virtual BrowserWindow* CreateBrowserWindow() override { | 334 BrowserWindow* CreateBrowserWindow() override { |
| 341 return new FullscreenTestBrowserWindow; | 335 return new FullscreenTestBrowserWindow; |
| 342 } | 336 } |
| 343 | 337 |
| 344 private: | 338 private: |
| 345 DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerFullscreenTest); | 339 DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerFullscreenTest); |
| 346 }; | 340 }; |
| 347 | 341 |
| 348 TEST_F(BrowserCommandControllerFullscreenTest, | 342 TEST_F(BrowserCommandControllerFullscreenTest, |
| 349 UpdateCommandsForFullscreenMode) { | 343 UpdateCommandsForFullscreenMode) { |
| 350 // Defaults for a tabbed browser. | 344 // Defaults for a tabbed browser. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 449 |
| 456 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 450 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 457 chrome::BrowserCommandController command_controller(browser()); | 451 chrome::BrowserCommandController command_controller(browser()); |
| 458 const CommandUpdater* command_updater = command_controller.command_updater(); | 452 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 459 | 453 |
| 460 // Check that the SYNC_SETUP command is updated on preference change. | 454 // Check that the SYNC_SETUP command is updated on preference change. |
| 461 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 455 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 462 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 456 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 463 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 457 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 464 } | 458 } |
| OLD | NEW |