diff --git a/app/CONTRIBUTING.md b/app/CONTRIBUTING.md index 92a65ec2..7bfa53b9 100644 --- a/app/CONTRIBUTING.md +++ b/app/CONTRIBUTING.md @@ -103,28 +103,30 @@ This will generate icons for both iOS as well as Android. ## Updating screencast and screenshots πŸ™… _Not working yet due to login redirect, but keeping script for Sinai_ -_version (login without redirect)._ +_version (login without redirect) – can adopt once different login types are_ +_supported._ -The `generate_screenshots/generate_screencast.sh` script will create screenshots -and screencasts. It uses Xcode to record the screencast and -[`ffmpeg`](https://ffmpeg.org/) -to cut the `full.mov` to relevant subsets. +Scripts were created to click through the app using tests and record the +screeen. -Run the script with `bash generate_screenshots/generate_screencast.sh`. +A simulator with the app in its initial state (or not installed) needs to be +running. -To only update the screenshots in `../docs/screenshots` +### Screencasts + +The `generate_screendocs/generate_screencast.sh` script will create screencasts. +It uses Xcode to record the screencast and [`ffmpeg`](https://ffmpeg.org/) +to cut the `full.mov` to relevant subsets (needs to be installed). + +Run the script with `bash generate_screendocs/generate_screencast.sh`. + +## Screenshots + +To update the screenshots in `../docs/screenshots` (used in [πŸ“‘ App screens](../docs/App-screens.md), [πŸ“‘ User instructions](../docs/User-instructions.html), and the -[README](./README.md)), run the following command after adding username and -password to: - -```shell -flutter drive \ - --driver=generate_screenshots/test_driver.dart \ - --target=generate_screenshots/app_test.dart \ - --dart-define=TEST_USER= \ - --dart-define=TEST_PASSWORD= -``` +[README](./README.md)), run the following command: +`bash generate_screendocs/generate_screenshots.sh`. If the error `The following MissingPluginException was thrown running a test: MissingPluginException(No implementation found for method captureScreenshot on diff --git a/app/generate_screendocs/app_sequence_utils.dart b/app/generate_screendocs/app_sequence_utils.dart new file mode 100644 index 00000000..a082b0a2 --- /dev/null +++ b/app/generate_screendocs/app_sequence_utils.dart @@ -0,0 +1,27 @@ +import 'package:app/app.dart'; +import 'package:app/common/module.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:provider/provider.dart'; + +Future loadApp(WidgetTester tester) async { + // Part before runApp in lib/main.dart + await initServices(); + await updateGenotypeResults(); + // Load the app + await tester.pumpWidget( + ChangeNotifierProvider( + create: (context) => ActiveDrugs(), + child: PharMeApp(), + ), + ); + await tester.pumpAndSettle(); +} + +Future cleanupApp() async { + // Part after runApp in lib/main.dart + await cleanupServices(); +} + +Future wait(int seconds) async { + await Future.delayed(Duration(seconds: seconds)); +} \ No newline at end of file diff --git a/app/generate_screenshots/generate_screencast.sh b/app/generate_screendocs/generate_screencast.sh similarity index 92% rename from app/generate_screenshots/generate_screencast.sh rename to app/generate_screendocs/generate_screencast.sh index 50be89f5..4aec3e57 100644 --- a/app/generate_screenshots/generate_screencast.sh +++ b/app/generate_screendocs/generate_screencast.sh @@ -26,10 +26,10 @@ export RECORDING_PID=${!} echo "Recording process up with pid: ${RECORDING_PID}" echo "Running app" flutter drive \ ---driver=generate_screenshots/test_driver.dart \ ---target=generate_screenshots/app_test.dart \ ---dart-define=TEST_USER="$username" \ ---dart-define=TEST_PASSWORD="$password" | tee "$test_log_path" + --driver=generate_screendocs/test_driver.dart \ + --target=generate_screendocs/screencast_sequence.dart \ + --dart-define=TEST_USER="$username" \ + --dart-define=TEST_PASSWORD="$password" | tee "$test_log_path" # Write cut timestamps from test.log to cut.log diff --git a/app/generate_screendocs/generate_screenshots.sh b/app/generate_screendocs/generate_screenshots.sh new file mode 100644 index 00000000..07d3e323 --- /dev/null +++ b/app/generate_screendocs/generate_screenshots.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +read -p "Enter username: " username +read -p "Enter password: " password + +flutter drive \ + --driver=generate_screendocs/test_driver.dart \ + --target=generate_screendocs/screenshot_sequence.dart \ + --dart-define=TEST_USER="$username" \ + --dart-define=TEST_PASSWORD="$password" diff --git a/app/generate_screendocs/screencast_sequence.dart b/app/generate_screendocs/screencast_sequence.dart new file mode 100644 index 00000000..8bace9b1 --- /dev/null +++ b/app/generate_screendocs/screencast_sequence.dart @@ -0,0 +1,41 @@ +// Clicks though most parts of the app and outputs timestamp logs for cutting +// smaller screencasts in generate_screencast.sh script + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'app_sequence_utils.dart'; + +void logTimeStamp(String description) { + final timestamp = DateTime.now().millisecondsSinceEpoch; + // ignore: avoid_print + print('TIMESTAMP: $timestamp $description'); +} + +void main() { + group('click through the app and create screenshots', () { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + testWidgets('take screencast', (tester) async { + // ignore: unused_local_variable + const username = String.fromEnvironment('TEST_USER'); + // ignore: unused_local_variable + const password = String.fromEnvironment('TEST_PASSWORD'); + + await loadApp(tester); + logTimeStamp('test_start'); + + // login + await wait(5); + logTimeStamp('login'); + + // login-redirect (not working; only taking screenshot of loading screen) + // could try to use cubit function to directly sign in which will only + // open the webview and close it again + // await tester.tap(find.byType(FullWidthButton).first); + // await Future.delayed(Duration(seconds: 3)); // wait for dialog + // await takeScreenshot(tester, binding, 'login-redirect'); + + await cleanupApp(); + }); + }); +} \ No newline at end of file diff --git a/app/generate_screenshots/app_test.dart b/app/generate_screendocs/screenshot_sequence.dart similarity index 63% rename from app/generate_screenshots/app_test.dart rename to app/generate_screendocs/screenshot_sequence.dart index 2f7c9b1f..93dab51d 100644 --- a/app/generate_screenshots/app_test.dart +++ b/app/generate_screendocs/screenshot_sequence.dart @@ -3,11 +3,10 @@ import 'dart:io'; -import 'package:app/app.dart'; -import 'package:app/common/module.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; -import 'package:provider/provider.dart'; + +import 'app_sequence_utils.dart'; Future takeScreenshot( WidgetTester tester, @@ -21,12 +20,6 @@ Future takeScreenshot( await binding.takeScreenshot(fileName); } -void logTimeStamp(String description) { - final timestamp = DateTime.now().millisecondsSinceEpoch; - // ignore: avoid_print - print('TIMESTAMP: $timestamp $description'); -} - void main() { group('click through the app and create screenshots', () { final binding = IntegrationTestWidgetsFlutterBinding(); @@ -37,29 +30,12 @@ void main() { // ignore: unused_local_variable const password = String.fromEnvironment('TEST_PASSWORD'); - // Part before runApp in lib/main.dart - await initServices(); - await updateGenotypeResults(); - - // Load the app - await tester.pumpWidget( - ChangeNotifierProvider( - create: (context) => ActiveDrugs(), - child: PharMeApp(), - ), - ); - await tester.pumpAndSettle(); - - logTimeStamp('test_start'); - - // Click though the app and create screenshots + await loadApp(tester); // login - await Future.delayed(Duration(seconds: 5)); // wait for logo & screencast + await wait(5); // wait for logo await takeScreenshot(tester, binding, 'login'); - logTimeStamp('login'); - // login-redirect (not working; only taking screenshot of loading screen) // could try to use cubit function to directly sign in which will only // open the webview and close it again @@ -67,8 +43,7 @@ void main() { // await Future.delayed(Duration(seconds: 3)); // wait for dialog // await takeScreenshot(tester, binding, 'login-redirect'); - // Part after runApp in lib/main.dart - await cleanupServices(); + await cleanupApp(); }); }); } \ No newline at end of file diff --git a/app/generate_screenshots/test_driver.dart b/app/generate_screendocs/test_driver.dart similarity index 100% rename from app/generate_screenshots/test_driver.dart rename to app/generate_screendocs/test_driver.dart