Commit b71e98cd authored by peconn's avatar peconn Committed by Commit bot

Move fullscreen web content to a new Activity.

Introduce the FullscreenMediaActivity and move Tabs to it when entering
fullscreen and away from it when leaving fullscreen.

BUG=709042

Review-Url: https://codereview.chromium.org/2807663002
Cr-Commit-Position: refs/heads/master@{#467705}
parent e851ad47
...@@ -370,6 +370,12 @@ by a child template that "extends" this file. ...@@ -370,6 +370,12 @@ by a child template that "extends" this file.
android:exported="false" android:exported="false"
{{ self.chrome_activity_common() }}> {{ self.chrome_activity_common() }}>
</activity> </activity>
<activity android:name="org.chromium.chrome.browser.FullscreenWebContentsActivity"
android:theme="@style/MainTheme"
android:exported="false"
{{ self.chrome_activity_common() }}
{{ self.supports_video_persistence() }} >
</activity>
<activity android:name="org.chromium.chrome.browser.sync.ui.PassphraseActivity" <activity android:name="org.chromium.chrome.browser.sync.ui.PassphraseActivity"
android:theme="@style/MainTheme" android:theme="@style/MainTheme"
......
...@@ -2160,4 +2160,12 @@ public abstract class ChromeActivity extends AsyncInitializationActivity ...@@ -2160,4 +2160,12 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
* in this call, including showing 2D UI that was hidden. * in this call, including showing 2D UI that was hidden.
*/ */
public void onExitVr() {} public void onExitVr() {}
/**
* Whether this Activity supports moving a {@link Tab} to the
* {@link FullscreenWebContentsActivity} when it enters fullscreen.
*/
public boolean supportsFullscreenActivity() {
return false;
}
} }
...@@ -2038,4 +2038,9 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode ...@@ -2038,4 +2038,9 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
} }
return false; return false;
} }
@Override
public boolean supportsFullscreenActivity() {
return true;
}
} }
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.provider.Browser;
import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
import org.chromium.chrome.browser.tabmodel.TabReparentingParams;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.webapps.FullScreenActivity;
/**
* An Activity used to display fullscreen WebContents.
*/
public class FullscreenWebContentsActivity extends FullScreenActivity {
private static final String TAG = "FullWebConActivity";
@Override
protected Tab createTab() {
assert getIntent().hasExtra(IntentHandler.EXTRA_TAB_ID);
int tabId = IntentUtils.safeGetIntExtra(
getIntent(), IntentHandler.EXTRA_TAB_ID, Tab.INVALID_TAB_ID);
TabReparentingParams params = (TabReparentingParams) AsyncTabParamsManager.remove(tabId);
Tab tab = params.getTabToReparent();
tab.attachAndFinishReparenting(this, createTabDelegateFactory(), params);
return tab;
}
@Override
protected int getControlContainerLayoutId() {
// TODO(peconn): Determine if there's something more suitable to use here.
return R.layout.webapp_control_container;
}
@Override
protected ChromeFullscreenManager createFullscreenManager() {
// Create a Fullscreen manager that won't change the Tab's fullscreen state when the
// Activity ends - we handle leaving fullscreen ourselves.
return new ChromeFullscreenManager(this, false, false);
}
@Override
public boolean supportsFullscreenActivity() {
return true;
}
public static void toggleFullscreenMode(final boolean enableFullscreen, final Tab tab) {
if (tab.getFullscreenManager() == null) {
Log.w(TAG, "Cannot toggle fullscreen, manager is null.");
return;
}
if (tab.getFullscreenManager().getTab() == tab) {
tab.getFullscreenManager().setTab(null);
}
Runnable setFullscreen = new Runnable() {
@Override
public void run() {
// The Tab's FullscreenManager changes when it is moved.
tab.getFullscreenManager().setTab(tab);
tab.toggleFullscreenMode(enableFullscreen);
}
};
Intent intent = new Intent();
Activity activity = tab.getActivity();
if (enableFullscreen) {
// Send to the FullscreenWebContentsActivity.
intent.setClass(tab.getActivity(), FullscreenWebContentsActivity.class);
intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// In multiwindow mode we want both activities to be able to launch independent
// FullscreenWebContentsActivity's.
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
} else {
// Send back to the Activity it came from.
ComponentName parent = IntentUtils.safeGetParcelableExtra(
activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
if (parent != null) {
intent.setComponent(parent);
} else {
Log.d(TAG, "Cannot return fullscreen tab to parent Activity.");
// Tab.detachAndStartReparenting will give the intent a default component if it
// has none.
}
// TODO(peconn): Deal with tricky multiwindow scenarios.
}
intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
tab.detachAndStartReparenting(intent, null, setFullscreen);
}
}
...@@ -156,6 +156,8 @@ public class ReaderModeManager extends TabModelSelectorTabObserver ...@@ -156,6 +156,8 @@ public class ReaderModeManager extends TabModelSelectorTabObserver
@Override @Override
public void onShown(Tab shownTab) { public void onShown(Tab shownTab) {
if (mTabModelSelector == null) return;
int shownTabId = shownTab.getId(); int shownTabId = shownTab.getId();
Tab previousTab = mTabModelSelector.getTabById(mTabId); Tab previousTab = mTabModelSelector.getTabById(mTabId);
mTabId = shownTabId; mTabId = shownTabId;
......
...@@ -49,6 +49,7 @@ public class ChromeFullscreenManager ...@@ -49,6 +49,7 @@ public class ChromeFullscreenManager
private final Window mWindow; private final Window mWindow;
private final BrowserStateBrowserControlsVisibilityDelegate mBrowserVisibilityDelegate; private final BrowserStateBrowserControlsVisibilityDelegate mBrowserVisibilityDelegate;
private final boolean mIsBottomControls; private final boolean mIsBottomControls;
private final boolean mExitFullscreenOnStop;
private ControlContainer mControlContainer; private ControlContainer mControlContainer;
private int mTopControlContainerHeight; private int mTopControlContainerHeight;
...@@ -70,7 +71,7 @@ public class ChromeFullscreenManager ...@@ -70,7 +71,7 @@ public class ChromeFullscreenManager
private boolean mBrowserControlsPermanentlyHidden; private boolean mBrowserControlsPermanentlyHidden;
private boolean mBrowserControlsAndroidViewHidden; private boolean mBrowserControlsAndroidViewHidden;
private final ArrayList<FullscreenListener> mListeners = new ArrayList<FullscreenListener>(); private final ArrayList<FullscreenListener> mListeners = new ArrayList<>();
/** /**
* A listener that gets notified of changes to the fullscreen state. * A listener that gets notified of changes to the fullscreen state.
...@@ -123,11 +124,24 @@ public class ChromeFullscreenManager ...@@ -123,11 +124,24 @@ public class ChromeFullscreenManager
* @param isBottomControls Whether or not the browser controls are at the bottom of the screen. * @param isBottomControls Whether or not the browser controls are at the bottom of the screen.
*/ */
public ChromeFullscreenManager(Activity activity, boolean isBottomControls) { public ChromeFullscreenManager(Activity activity, boolean isBottomControls) {
this(activity, isBottomControls, true);
}
/**
* Creates an instance of the fullscreen mode manager.
* @param activity The activity that supports fullscreen.
* @param isBottomControls Whether or not the browser controls are at the bottom of the screen.
* @param exitFullscreenOnStop Whether fullscreen mode should exit on stop - should be
* true for Activities that are not always fullscreen.
*/
public ChromeFullscreenManager(
Activity activity, boolean isBottomControls, boolean exitFullscreenOnStop) {
super(activity.getWindow()); super(activity.getWindow());
mActivity = activity; mActivity = activity;
mWindow = activity.getWindow(); mWindow = activity.getWindow();
mIsBottomControls = isBottomControls; mIsBottomControls = isBottomControls;
mExitFullscreenOnStop = exitFullscreenOnStop;
mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDelegate( mBrowserVisibilityDelegate = new BrowserStateBrowserControlsVisibilityDelegate(
new Runnable() { new Runnable() {
@Override @Override
...@@ -228,7 +242,7 @@ public class ChromeFullscreenManager ...@@ -228,7 +242,7 @@ public class ChromeFullscreenManager
@Override @Override
public void onActivityStateChange(Activity activity, int newState) { public void onActivityStateChange(Activity activity, int newState) {
if (newState == ActivityState.STOPPED) { if (newState == ActivityState.STOPPED && mExitFullscreenOnStop) {
// Exit fullscreen in onStop to ensure the system UI flags are set correctly when // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
// showing again (on JB MR2+ builds, the omnibox would be covered by the // showing again (on JB MR2+ builds, the omnibox would be covered by the
// notification bar when this was done in onStart()). // notification bar when this was done in onStart()).
......
...@@ -2438,7 +2438,7 @@ public class Tab ...@@ -2438,7 +2438,7 @@ public class Tab
/** /**
* @return An instance of a {@link FullscreenManager}. * @return An instance of a {@link FullscreenManager}.
*/ */
protected FullscreenManager getFullscreenManager() { public FullscreenManager getFullscreenManager() {
return mFullscreenManager; return mFullscreenManager;
} }
......
...@@ -24,6 +24,8 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -24,6 +24,8 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.blink_public.platform.WebDisplayMode; import org.chromium.blink_public.platform.WebDisplayMode;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.AppHooks; import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.FullscreenWebContentsActivity;
import org.chromium.chrome.browser.RepostFormWarningDialog; import org.chromium.chrome.browser.RepostFormWarningDialog;
import org.chromium.chrome.browser.document.DocumentUtils; import org.chromium.chrome.browser.document.DocumentUtils;
import org.chromium.chrome.browser.document.DocumentWebContentsDelegate; import org.chromium.chrome.browser.document.DocumentWebContentsDelegate;
...@@ -215,8 +217,14 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid { ...@@ -215,8 +217,14 @@ public class TabWebContentsDelegateAndroid extends WebContentsDelegateAndroid {
@Override @Override
public void toggleFullscreenModeForTab(boolean enableFullscreen) { public void toggleFullscreenModeForTab(boolean enableFullscreen) {
if (!VideoPersister.getInstance().shouldDelayFullscreenModeChange(mTab, enableFullscreen)) { if (ChromeFeatureList.isEnabled(ChromeFeatureList.FULLSCREEN_ACTIVITY)
mTab.toggleFullscreenMode(enableFullscreen); && mTab.getActivity().supportsFullscreenActivity()) {
FullscreenWebContentsActivity.toggleFullscreenMode(enableFullscreen, mTab);
} else {
if (!VideoPersister.getInstance().shouldDelayFullscreenModeChange(
mTab, enableFullscreen)) {
mTab.toggleFullscreenMode(enableFullscreen);
}
} }
} }
......
...@@ -18,7 +18,7 @@ import org.chromium.chrome.browser.tab.Tab; ...@@ -18,7 +18,7 @@ import org.chromium.chrome.browser.tab.Tab;
*/ */
public class SingleTabModel implements TabModel { public class SingleTabModel implements TabModel {
private final Activity mActivity; private final Activity mActivity;
private final ObserverList<TabModelObserver> mObservers = new ObserverList<TabModelObserver>(); private final ObserverList<TabModelObserver> mObservers = new ObserverList<>();
private Tab mTab; private Tab mTab;
private boolean mIsIncognito; private boolean mIsIncognito;
...@@ -173,7 +173,8 @@ public class SingleTabModel implements TabModel { ...@@ -173,7 +173,8 @@ public class SingleTabModel implements TabModel {
@Override @Override
public void removeTab(Tab tab) { public void removeTab(Tab tab) {
assert false; mTab = null;
for (TabModelObserver obs : mObservers) obs.tabRemoved(tab);
} }
@Override @Override
......
...@@ -46,8 +46,6 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -46,8 +46,6 @@ public abstract class FullScreenActivity extends ChromeActivity {
protected static final String BUNDLE_TAB_URL = "tabUrl"; protected static final String BUNDLE_TAB_URL = "tabUrl";
private static final String TAG = "FullScreenActivity"; private static final String TAG = "FullScreenActivity";
private Tab mTab;
private WebContents mWebContents; private WebContents mWebContents;
@SuppressWarnings("unused") // Reference needed to prevent GC. @SuppressWarnings("unused") // Reference needed to prevent GC.
private WebContentsObserver mWebContentsObserver; private WebContentsObserver mWebContentsObserver;
...@@ -84,10 +82,10 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -84,10 +82,10 @@ public abstract class FullScreenActivity extends ChromeActivity {
public void initializeState() { public void initializeState() {
super.initializeState(); super.initializeState();
mTab = createTab(); Tab tab = createTab();
getTabModelSelector().setTab(tab);
handleTabContentChanged(); handleTabContentChanged();
getTabModelSelector().setTab(mTab); tab.show(TabSelectionType.FROM_NEW);
mTab.show(TabSelectionType.FROM_NEW);
} }
@Override @Override
...@@ -109,18 +107,13 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -109,18 +107,13 @@ public abstract class FullScreenActivity extends ChromeActivity {
return (SingleTabModelSelector) super.getTabModelSelector(); return (SingleTabModelSelector) super.getTabModelSelector();
} }
@Override
public final Tab getActivityTab() {
return mTab;
}
/** /**
* Creates the {@link Tab} used by the FullScreenActivity. * Creates the {@link Tab} used by the FullScreenActivity.
* If the {@code savedInstanceState} exists, then the user did not intentionally close the app * If the {@code savedInstanceState} exists, then the user did not intentionally close the app
* by swiping it away in the recent tasks list. In that case, we try to restore the tab from * by swiping it away in the recent tasks list. In that case, we try to restore the tab from
* disk. * disk.
*/ */
private Tab createTab() { protected Tab createTab() {
Tab tab = null; Tab tab = null;
boolean unfreeze = false; boolean unfreeze = false;
...@@ -149,7 +142,7 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -149,7 +142,7 @@ public abstract class FullScreenActivity extends ChromeActivity {
tab.addObserver(new EmptyTabObserver() { tab.addObserver(new EmptyTabObserver() {
@Override @Override
public void onContentChanged(Tab tab) { public void onContentChanged(Tab tab) {
assert tab == mTab; assert tab == getActivityTab();
handleTabContentChanged(); handleTabContentChanged();
} }
}); });
...@@ -157,9 +150,10 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -157,9 +150,10 @@ public abstract class FullScreenActivity extends ChromeActivity {
} }
private void handleTabContentChanged() { private void handleTabContentChanged() {
assert mTab != null; final Tab tab = getActivityTab();
assert tab != null;
WebContents webContents = mTab.getWebContents(); WebContents webContents = tab.getWebContents();
if (mWebContents == webContents) return; if (mWebContents == webContents) return;
// Clean up any old references to the previous WebContents. // Clean up any old references to the previous WebContents.
...@@ -181,8 +175,7 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -181,8 +175,7 @@ public abstract class FullScreenActivity extends ChromeActivity {
if (hasCommitted && isInMainFrame) { if (hasCommitted && isInMainFrame) {
// Notify the renderer to permanently hide the top controls since they do // Notify the renderer to permanently hide the top controls since they do
// not apply to fullscreen content views. // not apply to fullscreen content views.
mTab.updateBrowserControlsState( tab.updateBrowserControlsState(tab.getBrowserControlsStateConstraints(), true);
mTab.getBrowserControlsStateConstraints(), true);
} }
} }
}; };
...@@ -204,12 +197,13 @@ public abstract class FullScreenActivity extends ChromeActivity { ...@@ -204,12 +197,13 @@ public abstract class FullScreenActivity extends ChromeActivity {
@Override @Override
protected boolean handleBackPressed() { protected boolean handleBackPressed() {
if (mTab == null) return false; Tab tab = getActivityTab();
if (tab == null) return false;
if (exitFullscreenIfShowing()) return true; if (exitFullscreenIfShowing()) return true;
if (mTab.canGoBack()) { if (tab.canGoBack()) {
mTab.goBack(); tab.goBack();
return true; return true;
} }
return false; return false;
......
...@@ -37,6 +37,7 @@ chrome_java_sources = [ ...@@ -37,6 +37,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/DevToolsServer.java", "java/src/org/chromium/chrome/browser/DevToolsServer.java",
"java/src/org/chromium/chrome/browser/FileProviderHelper.java", "java/src/org/chromium/chrome/browser/FileProviderHelper.java",
"java/src/org/chromium/chrome/browser/FrozenNativePage.java", "java/src/org/chromium/chrome/browser/FrozenNativePage.java",
"java/src/org/chromium/chrome/browser/FullscreenWebContentsActivity.java",
"java/src/org/chromium/chrome/browser/InsetObserverView.java", "java/src/org/chromium/chrome/browser/InsetObserverView.java",
"java/src/org/chromium/chrome/browser/IntentHandler.java", "java/src/org/chromium/chrome/browser/IntentHandler.java",
"java/src/org/chromium/chrome/browser/IntentHelper.java", "java/src/org/chromium/chrome/browser/IntentHelper.java",
...@@ -1277,6 +1278,7 @@ chrome_test_java_sources = [ ...@@ -1277,6 +1278,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/CopylessPasteTest.java", "javatests/src/org/chromium/chrome/browser/CopylessPasteTest.java",
"javatests/src/org/chromium/chrome/browser/CrashTest.java", "javatests/src/org/chromium/chrome/browser/CrashTest.java",
"javatests/src/org/chromium/chrome/browser/FocusedEditableTextFieldZoomTest.java", "javatests/src/org/chromium/chrome/browser/FocusedEditableTextFieldZoomTest.java",
"javatests/src/org/chromium/chrome/browser/FullscreenWebContentsActivityTest.java",
"javatests/src/org/chromium/chrome/browser/HistoryUITest.java", "javatests/src/org/chromium/chrome/browser/HistoryUITest.java",
"javatests/src/org/chromium/chrome/browser/IntentHandlerTest.java", "javatests/src/org/chromium/chrome/browser/IntentHandlerTest.java",
"javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java", "javatests/src/org/chromium/chrome/browser/ItemChooserDialogTest.java",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser;
import android.app.Activity;
import android.content.Intent;
import android.provider.Browser;
import android.support.test.filters.MediumTest;
import android.support.test.rule.UiThreadTestRule;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.common.ContentSwitches;
import org.chromium.content_public.browser.WebContents;
import org.chromium.net.test.EmbeddedTestServer;
/**
* Tests for FullscreenWebContentsActivity.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ContentSwitches.DISABLE_GESTURE_REQUIREMENT_FOR_MEDIA_PLAYBACK,
"enable-features=" + ChromeFeatureList.FULLSCREEN_ACTIVITY})
public class FullscreenWebContentsActivityTest {
private static final String TEST_PATH = "/content/test/data/media/video-player.html";
private static final String VIDEO_ID = "video";
@Rule
public UiThreadTestRule mUiThreadTestRule = new UiThreadTestRule();
@Rule
public ChromeActivityTestRule<ChromeTabbedActivity> mActivityTestRule =
new ChromeActivityTestRule<>(ChromeTabbedActivity.class);
private EmbeddedTestServer mTestServer;
private ChromeTabbedActivity mActivity;
@Before
public void setUp() throws InterruptedException {
mTestServer = EmbeddedTestServer.createAndStartServer(
mActivityTestRule.getInstrumentation().getContext());
mActivityTestRule.startMainActivityWithURL(mTestServer.getURL(TEST_PATH));
mActivity = mActivityTestRule.getActivity();
}
@After
public void tearDown() throws Exception {
mTestServer.stopAndDestroyServer();
}
/**
* Manually moves a Tab from a ChromeTabbedActivity to a FullscreenWebContentsActivity and back.
*/
@Test
@MediumTest
public void testTransfer() throws Throwable {
final Tab tab = mActivityTestRule.getActivity().getActivityTab();
moveTabToActivity(mActivity, tab, FullscreenWebContentsActivity.class);
waitForActivity(FullscreenWebContentsActivity.class);
final FullscreenWebContentsActivity fullscreenActivity =
(FullscreenWebContentsActivity) ApplicationStatus.getLastTrackedFocusedActivity();
Assert.assertEquals(tab.getId(), fullscreenActivity.getActivityTab().getId());
moveTabToActivity(fullscreenActivity, tab, ChromeTabbedActivity.class);
waitForActivity(ChromeTabbedActivity.class);
}
/**
* Manually moves the Tab to an Activity.
*/
private void moveTabToActivity(final Activity fromActivity, final Tab tab,
final Class<? extends ChromeActivity> targetClass) throws Throwable {
mUiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(fromActivity, targetClass);
intent.putExtra(
IntentHandler.EXTRA_PARENT_COMPONENT, fromActivity.getComponentName());
intent.putExtra(Browser.EXTRA_APPLICATION_ID, fromActivity.getPackageName());
if (targetClass == FullscreenWebContentsActivity.class) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
tab.detachAndStartReparenting(intent, null, null);
}
});
}
/**
* Waits for an Activity of the given class to be started and for it to have a Tab.
*/
private static void waitForActivity(final Class<? extends ChromeActivity> activityClass) {
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
Activity lastActivity = ApplicationStatus.getLastTrackedFocusedActivity();
if (lastActivity.getClass() != activityClass) return false;
return ((ChromeActivity) lastActivity).getActivityTab() != null;
}
});
}
/**
* Toggles fullscreen to check FullscreenWebContentsActivity has been started.
*/
@Test
@MediumTest
public void testFullscreen() throws Throwable {
enterFullscreen();
// TODO(peconn): Test leaving fullscreen by pressing Back
// TODO(peconn): Test leaving fullscreen by DOMUtils.exitFullscreen(WebContents)
}
/**
* Clicks on the fullscreen button in the webpage and waits for the
* FullscreenWebContentsActivity to be started.
*/
private void enterFullscreen() throws Throwable {
// Start playback to guarantee it's properly loaded.
WebContents webContents = mActivity.getCurrentContentViewCore().getWebContents();
Assert.assertTrue(DOMUtils.isMediaPaused(webContents, VIDEO_ID));
DOMUtils.playMedia(webContents, VIDEO_ID);
DOMUtils.waitForMediaPlay(webContents, VIDEO_ID);
// Trigger requestFullscreen() via a click on a button.
Assert.assertTrue(DOMUtils.clickNode(mActivity.getCurrentContentViewCore(), "fullscreen"));
waitForActivity(FullscreenWebContentsActivity.class);
}
/**
* Tests that no flags change on the ChromeTabbedActivity when going fullscreen.
*/
@Test
@MediumTest
public void testFullscreenFlags() throws Throwable {
int old = mActivity.getTabsView().getSystemUiVisibility();
enterFullscreen();
Assert.assertEquals(old, mActivity.getTabsView().getSystemUiVisibility());
// TODO(peconn): Test again after leaving fullscreen.
}
}
...@@ -143,7 +143,7 @@ const base::Feature kDownloadAutoResumptionThrottling{ ...@@ -143,7 +143,7 @@ const base::Feature kDownloadAutoResumptionThrottling{
"DownloadAutoResumptionThrottling", base::FEATURE_ENABLED_BY_DEFAULT}; "DownloadAutoResumptionThrottling", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kFullscreenActivity{"FullscreenActivity", const base::Feature kFullscreenActivity{"FullscreenActivity",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kImportantSitesInCBD{"ImportantSitesInCBD", const base::Feature kImportantSitesInCBD{"ImportantSitesInCBD",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment