Bug 1529082 - Move TestRunnerActivity to test_runner. r=ahal,owlish

The fact that the test runner app is defined inside the geckoview test package
has always felt like a hack to me. I've mistakenly thought that
TestRunnerActivity was used in GeckoView's junit tests many times (even though
that's not the case).

From what I can see, there's no way to generate an AAB package for androidTest,
so to be able to run Gecko tests as AAB we finally need to define the
TestRunner as an ordinary package instead.

Differential Revision: https://phabricator.services.mozilla.com/D127320
This commit is contained in:
Agi Sferro 2021-11-02 18:56:26 +00:00
parent 823690869d
commit dccddb81bc
56 changed files with 301 additions and 71 deletions

View file

@ -154,7 +154,7 @@ class ReftestRunner(MozbuildObject):
if not args.xrePath: if not args.xrePath:
args.xrePath = os.environ.get("MOZ_HOST_BIN") args.xrePath = os.environ.get("MOZ_HOST_BIN")
if not args.app: if not args.app:
args.app = "org.mozilla.geckoview.test" args.app = "org.mozilla.geckoview.test_runner"
if not args.utilityPath: if not args.utilityPath:
args.utilityPath = args.xrePath args.utilityPath = args.xrePath
args.ignoreWindowSize = True args.ignoreWindowSize = True

View file

@ -61,7 +61,7 @@ def run_reftest_desktop(context, args):
def run_reftest_android(context, args): def run_reftest_android(context, args):
from remotereftest import run_test_harness from remotereftest import run_test_harness
args.app = args.app or "org.mozilla.geckoview.test" args.app = args.app or "org.mozilla.geckoview.test_runner"
args.utilityPath = context.hostutils args.utilityPath = context.hostutils
args.xrePath = context.hostutils args.xrePath = context.hostutils
args.httpdPath = context.module_dir args.httpdPath = context.module_dir

View file

@ -13,22 +13,11 @@
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:name="androidx.multidex.MultiDexApplication"> android:name="androidx.multidex.MultiDexApplication">
<activity android:name=".TestRunnerActivity" android:exported="true"/>
<activity android:name=".GeckoViewTestActivity" android:exported="true"/> <activity android:name=".GeckoViewTestActivity" android:exported="true"/>
<activity-alias android:name=".App" android:targetActivity=".TestRunnerActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="org.mozilla.geckoview.test.XPCSHELL_TEST"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
<!-- This is used for crash handling in GeckoSessionTestRule --> <!-- This is used for crash handling in GeckoSessionTestRule -->
<service <service
android:name=".TestCrashHandler" android:name=".TestCrashHandler"
@ -50,18 +39,5 @@
<service android:name=".TestRuntimeService$instance1" android:enabled="true" android:exported="false" android:process=":runtime1" /> <service android:name=".TestRuntimeService$instance1" android:enabled="true" android:exported="false" android:process=":runtime1" />
<service android:name=".TrackingPermissionService" android:enabled="true" android:exported="false" android:process=":tp" /> <service android:name=".TrackingPermissionService" android:enabled="true" android:exported="false" android:process=":tp" />
<!-- This is used to run xpcshell tests -->
<service android:name=".XpcshellTestRunnerService$i0" android:enabled="true" android:exported="true" android:process=":xpcshell0"/>
<service android:name=".XpcshellTestRunnerService$i1" android:enabled="true" android:exported="true" android:process=":xpcshell1"/>
<service android:name=".XpcshellTestRunnerService$i2" android:enabled="true" android:exported="true" android:process=":xpcshell2"/>
<service android:name=".XpcshellTestRunnerService$i3" android:enabled="true" android:exported="true" android:process=":xpcshell3"/>
<service android:name=".XpcshellTestRunnerService$i4" android:enabled="true" android:exported="true" android:process=":xpcshell4"/>
<service android:name=".XpcshellTestRunnerService$i5" android:enabled="true" android:exported="true" android:process=":xpcshell5"/>
<service android:name=".XpcshellTestRunnerService$i6" android:enabled="true" android:exported="true" android:process=":xpcshell6"/>
<service android:name=".XpcshellTestRunnerService$i7" android:enabled="true" android:exported="true" android:process=":xpcshell7"/>
<service android:name=".XpcshellTestRunnerService$i8" android:enabled="true" android:exported="true" android:process=":xpcshell8"/>
<service android:name=".XpcshellTestRunnerService$i9" android:enabled="true" android:exported="true" android:process=":xpcshell9"/>
</application> </application>
</manifest> </manifest>

View file

@ -373,7 +373,7 @@ public final class GeckoRuntime implements Parcelable {
if (info.xpcshell if (info.xpcshell
&& (!BuildConfig.DEBUG && (!BuildConfig.DEBUG
|| !"org.mozilla.geckoview.test" || !"org.mozilla.geckoview.test_runner"
.equals(context.getApplicationContext().getPackageName()))) { .equals(context.getApplicationContext().getPackageName()))) {
throw new IllegalArgumentException("Only the test app can run -xpcshell."); throw new IllegalArgumentException("Only the test app can run -xpcshell.");
} }

View file

@ -111,6 +111,42 @@ set_config(
) )
@depends(gradle_android_build_config)
def gradle_android_geckoview_test_runner_bundle(build_config):
"""Path to intermediates classes folder."""
def uncapitalize(s):
if s:
return s[0].lower() + s[1:]
else:
return s
def capitalize(s):
# str.capitalize lower cases trailing letters.
if s:
return s[0].upper() + s[1:]
else:
return s
productFlavor = uncapitalize(
"".join(capitalize(f) for f in build_config.geckoview.variant.productFlavors)
)
buildType = uncapitalize(build_config.geckoview.variant.buildType)
variant = uncapitalize(build_config.geckoview.variant.name)
return "gradle/build/mobile/android/test_runner/outputs/bundle/{}/test_runner-{}-{}.aab".format(
variant,
productFlavor,
buildType,
)
set_config(
"GRADLE_ANDROID_GECKOVIEW_TEST_RUNNER_BUNDLE",
gradle_android_geckoview_test_runner_bundle,
)
@depends(gradle_android_build_config) @depends(gradle_android_build_config)
def gradle_android_variant_name(build_config): def gradle_android_variant_name(build_config):
"""Like "withoutGeckoBinariesDebug".""" """Like "withoutGeckoBinariesDebug"."""
@ -231,6 +267,7 @@ set_config(
"mobile/android/annotations", "mobile/android/annotations",
"mobile/android/geckoview", "mobile/android/geckoview",
"mobile/android/geckoview_example", "mobile/android/geckoview_example",
"mobile/android/test_runner",
"mobile/android/examples/messaging_example", "mobile/android/examples/messaging_example",
"mobile/android/examples/port_messaging_example", "mobile/android/examples/port_messaging_example",
], ],
@ -283,6 +320,9 @@ def gradle_android_archive_geckoview_tasks(build_config):
"geckoview:assemble{geckoview.variant.name}AndroidTest".format( "geckoview:assemble{geckoview.variant.name}AndroidTest".format(
geckoview=build_config.geckoview geckoview=build_config.geckoview
), ),
"test_runner:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example
),
"geckoview_example:assemble{geckoview_example.variant.name}".format( "geckoview_example:assemble{geckoview_example.variant.name}".format(
geckoview_example=build_config.geckoview_example geckoview_example=build_config.geckoview_example
), ),
@ -384,6 +424,9 @@ def gradle_android_build_geckoview_example_tasks(build_config):
"geckoview:assemble{geckoview.variant.name}AndroidTest".format( "geckoview:assemble{geckoview.variant.name}AndroidTest".format(
geckoview=build_config.geckoview geckoview=build_config.geckoview
), ),
"test_runner:assemble{geckoview.variant.name}".format(
geckoview=build_config.geckoview
),
] ]
@ -393,6 +436,22 @@ set_config(
) )
@depends(gradle_android_build_config)
def gradle_android_install_geckoview_test_runner_tasks(build_config):
"""Gradle tasks run by |mach android install-geckoview-test_runner|."""
return [
"test_runner:install{geckoview.variant.name}".format(
geckoview=build_config.geckoview
),
]
set_config(
"GRADLE_ANDROID_INSTALL_GECKOVIEW_TEST_RUNNER_TASKS",
gradle_android_install_geckoview_test_runner_tasks,
)
@depends(gradle_android_build_config) @depends(gradle_android_build_config)
def gradle_android_install_geckoview_example_tasks(build_config): def gradle_android_install_geckoview_example_tasks(build_config):
"""Gradle tasks run by |mach android install-geckoview_example|.""" """Gradle tasks run by |mach android install-geckoview_example|."""

View file

@ -223,6 +223,15 @@ def android_build_geckoview_example(command_context, args):
return 0 return 0
def install_app_bundle(command_context, bundle):
from mozdevice import ADBDeviceFactory
bundletool = mozpath.join(command_context._mach_context.state_dir, "bundletool.jar")
device = ADBDeviceFactory(verbose=True)
bundle_path = mozpath.join(command_context.topobjdir, bundle)
device.install_app_bundle(bundletool, bundle_path, timeout=120)
@SubCommand("android", "install-geckoview_example", """Install geckoview_example """) @SubCommand("android", "install-geckoview_example", """Install geckoview_example """)
@CommandArgument("args", nargs=argparse.REMAINDER) @CommandArgument("args", nargs=argparse.REMAINDER)
def android_install_geckoview_example(command_context, args): def android_install_geckoview_example(command_context, args):
@ -240,6 +249,34 @@ def android_install_geckoview_example(command_context, args):
return 0 return 0
@SubCommand(
"android", "install-geckoview-test_runner", """Install geckoview.test_runner """
)
@CommandArgument("args", nargs=argparse.REMAINDER)
def android_install_geckoview_test_runner(command_context, args):
gradle(
command_context,
command_context.substs["GRADLE_ANDROID_INSTALL_GECKOVIEW_TEST_RUNNER_TASKS"]
+ args,
verbose=True,
)
return 0
@SubCommand(
"android",
"install-geckoview-test_runner-aab",
"""Install geckoview.test_runner with AAB""",
)
@CommandArgument("args", nargs=argparse.REMAINDER)
def android_install_geckoview_test_runner_aab(command_context, args):
install_app_bundle(
command_context,
command_context.substs["GRADLE_ANDROID_GECKOVIEW_TEST_RUNNER_BUNDLE"],
)
return 0
@SubCommand( @SubCommand(
"android", "android",
"geckoview-docs", "geckoview-docs",

View file

@ -0,0 +1,63 @@
buildDir "${topobjdir}/gradle/build/mobile/android/test_runner"
apply plugin: 'com.android.application'
apply from: "${topsrcdir}/mobile/android/gradle/product_flavors.gradle"
android {
buildToolsVersion project.ext.buildToolsVersion
compileSdkVersion project.ext.compileSdkVersion
defaultConfig {
targetSdkVersion project.ext.targetSdkVersion
minSdkVersion project.ext.minSdkVersion
manifestPlaceholders = project.ext.manifestPlaceholders
applicationId "org.mozilla.geckoview.test_runner"
versionCode 1
versionName "1.0"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "32g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// By default the android plugins ignores folders that start with `_`, but
// we need those in web extensions.
// See also:
// - https://issuetracker.google.com/issues/36911326
// - https://stackoverflow.com/questions/9206117/how-to-workaround-autoomitting-fiiles-folders-starting-with-underscore-in
aaptOptions {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
noCompress 'ja'
}
project.configureProductFlavors.delegate = it
project.configureProductFlavors()
}
dependencies {
implementation "androidx.annotation:annotation:1.0.0"
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "androidx.preference:preference:1.0.0"
implementation project(path: ':geckoview')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
}

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mozilla.geckoview.test_runner">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="androidx.multidex.MultiDexApplication">
<uses-library android:name="android.test.runner" android:required="false"/>
<activity android:name=".TestRunnerActivity" android:exported="true"/>
<activity-alias android:name=".App" android:targetActivity=".TestRunnerActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="org.mozilla.geckoview.test_runner.XPCSHELL_TEST"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
<!-- This is used to run xpcshell tests -->
<service android:name=".XpcshellTestRunnerService$i0" android:enabled="true" android:exported="true" android:process=":xpcshell0"/>
<service android:name=".XpcshellTestRunnerService$i1" android:enabled="true" android:exported="true" android:process=":xpcshell1"/>
<service android:name=".XpcshellTestRunnerService$i2" android:enabled="true" android:exported="true" android:process=":xpcshell2"/>
<service android:name=".XpcshellTestRunnerService$i3" android:enabled="true" android:exported="true" android:process=":xpcshell3"/>
<service android:name=".XpcshellTestRunnerService$i4" android:enabled="true" android:exported="true" android:process=":xpcshell4"/>
<service android:name=".XpcshellTestRunnerService$i5" android:enabled="true" android:exported="true" android:process=":xpcshell5"/>
<service android:name=".XpcshellTestRunnerService$i6" android:enabled="true" android:exported="true" android:process=":xpcshell6"/>
<service android:name=".XpcshellTestRunnerService$i7" android:enabled="true" android:exported="true" android:process=":xpcshell7"/>
<service android:name=".XpcshellTestRunnerService$i8" android:enabled="true" android:exported="true" android:process=":xpcshell8"/>
<service android:name=".XpcshellTestRunnerService$i9" android:enabled="true" android:exported="true" android:process=":xpcshell9"/>
</application>
</manifest>

View file

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
package org.mozilla.geckoview.test; package org.mozilla.geckoview.test_runner;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@ -385,8 +385,7 @@ public class TestRunnerActivity extends Activity {
.contentBlocking( .contentBlocking(
new ContentBlocking.Settings.Builder() new ContentBlocking.Settings.Builder()
.safeBrowsingProviders(google, googleLegacy) .safeBrowsingProviders(google, googleLegacy)
.build()) .build());
.crashHandler(TestCrashHandler.class);
sRuntime = GeckoRuntime.create(this, runtimeSettingsBuilder.build()); sRuntime = GeckoRuntime.create(this, runtimeSettingsBuilder.build());
@ -400,7 +399,7 @@ public class TestRunnerActivity extends Activity {
}); });
webExtensionController() webExtensionController()
.installBuiltIn("resource://android/assets/web_extensions/test-runner-support/") .installBuiltIn("resource://android/assets/test-runner-support/")
.accept( .accept(
extension -> { extension -> {
extension.setMessageDelegate(mApiEngine, "test-runner-support"); extension.setMessageDelegate(mApiEngine, "test-runner-support");

View file

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
package org.mozilla.geckoview.test; package org.mozilla.geckoview.test_runner;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;

View file

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
package org.mozilla.geckoview.test; package org.mozilla.geckoview.test_runner;
import android.app.Service; import android.app.Service;
import android.content.Intent; import android.content.Intent;
@ -81,7 +81,6 @@ public class XpcshellTestRunnerService extends Service {
new ContentBlocking.Settings.Builder() new ContentBlocking.Settings.Builder()
.safeBrowsingProviders(google, googleLegacy) .safeBrowsingProviders(google, googleLegacy)
.build()) .build())
.crashHandler(TestCrashHandler.class)
.build(); .build();
sRuntime = GeckoRuntime.create(this, runtimeSettings); sRuntime = GeckoRuntime.create(this, runtimeSettings);

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources>
<string name="app_name">GeckoView Test Runner</string>
</resources>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>

View file

@ -571,7 +571,7 @@ def join_ensure_dir(dir1, dir2):
@CommandArgumentGroup("Android") @CommandArgumentGroup("Android")
@CommandArgument( @CommandArgument(
"--package", "--package",
default="org.mozilla.geckoview.test", default="org.mozilla.geckoview.test_runner",
group="Android", group="Android",
help="Package name of test app.", help="Package name of test app.",
) )
@ -1247,8 +1247,8 @@ def _run_android(
if app == "org.mozilla.geckoview_example": if app == "org.mozilla.geckoview_example":
activity_name = "org.mozilla.geckoview_example.GeckoViewActivity" activity_name = "org.mozilla.geckoview_example.GeckoViewActivity"
elif app == "org.mozilla.geckoview.test": elif app == "org.mozilla.geckoview.test_runner":
activity_name = "org.mozilla.geckoview.test.TestRunnerActivity" activity_name = "org.mozilla.geckoview.test_runner.TestRunnerActivity"
elif "fennec" in app or "firefox" in app: elif "fennec" in app or "firefox" in app:
activity_name = "org.mozilla.gecko.BrowserApp" activity_name = "org.mozilla.gecko.BrowserApp"
else: else:

View file

@ -53,11 +53,13 @@ System.setProperty('android.home', json.substs.ANDROID_SDK_ROOT)
include ':annotations', ':messaging_example', ':port_messaging_example' include ':annotations', ':messaging_example', ':port_messaging_example'
include ':geckoview' include ':geckoview'
include ':geckoview_example' include ':geckoview_example'
include ':test_runner'
include ':omnijar' include ':omnijar'
project(':annotations').projectDir = new File("${json.topsrcdir}/mobile/android/annotations") project(':annotations').projectDir = new File("${json.topsrcdir}/mobile/android/annotations")
project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview") project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview")
project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example") project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example")
project(':test_runner').projectDir = new File("${json.topsrcdir}/mobile/android/test_runner")
project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar") project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar")
// The Gradle instance is shared between settings.gradle and all the // The Gradle instance is shared between settings.gradle and all the

View file

@ -40,6 +40,9 @@ job-defaults:
- name: public/build/geckoview-androidTest.apk - name: public/build/geckoview-androidTest.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk
type: file type: file
- name: public/build/geckoview-test_runner.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/test_runner/outputs/apk/withGeckoBinaries/debug/test_runner-withGeckoBinaries-debug.apk
type: file
- name: public/build/geckoview_example.apk - name: public/build/geckoview_example.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk
type: file type: file

View file

@ -19,6 +19,9 @@ job-defaults:
- name: public/build/geckoview-androidTest.apk - name: public/build/geckoview-androidTest.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk
type: file type: file
- name: public/build/geckoview-test_runner.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/test_runner/outputs/apk/withGeckoBinaries/debug/test_runner-withGeckoBinaries-debug.apk
type: file
- name: public/build/geckoview_example.apk - name: public/build/geckoview_example.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk
type: file type: file

View file

@ -112,7 +112,7 @@ jobs:
job-script: taskcluster/scripts/tester/test-linux.sh job-script: taskcluster/scripts/tester/test-linux.sh
script: android_emulator_pgo.py script: android_emulator_pgo.py
tooltool-downloads: internal tooltool-downloads: internal
options: [installer-path=/builds/worker/fetches/geckoview-androidTest.apk] options: [installer-path=/builds/worker/fetches/geckoview-test_runner.apk]
config: config:
- android/android_common.py - android/android_common.py
- android/android-x86_64-profile-generation.py - android/android-x86_64-profile-generation.py
@ -152,7 +152,7 @@ jobs:
job-script: taskcluster/scripts/tester/test-linux.sh job-script: taskcluster/scripts/tester/test-linux.sh
script: android_emulator_pgo.py script: android_emulator_pgo.py
tooltool-downloads: internal tooltool-downloads: internal
options: [installer-path=/builds/worker/fetches/geckoview-androidTest.apk] options: [installer-path=/builds/worker/fetches/geckoview-test_runner.apk]
config: config:
- android/android_common.py - android/android_common.py
- android/android-x86_64-profile-generation.py - android/android-x86_64-profile-generation.py

View file

@ -156,6 +156,9 @@ jobs:
- name: public/build/geckoview-androidTest.apk - name: public/build/geckoview-androidTest.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk
type: file type: file
- name: public/build/geckoview-test_runner.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/test_runner/outputs/apk/withGeckoBinaries/debug/test_runner-withGeckoBinaries-debug.apk
type: file
- name: public/build/geckoview_example.apk - name: public/build/geckoview_example.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk
type: file type: file
@ -202,6 +205,9 @@ jobs:
- name: public/build/geckoview-androidTest.apk - name: public/build/geckoview-androidTest.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/withGeckoBinaries/debug/geckoview-withGeckoBinaries-debug-androidTest.apk
type: file type: file
- name: public/build/geckoview-test_runner.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/test_runner/outputs/apk/withGeckoBinaries/debug/test_runner-withGeckoBinaries-debug.apk
type: file
- name: public/build/geckoview_example.apk - name: public/build/geckoview_example.apk
path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk
type: file type: file

View file

@ -36,7 +36,7 @@ cppunit:
treeherder-symbol: cppunit treeherder-symbol: cppunit
target: target:
by-test-platform: by-test-platform:
android-em-7.*: geckoview-androidTest.apk android-em-7.*: geckoview-test_runner.apk
default: null default: null
tier: default tier: default
run-on-projects: built-projects run-on-projects: built-projects
@ -57,7 +57,7 @@ gtest:
default: built-projects default: built-projects
target: target:
by-test-platform: by-test-platform:
android-em-7.*: geckoview-androidTest.apk android-em-7.*: geckoview-test_runner.apk
default: null default: null
tier: tier:
by-test-platform: by-test-platform:
@ -97,7 +97,7 @@ jittest:
default: true default: true
target: target:
by-test-platform: by-test-platform:
android-.*: geckoview-androidTest.apk android-.*: geckoview-test_runner.apk
default: null default: null
tier: tier:
by-test-platform: by-test-platform:
@ -123,7 +123,7 @@ jittest-all:
default: None default: None
target: target:
by-test-platform: by-test-platform:
android-.*: geckoview-androidTest.apk android-.*: geckoview-test_runner.apk
default: null default: null
tier: tier:
by-test-platform: by-test-platform:

View file

@ -7,8 +7,8 @@ job-defaults:
category: mochitest category: mochitest
target: target:
by-test-platform: by-test-platform:
android-em-7.*: geckoview-androidTest.apk android-em-7.*: geckoview-test_runner.apk
android-hw.*: geckoview-androidTest.apk android-hw.*: geckoview-test_runner.apk
default: null default: null
tier: tier:
by-variant: by-variant:

View file

@ -7,8 +7,8 @@ job-defaults:
category: reftest category: reftest
target: target:
by-test-platform: by-test-platform:
android-em-7.*: geckoview-androidTest.apk android-em-7.*: geckoview-test_runner.apk
android-hw-.*: geckoview-androidTest.apk android-hw-.*: geckoview-test_runner.apk
default: null default: null
python-3: true python-3: true
tier: tier:

View file

@ -26,9 +26,9 @@ job-defaults:
- remove_executables.py - remove_executables.py
target: target:
by-test-platform: by-test-platform:
android-em-7.0-x86_64-shippable(-lite)?-qr/opt: geckoview-androidTest.apk android-em-7.0-x86_64-shippable(-lite)?-qr/opt: geckoview-test_runner.apk
android-em-7.0-x86_64(-lite)?-qr/opt: geckoview-androidTest.apk android-em-7.0-x86_64(-lite)?-qr/opt: geckoview-test_runner.apk
android-em-7.0-x86_64(-lite)?-qr/debug(-isolated-process)?: geckoview-androidTest.apk android-em-7.0-x86_64(-lite)?-qr/debug(-isolated-process)?: geckoview-test_runner.apk
default: null default: null
python-3: true python-3: true

View file

@ -6,7 +6,7 @@ job-defaults:
suite: xpcshell suite: xpcshell
target: target:
by-test-platform: by-test-platform:
android-em-7.*: geckoview-androidTest.apk android-em-7.*: geckoview-test_runner.apk
default: null default: null
python-3: true python-3: true
mozharness: mozharness:

View file

@ -21,7 +21,7 @@ def run_profile_data(config, jobs):
build_platform = job["attributes"].get("build_platform") build_platform = job["attributes"].get("build_platform")
instr = "instrumented-build-{}".format(job["name"]) instr = "instrumented-build-{}".format(job["name"])
if "android" in build_platform: if "android" in build_platform:
artifact = "geckoview-androidTest.apk" artifact = "geckoview-test_runner.apk"
elif "macosx64" in build_platform: elif "macosx64" in build_platform:
artifact = "target.dmg" artifact = "target.dmg"
elif "win" in build_platform: elif "win" in build_platform:

View file

@ -367,7 +367,7 @@ class remoteGtestOptions(argparse.ArgumentParser):
self.add_argument( self.add_argument(
"--package", "--package",
dest="package", dest="package",
default="org.mozilla.geckoview.test", default="org.mozilla.geckoview.test_runner",
help="Package name of test app.", help="Package name of test app.",
) )
self.add_argument( self.add_argument(

View file

@ -459,7 +459,7 @@ def run_mochitest_general(
app = kwargs.get("app") app = kwargs.get("app")
if not app: if not app:
app = "org.mozilla.geckoview.test" app = "org.mozilla.geckoview.test_runner"
device_serial = kwargs.get("deviceSerial") device_serial = kwargs.get("deviceSerial")
install = InstallIntent.NO if kwargs.get("no_install") else InstallIntent.YES install = InstallIntent.NO if kwargs.get("no_install") else InstallIntent.YES

View file

@ -121,7 +121,7 @@ def run_mochitest_desktop(context, args):
def set_android_args(context, args): def set_android_args(context, args):
args.app = args.app or "org.mozilla.geckoview.test" args.app = args.app or "org.mozilla.geckoview.test_runner"
args.utilityPath = context.hostutils args.utilityPath = context.hostutils
args.xrePath = context.hostutils args.xrePath = context.hostutils
config = context.mozharness_config config = context.mozharness_config

View file

@ -1307,7 +1307,7 @@ class AndroidArguments(ArgumentContainer):
options.webServer = options.remoteWebServer options.webServer = options.remoteWebServer
if options.app is None: if options.app is None:
options.app = "org.mozilla.geckoview.test" options.app = "org.mozilla.geckoview.test_runner"
if build_obj and "MOZ_HOST_BIN" in os.environ: if build_obj and "MOZ_HOST_BIN" in os.environ:
options.xrePath = os.environ["MOZ_HOST_BIN"] options.xrePath = os.environ["MOZ_HOST_BIN"]

View file

@ -752,8 +752,8 @@ class ADBDevice(ADBCommand):
adbdevice = ADBDevice() adbdevice = ADBDevice()
print(adbdevice.list_files("/mnt/sdcard")) print(adbdevice.list_files("/mnt/sdcard"))
if adbdevice.process_exist("org.mozilla.geckoview.test"): if adbdevice.process_exist("org.mozilla.geckoview.test_runner"):
print("org.mozilla.geckoview.test is running") print("org.mozilla.geckoview.test_runner is running")
""" """
SOCKET_DIRECTION_REVERSE = "reverse" SOCKET_DIRECTION_REVERSE = "reverse"
@ -4187,7 +4187,7 @@ class ADBDevice(ADBCommand):
debugging arguments; convenient for geckoview apps. debugging arguments; convenient for geckoview apps.
:param str app_name: Name of application (e.g. :param str app_name: Name of application (e.g.
`org.mozilla.geckoview_example` or `org.mozilla.geckoview.test`) `org.mozilla.geckoview_example` or `org.mozilla.geckoview.test_runner`)
:param str activity_name: Activity name, like `GeckoViewActivity`, or :param str activity_name: Activity name, like `GeckoViewActivity`, or
`TestRunnerActivity`. `TestRunnerActivity`.
:param str intent: Intent to launch application. :param str intent: Intent to launch application.
@ -4256,7 +4256,7 @@ class ADBDevice(ADBCommand):
debugging arguments; convenient for geckoview apps. debugging arguments; convenient for geckoview apps.
:param str app_name: Name of application (e.g. :param str app_name: Name of application (e.g.
`org.mozilla.geckoview_example` or `org.mozilla.geckoview.test`) `org.mozilla.geckoview_example` or `org.mozilla.geckoview.test_runner`)
:param str activity_name: Activity name, like `GeckoViewActivity`, or :param str activity_name: Activity name, like `GeckoViewActivity`, or
`TestRunnerActivity`. `TestRunnerActivity`.
:param str intent: Intent to launch application. :param str intent: Intent to launch application.

View file

@ -326,7 +326,7 @@ def verify_android_device(
# - it prevents testing against other builds (downloaded apk) # - it prevents testing against other builds (downloaded apk)
# - installation may take a couple of minutes. # - installation may take a couple of minutes.
if not app: if not app:
app = "org.mozilla.geckoview.test" app = "org.mozilla.geckoview.test_runner"
device = _get_device(build_obj.substs, device_serial) device = _get_device(build_obj.substs, device_serial)
response = "" response = ""
installed = device.is_app_installed(app) installed = device.is_app_installed(app)
@ -346,6 +346,14 @@ def verify_android_device(
build_obj._mach_context.commands.dispatch( build_obj._mach_context.commands.dispatch(
"gradle", build_obj._mach_context, args=[sub] "gradle", build_obj._mach_context, args=[sub]
) )
elif app == "org.mozilla.geckoview.test_runner":
if installed:
device.uninstall_app(app)
_log_info("Installing geckoview test_runner...")
sub = "install-geckoview-test_runner"
build_obj._mach_context.commands.dispatch(
"android", build_obj._mach_context, subcommand=sub, args=[]
)
elif app == "org.mozilla.geckoview_example": elif app == "org.mozilla.geckoview_example":
if installed: if installed:
device.uninstall_app(app) device.uninstall_app(app)
@ -528,7 +536,7 @@ def get_adb_path(build_obj):
def grant_runtime_permissions(build_obj, app, device_serial=None): def grant_runtime_permissions(build_obj, app, device_serial=None):
""" """
Grant required runtime permissions to the specified app Grant required runtime permissions to the specified app
(eg. org.mozilla.geckoview.test). (eg. org.mozilla.geckoview.test_runner).
""" """
device = _get_device(build_obj.substs, device_serial) device = _get_device(build_obj.substs, device_serial)
device.run_as_package = app device.run_as_package = app

View file

@ -508,6 +508,8 @@ class AndroidMixin(object):
# target looks like geckoview. # target looks like geckoview.
if "androidTest" in self.installer_path: if "androidTest" in self.installer_path:
self.app_name = "org.mozilla.geckoview.test" self.app_name = "org.mozilla.geckoview.test"
elif "test_runner" in self.installer_path:
self.app_name = "org.mozilla.geckoview.test_runner"
elif "geckoview" in self.installer_path: elif "geckoview" in self.installer_path:
self.app_name = "org.mozilla.geckoview_example" self.app_name = "org.mozilla.geckoview_example"
if self.app_name is None: if self.app_name is None:

View file

@ -39,12 +39,12 @@ Running in Android (GeckoView)
You can run the tests against a Gecko-based browser (GeckoView) on an You can run the tests against a Gecko-based browser (GeckoView) on an
Android emulator. As shown below, to do so you must start an emulator, Android emulator. As shown below, to do so you must start an emulator,
build Firefox for Android and then run mach wpt with the build Firefox for Android and then run mach wpt with the
`org.mozilla.geckoview.test` package. The package will be installed `org.mozilla.geckoview.test_runner` package. The package will be installed
interactively by `mach` and tests will run against TestRunnerActivity. interactively by `mach` and tests will run against TestRunnerActivity.
./mach android-emulator --version x86-7.0 ./mach android-emulator --version x86-7.0
./mach build ./mach build
./mach wpt --package=org.mozilla.geckoview.test ./mach wpt --package=org.mozilla.geckoview.test_runner
FAQ FAQ
--- ---

View file

@ -52,7 +52,9 @@ class WebPlatformTestsRunnerSetup(MozbuildObject):
# package_name may be different in the future # package_name may be different in the future
package_name = kwargs["package_name"] package_name = kwargs["package_name"]
if not package_name: if not package_name:
kwargs["package_name"] = package_name = "org.mozilla.geckoview.test" kwargs[
"package_name"
] = package_name = "org.mozilla.geckoview.test_runner"
# Note that this import may fail in non-firefox-for-android trees # Note that this import may fail in non-firefox-for-android trees
from mozrunner.devices.android_device import ( from mozrunner.devices.android_device import (

View file

@ -286,7 +286,7 @@ class FirefoxAndroid(BrowserSetup):
kwargs["prefs_root"] = prefs_root kwargs["prefs_root"] = prefs_root
if kwargs["package_name"] is None: if kwargs["package_name"] is None:
kwargs["package_name"] = "org.mozilla.geckoview.test" kwargs["package_name"] = "org.mozilla.geckoview.test_runner"
app = kwargs["package_name"] app = kwargs["package_name"]
if kwargs["device_serial"] is None: if kwargs["device_serial"] is None:

View file

@ -133,7 +133,7 @@ class FirefoxAndroidBrowser(Browser):
init_timeout = 300 init_timeout = 300
shutdown_timeout = 60 shutdown_timeout = 60
def __init__(self, logger, prefs_root, test_type, package_name="org.mozilla.geckoview.test", def __init__(self, logger, prefs_root, test_type, package_name="org.mozilla.geckoview.test_runner",
device_serial="emulator-5444", extra_prefs=None, debug_info=None, device_serial="emulator-5444", extra_prefs=None, debug_info=None,
symbols_path=None, stackwalk_binary=None, certutil_binary=None, symbols_path=None, stackwalk_binary=None, certutil_binary=None,
ca_certificate_path=None, e10s=False, enable_webrender=False, stackfix_dir=None, ca_certificate_path=None, e10s=False, enable_webrender=False, stackfix_dir=None,

View file

@ -183,7 +183,7 @@ class AndroidXPCShellRunner(MozbuildObject):
for root, _, paths in os.walk(os.path.join(kwargs["objdir"], "gradle")): for root, _, paths in os.walk(os.path.join(kwargs["objdir"], "gradle")):
for file_name in paths: for file_name in paths:
if file_name.endswith(".apk") and file_name.startswith( if file_name.endswith(".apk") and file_name.startswith(
"geckoview-withGeckoBinaries" "test_runner-withGeckoBinaries"
): ):
kwargs["localAPK"] = os.path.join(root, file_name) kwargs["localAPK"] = os.path.join(root, file_name)
print("using APK: %s" % kwargs["localAPK"]) print("using APK: %s" % kwargs["localAPK"])

View file

@ -63,7 +63,7 @@ class RemoteProcessMonitor(object):
# tests get foreground priority scheduling. # tests get foreground priority scheduling.
self.device.launch_activity( self.device.launch_activity(
self.package, self.package,
intent="org.mozilla.geckoview.test.XPCSHELL_TEST_MAIN", intent="org.mozilla.geckoview.test_runner.XPCSHELL_TEST_MAIN",
activity_name="TestRunnerActivity", activity_name="TestRunnerActivity",
e10s=True, e10s=True,
) )
@ -314,7 +314,7 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
self, cmd, stdout, stderr, env, cwd, timeout=None, test_name=None self, cmd, stdout, stderr, env, cwd, timeout=None, test_name=None
): ):
rpm = RemoteProcessMonitor( rpm = RemoteProcessMonitor(
"org.mozilla.geckoview.test", "org.mozilla.geckoview.test_runner",
self.device, self.device,
self.log, self.log,
self.remoteLogFile, self.remoteLogFile,
@ -449,7 +449,7 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
self.initDir(self.profileDir) self.initDir(self.profileDir)
# Make sure we get a fresh start # Make sure we get a fresh start
self.device.stop_application("org.mozilla.geckoview.test") self.device.stop_application("org.mozilla.geckoview.test_runner")
for i in range(options["threadCount"]): for i in range(options["threadCount"]):
RemoteProcessMonitor.processStatus += [False] RemoteProcessMonitor.processStatus += [False]