-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Screenshots and screen recordings of tests #541
Closed
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4216d52
Initial work on screenshots and screen recordings.
donataswix 62dbbb0
creating directory recursivley, avoding errors
rotemmiz d0b98cf
cleanup
rotemmiz 7fe0e4d
Some cleanup.
donataswix 7619257
Fix ArtifactsPathsProvider tests.
donataswix b792353
Fix coverage.
donataswix b4c51a9
Queue videos to be copied at the end of all tests.
donataswix 120f88e
Merge branch 'master' into screenshots-and-videos
donataswix 0fa555b
Bring back --take-screenshots and --record-videos flags
donataswix 0aa6740
Fix EmulatorDriver.stopVideo() to return only on process exit.
donataswix 3e738a9
Don't create artifacts for e2e tests by default.
donataswix db690b0
Helpful warning about missing --artifacts-location.
donataswix 05b6050
also support video/screenshot trigger on Jest
rotemmiz ca67b24
Move new methods to AndroidDriver.
donataswix b92ae9e
"failing" option for --take-screenshots and --record-videos.
donataswix c4485b7
Fix test failures on CI.
donataswix afa1bc9
Merge branch 'master' into screenshots-and-videos
donataswix 60f8a41
Add upload artifacts
yershalom fae2a7c
Add the upload script
yershalom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const _ = require('lodash'); | ||
const path = require('path'); | ||
const tempfile = require('tempfile'); | ||
const Emulator = require('./android/Emulator'); | ||
const EmulatorTelnet = require('./android/EmulatorTelnet'); | ||
const Environment = require('../utils/environment'); | ||
|
@@ -81,6 +82,66 @@ class EmulatorDriver extends AndroidDriver { | |
await telnet.connect(port); | ||
await telnet.kill(); | ||
} | ||
|
||
async takeScreenshot(deviceId) { | ||
const dst = tempfile('.png'); | ||
const src = '/sdcard/screenshot.png'; | ||
await this.adb.adbCmd(deviceId, `shell screencap ${src}`); | ||
await this.adb.adbCmd(deviceId, `pull ${src} ${dst}`); | ||
return dst; | ||
} | ||
|
||
async startVideo(deviceId) { | ||
const adb = this.adb; | ||
|
||
await adb.adbCmd(deviceId, `shell rm -f /sdcard/recording.mp4`); | ||
let {width, height} = await adb.getScreenSize(); | ||
let promise = spawnRecording(width *= 2, height *= 2); | ||
promise.catch(handleRecordingTermination); | ||
|
||
let recording = false; | ||
let size = 0; | ||
while (!recording) { | ||
size = 0; | ||
recording = true; | ||
// console.log('>>> waiting for recording to start'); | ||
try { | ||
size = await adb.getFileSize(deviceId, '/sdcard/recording.mp4'); | ||
if (size < 1) { | ||
recording = false; | ||
} | ||
} catch (e) { | ||
recording = false; | ||
} | ||
} | ||
|
||
this._video = promise.childProcess; | ||
|
||
function spawnRecording(width, height) { | ||
return adb.spawn(deviceId, [ | ||
'shell', 'screenrecord', '--size', width + 'x' + height, '--verbose', '/sdcard/recording.mp4' | ||
]); | ||
} | ||
|
||
function handleRecordingTermination(result) { | ||
const proc = result.childProcess; | ||
if (proc.exitCode !== 0 && proc.signalCode !== 'SIGINT') { | ||
promise = spawnRecording(width >>= 1, height >>= 1); | ||
promise.catch(handleRecordingTermination); | ||
} | ||
} | ||
} | ||
|
||
async stopVideo(deviceId) { | ||
if (this._video) { | ||
this._video.kill(2); | ||
await this.adb.adbCmd(deviceId, 'shell sleep 1'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this line and saw the corrupted videos you talked about.
WDYT ? |
||
const dest = tempfile('.mp4'); | ||
await this.adb.adbCmd(deviceId, `pull /sdcard/recording.mp4 ${dest}`); | ||
await this.adb.adbCmd(deviceId, `shell rm /sdcard/recording.mp4`); | ||
return dest; | ||
} | ||
} | ||
} | ||
|
||
module.exports = EmulatorDriver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from https://developer.android.com/studio/command-line/adb.html
"Sets the video size: 1280x720. The default value is the device's native display resolution (if supported), 1280x720 if not. For best results, use a size supported by your device's Advanced Video Coding (AVC) encoder."
Did you encounter any issues with default values ?
Why do you use twice the native resolution for recording ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was left over from my tests, will be removed.