Bug 1291387 - Make mochitest and reftest work against TestRunnerActivity r=gbrown,jchen draft
authorJames Willcox <snorp@snorp.net>
Thu, 25 Jan 2018 13:59:51 -0600
changeset 757620 b7419df1793d3119aa631b286f4d1cb43323b004
parent 757619 afac35463d52566a3e18d8ec27f283ee1e03cb6d
push id99801
push userbmo:snorp@snorp.net
push dateTue, 20 Feb 2018 22:23:15 +0000
reviewersgbrown, jchen
bugs1291387
milestone60.0a1
Bug 1291387 - Make mochitest and reftest work against TestRunnerActivity r=gbrown,jchen Pass --appname org.mozilla.geckoview.test to 'mach mochitest' or 'mach reftest'. This runs the tests without e10s currently. MozReview-Commit-ID: 7TIvA3zRCw2
layout/tools/reftest/mach_commands.py
mobile/android/installer/package-manifest.in
testing/mochitest/mach_commands.py
testing/mochitest/runtestsremote.py
testing/mozbase/mozdevice/mozdevice/adb_android.py
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
testing/mozbase/mozdevice/mozdevice/droid.py
testing/mozbase/mozrunner/mozrunner/devices/android_device.py
--- a/layout/tools/reftest/mach_commands.py
+++ b/layout/tools/reftest/mach_commands.py
@@ -132,17 +132,17 @@ class ReftestRunner(MozbuildObject):
         if not args.app:
             args.app = self.substs["ANDROID_PACKAGE_NAME"]
         if not args.utilityPath:
             args.utilityPath = args.xrePath
         args.ignoreWindowSize = True
         args.printDeviceInfo = False
 
         from mozrunner.devices.android_device import grant_runtime_permissions, get_adb_path
-        grant_runtime_permissions(self)
+        grant_runtime_permissions(self, args.app)
 
         if not args.adb_path:
             args.adb_path = get_adb_path(self)
 
         # A symlink and some path manipulations are required so that test
         # manifests can be found both locally and remotely (via a url)
         # using the same relative path.
         if args.suite == "jstestbrowser":
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -285,43 +285,45 @@
 @BINPATH@/components/crypto-SDR.js
 @BINPATH@/components/TooltipTextProvider.js
 @BINPATH@/components/TooltipTextProvider.manifest
 @BINPATH@/components/NetworkGeolocationProvider.manifest
 @BINPATH@/components/NetworkGeolocationProvider.js
 @BINPATH@/components/EditorUtils.manifest
 @BINPATH@/components/EditorUtils.js
 
+@BINPATH@/components/extensions.manifest
+@BINPATH@/components/addonManager.js
+@BINPATH@/components/nsBlocklistService.js
+
 #ifndef MOZ_GECKOVIEW_JAR
-@BINPATH@/components/extensions.manifest
 @BINPATH@/components/utils.manifest
 @BINPATH@/components/simpleServices.js
-@BINPATH@/components/addonManager.js
 @BINPATH@/components/amContentHandler.js
+@BINPATH@/components/amWebAPI.js
 @BINPATH@/components/amInstallTrigger.js
-@BINPATH@/components/amWebAPI.js
-@BINPATH@/components/nsBlocklistService.js
 #ifndef RELEASE_OR_BETA
 @BINPATH@/components/TabSource.js
 #endif
 #endif
 
 @BINPATH@/components/webvtt.xpt
 @BINPATH@/components/WebVTT.manifest
 @BINPATH@/components/WebVTTParserWrapper.js
 
 #ifndef MOZ_GECKOVIEW_JAR
 #ifdef MOZ_UPDATER
 @BINPATH@/components/nsUpdateService.manifest
 @BINPATH@/components/nsUpdateService.js
 @BINPATH@/components/nsUpdateServiceStub.js
 #endif
+#endif
+
 @BINPATH@/components/nsUpdateTimerManager.manifest
 @BINPATH@/components/nsUpdateTimerManager.js
-#endif
 
 @BINPATH@/components/pluginGlue.manifest
 @BINPATH@/components/ProcessSingleton.manifest
 @BINPATH@/components/MainProcessSingleton.js
 @BINPATH@/components/ContentProcessSingleton.js
 @BINPATH@/components/nsURLFormatter.manifest
 @BINPATH@/components/nsURLFormatter.js
 @BINPATH@/components/txEXSLTRegExFunctions.manifest
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -388,19 +388,23 @@ class MachCommands(MachCommandBase):
                 msg.append('    mochitest -f {} ({})'.format(name, reason))
             print(SUPPORTED_TESTS_NOT_FOUND.format(
                 buildapp, '\n'.join(sorted(msg))))
             return 1
 
         if buildapp == 'android':
             from mozrunner.devices.android_device import grant_runtime_permissions
             from mozrunner.devices.android_device import verify_android_device
+            app = kwargs.get('app')
+            if not app:
+                app = self.substs["ANDROID_PACKAGE_NAME"]
+
             # verify installation
-            verify_android_device(self, install=True, xre=False, app=kwargs['app'])
-            grant_runtime_permissions(self)
+            verify_android_device(self, install=True, xre=False, app=app)
+            grant_runtime_permissions(self, app)
             run_mochitest = mochitest.run_android_test
         else:
             run_mochitest = mochitest.run_desktop_test
 
         overall = None
         for (flavor, subsuite), tests in sorted(suites.items()):
             fobj = ALL_FLAVORS[flavor]
 
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -302,24 +302,23 @@ class MochiRemote(MochitestDesktop):
 
         ret, _ = self._automation.runApp(*args, **kwargs)
         self.countpass += self.counts['pass']
         self.countfail += self.counts['fail']
         self.counttodo += self.counts['todo']
 
         return ret, None
 
-
 def run_test_harness(parser, options):
     parser.validate(options)
 
     message_logger = MessageLogger(logger=None)
     counts = dict()
     process_args = {'messageLogger': message_logger, 'counts': counts}
-    auto = RemoteAutomation(None, "fennec", processArgs=process_args)
+    auto = RemoteAutomation(None, options.app, processArgs=process_args)
 
     if options is None:
         raise ValueError("Invalid options specified, use --help for a list of valid options")
 
     options.runByManifest = True
     # roboextender is used by mochitest-chrome tests like test_java_addons.html,
     # but not by any plain mochitests
     if options.flavor != 'chrome':
--- a/testing/mozbase/mozdevice/mozdevice/adb_android.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb_android.py
@@ -395,17 +395,17 @@ class ADBAndroid(ADBDevice):
             for (env_count, (env_key, env_val)) in enumerate(moz_env.iteritems()):
                 extras["env" + str(env_count)] = env_key + "=" + env_val
 
         # Additional command line arguments that fennec will read and use (e.g.
         # with a custom profile)
         if extra_args:
             extras['args'] = " ".join(extra_args)
 
-        self.launch_application(app_name, "org.mozilla.gecko.BrowserApp",
+        self.launch_application(app_name, ".App",
                                 intent, url=url, extras=extras,
                                 wait=wait, fail_if_running=fail_if_running,
                                 timeout=timeout)
 
     def stop_application(self, app_name, timeout=None, root=False):
         """Stops the specified application
 
         For Android 3.0+, we use the "am force-stop" to do this, which
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -419,17 +419,17 @@ class DeviceManagerADB(DeviceManager):
         uri = ""
         args = ""
         if re_url.match(cmd[last:].strip()):
             args = cmd[i:last].strip()
             uri = cmd[last:].strip()
         else:
             args = cmd[i:].strip()
         acmd.append("-n")
-        acmd.append(cmd[0:i] + "/org.mozilla.gecko.BrowserApp")
+        acmd.append(cmd[0:i] + "/.App")
         if args != "":
             acmd.append("--es")
             acmd.append("args")
             acmd.append(args)
         if env != '' and env is not None:
             envCnt = 0
             # env is expected to be a dict of environment variables
             for envkey, envval in env.iteritems():
--- a/testing/mozbase/mozdevice/mozdevice/droid.py
+++ b/testing/mozbase/mozdevice/mozdevice/droid.py
@@ -96,17 +96,17 @@ class DroidMixin(object):
             for (envCnt, (envkey, envval)) in enumerate(mozEnv.iteritems()):
                 extras["env" + str(envCnt)] = envkey + "=" + envval
 
         # Additional command line arguments that fennec will read and use (e.g.
         # with a custom profile)
         if extraArgs:
             extras['args'] = " ".join(extraArgs)
 
-        self.launchApplication(appName, "org.mozilla.gecko.BrowserApp", intent, url=url,
+        self.launchApplication(appName, ".App", intent, url=url,
                                extras=extras,
                                wait=wait, failIfRunning=failIfRunning)
 
     def getInstalledApps(self):
         """
         Lists applications installed on this Android device
 
         Returns a list of application names in the form [ 'org.mozilla.fennec', ... ]
--- a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
+++ b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
@@ -361,22 +361,21 @@ def run_firefox_for_android(build_obj, p
         output = dm.shellCheckOutput(cmd, timeout=10)
         _log_info(output)
     except DMError:
         _log_warning("unable to launch Firefox for Android")
         return 1
     return 0
 
 
-def grant_runtime_permissions(build_obj):
+def grant_runtime_permissions(build_obj, app):
     """
     Grant required runtime permissions to the specified app
     (typically org.mozilla.fennec_$USER).
     """
-    app = build_obj.substs['ANDROID_PACKAGE_NAME']
     adb_path = _find_sdk_exe(build_obj.substs, 'adb', False)
     if not adb_path:
         adb_path = 'adb'
     dm = DeviceManagerADB(autoconnect=False, adbPath=adb_path, retryLimit=1)
     dm.default_timeout = 10
     try:
         sdk_level = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
         if sdk_level and int(sdk_level) >= 23: