New issue
Advanced search Search tips

Issue 715583 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Instrumentation Tests do not report when phone screen is off

Project Member Reported by peconn@chromium.org, Apr 26 2017

Issue description

When running instrumentation tests on a local device, if the device screen is off the tests all fail with (CRASHED). It'd be nice if the test scripts (like run_chrome_public_test_apk) could detect that the screen is off and print a more informative error.
 
Cc: jbudorick@chromium.org
Components: Test>Android
Labels: OS-Android
Owner: shenghua...@chromium.org
Status: Assigned (was: Untriaged)
We could also look at turning the screen on if we detect that it's off.

A couple of starting tips:
 - DeviceUtils has a couple of functions for dealing w/ the screen in SetScreen and IsScreenOn.
 - We do some additional screen-on settings work on the bots in provision_devices. Not sure if those will be necessary here.
Cc: yolandyan@chromium.org
'SetScreen' works differently with different devices:
1. provision_devices (or devices with no screen lock)
Since the provision_devices disabled the lock screen, the phone screen is either 'off' or 'on'. 'SetScreen' can easily turn screen 'on' without dealing with 'lock' screen.
Here is a CL helping with provision_devices https://codereview.chromium.org/2891543002

2. normal local devices (non provision_devices)
The phone screen has 3 modes, 'off', 'lock' and 'on', and 'SetScreen' can only turn screen from 'off' to 'lock'. Those tests needing screen-monitoring (like some of content_shell_test_apk) would fail, since they requires screen 'on' to run those tests.


Unfortunately since local devices have various 'unlock' ways (could be password/patterns/swipe), it is hardly to have a 'SetScreenOnFromLock' function. But we could try to detect phone screen and print error before running tests. Some ideas:
Set e.g. 'NeedScreenOn' flag in Manifest.xml of the package needing screen on, and check the flag in test_runner. If the screen is not 'on' then print error (and stop the package tests run).
Similar to the 'junit-4' example: https://codereview.chromium.org/2668203005/
https://codesearch.chromium.org/chromium/src/chrome/android/javatests/AndroidManifest.xml?q=chromium-junit4&dr=C&l=60

One thing needs to mention is, this will block the whole package run, though probably just some of the tests needing screen on.



If we just want to print out error message of screen-off, found that 'content_shell_apk' Java test runner has screen-on detecting function, it detects screen when run test and print error in logcat. Probably could do some similar to Java side TestRunner for chrome_public_test_apk like this: https://cs.chromium.org/chromium/src/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestCommon.java?type=cs&l=60

Which is the case?

I would prefer that we do this on the python side, as it:
 - can at least try to turn the screen on
 - fails faster if it can't do so

I think we should require the screen be on either at the APK level or globally. (The latter is probably a better starting point.) The test runner should try to turn on the screen; if it fails to do so, it should raise an exception.
Cc: -yolandyan@chromium.org
Owner: ----
Status: Available (was: Assigned)

Sign in to add a comment