Commit 452e849a authored by John Budorick's avatar John Budorick Committed by Commit Bot

Launch ChromeBrowserTestsActivity intent w/ about:blank.

crrev.com/c/2032038 revealed that android_browsertests are opening
the NTP on initialization rather than about:blank. This caused issues
w/ the switch from the old NTP to start surface, which doesn't have
an associated WebContents.

This CL instead always opens the initial tab in android_browsertests
on about:blank, which should ensure that an actual Tab (and
WebContents) are created regardless of whether we're using the NTP
or start surface.

Change-Id: I5a87e3093a5f78ea76179fe605b859df9dc3b193
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065331
Commit-Queue: John Budorick <jbudorick@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743389}
parent 0a3b2369
...@@ -634,6 +634,7 @@ if (is_android) { ...@@ -634,6 +634,7 @@ if (is_android) {
sources = [ sources = [
"android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java", "android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java",
"android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java", "android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java",
"android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsInstrumentationTestRunner.java",
] ]
} }
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
{% endfor %} {% endfor %}
</application> </application>
<instrumentation android:name="org.chromium.native_test.NativeTestInstrumentationTestRunner" <instrumentation android:name="org.chromium.android_browsertests_apk.ChromeBrowserTestsInstrumentationTestRunner"
android:label="ChromeBrowserTests" android:label="ChromeBrowserTests"
android:targetPackage="org.chromium.android_browsertests_apk" android:targetPackage="org.chromium.android_browsertests_apk"
chromium-junit3="true"/> chromium-junit3="true"/>
......
...@@ -52,6 +52,14 @@ public class ChromeBrowserTestsActivity extends ChromeTabbedActivity { ...@@ -52,6 +52,14 @@ public class ChromeBrowserTestsActivity extends ChromeTabbedActivity {
}); });
} }
/**
* Tests don't use the preallocated child connection.
*/
@Override
public boolean shouldAllocateChildConnection() {
return false;
}
/** /**
* Tests should not go through the first run process every time. * Tests should not go through the first run process every time.
*/ */
......
// Copyright 2020 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.android_browsertests_apk;
import android.content.Intent;
import android.net.Uri;
import org.chromium.content_public.common.ContentUrlConstants;
import org.chromium.native_test.NativeTestInstrumentationTestRunner;
/**
* An Instrumentation for android_browsertests that includes chrome:blank in the intent.
*/
public class ChromeBrowserTestsInstrumentationTestRunner
extends NativeTestInstrumentationTestRunner {
@Override
protected Intent createShardMainIntent() {
Intent i = super.createShardMainIntent();
i.setData(Uri.parse(ContentUrlConstants.ABOUT_BLANK_DISPLAY_URL));
return i;
}
}
...@@ -228,21 +228,25 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation { ...@@ -228,21 +228,25 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation {
return false; return false;
} }
protected Intent createShardMainIntent() {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(new ComponentName(getContext().getPackageName(), mNativeTestActivity));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtras(mTransparentArguments);
if (mShards != null && !mShards.isEmpty()) {
ArrayList<String> shard = mShards.remove();
i.putStringArrayListExtra(NativeTest.EXTRA_SHARD, shard);
}
i.putExtra(NativeTest.EXTRA_STDOUT_FILE, mStdoutFile.getAbsolutePath());
return i;
}
/** Starts the NativeTest Activity. /** Starts the NativeTest Activity.
*/ */
private class ShardStarter implements Runnable { private class ShardStarter implements Runnable {
@Override @Override
public void run() { public void run() {
Intent i = new Intent(Intent.ACTION_MAIN); getContext().startActivity(createShardMainIntent());
i.setComponent(new ComponentName(getContext().getPackageName(), mNativeTestActivity));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtras(mTransparentArguments);
if (mShards != null && !mShards.isEmpty()) {
ArrayList<String> shard = mShards.remove();
i.putStringArrayListExtra(NativeTest.EXTRA_SHARD, shard);
}
i.putExtra(NativeTest.EXTRA_STDOUT_FILE, mStdoutFile.getAbsolutePath());
getContext().startActivity(i);
} }
} }
......
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