Skip to content

Commit

Permalink
upgrade packages, upgrade buildrunner, upgrade device for android + r…
Browse files Browse the repository at this point in the history
…un buildrunner + parse device options
  • Loading branch information
stefanschaller committed Feb 19, 2024
1 parent ead32f4 commit a217181
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.16.5",
"flutterSdkVersion": "3.16.9",
"flavors": {}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> devices,
required List<String> devices,
@Default(true) bool networkLogs,
@Default(true) bool deviceLogs,
}) = _IntegrationTestAndroidOption;
Expand All @@ -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 =
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ part of 'integration_test_android_option.dart';
T _$identity<T>(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 {
Expand Down Expand Up @@ -183,7 +183,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
required this.browserstackAccessKey,
required this.apk,
required this.testSuite,
final List<String> devices = const ["Samsung Galaxy S9 Plus-9.0"],
final List<String> devices = const ["Samsung Galaxy S22-12.0"],
this.networkLogs = true,
this.deviceLogs = true})
: _devices = devices,
Expand Down
16 changes: 13 additions & 3 deletions lib/src/integration_test/option/integration_test_ios_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
required String browserstackUsername,
required String browserstackAccessKey,
required File testPackage,
required List<String> devices,
@Default(true) bool networkLogs,
@Default(true) bool deviceLogs,
}) = _IntegrationTestIosOption;
Expand All @@ -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,
Expand All @@ -45,6 +57,4 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
String get basicAuthValue {
return "Basic ${base64Encode(utf8.encode("$browserstackUsername:$browserstackAccessKey"))}";
}

List<String> get devices => ["iPhone 14 Plus-16"];
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ part of 'integration_test_ios_option.dart';
T _$identity<T>(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<String> get devices => throw _privateConstructorUsedError;
bool get networkLogs => throw _privateConstructorUsedError;
bool get deviceLogs => throw _privateConstructorUsedError;

Expand All @@ -37,6 +38,7 @@ abstract class $IntegrationTestIosOptionCopyWith<$Res> {
{String browserstackUsername,
String browserstackAccessKey,
File testPackage,
List<String> devices,
bool networkLogs,
bool deviceLogs});
}
Expand All @@ -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,
}) {
Expand All @@ -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<String>,
networkLogs: null == networkLogs
? _value.networkLogs
: networkLogs // ignore: cast_nullable_to_non_nullable
Expand All @@ -99,6 +106,7 @@ abstract class _$$IntegrationTestIosOptionImplCopyWith<$Res>
{String browserstackUsername,
String browserstackAccessKey,
File testPackage,
List<String> devices,
bool networkLogs,
bool deviceLogs});
}
Expand All @@ -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,
}) {
Expand All @@ -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<String>,
networkLogs: null == networkLogs
? _value.networkLogs
: networkLogs // ignore: cast_nullable_to_non_nullable
Expand All @@ -154,16 +167,27 @@ class _$IntegrationTestIosOptionImpl extends _IntegrationTestIosOption {
{required this.browserstackUsername,
required this.browserstackAccessKey,
required this.testPackage,
final List<String> devices = const ["Samsung Galaxy S22-12.0"],
this.networkLogs = true,
this.deviceLogs = true})
: super._();
: _devices = devices,
super._();

@override
final String browserstackUsername;
@override
final String browserstackAccessKey;
@override
final File testPackage;
final List<String> _devices;
@override
@JsonKey()
List<String> get devices {
if (_devices is EqualUnmodifiableListView) return _devices;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_devices);
}

@override
@JsonKey()
final bool networkLogs;
Expand All @@ -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
Expand All @@ -187,15 +211,22 @@ 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) ||
other.deviceLogs == deviceLogs));
}

@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
Expand All @@ -210,6 +241,7 @@ abstract class _IntegrationTestIosOption extends IntegrationTestIosOption {
{required final String browserstackUsername,
required final String browserstackAccessKey,
required final File testPackage,
final List<String> devices,
final bool networkLogs,
final bool deviceLogs}) = _$IntegrationTestIosOptionImpl;
const _IntegrationTestIosOption._() : super._();
Expand All @@ -221,6 +253,8 @@ abstract class _IntegrationTestIosOption extends IntegrationTestIosOption {
@override
File get testPackage;
@override
List<String> get devices;
@override
bool get networkLogs;
@override
bool get deviceLogs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ class IntegrationTestParameter {

static const String testPackagePathParam = "path";

static const String devicesParam = "devices";

// endregion
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a217181

Please sign in to comment.