| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_tabstrip.h" | 8 #include "chrome/browser/ui/browser_tabstrip.h" |
| 9 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 9 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" | 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // Tests that, in a browser configured for Fullscreen-Within-Tab mode, | 478 // Tests that, in a browser configured for Fullscreen-Within-Tab mode, |
| 479 // fullscreening a screen-captured tab will NOT cause any fullscreen state | 479 // fullscreening a screen-captured tab will NOT cause any fullscreen state |
| 480 // change to the browser window. Furthermore, the test switches between tabs to | 480 // change to the browser window. Furthermore, the test switches between tabs to |
| 481 // confirm a captured tab will be resized by FullscreenController to the capture | 481 // confirm a captured tab will be resized by FullscreenController to the capture |
| 482 // video resolution once the widget is detached from the UI. | 482 // video resolution once the widget is detached from the UI. |
| 483 // | 483 // |
| 484 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. | 484 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. |
| 485 TEST_F(FullscreenControllerStateUnitTest, OneCapturedFullscreenedTab) { | 485 TEST_F(FullscreenControllerStateUnitTest, OneCapturedFullscreenedTab) { |
| 486 content::WebContentsDelegate* const wc_delegate = | 486 content::WebContentsDelegate* const wc_delegate = |
| 487 static_cast<content::WebContentsDelegate*>(browser()); | 487 static_cast<content::WebContentsDelegate*>(browser()); |
| 488 if (!wc_delegate->EmbedsFullscreenWidget()) { | 488 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); |
| 489 LOG(WARNING) << "Skipping test since fullscreen-within-tab is disabled."; | |
| 490 return; | |
| 491 } | |
| 492 | 489 |
| 493 AddTab(browser(), GURL(url::kAboutBlankURL)); | 490 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 494 AddTab(browser(), GURL(url::kAboutBlankURL)); | 491 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 495 content::WebContents* const first_tab = | 492 content::WebContents* const first_tab = |
| 496 browser()->tab_strip_model()->GetWebContentsAt(0); | 493 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 497 content::WebContents* const second_tab = | 494 content::WebContents* const second_tab = |
| 498 browser()->tab_strip_model()->GetWebContentsAt(1); | 495 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 499 | 496 |
| 500 // Activate the first tab and tell its WebContents it is being captured. | 497 // Activate the first tab and tell its WebContents it is being captured. |
| 501 browser()->tab_strip_model()->ActivateTabAt(0, true); | 498 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 // each other. One tab is being screen-captured and is toggled into fullscreen | 542 // each other. One tab is being screen-captured and is toggled into fullscreen |
| 546 // mode, and then the user switches to another tab not being screen-captured and | 543 // mode, and then the user switches to another tab not being screen-captured and |
| 547 // fullscreens it. The first tab's fullscreen toggle does not affect the | 544 // fullscreens it. The first tab's fullscreen toggle does not affect the |
| 548 // browser window fullscreen, while the second one's does. Then, the order of | 545 // browser window fullscreen, while the second one's does. Then, the order of |
| 549 // operations is reversed. | 546 // operations is reversed. |
| 550 // | 547 // |
| 551 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. | 548 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. |
| 552 TEST_F(FullscreenControllerStateUnitTest, TwoFullscreenedTabsOneCaptured) { | 549 TEST_F(FullscreenControllerStateUnitTest, TwoFullscreenedTabsOneCaptured) { |
| 553 content::WebContentsDelegate* const wc_delegate = | 550 content::WebContentsDelegate* const wc_delegate = |
| 554 static_cast<content::WebContentsDelegate*>(browser()); | 551 static_cast<content::WebContentsDelegate*>(browser()); |
| 555 if (!wc_delegate->EmbedsFullscreenWidget()) { | 552 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); |
| 556 LOG(WARNING) << "Skipping test since fullscreen-within-tab is disabled."; | |
| 557 return; | |
| 558 } | |
| 559 | 553 |
| 560 AddTab(browser(), GURL(url::kAboutBlankURL)); | 554 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 561 AddTab(browser(), GURL(url::kAboutBlankURL)); | 555 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 562 content::WebContents* const first_tab = | 556 content::WebContents* const first_tab = |
| 563 browser()->tab_strip_model()->GetWebContentsAt(0); | 557 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 564 content::WebContents* const second_tab = | 558 content::WebContents* const second_tab = |
| 565 browser()->tab_strip_model()->GetWebContentsAt(1); | 559 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 566 | 560 |
| 567 // Start capturing the first tab, fullscreen it, then switch to the second tab | 561 // Start capturing the first tab, fullscreen it, then switch to the second tab |
| 568 // and fullscreen that. The second tab will cause the browser window to | 562 // and fullscreen that. The second tab will cause the browser window to |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 // TwoFullscreenedTabsOneCaptured test above, except that the screen-captured | 600 // TwoFullscreenedTabsOneCaptured test above, except that the screen-captured |
| 607 // tab exits fullscreen mode while the second tab is still in the foreground. | 601 // tab exits fullscreen mode while the second tab is still in the foreground. |
| 608 // When the first tab exits fullscreen, the fullscreen state of the second tab | 602 // When the first tab exits fullscreen, the fullscreen state of the second tab |
| 609 // and the browser window should remain unchanged. | 603 // and the browser window should remain unchanged. |
| 610 // | 604 // |
| 611 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. | 605 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. |
| 612 TEST_F(FullscreenControllerStateUnitTest, | 606 TEST_F(FullscreenControllerStateUnitTest, |
| 613 BackgroundCapturedTabExitsFullscreen) { | 607 BackgroundCapturedTabExitsFullscreen) { |
| 614 content::WebContentsDelegate* const wc_delegate = | 608 content::WebContentsDelegate* const wc_delegate = |
| 615 static_cast<content::WebContentsDelegate*>(browser()); | 609 static_cast<content::WebContentsDelegate*>(browser()); |
| 616 if (!wc_delegate->EmbedsFullscreenWidget()) { | 610 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); |
| 617 LOG(WARNING) << "Skipping test since fullscreen-within-tab is disabled."; | |
| 618 return; | |
| 619 } | |
| 620 | 611 |
| 621 AddTab(browser(), GURL(url::kAboutBlankURL)); | 612 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 622 AddTab(browser(), GURL(url::kAboutBlankURL)); | 613 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 623 content::WebContents* const first_tab = | 614 content::WebContents* const first_tab = |
| 624 browser()->tab_strip_model()->GetWebContentsAt(0); | 615 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 625 content::WebContents* const second_tab = | 616 content::WebContents* const second_tab = |
| 626 browser()->tab_strip_model()->GetWebContentsAt(1); | 617 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 627 | 618 |
| 628 // Start capturing the first tab, fullscreen it, then switch to the second tab | 619 // Start capturing the first tab, fullscreen it, then switch to the second tab |
| 629 // and fullscreen that. The second tab will cause the browser window to | 620 // and fullscreen that. The second tab will cause the browser window to |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 // fullscreening a screen-captured tab will NOT cause any fullscreen state | 656 // fullscreening a screen-captured tab will NOT cause any fullscreen state |
| 666 // change to the browser window. Then, toggling Browser Fullscreen mode should | 657 // change to the browser window. Then, toggling Browser Fullscreen mode should |
| 667 // fullscreen the browser window, but this should behave fully independently of | 658 // fullscreen the browser window, but this should behave fully independently of |
| 668 // the tab's fullscreen state. | 659 // the tab's fullscreen state. |
| 669 // | 660 // |
| 670 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. | 661 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. |
| 671 TEST_F(FullscreenControllerStateUnitTest, | 662 TEST_F(FullscreenControllerStateUnitTest, |
| 672 OneCapturedTabFullscreenedBeforeBrowserFullscreen) { | 663 OneCapturedTabFullscreenedBeforeBrowserFullscreen) { |
| 673 content::WebContentsDelegate* const wc_delegate = | 664 content::WebContentsDelegate* const wc_delegate = |
| 674 static_cast<content::WebContentsDelegate*>(browser()); | 665 static_cast<content::WebContentsDelegate*>(browser()); |
| 675 if (!wc_delegate->EmbedsFullscreenWidget()) { | 666 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); |
| 676 LOG(WARNING) << "Skipping test since fullscreen-within-tab is disabled."; | |
| 677 return; | |
| 678 } | |
| 679 | 667 |
| 680 AddTab(browser(), GURL(url::kAboutBlankURL)); | 668 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 681 content::WebContents* const tab = | 669 content::WebContents* const tab = |
| 682 browser()->tab_strip_model()->GetWebContentsAt(0); | 670 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 683 | 671 |
| 684 // Start capturing the tab and fullscreen it. The state of the browser window | 672 // Start capturing the tab and fullscreen it. The state of the browser window |
| 685 // should remain unchanged. | 673 // should remain unchanged. |
| 686 browser()->tab_strip_model()->ActivateTabAt(0, true); | 674 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 687 const gfx::Size kCaptureSize(1280, 720); | 675 const gfx::Size kCaptureSize(1280, 720); |
| 688 tab->IncrementCapturerCount(kCaptureSize); | 676 tab->IncrementCapturerCount(kCaptureSize); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 719 } | 707 } |
| 720 | 708 |
| 721 // Tests that the state of a fullscreened, screen-captured tab is preserved if | 709 // Tests that the state of a fullscreened, screen-captured tab is preserved if |
| 722 // the tab is detached from one Browser window and attached to another. | 710 // the tab is detached from one Browser window and attached to another. |
| 723 // | 711 // |
| 724 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. | 712 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. |
| 725 TEST_F(FullscreenControllerStateUnitTest, | 713 TEST_F(FullscreenControllerStateUnitTest, |
| 726 CapturedFullscreenedTabTransferredBetweenBrowserWindows) { | 714 CapturedFullscreenedTabTransferredBetweenBrowserWindows) { |
| 727 content::WebContentsDelegate* const wc_delegate = | 715 content::WebContentsDelegate* const wc_delegate = |
| 728 static_cast<content::WebContentsDelegate*>(browser()); | 716 static_cast<content::WebContentsDelegate*>(browser()); |
| 729 if (!wc_delegate->EmbedsFullscreenWidget()) { | 717 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); |
| 730 LOG(WARNING) << "Skipping test since fullscreen-within-tab is disabled."; | |
| 731 return; | |
| 732 } | |
| 733 | 718 |
| 734 AddTab(browser(), GURL(url::kAboutBlankURL)); | 719 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 735 AddTab(browser(), GURL(url::kAboutBlankURL)); | 720 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| 736 content::WebContents* const tab = | 721 content::WebContents* const tab = |
| 737 browser()->tab_strip_model()->GetWebContentsAt(0); | 722 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 738 | 723 |
| 739 // Activate the first tab and tell its WebContents it is being captured. | 724 // Activate the first tab and tell its WebContents it is being captured. |
| 740 browser()->tab_strip_model()->ActivateTabAt(0, true); | 725 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 741 const gfx::Size kCaptureSize(1280, 720); | 726 const gfx::Size kCaptureSize(1280, 720); |
| 742 tab->IncrementCapturerCount(kCaptureSize); | 727 tab->IncrementCapturerCount(kCaptureSize); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 EXPECT_FALSE(browser()->window()->IsFullscreen()); | 782 EXPECT_FALSE(browser()->window()->IsFullscreen()); |
| 798 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); | 783 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); |
| 799 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); | 784 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); |
| 800 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); | 785 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); |
| 801 EXPECT_FALSE(second_browser->fullscreen_controller()-> | 786 EXPECT_FALSE(second_browser->fullscreen_controller()-> |
| 802 IsWindowFullscreenForTabOrPending()); | 787 IsWindowFullscreenForTabOrPending()); |
| 803 | 788 |
| 804 // Required tear-down specific to this test. | 789 // Required tear-down specific to this test. |
| 805 second_browser->tab_strip_model()->CloseAllTabs(); | 790 second_browser->tab_strip_model()->CloseAllTabs(); |
| 806 } | 791 } |
| OLD | NEW |