Use screencap to capture on physical android device screenshots

RESOLVED FIXED in Firefox 63

Status

enhancement
RESOLVED FIXED
Last year
8 months ago

People

(Reporter: bc, Assigned: bc)

Tracking

(Blocks 1 bug)

Trunk
mozilla63
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox63 fixed)

Details

Attachments

(1 attachment)

We currently use dump_screen on desktop and android emulator tests to get screen shots but this isn't useful on physical android devices. We can use screencap on physical devices and achieve parity.
mozbase is a better component upon reflection.
Component: General → Mozbase
Works well locally with my pixel2. Try run coming up.
Attachment #8999606 - Flags: review?(gbrown)
Comment on attachment 8999606 [details] [diff] [review]
dump_screen.patch

Review of attachment 8999606 [details] [diff] [review]:
-----------------------------------------------------------------

Just a few minor concerns for your consideration...

::: testing/mozbase/mozscreenshot/mozscreenshot/__init__.py
@@ +64,5 @@
> +
> +
> +def dump_device_screen(device, log):
> +    """dumps a screenshot of a real device's entire screen to a directory specified by
> +    the MOZ_UPLOAD_DIR environment variable. Cloned from mozscreenshot.dump_screen"""

Consider documenting the parameters, at least the expected type of "device".

@@ +81,5 @@
> +        # Android 6.0 and later support mktemp.  See
> +        # https://android.googlesource.com/platform/system/core/
> +        # +/master/shell_and_utilities/README.md#android-6_0-marshmallow
> +        # We can use mktemp on real devices since we do not test on
> +        # real devices older than Android 6.0. Note we must create the

How about someone running tests locally on whatever phone they happen to have?

@@ +89,5 @@
> +        pngfilename = filename + '.png'
> +        device.mv(filename, pngfilename)
> +        if is_structured_log:
> +            log.process_start(utilityname)
> +        device.shell_output('screencap -p %s' % pngfilename)

device.shell_output('%s -p %s' % (utilityname, pngfilename))
Attachment #8999606 - Flags: review?(gbrown) → review+
(In reply to Geoff Brown [:gbrown] from comment #4)
> 
> Consider documenting the parameters, at least the expected type of "device".

Ok. I guess I should do dump_screen as well.

> 
> 
> How about someone running tests locally on whatever phone they happen to
> have?
> 

If it is older than sdk23/6.0 it would bork with an ADBError but it would only result in an error message being written to the log and since they don't get screenshots even now they wouldn't be losing functionality. Since Android 6.0 is almost 3 years old now, and we won't be supporting anything less than 7 in automation I didn't feel the complexity was worth it. I tried an approach where I used the unix timestamp for the random part of the file name but it would still have the possibility of a collision if two files were created within the same second. It worked, but the random chance of collision would still be there. In the end, I didn't feel that spending time on such an edge case which is rapidly approaching extinction was worth the time or complexity of supporting it.

> device.shell_output('%s -p %s' % (utilityname, pngfilename))

Ok.
Pushed by bclary@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/74595d74ea3e
Use screencap to capture on physical android device screenshots, r=gbrown.
https://hg.mozilla.org/mozilla-central/rev/74595d74ea3e
Status: ASSIGNED → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Blocks: 1483695
You need to log in before you can comment on or make changes to this bug.