Commit d9776b2d authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Private-package Tab.swapWebContents

The method is not used outside the chrome.browser.tab package.
Did a little refactoring in tests to make it private-package.

Bug: 995903
Change-Id: I65dcd3d5c0f5e773f5b0f49135f3c6a7ea19c533
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1870155
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708029}
parent 06654e11
...@@ -1517,9 +1517,7 @@ public class Tab { ...@@ -1517,9 +1517,7 @@ public class Tab {
} }
/** This is currently called when committing a pre-rendered page. */ /** This is currently called when committing a pre-rendered page. */
@VisibleForTesting void swapWebContents(WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
public void swapWebContents(
WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
int originalWidth = 0; int originalWidth = 0;
int originalHeight = 0; int originalHeight = 0;
if (mContentView != null && mWebContents != null) { if (mContentView != null && mWebContents != null) {
......
...@@ -31,6 +31,7 @@ import org.chromium.chrome.browser.WebContentsFactory; ...@@ -31,6 +31,7 @@ import org.chromium.chrome.browser.WebContentsFactory;
import org.chromium.chrome.browser.datareduction.DataReductionPromoUtils; import org.chromium.chrome.browser.datareduction.DataReductionPromoUtils;
import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.tab.SadTab; import org.chromium.chrome.browser.tab.SadTab;
import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.InfoBarTestAnimationListener; import org.chromium.chrome.test.util.InfoBarTestAnimationListener;
...@@ -547,8 +548,8 @@ public class InfoBarTest { ...@@ -547,8 +548,8 @@ public class InfoBarTest {
mActivityTestRule.getInfoBarContainer().addAnimationListener(removeListener); mActivityTestRule.getInfoBarContainer().addAnimationListener(removeListener);
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
WebContents newContents = WebContentsFactory.createWebContents(false, false); WebContents newContents = WebContentsFactory.createWebContents(false, false);
mActivityTestRule.getActivity().getActivityTab().swapWebContents( TabTestUtils.swapWebContents(
newContents, false, false); mActivityTestRule.getActivity().getActivityTab(), newContents, false, false);
}); });
mActivityTestRule.loadUrl(HELLO_WORLD_URL); mActivityTestRule.loadUrl(HELLO_WORLD_URL);
removeListener.removeInfoBarAnimationFinished("InfoBar not removed."); removeListener.removeInfoBarAnimationFinished("InfoBar not removed.");
......
...@@ -8,6 +8,7 @@ import android.view.View; ...@@ -8,6 +8,7 @@ import android.view.View;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
import org.chromium.base.ObserverList.RewindableIterator; import org.chromium.base.ObserverList.RewindableIterator;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
/** /**
...@@ -98,4 +99,16 @@ public class TabTestUtils { ...@@ -98,4 +99,16 @@ public class TabTestUtils {
public static void restoreFieldsFromState(Tab tab, TabState state) { public static void restoreFieldsFromState(Tab tab, TabState state) {
tab.restoreFieldsFromState(state); tab.restoreFieldsFromState(state);
} }
/**
* Swap {@link WebContents} object being used in a tab.
* @param tab {@link Tab} object.
* @param webContents {@link WebContents} to swap in.
* @param didStartLoad Whether the content started loading.
* @param didFinishLoad Whether the content finished loading.
*/
public static void swapWebContents(
Tab tab, WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
tab.swapWebContents(webContents, didStartLoad, didFinishLoad);
}
} }
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