Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc

Issue 1488653002: Fix scroll restoration when exiting fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Accidentally made will_cause_resize always false in previous cleanup. Fixed Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 DISALLOW_COPY_AND_ASSIGN(FullscreenChangeObserver);
763 };
764
765 // Tests that going from tab fullscreen -> browser fullscreen causes an explicit
766 // WasResized to be called on ExitFullscreen while going from tab fullscreen ->
767 // Normal does not. This ensures that the Resize message we get in the renderer
768 // will have both the fullscreen change and size change in the same message.
769 // crbug.com/142427.
770 TEST_F(FullscreenControllerStateUnitTest, TabToBrowserFullscreenCausesResize) {
771 AddTab(browser(), GURL(url::kAboutBlankURL));
772 content::WebContents* const tab =
773 browser()->tab_strip_model()->GetWebContentsAt(0);
774
775 FullscreenChangeObserver fullscreenObserver(tab);
776
777 // Go into browser fullscreen, then tab fullscreen. Exiting tab fullscreen
778 // should call WasResized since the fullscreen change won't cause a size
779 // change itself.
780 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN));
781 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
782 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
783 ASSERT_TRUE(browser()->window()->IsFullscreen());
784
785 // The second parameter in DidToggleFullscreenModeForTab should be false,
786 // indicating that the fullscreen change will *not* cause a resize.
787 EXPECT_CALL(fullscreenObserver,
788 DidToggleFullscreenModeForTab(false, false));
789 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE));
790 testing::Mock::VerifyAndClearExpectations(&fullscreenObserver);
791
792 ASSERT_TRUE(InvokeEvent(TOGGLE_FULLSCREEN));
793 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
794 ASSERT_FALSE(browser()->window()->IsFullscreen());
795
796 // Go into tab fullscreen only. Exiting tab fullscreen should *not* cause
797 // a call to WasResized since the window will change size and we want the
798 // fullscreen change and size change to be in one Resize message.
799 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
800 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
801 ASSERT_TRUE(browser()->window()->IsFullscreen());
802
803 // The second parameter in DidToggleFullscreenModeForTab should now be true,
804 // indicating that the fullscreen change *will* cause a resize.
805 EXPECT_CALL(fullscreenObserver,
806 DidToggleFullscreenModeForTab(false, true));
807 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE));
808 ASSERT_FALSE(browser()->window()->IsFullscreen());
809 testing::Mock::VerifyAndClearExpectations(&fullscreenObserver);
810 }
811
752 // Tests that the state of a fullscreened, screen-captured tab is preserved if 812 // 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. 813 // the tab is detached from one Browser window and attached to another.
754 // 814 //
755 // See 'FullscreenWithinTab Note' in fullscreen_controller.h. 815 // See 'FullscreenWithinTab Note' in fullscreen_controller.h.
756 TEST_F(FullscreenControllerStateUnitTest, 816 TEST_F(FullscreenControllerStateUnitTest,
757 CapturedFullscreenedTabTransferredBetweenBrowserWindows) { 817 CapturedFullscreenedTabTransferredBetweenBrowserWindows) {
758 content::WebContentsDelegate* const wc_delegate = 818 content::WebContentsDelegate* const wc_delegate =
759 static_cast<content::WebContentsDelegate*>(browser()); 819 static_cast<content::WebContentsDelegate*>(browser());
760 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget()); 820 ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget());
761 821
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); 888 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab));
829 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); 889 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab));
830 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); 890 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending());
831 EXPECT_FALSE(second_browser->exclusive_access_manager() 891 EXPECT_FALSE(second_browser->exclusive_access_manager()
832 ->fullscreen_controller() 892 ->fullscreen_controller()
833 ->IsWindowFullscreenForTabOrPending()); 893 ->IsWindowFullscreenForTabOrPending());
834 894
835 // Required tear-down specific to this test. 895 // Required tear-down specific to this test.
836 second_browser->tab_strip_model()->CloseAllTabs(); 896 second_browser->tab_strip_model()->CloseAllTabs();
837 } 897 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/exclusive_access/fullscreen_controller.cc ('k') | components/guest_view/browser/guest_view_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698