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

Unified Diff: chrome/browser/ui/fullscreen/fullscreen_controller_state_unittest.cc

Issue 158253002: Tabs being screen-captured will fullscreen within their tab contents area. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/fullscreen/fullscreen_controller_state_unittest.cc
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_state_unittest.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_state_unittest.cc
index 0f2d94d93fe884175c88a17f4d0f5b185b267de6..0d3ef6c5f74abfb67bcea299773af85ad672867b 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller_state_unittest.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller_state_unittest.cc
@@ -2,14 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
#include "content/public/common/url_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -473,3 +476,98 @@ TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaReplacingTab) {
ChangeWindowFullscreenState();
EXPECT_FALSE(browser()->window()->IsFullscreen());
}
+
+TEST_F(FullscreenControllerStateUnitTest, OneCapturedFullscreenedTab) {
scheib 2014/02/12 01:41:16 Please comment the intent of each test and referen
miu 2014/02/12 08:25:19 Done.
+ CommandLine::ForCurrentProcess()->
+ AppendSwitch(switches::kEmbedFlashFullscreen);
+ content::WebContentsDelegate* const wc_delegate =
+ static_cast<content::WebContentsDelegate*>(browser());
+ ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget());
+
+ AddTab(browser(), GURL(content::kAboutBlankURL));
+ AddTab(browser(), GURL(content::kAboutBlankURL));
+ content::WebContents* const first_tab =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ content::WebContents* const second_tab =
+ browser()->tab_strip_model()->GetWebContentsAt(1);
+
+ // Activate the first tab and tell its WebContents it is being captured.
+ browser()->tab_strip_model()->ActivateTabAt(0, true);
+ const gfx::Size kCaptureSize(1280, 720);
+ first_tab->IncrementCapturerCount(kCaptureSize);
+ ASSERT_FALSE(browser()->window()->IsFullscreen());
+ ASSERT_FALSE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ ASSERT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
scheib 2014/02/12 01:41:16 Add assert for "IsFullscreenForTabOrPending()"?
miu 2014/02/12 08:25:19 Done, and throughout all these new tests.
+
+ // Enter tab fullscreen. Since the tab is being captured, the browser window
+ // should not expand to fill the screen.
+ ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+
+ // Switch to the other tab. Check that the first tab was resized to the
+ // WebContents' preferred size.
+ browser()->tab_strip_model()->ActivateTabAt(1, true);
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+ EXPECT_EQ(kCaptureSize, first_tab->GetView()->GetViewBounds().size());
+
+ // Switch back to the first tab and exit fullscreen.
scheib 2014/02/12 01:41:16 What size should it be now?
miu 2014/02/12 08:25:19 It can't be determined in these tests since we've
+ browser()->tab_strip_model()->ActivateTabAt(0, true);
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+ ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE));
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+}
+
+TEST_F(FullscreenControllerStateUnitTest, TwoFullscreenedTabsOneCaptured) {
+ CommandLine::ForCurrentProcess()->
+ AppendSwitch(switches::kEmbedFlashFullscreen);
+ content::WebContentsDelegate* const wc_delegate =
+ static_cast<content::WebContentsDelegate*>(browser());
+ ASSERT_TRUE(wc_delegate->EmbedsFullscreenWidget());
+
+ AddTab(browser(), GURL(content::kAboutBlankURL));
+ AddTab(browser(), GURL(content::kAboutBlankURL));
+ content::WebContents* const first_tab =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ content::WebContents* const second_tab =
+ browser()->tab_strip_model()->GetWebContentsAt(1);
+
+ // Start capturing the first tab, fullscreen it, then switch to the second tab
+ // and fullscreen that. The second tab will cause the browser window to
+ // expand to fill the screen.
+ browser()->tab_strip_model()->ActivateTabAt(0, true);
+ const gfx::Size kCaptureSize(1280, 720);
+ first_tab->IncrementCapturerCount(kCaptureSize);
+ ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+ browser()->tab_strip_model()->ActivateTabAt(1, true);
+ ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
+ ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
+ EXPECT_TRUE(browser()->window()->IsFullscreen());
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+
+ // Now exit fullscreen while still in the second tab. The browser window
+ // should no longer be fullscreened.
+ ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE));
+ ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_TRUE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+
+ // Finally, exit fullscreen on the captured tab.
+ browser()->tab_strip_model()->ActivateTabAt(0, true);
+ ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_FALSE));
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(first_tab));
+ EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(second_tab));
+}
scheib 2014/02/12 01:41:16 Some other test scenarios: - Tab already fullscree
miu 2014/02/12 08:25:19 Done, except for the first scenario because there'

Powered by Google App Engine
This is Rietveld 408576698