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 "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/exclusive_access/exclusive_access_context.h" | 9 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
| 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h" | 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 // The FullscreenControllerStateUnitTest unit test suite exhastively tests | 19 // The FullscreenControllerStateUnitTest unit test suite exhastively tests |
| 19 // the FullscreenController through all permutations of events. The behavior | 20 // the FullscreenController through all permutations of events. The behavior |
| 20 // of the BrowserWindow is mocked via FullscreenControllerTestWindow. | 21 // of the BrowserWindow is mocked via FullscreenControllerTestWindow. |
| 21 | 22 |
| 22 | 23 |
| 23 // FullscreenControllerTestWindow ---------------------------------------------- | 24 // FullscreenControllerTestWindow ---------------------------------------------- |
| 24 | 25 |
| 25 // A BrowserWindow used for testing FullscreenController. The behavior of this | 26 // A BrowserWindow used for testing FullscreenController. The behavior of this |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 // tab fullscreen mode. The browser window should stay fullscreened, while | 743 // tab fullscreen mode. The browser window should stay fullscreened, while |
| 743 // the tab exits fullscreen mode. | 744 // the tab exits fullscreen mode. |
| 744 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN)); | 745 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN)); |
| 745 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); | 746 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); |
| 746 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE)); | 747 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE)); |
| 747 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); | 748 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); |
| 748 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); | 749 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); |
| 749 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser()); | 750 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser()); |
| 750 } | 751 } |
| 751 | 752 |
| 753 class FullscreenChangeObserver : public content::WebContentsObserver { | |
| 754 public: | |
| 755 explicit FullscreenChangeObserver(content::WebContents* web_contents) | |
| 756 : WebContentsObserver(web_contents) { | |
| 757 } | |
| 758 | |
| 759 MOCK_METHOD2(DidToggleFullscreenModeForTab, void(bool, bool)); | |
| 760 | |
| 761 private: | |
| 762 | |
| 763 DISALLOW_COPY_AND_ASSIGN(FullscreenChangeObserver); | |
| 764 }; | |
| 765 | |
| 766 // Tests that going from tab fullscreen -> browser fullscreen causes an explicit | |
|
scheib
2016/01/04 22:26:48
Comment here and in body describes how ::WasResize
bokan
2016/01/05 15:37:11
Done.
| |
| 767 // WasResized to be called on ExitFullscreen while going from tab fullscreen -> | |
| 768 // Normal does not. This ensures that the Resize message we get in the renderer | |
| 769 // will have both the fullscreen change and size change in the same message. | |
| 770 // crbug.com/142427. | |
| 771 TEST_F(FullscreenControllerStateUnitTest, TabToBrowserFullscreenCausesResize) { | |
| 772 AddTab(browser(), GURL(url::kAboutBlankURL)); | |
| 773 content::WebContents* const tab = | |
| 774 browser()->tab_strip_model()->GetWebContentsAt(0); | |
| 775 | |
| 776 FullscreenChangeObserver fullscreenObserver(tab); | |
| 777 | |
| 778 // Go into browser fullscreen, then tab fullscreen. Exiting tab fullscreen | |
| 779 // should call WasResized since the fullscreen change wont cause a size change | |
| 780 // itself. | |
| 781 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN)); | |
| 782 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); | |
| 783 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); | |
| 784 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 785 | |
| 786 EXPECT_CALL(fullscreenObserver, | |
| 787 DidToggleFullscreenModeForTab(false, false)); | |
| 788 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE)); | |
| 789 testing::Mock::VerifyAndClearExpectations(&fullscreenObserver); | |
| 790 | |
| 791 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN)); | |
| 792 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); | |
| 793 ASSERT_FALSE(browser()->window()->IsFullscreen()); | |
| 794 | |
| 795 // Go into tab fullscreen only. Exiting tab fullscreen should *not* cause | |
| 796 // a call to WasResized since the window will change size and we want the | |
| 797 // fullscreen change and size change to be in one Resize message. | |
| 798 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); | |
| 799 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); | |
| 800 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 801 | |
| 802 EXPECT_CALL(fullscreenObserver, | |
| 803 DidToggleFullscreenModeForTab(false, true)); | |
| 804 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE)); | |
| 805 ASSERT_FALSE(browser()->window()->IsFullscreen()); | |
| 806 testing::Mock::VerifyAndClearExpectations(&fullscreenObserver); | |
| 807 } | |
| 808 | |
| 752 // Tests that the state of a fullscreened, screen-captured tab is preserved if | 809 // Tests that the state of a fullscreened, screen-captured tab is preserved if |
| 753 // the tab is detached from one Browser window and attached to another. | 810 // the tab is detached from one Browser window and attached to another. |
| 754 // | 811 // |
| 755 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. | 812 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. |
| 756 TEST_F(FullscreenControllerStateUnitTest, | 813 TEST_F(FullscreenControllerStateUnitTest, |
| 757 CapturedFullscreenedTabTransferredBetweenBrowserWindows) { | 814 CapturedFullscreenedTabTransferredBetweenBrowserWindows) { |
| 758 content::WebContentsDelegate* const wc_delegate = | 815 content::WebContentsDelegate* const wc_delegate = |
| 759 static_cast<content::WebContentsDelegate*>(browser()); | 816 static_cast<content::WebContentsDelegate*>(browser()); |
| 760 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); | 817 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); |
| 761 | 818 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); | 885 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); |
| 829 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); | 886 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); |
| 830 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); | 887 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); |
| 831 EXPECT_FALSE(second_browser->exclusive_access_manager() | 888 EXPECT_FALSE(second_browser->exclusive_access_manager() |
| 832 ->fullscreen_controller() | 889 ->fullscreen_controller() |
| 833 ->IsWindowFullscreenForTabOrPending()); | 890 ->IsWindowFullscreenForTabOrPending()); |
| 834 | 891 |
| 835 // Required tear-down specific to this test. | 892 // Required tear-down specific to this test. |
| 836 second_browser->tab_strip_model()->CloseAllTabs(); | 893 second_browser->tab_strip_model()->CloseAllTabs(); |
| 837 } | 894 } |
| OLD | NEW |