Commit f74063bc authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Fix --wait-for-java-debugger for smoke tests

It was getting the package name from --apk-under-test, but for smoke
tests the apk-under-test != targetPackage.

Bug: None
Change-Id: I39989b3417d3cdc9320d0231c2b78a3dadb19744
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216031
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771846}
parent 08c63e8a
......@@ -139,6 +139,12 @@ _CURRENT_FOCUS_CRASH_RE = re.compile(
r'\s*mCurrentFocus.*Application (Error|Not Responding): (\S+)}')
def _GetTargetPackageName(test_apk):
# apk_under_test does not work for smoke tests, where it is set to an
# apk that is not listed as the targetPackage in the test apk's manifest.
return test_apk.GetAllInstrumentations()[0]['android:targetPackage']
class LocalDeviceInstrumentationTestRun(
local_device_test_run.LocalDeviceTestRun):
def __init__(self, env, test_instance):
......@@ -158,6 +164,8 @@ class LocalDeviceInstrumentationTestRun(
#override
def SetUp(self):
target_package = _GetTargetPackageName(self._test_instance.test_apk)
@local_device_environment.handle_shard_failures_with(
self._env.BlacklistDevice)
@trace_event.traced
......@@ -272,18 +280,10 @@ class LocalDeviceInstrumentationTestRun(
def set_debug_app(dev):
# Set debug app in order to enable reading command line flags on user
# builds
package_name = None
if self._test_instance.apk_under_test:
package_name = self._test_instance.apk_under_test.GetPackageName()
elif self._test_instance.test_apk:
package_name = self._test_instance.test_apk.GetPackageName()
else:
logging.error("Couldn't set debug app: no package name found")
return
cmd = ['am', 'set-debug-app', '--persistent']
if self._test_instance.wait_for_java_debugger:
cmd.append('-w')
cmd.append(package_name)
cmd.append(target_package)
dev.RunShellCommand(cmd, check_return=True)
@trace_event.traced
......@@ -387,10 +387,9 @@ class LocalDeviceInstrumentationTestRun(
self._skia_gold_session_manager = gold_utils.SkiaGoldSessionManager(
self._skia_gold_work_dir, self._test_instance.skia_gold_properties)
if self._test_instance.wait_for_java_debugger:
apk = self._test_instance.apk_under_test or self._test_instance.test_apk
logging.warning('*' * 80)
logging.warning('Waiting for debugger to attach to process: %s',
apk.GetPackageName())
target_package)
logging.warning('*' * 80)
#override
......
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