driver: screenshot generation WIP
This commit is contained in:
parent
1b08c36429
commit
5fa0d51382
4 changed files with 70 additions and 12 deletions
BIN
en-1-collection_overlay.png
Normal file
BIN
en-1-collection_overlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
BIN
logo.gif
Normal file
BIN
logo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
59
scripts/screenshot_post_process.sh
Executable file
59
scripts/screenshot_post_process.sh
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
# process raw screenshots from test driver to generate:
|
||||
# - scaled down versions for IzzyOnDroid
|
||||
# - framed versions for Google Play
|
||||
|
||||
# expects:
|
||||
# - ImageMagick 6
|
||||
# - raw screenshots sized at 1080x2280 in `/screenshots/raw`
|
||||
|
||||
DEVICE_OVERLAY=~/code/aves_extra/screenshots/device_overlay_s10e.png
|
||||
DEVICE_FRAME=~/code/aves_extra/screenshots/device_frame_s10e.png
|
||||
# DEVICE_FRAME: dimensions of DEVICE_FRAME
|
||||
FRAME_SIZE=1142x2410
|
||||
# FRAME_OFFSET: offset for content in DEVICE_FRAME
|
||||
FRAME_OFFSET=31x53
|
||||
# PLAY_SIZE: contain FRAME_SIZE in 9:16
|
||||
PLAY_SIZE=1356x2410
|
||||
|
||||
cd screenshots || exit
|
||||
|
||||
# add Android system overlay
|
||||
for source in raw/*/*; do
|
||||
if [[ -f "$source" ]]; then
|
||||
target=${source/raw/overlay}
|
||||
echo "$source -> $target"
|
||||
mkdir -p "$(dirname "$target")"
|
||||
convert "$source" $DEVICE_OVERLAY -composite "$target"
|
||||
fi
|
||||
done
|
||||
|
||||
# izzy: scale down
|
||||
for source in overlay/*/*; do
|
||||
if [[ -f "$source" ]]; then
|
||||
target=${source/overlay/izzy}
|
||||
echo "$source -> $target"
|
||||
mkdir -p "$(dirname "$target")"
|
||||
convert -resize 350x "$source" "$target"
|
||||
fi
|
||||
done
|
||||
|
||||
# play: add device frame
|
||||
for source in overlay/*/*; do
|
||||
if [[ -f "$source" ]]; then
|
||||
target=${source/overlay/framed}
|
||||
echo "$source -> $target"
|
||||
mkdir -p "$(dirname "$target")"
|
||||
convert "$source" -background transparent -splice $FRAME_OFFSET -extent $FRAME_SIZE $DEVICE_FRAME -composite "$target"
|
||||
fi
|
||||
done
|
||||
|
||||
# play: fix aspect ratio
|
||||
for source in framed/*/*; do
|
||||
if [[ -f "$source" ]]; then
|
||||
target=${source/framed/play}
|
||||
echo "$source -> $target"
|
||||
mkdir -p "$(dirname "$target")"
|
||||
convert "$source" -gravity center -background transparent -extent $PLAY_SIZE "$target"
|
||||
fi
|
||||
done
|
|
@ -14,13 +14,11 @@ import 'utils/driver_extension.dart';
|
|||
late FlutterDriver driver;
|
||||
String _languageCode = '';
|
||||
|
||||
const outputDirectory = 'screenshots';
|
||||
const outputDirectory = 'screenshots/raw';
|
||||
|
||||
void main() {
|
||||
group('[Aves app]', () {
|
||||
setUpAll(() async {
|
||||
await Directory(outputDirectory).create();
|
||||
|
||||
await copyContent(screenshotsSourceDir, screenshotsTargetDirAdb);
|
||||
await Future.forEach<String>(
|
||||
[
|
||||
|
@ -40,7 +38,8 @@ void main() {
|
|||
});
|
||||
|
||||
test('scan media dir', () => driver.scanMediaDir(screenshotsTargetDirAndroid));
|
||||
SupportedLocales.languagesByLanguageCode.keys.forEach((languageCode) {
|
||||
SupportedLocales.languagesByLanguageCode.keys.forEach((languageCode) async {
|
||||
await Directory('$outputDirectory/$_languageCode').create(recursive: true);
|
||||
setLanguage(languageCode);
|
||||
configureCollectionVisibility(AppDebugAction.prepScreenshotThumbnails);
|
||||
collection();
|
||||
|
@ -65,7 +64,7 @@ Future<void> _search(String query, String chipKey) async {
|
|||
|
||||
Future<void> _takeScreenshot(FlutterDriver driver, String name) async {
|
||||
final pixels = await driver.screenshot();
|
||||
final file = File('$outputDirectory/$_languageCode-$name.png');
|
||||
final file = File('$outputDirectory/$_languageCode/$name.png');
|
||||
await file.writeAsBytes(pixels);
|
||||
print('* saved screenshot to ${file.path}');
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ void collection() {
|
|||
await _search('birds', 'tag-birds');
|
||||
await _search('South Korea', 'tag-South Korea');
|
||||
|
||||
await _takeScreenshot(driver, '1-collection');
|
||||
await _takeScreenshot(driver, '1');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -129,7 +128,7 @@ void viewer() {
|
|||
await driver.doubleTap(imageView);
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
await _takeScreenshot(driver, '2-viewer');
|
||||
await _takeScreenshot(driver, '2');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -140,9 +139,9 @@ void info() {
|
|||
await driver.scroll(verticalPageView, 0, -600, const Duration(milliseconds: 400));
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
await _takeScreenshot(driver, '3-info-basic');
|
||||
await _takeScreenshot(driver, '3');
|
||||
|
||||
await driver.scroll(verticalPageView, 0, -800, const Duration(milliseconds: 600));
|
||||
await driver.scroll(verticalPageView, 0, -750, const Duration(milliseconds: 600));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
final gpsTile = find.descendant(
|
||||
|
@ -152,7 +151,7 @@ void info() {
|
|||
await driver.tap(gpsTile);
|
||||
await driver.waitUntilNoTransientCallbacks();
|
||||
|
||||
await _takeScreenshot(driver, '3-info-metadata');
|
||||
await _takeScreenshot(driver, '4');
|
||||
|
||||
await pressDeviceBackButton();
|
||||
await driver.waitUntilNoTransientCallbacks();
|
||||
|
@ -170,7 +169,7 @@ void stats() {
|
|||
await driver.tapKeyAndWait('appbar-menu-button');
|
||||
await driver.tapKeyAndWait('menu-stats');
|
||||
|
||||
await _takeScreenshot(driver, '5-stats');
|
||||
await _takeScreenshot(driver, '5');
|
||||
|
||||
await pressDeviceBackButton();
|
||||
await driver.waitUntilNoTransientCallbacks();
|
||||
|
@ -182,6 +181,6 @@ void countries() {
|
|||
await driver.tapKeyAndWait('appbar-leading-button');
|
||||
await driver.tapKeyAndWait('drawer-page-/countries');
|
||||
|
||||
await _takeScreenshot(driver, '6-countries');
|
||||
await _takeScreenshot(driver, '6');
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue