Bug 1452694 - Use TestRunnerActivity for geckoview mochitest/reftest; r=bc
authorGeoff Brown <gbrown@mozilla.com>
Tue, 10 Apr 2018 13:26:11 -0600
changeset 412660 893740eee6151bceadf477e441148acb4f962462
parent 412659 6d07dcc83134655d152a1a3af64e3eed4866f63f
child 412661 3f00b6633b3bb696d6ec035e85af187326c23a99
push id33814
push userccoroiu@mozilla.com
push dateTue, 10 Apr 2018 21:56:42 +0000
treeherdermozilla-central@0528a414c2a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbc
bugs1452694
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1452694 - Use TestRunnerActivity for geckoview mochitest/reftest; r=bc This makes the changes necessary to use TestRunnerActivity when geckoview is installed and requested, but we do not yet attempt to run any such test tasks in automation.
build/mobile/remoteautomation.py
testing/mochitest/rungeckoview.py
testing/mozbase/mozdevice/mozdevice/adb_android.py
testing/mozharness/scripts/android_emulator_unittest.py
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -242,17 +242,19 @@ class RemoteAutomation(Automation):
                     args = args[1:]
                 url = args[-1:][0]
                 if url.startswith('/'):
                     # this is probably a reftest profile directory, not a url
                     url = None
                 else:
                     args = args[:-1]
                 if 'geckoview' in app:
-                    self.device.launch_geckoview_example(app, moz_env=env, extra_args=args, url=url)
+                    activity = "TestRunnerActivity"
+                    self.device.launch_activity(app, activity, e10s=True, moz_env=env,
+                                                extra_args=args, url=url)
                 else:
                     self.device.launch_fennec(app, moz_env=env, extra_args=args, url=url)
 
             # Setting timeout at 1 hour since on a remote device this takes much longer.
             # Temporarily increased to 90 minutes because no more chunks can be created.
             self.timeout = 5400
 
             # Used to buffer log messages until we meet a line break
--- a/testing/mochitest/rungeckoview.py
+++ b/testing/mochitest/rungeckoview.py
@@ -97,18 +97,19 @@ class GeckoviewTestRunner:
             env["MOZ_CRASHREPORTER_SHUTDOWN"] = "1"
             env["XPCOM_DEBUG_BREAK"] = "stack"
             env["DISABLE_UNSAFE_CPOW_WARNINGS"] = "1"
             env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
             env["MOZ_IN_AUTOMATION"] = "1"
             env["R_LOG_VERBOSE"] = "1"
             env["R_LOG_LEVEL"] = "6"
             env["R_LOG_DESTINATION"] = "stderr"
-            self.device.launch_geckoview_example("org.mozilla.geckoview_example",
-                                                 extra_args=args, moz_env=env)
+            self.device.launch_activity("org.mozilla.geckoview_example",
+                                        "GeckoViewActivity",
+                                        extra_args=args, moz_env=env)
         except Exception:
             return (False, "Exception during %s startup" % self.appname)
         return (True, "%s started" % self.appname)
 
     def started(self):
         """
         startup logcat messages
         """
--- a/testing/mozbase/mozdevice/mozdevice/adb_android.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb_android.py
@@ -444,27 +444,30 @@ class ADBAndroid(ADBDevice):
         if extra_args:
             extras['args'] = " ".join(extra_args)
 
         self.launch_application(app_name, "org.mozilla.gecko.BrowserApp",
                                 intent, url=url, extras=extras,
                                 wait=wait, fail_if_running=fail_if_running,
                                 timeout=timeout)
 
-    def launch_geckoview_example(self, app_name, intent="android.intent.action.Main",
-                                 moz_env=None, extra_args=None, url=None, e10s=False,
-                                 wait=True, fail_if_running=True, timeout=None):
-        """Convenience method to launch geckoview_example on Android with various
-        debugging arguments
+    def launch_activity(self, app_name, activity_name=None,
+                        intent="android.intent.action.Main",
+                        moz_env=None, extra_args=None, url=None, e10s=False,
+                        wait=True, fail_if_running=True, timeout=None):
+        """Convenience method to launch an application on Android with various
+        debugging arguments; convenient for geckoview apps.
 
         :param str app_name: Name of application (e.g.
-            `org.mozilla.geckoview_example`)
+            `org.mozilla.geckoview_example` or `org.mozilla.geckoview.test`)
+        :param str activity_name: Activity name, like `GeckoViewActivity`, or
+            `TestRunnerActivity`.
         :param str intent: Intent to launch application.
         :type moz_env: str or None
-        :param extra_args: Extra arguments to be parsed by fennec.
+        :param extra_args: Extra arguments to be parsed by the app.
         :type extra_args: str or None
         :param url: URL to open
         :type url: str or None
         :param bool e10s: If True, run in multiprocess mode.
         :param bool wait: If True, wait for application to start before
             returning.
         :param bool fail_if_running: Raise an exception if instance of
             application is already running.
@@ -481,23 +484,23 @@ class ADBAndroid(ADBDevice):
         extras = {}
 
         if moz_env:
             # moz_env is expected to be a dictionary of environment variables:
             # geckoview_example itself will set them when launched
             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 geckoview_example will read and use (e.g.
+        # Additional command line arguments that the app will read and use (e.g.
         # with a custom profile)
         if extra_args:
             extras['args'] = " ".join(extra_args)
         extras['use_multiprocess'] = e10s
         self.launch_application(app_name,
-                                "%s.GeckoViewActivity" % app_name,
+                                "%s.%s" % (app_name, activity_name),
                                 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/mozharness/scripts/android_emulator_unittest.py
+++ b/testing/mozharness/scripts/android_emulator_unittest.py
@@ -374,19 +374,21 @@ class AndroidEmulatorTest(TestingMixin, 
             os.close(tmpfd)
             self.info("Taking screenshot with %s; saving to %s" % (utility, filename))
             subprocess.call([utility, filename], env=self.query_env())
         except OSError, err:
             self.warning("Failed to take screenshot: %s" % err.strerror)
 
     def _query_package_name(self):
         if self.app_name is None:
-            # For convenience, assume geckoview_example when install target
-            # looks like geckoview.
-            if 'geckoview' in self.installer_path:
+            # For convenience, assume geckoview.test/geckoview_example when install
+            # target looks like geckoview.
+            if 'androidTest' in self.installer_path:
+                self.app_name = 'org.mozilla.geckoview.test'
+            elif 'geckoview' in self.installer_path:
                 self.app_name = 'org.mozilla.geckoview_example'
         if self.app_name is None:
             # Find appname from package-name.txt - assumes download-and-extract
             # has completed successfully.
             # The app/package name will typically be org.mozilla.fennec,
             # but org.mozilla.firefox for release builds, and there may be
             # other variations. 'aapt dump badging <apk>' could be used as an
             # alternative to package-name.txt, but introduces a dependency