From a217181a5a5cf48c6a25096b1214f7173daa16ad Mon Sep 17 00:00:00 2001 From: Stefan Schaller Date: Mon, 19 Feb 2024 16:55:25 +0100 Subject: [PATCH] upgrade packages, upgrade buildrunner, upgrade device for android + run buildrunner + parse device options --- .fvm/fvm_config.json | 2 +- README.md | 2 + .../integration_test_android_option.dart | 15 ++++++- ...tegration_test_android_option.freezed.dart | 4 +- .../option/integration_test_ios_option.dart | 16 +++++-- .../integration_test_ios_option.freezed.dart | 44 ++++++++++++++++--- .../option/integration_test_parameter.dart | 2 + pubspec.yaml | 4 +- 8 files changed, 74 insertions(+), 15 deletions(-) diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 35382a9..2f5541f 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.16.5", + "flutterSdkVersion": "3.16.9", "flavors": {} } diff --git a/README.md b/README.md index 5b61408..6c24f9b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ popd fvm dart run lib/android_tests.dart --user="$BROWSERSTACK_USERNAME" --accessKey="$BROWSERSTACK_ACCESS_KEY" --apk="../app/build/app/outputs/apk/debug/app-debug.apk" --testSuite="../app/build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk ``` +⚠️ The devices need to be comma separated, like: `--devices="Samsung Galaxy S22-12.0, Samsung Galaxy A52-11.0"`. + The file in `lib/android_tests.dart` is just wrapping the `run_android_intergration_test.dart` method. This can be customized based on your workflow. diff --git a/lib/src/integration_test/option/integration_test_android_option.dart b/lib/src/integration_test/option/integration_test_android_option.dart index ce87817..070f0d4 100644 --- a/lib/src/integration_test/option/integration_test_android_option.dart +++ b/lib/src/integration_test/option/integration_test_android_option.dart @@ -17,7 +17,7 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption { required String browserstackAccessKey, required File apk, required File testSuite, - @Default(["Samsung Galaxy S9 Plus-9.0"]) List devices, + required List devices, @Default(true) bool networkLogs, @Default(true) bool deviceLogs, }) = _IntegrationTestAndroidOption; @@ -29,10 +29,20 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption { ..addOption(IntegrationTestParameter.apkPathParam) ..addOption(IntegrationTestParameter.testSuitePathParam) ..addOption(IntegrationTestParameter.browserstackUserParam) - ..addOption(IntegrationTestParameter.browserstackAccessKeyParam); + ..addOption(IntegrationTestParameter.browserstackAccessKeyParam) + ..addOption( + IntegrationTestParameter.devicesParam, + defaultsTo: "Samsung Galaxy S22-12.0", + ); final argResults = parser.parse(arguments); + final devices = + (argResults[IntegrationTestParameter.devicesParam] as String) + .split(",") + .map((device) => device.trim()) + .toList(); + final apkPath = argResults[IntegrationTestParameter.apkPathParam] as String; final testSuitePath = @@ -41,6 +51,7 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption { return IntegrationTestAndroidOption( apk: await fileFromRelativePath(apkPath), testSuite: await fileFromRelativePath(testSuitePath), + devices: devices, browserstackUsername: argResults[IntegrationTestParameter.browserstackUserParam] as String, browserstackAccessKey: diff --git a/lib/src/integration_test/option/integration_test_android_option.freezed.dart b/lib/src/integration_test/option/integration_test_android_option.freezed.dart index 50dfb55..ce49511 100644 --- a/lib/src/integration_test/option/integration_test_android_option.freezed.dart +++ b/lib/src/integration_test/option/integration_test_android_option.freezed.dart @@ -12,7 +12,7 @@ part of 'integration_test_android_option.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); /// @nodoc mixin _$IntegrationTestAndroidOption { @@ -183,7 +183,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption { required this.browserstackAccessKey, required this.apk, required this.testSuite, - final List devices = const ["Samsung Galaxy S9 Plus-9.0"], + final List devices = const ["Samsung Galaxy S22-12.0"], this.networkLogs = true, this.deviceLogs = true}) : _devices = devices, diff --git a/lib/src/integration_test/option/integration_test_ios_option.dart b/lib/src/integration_test/option/integration_test_ios_option.dart index 653e1be..5ae71aa 100644 --- a/lib/src/integration_test/option/integration_test_ios_option.dart +++ b/lib/src/integration_test/option/integration_test_ios_option.dart @@ -15,6 +15,7 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption { required String browserstackUsername, required String browserstackAccessKey, required File testPackage, + required List devices, @Default(true) bool networkLogs, @Default(true) bool deviceLogs, }) = _IntegrationTestIosOption; @@ -25,16 +26,27 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption { final parser = ArgParser() ..addOption(IntegrationTestParameter.browserstackUserParam) ..addOption(IntegrationTestParameter.browserstackAccessKeyParam) - ..addOption(IntegrationTestParameter.testPackagePathParam); + ..addOption(IntegrationTestParameter.testPackagePathParam) + ..addOption( + IntegrationTestParameter.devicesParam, + defaultsTo: "iPhone 14 Plus-16", + ); final argResults = parser.parse(arguments); final testPackagePath = argResults[IntegrationTestParameter.testPackagePathParam] as String; + final devices = + (argResults[IntegrationTestParameter.devicesParam] as String) + .split(",") + .map((device) => device.trim()) + .toList(); + return IntegrationTestIosOption( browserstackUsername: argResults[IntegrationTestParameter.browserstackUserParam] as String, + devices: devices, browserstackAccessKey: argResults[IntegrationTestParameter.browserstackAccessKeyParam] as String, @@ -45,6 +57,4 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption { String get basicAuthValue { return "Basic ${base64Encode(utf8.encode("$browserstackUsername:$browserstackAccessKey"))}"; } - - List get devices => ["iPhone 14 Plus-16"]; } diff --git a/lib/src/integration_test/option/integration_test_ios_option.freezed.dart b/lib/src/integration_test/option/integration_test_ios_option.freezed.dart index ee1c823..02c897c 100644 --- a/lib/src/integration_test/option/integration_test_ios_option.freezed.dart +++ b/lib/src/integration_test/option/integration_test_ios_option.freezed.dart @@ -12,13 +12,14 @@ part of 'integration_test_ios_option.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); /// @nodoc mixin _$IntegrationTestIosOption { String get browserstackUsername => throw _privateConstructorUsedError; String get browserstackAccessKey => throw _privateConstructorUsedError; File get testPackage => throw _privateConstructorUsedError; + List get devices => throw _privateConstructorUsedError; bool get networkLogs => throw _privateConstructorUsedError; bool get deviceLogs => throw _privateConstructorUsedError; @@ -37,6 +38,7 @@ abstract class $IntegrationTestIosOptionCopyWith<$Res> { {String browserstackUsername, String browserstackAccessKey, File testPackage, + List devices, bool networkLogs, bool deviceLogs}); } @@ -58,6 +60,7 @@ class _$IntegrationTestIosOptionCopyWithImpl<$Res, Object? browserstackUsername = null, Object? browserstackAccessKey = null, Object? testPackage = null, + Object? devices = null, Object? networkLogs = null, Object? deviceLogs = null, }) { @@ -74,6 +77,10 @@ class _$IntegrationTestIosOptionCopyWithImpl<$Res, ? _value.testPackage : testPackage // ignore: cast_nullable_to_non_nullable as File, + devices: null == devices + ? _value.devices + : devices // ignore: cast_nullable_to_non_nullable + as List, networkLogs: null == networkLogs ? _value.networkLogs : networkLogs // ignore: cast_nullable_to_non_nullable @@ -99,6 +106,7 @@ abstract class _$$IntegrationTestIosOptionImplCopyWith<$Res> {String browserstackUsername, String browserstackAccessKey, File testPackage, + List devices, bool networkLogs, bool deviceLogs}); } @@ -119,6 +127,7 @@ class __$$IntegrationTestIosOptionImplCopyWithImpl<$Res> Object? browserstackUsername = null, Object? browserstackAccessKey = null, Object? testPackage = null, + Object? devices = null, Object? networkLogs = null, Object? deviceLogs = null, }) { @@ -135,6 +144,10 @@ class __$$IntegrationTestIosOptionImplCopyWithImpl<$Res> ? _value.testPackage : testPackage // ignore: cast_nullable_to_non_nullable as File, + devices: null == devices + ? _value._devices + : devices // ignore: cast_nullable_to_non_nullable + as List, networkLogs: null == networkLogs ? _value.networkLogs : networkLogs // ignore: cast_nullable_to_non_nullable @@ -154,9 +167,11 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption { {required this.browserstackUsername, required this.browserstackAccessKey, required this.testPackage, + final List devices = const ["Samsung Galaxy S22-12.0"], this.networkLogs = true, this.deviceLogs = true}) - : super._(); + : _devices = devices, + super._(); @override final String browserstackUsername; @@ -164,6 +179,15 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption { final String browserstackAccessKey; @override final File testPackage; + final List _devices; + @override + @JsonKey() + List get devices { + if (_devices is EqualUnmodifiableListView) return _devices; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_devices); + } + @override @JsonKey() final bool networkLogs; @@ -173,7 +197,7 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption { @override String toString() { - return 'IntegrationTestIosOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, testPackage: $testPackage, networkLogs: $networkLogs, deviceLogs: $deviceLogs)'; + return 'IntegrationTestIosOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, testPackage: $testPackage, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)'; } @override @@ -187,6 +211,7 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption { other.browserstackAccessKey == browserstackAccessKey) && (identical(other.testPackage, testPackage) || other.testPackage == testPackage) && + const DeepCollectionEquality().equals(other._devices, _devices) && (identical(other.networkLogs, networkLogs) || other.networkLogs == networkLogs) && (identical(other.deviceLogs, deviceLogs) || @@ -194,8 +219,14 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption { } @override - int get hashCode => Object.hash(runtimeType, browserstackUsername, - browserstackAccessKey, testPackage, networkLogs, deviceLogs); + int get hashCode => Object.hash( + runtimeType, + browserstackUsername, + browserstackAccessKey, + testPackage, + const DeepCollectionEquality().hash(_devices), + networkLogs, + deviceLogs); @JsonKey(ignore: true) @override @@ -210,6 +241,7 @@ abstract class _IntegrationTestIosOption extends IntegrationTestIosOption { {required final String browserstackUsername, required final String browserstackAccessKey, required final File testPackage, + final List devices, final bool networkLogs, final bool deviceLogs}) = _$IntegrationTestIosOptionImpl; const _IntegrationTestIosOption._() : super._(); @@ -221,6 +253,8 @@ abstract class _IntegrationTestIosOption extends IntegrationTestIosOption { @override File get testPackage; @override + List get devices; + @override bool get networkLogs; @override bool get deviceLogs; diff --git a/lib/src/integration_test/option/integration_test_parameter.dart b/lib/src/integration_test/option/integration_test_parameter.dart index 6bd6fb4..7a7d80f 100644 --- a/lib/src/integration_test/option/integration_test_parameter.dart +++ b/lib/src/integration_test/option/integration_test_parameter.dart @@ -13,5 +13,7 @@ class IntegrationTestParameter { static const String testPackagePathParam = "path"; + static const String devicesParam = "devices"; + // endregion } diff --git a/pubspec.yaml b/pubspec.yaml index 64d03d5..08bc019 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,9 +17,9 @@ dependencies: intl: ^0.18.1 dev_dependencies: - build_runner: ^2.4.7 + build_runner: ^2.4.8 flutter_lints: ^3.0.1 - freezed: ^2.4.6 + freezed: ^2.4.7 tapped_lints: git: url: https://github.com/tappeddev/tapped_lints.git