Commit 4612d61c authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[WebLayer] Fix browsertests on Android

Due to some recent changes in how the fragment works, the browser tests
were crashing on Android.

Change-Id: I5302c63f1f02eccdac3d5e95fe711a9d24048cb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863592Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706106}
parent 02b3a745
......@@ -20,7 +20,7 @@ public abstract class NativeBrowserTestApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ContextUtils.initApplicationContext(this);
initApplicationContext();
if (isMainProcess() || isBrowserProcess()) {
// We need secondary dex in order to run EmbeddedTestServer in a
// privileged process.
......@@ -32,6 +32,14 @@ public abstract class NativeBrowserTestApplication extends Application {
}
}
/**
* Initializes the application context. Subclasses may want to override this if the
* application context is initialized elsewhere.
*/
protected void initApplicationContext() {
ContextUtils.initApplicationContext(this);
}
protected static boolean isMainProcess() {
// The test harness runs in the main process, and browser in :test_process.
return !ContextUtils.getProcessName().contains(":");
......
......@@ -21,7 +21,6 @@ import org.chromium.weblayer.BrowserController;
import org.chromium.weblayer.BrowserFragment;
import org.chromium.weblayer.BrowserFragmentController;
import org.chromium.weblayer.BrowserObserver;
import org.chromium.weblayer.ListenableFuture;
import org.chromium.weblayer.Profile;
import org.chromium.weblayer.WebLayer;
......@@ -49,8 +48,7 @@ public class WebLayerBrowserTestsActivity extends NativeBrowserTestActivity {
});
try {
ListenableFuture<WebLayer> future = WebLayer.create(getApplication());
future.addCallback((WebLayer webLayer) -> {
WebLayer.create(getApplication()).addCallback((WebLayer webLayer) -> {
mWebLayer = webLayer;
createShell();
});
......@@ -80,13 +78,13 @@ public class WebLayerBrowserTestsActivity extends NativeBrowserTestActivity {
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
BrowserFragment fragment = WebLayer.createBrowserFragment(null);
mBrowserFragmentController = fragment.getController();
mProfile = mBrowserFragmentController.getProfile();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(viewId, fragment);
transaction.commit();
transaction.commitNow();
mBrowserFragmentController = fragment.getController();
mProfile = mBrowserFragmentController.getProfile();
mBrowserFragmentController.setTopView(topContentsContainer);
mBrowserController = mBrowserFragmentController.getBrowserController();
......
......@@ -26,4 +26,7 @@ public class WebLayerBrowserTestsApplication extends NativeBrowserTestApplicatio
ResourceBundle.setNoAvailableLocalePaks();
}
}
@Override
protected void initApplicationContext() {}
}
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