Commit 6179300a authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Package-private |Tab.getWebContentsDelegateAndroid|

The only callsite outside chrome.browser.tab package now caches its
own TWCDA to avoid getting the reference through the Tab API. The
API can then be a package private method.

Moved TabTestUtils to target chrome_java_test_support. It now contains
a helper method for tests to use to get TWCDA.

Bug: 995903
Change-Id: I4614cc917710cd21f8be2e426dfcb29f0a4ba8da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881004Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712426}
parent 82295594
...@@ -1465,7 +1465,7 @@ public class Tab { ...@@ -1465,7 +1465,7 @@ public class Tab {
/** /**
* @return The current {@link TabWebContentsDelegateAndroid} instance. * @return The current {@link TabWebContentsDelegateAndroid} instance.
*/ */
public TabWebContentsDelegateAndroid getTabWebContentsDelegateAndroid() { TabWebContentsDelegateAndroid getTabWebContentsDelegateAndroid() {
return mWebContentsDelegate; return mWebContentsDelegate;
} }
......
...@@ -58,6 +58,7 @@ import org.chromium.chrome.browser.util.AndroidTaskUtils; ...@@ -58,6 +58,7 @@ import org.chromium.chrome.browser.util.AndroidTaskUtils;
import org.chromium.chrome.browser.util.ColorUtils; import org.chromium.chrome.browser.util.ColorUtils;
import org.chromium.chrome.browser.webapps.dependency_injection.WebappActivityComponent; import org.chromium.chrome.browser.webapps.dependency_injection.WebappActivityComponent;
import org.chromium.chrome.browser.webapps.dependency_injection.WebappActivityModule; import org.chromium.chrome.browser.webapps.dependency_injection.WebappActivityModule;
import org.chromium.components.embedder_support.delegate.WebContentsDelegateAndroid;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationHandle; import org.chromium.content_public.browser.NavigationHandle;
import org.chromium.content_public.browser.ScreenOrientationProvider; import org.chromium.content_public.browser.ScreenOrientationProvider;
...@@ -95,6 +96,8 @@ public class WebappActivity extends SingleTabActivity<WebappActivityComponent> { ...@@ -95,6 +96,8 @@ public class WebappActivity extends SingleTabActivity<WebappActivityComponent> {
private static Integer sOverrideCoreCountForTesting; private static Integer sOverrideCoreCountForTesting;
private WebappDelegateFactory mWebappDelegateFactory;
/** Initialization-on-demand holder. This exists for thread-safe lazy initialization. */ /** Initialization-on-demand holder. This exists for thread-safe lazy initialization. */
private static class Holder { private static class Holder {
// This static map is used to cache WebappInfo objects between their initial creation in // This static map is used to cache WebappInfo objects between their initial creation in
...@@ -500,6 +503,11 @@ public class WebappActivity extends SingleTabActivity<WebappActivityComponent> { ...@@ -500,6 +503,11 @@ public class WebappActivity extends SingleTabActivity<WebappActivityComponent> {
return mWebappInfo.scopeUrl(); return mWebappInfo.scopeUrl();
} }
WebContentsDelegateAndroid getWebContentsDelegate() {
assert mWebappDelegateFactory != null;
return mWebappDelegateFactory.getWebContentsDelegate();
}
public static void addWebappInfo(String id, WebappInfo info) { public static void addWebappInfo(String id, WebappInfo info) {
Holder.sWebappInfoMap.put(id, info); Holder.sWebappInfoMap.put(id, info);
} }
...@@ -777,7 +785,8 @@ public class WebappActivity extends SingleTabActivity<WebappActivityComponent> { ...@@ -777,7 +785,8 @@ public class WebappActivity extends SingleTabActivity<WebappActivityComponent> {
@Override @Override
protected TabDelegateFactory createTabDelegateFactory() { protected TabDelegateFactory createTabDelegateFactory() {
return new WebappDelegateFactory(this); mWebappDelegateFactory = new WebappDelegateFactory(this);
return mWebappDelegateFactory;
} }
@Override @Override
......
...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid; ...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.browser.tab_activity_glue.ActivityTabWebContentsDelegateAndroid; import org.chromium.chrome.browser.tab_activity_glue.ActivityTabWebContentsDelegateAndroid;
import org.chromium.chrome.browser.tab_activity_glue.TabDelegateFactoryImpl; import org.chromium.chrome.browser.tab_activity_glue.TabDelegateFactoryImpl;
import org.chromium.chrome.browser.util.IntentUtils; import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.components.embedder_support.delegate.WebContentsDelegateAndroid;
import org.chromium.webapk.lib.client.WebApkNavigationClient; import org.chromium.webapk.lib.client.WebApkNavigationClient;
/** /**
...@@ -97,6 +98,8 @@ public class WebappDelegateFactory extends TabDelegateFactoryImpl { ...@@ -97,6 +98,8 @@ public class WebappDelegateFactory extends TabDelegateFactoryImpl {
private final WebappActivity mActivity; private final WebappActivity mActivity;
private TabWebContentsDelegateAndroid mWebContentsDelegateAndroid;
public WebappDelegateFactory(WebappActivity activity) { public WebappDelegateFactory(WebappActivity activity) {
super(activity); super(activity);
mActivity = activity; mActivity = activity;
...@@ -110,7 +113,8 @@ public class WebappDelegateFactory extends TabDelegateFactoryImpl { ...@@ -110,7 +113,8 @@ public class WebappDelegateFactory extends TabDelegateFactoryImpl {
@Override @Override
public TabWebContentsDelegateAndroid createWebContentsDelegate(Tab tab) { public TabWebContentsDelegateAndroid createWebContentsDelegate(Tab tab) {
return new WebappWebContentsDelegateAndroid(mActivity, tab); mWebContentsDelegateAndroid = new WebappWebContentsDelegateAndroid(mActivity, tab);
return mWebContentsDelegateAndroid;
} }
@Override @Override
...@@ -120,4 +124,8 @@ public class WebappDelegateFactory extends TabDelegateFactoryImpl { ...@@ -120,4 +124,8 @@ public class WebappDelegateFactory extends TabDelegateFactoryImpl {
// Ensures browser controls hiding is delayed after activity start. // Ensures browser controls hiding is delayed after activity start.
mActivity.getFullscreenManager().getBrowserVisibilityDelegate()); mActivity.getFullscreenManager().getBrowserVisibilityDelegate());
} }
WebContentsDelegateAndroid getWebContentsDelegate() {
return mWebContentsDelegateAndroid;
}
} }
...@@ -87,7 +87,7 @@ public class WebappLauncherActivity extends Activity { ...@@ -87,7 +87,7 @@ public class WebappLauncherActivity extends Activity {
WeakReference<WebappActivity> webappActivity = WeakReference<WebappActivity> webappActivity =
WebappActivity.findWebappActivityWithTabId(tabId); WebappActivity.findWebappActivityWithTabId(tabId);
if (webappActivity == null || webappActivity.get() == null) return false; if (webappActivity == null || webappActivity.get() == null) return false;
webappActivity.get().getActivityTab().getTabWebContentsDelegateAndroid().activateContents(); webappActivity.get().getWebContentsDelegate().activateContents();
return true; return true;
} }
......
...@@ -2283,8 +2283,9 @@ public class CustomTabActivityTest { ...@@ -2283,8 +2283,9 @@ public class CustomTabActivityTest {
ApplicationStatus.registerStateListenerForAllActivities(listener); ApplicationStatus.registerStateListenerForAllActivities(listener);
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
cctActivity.getActivityTab().getTabWebContentsDelegateAndroid().openNewTab( TabTestUtils.getTabWebContentsDelegate(cctActivity.getActivityTab())
"about:blank", null, null, WindowOpenDisposition.OFF_THE_RECORD, false); .openNewTab(
"about:blank", null, null, WindowOpenDisposition.OFF_THE_RECORD, false);
}); });
mCctHiddenCallback.waitForCallback("CCT not hidden.", 0); mCctHiddenCallback.waitForCallback("CCT not hidden.", 0);
......
...@@ -41,6 +41,7 @@ import org.chromium.chrome.browser.omnibox.UrlBar; ...@@ -41,6 +41,7 @@ import org.chromium.chrome.browser.omnibox.UrlBar;
import org.chromium.chrome.browser.prerender.PrerenderTestHelper; import org.chromium.chrome.browser.prerender.PrerenderTestHelper;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabStateBrowserControlsVisibilityDelegate; import org.chromium.chrome.browser.tab.TabStateBrowserControlsVisibilityDelegate;
import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid; import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
...@@ -151,7 +152,7 @@ public class FullscreenManagerTest { ...@@ -151,7 +152,7 @@ public class FullscreenManagerTest {
mActivityTestRule.startMainActivityWithURL(LONG_HTML_TEST_PAGE); mActivityTestRule.startMainActivityWithURL(LONG_HTML_TEST_PAGE);
Tab tab = mActivityTestRule.getActivity().getActivityTab(); Tab tab = mActivityTestRule.getActivity().getActivityTab();
final TabWebContentsDelegateAndroid delegate = tab.getTabWebContentsDelegateAndroid(); final TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
FullscreenTestUtils.waitForFullscreenFlag(tab, false, mActivityTestRule.getActivity()); FullscreenTestUtils.waitForFullscreenFlag(tab, false, mActivityTestRule.getActivity());
FullscreenTestUtils.waitForPersistentFullscreen(delegate, false); FullscreenTestUtils.waitForPersistentFullscreen(delegate, false);
...@@ -173,7 +174,7 @@ public class FullscreenManagerTest { ...@@ -173,7 +174,7 @@ public class FullscreenManagerTest {
mActivityTestRule.startMainActivityWithURL(LONG_HTML_TEST_PAGE); mActivityTestRule.startMainActivityWithURL(LONG_HTML_TEST_PAGE);
final Tab tab = mActivityTestRule.getActivity().getActivityTab(); final Tab tab = mActivityTestRule.getActivity().getActivityTab();
final TabWebContentsDelegateAndroid delegate = tab.getTabWebContentsDelegateAndroid(); final TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
FullscreenTestUtils.waitForFullscreenFlag(tab, false, mActivityTestRule.getActivity()); FullscreenTestUtils.waitForFullscreenFlag(tab, false, mActivityTestRule.getActivity());
FullscreenTestUtils.waitForPersistentFullscreen(delegate, false); FullscreenTestUtils.waitForPersistentFullscreen(delegate, false);
...@@ -208,8 +209,7 @@ public class FullscreenManagerTest { ...@@ -208,8 +209,7 @@ public class FullscreenManagerTest {
Tab tab = mActivityTestRule.getActivity().getActivityTab(); Tab tab = mActivityTestRule.getActivity().getActivityTab();
View view = tab.getView(); View view = tab.getView();
final TabWebContentsDelegateAndroid delegate = final TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
tab.getTabWebContentsDelegateAndroid();
TouchCommon.singleClickView(view); TouchCommon.singleClickView(view);
FullscreenTestUtils.waitForPersistentFullscreen(delegate, true); FullscreenTestUtils.waitForPersistentFullscreen(delegate, true);
...@@ -443,8 +443,7 @@ public class FullscreenManagerTest { ...@@ -443,8 +443,7 @@ public class FullscreenManagerTest {
FullscreenManagerTestUtils.scrollBrowserControls(mActivityTestRule, false); FullscreenManagerTestUtils.scrollBrowserControls(mActivityTestRule, false);
Tab tab = mActivityTestRule.getActivity().getActivityTab(); Tab tab = mActivityTestRule.getActivity().getActivityTab();
final TabWebContentsDelegateAndroid delegate = final TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
tab.getTabWebContentsDelegateAndroid();
PostTask.runOrPostTask( PostTask.runOrPostTask(
UiThreadTaskTraits.DEFAULT, () -> { delegate.rendererUnresponsive(); }); UiThreadTaskTraits.DEFAULT, () -> { delegate.rendererUnresponsive(); });
FullscreenManagerTestUtils.waitForBrowserControlsPosition(mActivityTestRule, 0); FullscreenManagerTestUtils.waitForBrowserControlsPosition(mActivityTestRule, 0);
...@@ -536,7 +535,7 @@ public class FullscreenManagerTest { ...@@ -536,7 +535,7 @@ public class FullscreenManagerTest {
Tab tab = mActivityTestRule.getActivity().getActivityTab(); Tab tab = mActivityTestRule.getActivity().getActivityTab();
View view = tab.getView(); View view = tab.getView();
final TabWebContentsDelegateAndroid delegate = tab.getTabWebContentsDelegateAndroid(); final TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
TouchCommon.singleClickView(view); TouchCommon.singleClickView(view);
FullscreenTestUtils.waitForPersistentFullscreen(delegate, true); FullscreenTestUtils.waitForPersistentFullscreen(delegate, true);
......
...@@ -20,6 +20,7 @@ import org.chromium.chrome.browser.ChromeActivity; ...@@ -20,6 +20,7 @@ import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.browser.test.ScreenShooter; import org.chromium.chrome.browser.test.ScreenShooter;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
...@@ -78,7 +79,7 @@ public class InfoBarAppearanceTest { ...@@ -78,7 +79,7 @@ public class InfoBarAppearanceTest {
FramebustBlockInfoBar infoBar; FramebustBlockInfoBar infoBar;
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mTab.getTabWebContentsDelegateAndroid().showFramebustBlockInfobarForTesting(url1); TabTestUtils.getTabWebContentsDelegate(mTab).showFramebustBlockInfobarForTesting(url1);
}); });
infobars = mActivityTestRule.getInfoBarContainer().getInfoBarsForTesting(); infobars = mActivityTestRule.getInfoBarContainer().getInfoBarsForTesting();
assertEquals(1, infobars.size()); assertEquals(1, infobars.size());
...@@ -86,7 +87,7 @@ public class InfoBarAppearanceTest { ...@@ -86,7 +87,7 @@ public class InfoBarAppearanceTest {
assertEquals(url1, infoBar.getBlockedUrl()); assertEquals(url1, infoBar.getBlockedUrl());
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mTab.getTabWebContentsDelegateAndroid().showFramebustBlockInfobarForTesting(url2); TabTestUtils.getTabWebContentsDelegate(mTab).showFramebustBlockInfobarForTesting(url2);
}); });
infobars = mActivityTestRule.getInfoBarContainer().getInfoBarsForTesting(); infobars = mActivityTestRule.getInfoBarContainer().getInfoBarsForTesting();
assertEquals(1, infobars.size()); assertEquals(1, infobars.size());
...@@ -110,7 +111,7 @@ public class InfoBarAppearanceTest { ...@@ -110,7 +111,7 @@ public class InfoBarAppearanceTest {
mTab.addObserver(navigationWaiter); mTab.addObserver(navigationWaiter);
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mTab.getTabWebContentsDelegateAndroid().showFramebustBlockInfobarForTesting(url); TabTestUtils.getTabWebContentsDelegate(mTab).showFramebustBlockInfobarForTesting(url);
}); });
FramebustBlockInfoBar infoBar = FramebustBlockInfoBar infoBar =
(FramebustBlockInfoBar) mActivityTestRule.getInfoBarContainer() (FramebustBlockInfoBar) mActivityTestRule.getInfoBarContainer()
...@@ -134,7 +135,7 @@ public class InfoBarAppearanceTest { ...@@ -134,7 +135,7 @@ public class InfoBarAppearanceTest {
String url = "http://very.evil.biz"; String url = "http://very.evil.biz";
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mTab.getTabWebContentsDelegateAndroid().showFramebustBlockInfobarForTesting(url); TabTestUtils.getTabWebContentsDelegate(mTab).showFramebustBlockInfobarForTesting(url);
}); });
FramebustBlockInfoBar infoBar = FramebustBlockInfoBar infoBar =
(FramebustBlockInfoBar) mActivityTestRule.getInfoBarContainer() (FramebustBlockInfoBar) mActivityTestRule.getInfoBarContainer()
......
...@@ -32,6 +32,7 @@ import org.chromium.chrome.browser.datareduction.DataReductionPromoUtils; ...@@ -32,6 +32,7 @@ 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.browser.tab.TabTestUtils;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
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;
...@@ -116,6 +117,11 @@ public class InfoBarTest { ...@@ -116,6 +117,11 @@ public class InfoBarTest {
}); });
} }
private TabWebContentsDelegateAndroid getTabWebContentsDelegate() {
return TabTestUtils.getTabWebContentsDelegate(
mActivityTestRule.getActivity().getActivityTab());
}
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage(); mActivityTestRule.startMainActivityOnBlankPage();
...@@ -464,10 +470,7 @@ public class InfoBarTest { ...@@ -464,10 +470,7 @@ public class InfoBarTest {
// Fake an unresponsive renderer signal. // Fake an unresponsive renderer signal.
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HUNG_RENDERER_INFOBAR); CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HUNG_RENDERER_INFOBAR);
mActivityTestRule.getActivity() getTabWebContentsDelegate().rendererUnresponsive();
.getActivityTab()
.getTabWebContentsDelegateAndroid()
.rendererUnresponsive();
}); });
mListener.addInfoBarAnimationFinished("InfoBar not added"); mListener.addInfoBarAnimationFinished("InfoBar not added");
...@@ -478,12 +481,8 @@ public class InfoBarTest { ...@@ -478,12 +481,8 @@ public class InfoBarTest {
Assert.assertTrue(InfoBarUtil.hasSecondaryButton(infoBars.get(0))); Assert.assertTrue(InfoBarUtil.hasSecondaryButton(infoBars.get(0)));
// Fake a responsive renderer signal. // Fake a responsive renderer signal.
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT,
mActivityTestRule.getActivity() () -> { getTabWebContentsDelegate().rendererResponsive(); });
.getActivityTab()
.getTabWebContentsDelegateAndroid()
.rendererResponsive();
});
mListener.removeInfoBarAnimationFinished("InfoBar not removed."); mListener.removeInfoBarAnimationFinished("InfoBar not removed.");
Assert.assertTrue("Wrong infobar count", mActivityTestRule.getInfoBars().isEmpty()); Assert.assertTrue("Wrong infobar count", mActivityTestRule.getInfoBars().isEmpty());
} }
...@@ -501,10 +500,7 @@ public class InfoBarTest { ...@@ -501,10 +500,7 @@ public class InfoBarTest {
// Fake an unresponsive renderer signal. // Fake an unresponsive renderer signal.
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> { PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HUNG_RENDERER_INFOBAR); CommandLine.getInstance().appendSwitch(ChromeSwitches.ENABLE_HUNG_RENDERER_INFOBAR);
mActivityTestRule.getActivity() getTabWebContentsDelegate().rendererUnresponsive();
.getActivityTab()
.getTabWebContentsDelegateAndroid()
.rendererUnresponsive();
}); });
mListener.addInfoBarAnimationFinished("InfoBar not added"); mListener.addInfoBarAnimationFinished("InfoBar not added");
......
...@@ -27,6 +27,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity; ...@@ -27,6 +27,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.DeferredStartupHandler; import org.chromium.chrome.browser.DeferredStartupHandler;
import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider; import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider;
import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid; import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.browser.util.IntentUtils; import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
...@@ -215,7 +216,7 @@ public final class WebApkActivityTest { ...@@ -215,7 +216,7 @@ public final class WebApkActivityTest {
ChromeActivityTestRule.waitFor(mainClass); ChromeActivityTestRule.waitFor(mainClass);
TabWebContentsDelegateAndroid tabDelegate = TabWebContentsDelegateAndroid tabDelegate =
webApkActivity.getActivityTab().getTabWebContentsDelegateAndroid(); TabTestUtils.getTabWebContentsDelegate(webApkActivity.getActivityTab());
tabDelegate.activateContents(); tabDelegate.activateContents();
// WebApkActivity should have been brought back to the foreground. // WebApkActivity should have been brought back to the foreground.
......
...@@ -124,6 +124,14 @@ public class TabTestUtils { ...@@ -124,6 +124,14 @@ public class TabTestUtils {
* @return {@code true} if the current tab is a custom tab. * @return {@code true} if the current tab is a custom tab.
*/ */
public static boolean isCustomTab(Tab tab) { public static boolean isCustomTab(Tab tab) {
return tab.getTabWebContentsDelegateAndroid().isCustomTab(); return getTabWebContentsDelegate(tab).isCustomTab();
}
/**
* @param tab {@link Tab} object.
* @return {@link TabWebContentsDelegateAndroid} object for a given tab.
*/
public static TabWebContentsDelegateAndroid getTabWebContentsDelegate(Tab tab) {
return tab.getTabWebContentsDelegateAndroid();
} }
} }
...@@ -11,6 +11,7 @@ import android.view.WindowManager; ...@@ -11,6 +11,7 @@ import android.view.WindowManager;
import org.chromium.base.task.PostTask; import org.chromium.base.task.PostTask;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid; import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
...@@ -33,7 +34,7 @@ public class FullscreenTestUtils { ...@@ -33,7 +34,7 @@ public class FullscreenTestUtils {
*/ */
public static void togglePersistentFullscreenAndAssert(final Tab tab, final boolean state, public static void togglePersistentFullscreenAndAssert(final Tab tab, final boolean state,
Activity activity) { Activity activity) {
final TabWebContentsDelegateAndroid delegate = tab.getTabWebContentsDelegateAndroid(); final TabWebContentsDelegateAndroid delegate = TabTestUtils.getTabWebContentsDelegate(tab);
FullscreenTestUtils.togglePersistentFullscreen(delegate, state); FullscreenTestUtils.togglePersistentFullscreen(delegate, state);
FullscreenTestUtils.waitForFullscreenFlag(tab, state, activity); FullscreenTestUtils.waitForFullscreenFlag(tab, state, activity);
FullscreenTestUtils.waitForPersistentFullscreen(delegate, state); FullscreenTestUtils.waitForPersistentFullscreen(delegate, state);
......
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