diff --git a/{{cookiecutter.out_dir}}/integration_test/app_test.dart b/{{cookiecutter.out_dir}}/integration_test/app_test.dart new file mode 100644 index 0000000..cfdf7aa --- /dev/null +++ b/{{cookiecutter.out_dir}}/integration_test/app_test.dart @@ -0,0 +1,55 @@ +import 'package:flet_integration_test/flet_integration_test.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:{{ cookiecutter.project_name }}/main.dart' as app; + +void main() { + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + group('end-to-end test', () { + testWidgets('test app', (tester) async { + const testerServerUrl = String.fromEnvironment('FLET_TEST_SERVER_URL'); + late FlutterWidgetTester widgetTester; + + if (testerServerUrl.isNotEmpty) { + debugPrint('Connecting to remote tester at $testerServerUrl'); + widgetTester = await RemoteWidgetTester.connect( + tester: tester, + binding: binding, + serverUri: Uri.parse(testerServerUrl), + ); + } else { + widgetTester = FlutterWidgetTester(tester, binding); + } + + app.tester = widgetTester; + + final args = []; + + const fletTestAppUrl = String.fromEnvironment('FLET_TEST_APP_URL'); + if (fletTestAppUrl.isNotEmpty) { + args.add(fletTestAppUrl); + } + + const fletTestPidFile = String.fromEnvironment('FLET_TEST_PID_FILE_PATH'); + if (fletTestPidFile.isNotEmpty) { + args.add(fletTestPidFile); + } + + const fletTestAssetsDir = String.fromEnvironment('FLET_TEST_ASSETS_DIR'); + if (fletTestAssetsDir.isNotEmpty) { + args.add(fletTestAssetsDir); + } + + app.main(args); + + await Future.delayed(const Duration(milliseconds: 500)); + await widgetTester.pump(duration: const Duration(seconds: 1)); + await widgetTester + .pumpAndSettle(duration: const Duration(milliseconds: 100)); + await widgetTester.waitForTeardown(); + }); + }); +} diff --git a/{{cookiecutter.out_dir}}/pubspec.yaml b/{{cookiecutter.out_dir}}/pubspec.yaml index 3d346fd..236b14d 100644 --- a/{{cookiecutter.out_dir}}/pubspec.yaml +++ b/{{cookiecutter.out_dir}}/pubspec.yaml @@ -32,7 +32,7 @@ dependency_overrides: serious_python: git: url: https://github.com/flet-dev/serious-python.git - ref: android-16k + ref: main path: src/serious_python wakelock_plus: ^1.2.10 @@ -56,6 +56,13 @@ dev_dependencies: flutter_launcher_icons: ^0.14.1 flutter_native_splash: ^2.4.1 flutter_lints: ^2.0.0 + integration_test: + sdk: flutter + flet_integration_test: + git: + url: https://github.com/flet-dev/flet.git + ref: v1-flet-test + path: packages/flet_integration_test flutter: