Skip to content

Commit

Permalink
Merge branch 'main' into allow-custom-id
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianBissekkou committed Feb 19, 2024
2 parents 50fb102 + 46b56c7 commit f595fff
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 75 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 @@ -18,7 +18,7 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption {
required File apk,
required File testSuite,
String? customId,
@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 @@ -27,20 +27,23 @@ class IntegrationTestAndroidOption with _$IntegrationTestAndroidOption {
List<String> arguments,
) async {
final parser = ArgParser()
..addOption(IntegrationTestParameter.apkPathParam, mandatory: true)
..addOption(IntegrationTestParameter.testSuitePathParam, mandatory: true)
..addOption(IntegrationTestParameter.apkPathParam)
..addOption(IntegrationTestParameter.testSuitePathParam)
..addOption(IntegrationTestParameter.browserstackUserParam)
..addOption(IntegrationTestParameter.browserstackAccessKeyParam)
..addOption(
IntegrationTestParameter.browserstackUserParam,
mandatory: true,
)
..addOption(
IntegrationTestParameter.browserstackAccessKeyParam,
mandatory: true,
)
..addOption(IntegrationTestParameter.customIdParam);
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 @@ -49,6 +52,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,15 +12,14 @@ 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 {
String get browserstackUsername => throw _privateConstructorUsedError;
String get browserstackAccessKey => throw _privateConstructorUsedError;
File get apk => throw _privateConstructorUsedError;
File get testSuite => throw _privateConstructorUsedError;
String? get customId => throw _privateConstructorUsedError;
List<String> get devices => throw _privateConstructorUsedError;
bool get networkLogs => throw _privateConstructorUsedError;
bool get deviceLogs => throw _privateConstructorUsedError;
Expand All @@ -43,7 +42,6 @@ abstract class $IntegrationTestAndroidOptionCopyWith<$Res> {
String browserstackAccessKey,
File apk,
File testSuite,
String? customId,
List<String> devices,
bool networkLogs,
bool deviceLogs});
Expand All @@ -67,7 +65,6 @@ class _$IntegrationTestAndroidOptionCopyWithImpl<$Res,
Object? browserstackAccessKey = null,
Object? apk = null,
Object? testSuite = null,
Object? customId = freezed,
Object? devices = null,
Object? networkLogs = null,
Object? deviceLogs = null,
Expand All @@ -89,10 +86,6 @@ class _$IntegrationTestAndroidOptionCopyWithImpl<$Res,
? _value.testSuite
: testSuite // ignore: cast_nullable_to_non_nullable
as File,
customId: freezed == customId
? _value.customId
: customId // ignore: cast_nullable_to_non_nullable
as String?,
devices: null == devices
? _value.devices
: devices // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -123,7 +116,6 @@ abstract class _$$IntegrationTestAndroidOptionImplCopyWith<$Res>
String browserstackAccessKey,
File apk,
File testSuite,
String? customId,
List<String> devices,
bool networkLogs,
bool deviceLogs});
Expand All @@ -146,7 +138,6 @@ class __$$IntegrationTestAndroidOptionImplCopyWithImpl<$Res>
Object? browserstackAccessKey = null,
Object? apk = null,
Object? testSuite = null,
Object? customId = freezed,
Object? devices = null,
Object? networkLogs = null,
Object? deviceLogs = null,
Expand All @@ -168,10 +159,6 @@ class __$$IntegrationTestAndroidOptionImplCopyWithImpl<$Res>
? _value.testSuite
: testSuite // ignore: cast_nullable_to_non_nullable
as File,
customId: freezed == customId
? _value.customId
: customId // ignore: cast_nullable_to_non_nullable
as String?,
devices: null == devices
? _value._devices
: devices // ignore: cast_nullable_to_non_nullable
Expand All @@ -196,8 +183,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
required this.browserstackAccessKey,
required this.apk,
required this.testSuite,
this.customId,
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 All @@ -211,8 +197,6 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
final File apk;
@override
final File testSuite;
@override
final String? customId;
final List<String> _devices;
@override
@JsonKey()
Expand All @@ -231,7 +215,7 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {

@override
String toString() {
return 'IntegrationTestAndroidOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, apk: $apk, testSuite: $testSuite, customId: $customId, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)';
return 'IntegrationTestAndroidOption(browserstackUsername: $browserstackUsername, browserstackAccessKey: $browserstackAccessKey, apk: $apk, testSuite: $testSuite, devices: $devices, networkLogs: $networkLogs, deviceLogs: $deviceLogs)';
}

@override
Expand All @@ -246,8 +230,6 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
(identical(other.apk, apk) || other.apk == apk) &&
(identical(other.testSuite, testSuite) ||
other.testSuite == testSuite) &&
(identical(other.customId, customId) ||
other.customId == customId) &&
const DeepCollectionEquality().equals(other._devices, _devices) &&
(identical(other.networkLogs, networkLogs) ||
other.networkLogs == networkLogs) &&
Expand All @@ -262,7 +244,6 @@ class _$IntegrationTestAndroidOptionImpl extends _IntegrationTestAndroidOption {
browserstackAccessKey,
apk,
testSuite,
customId,
const DeepCollectionEquality().hash(_devices),
networkLogs,
deviceLogs);
Expand All @@ -283,7 +264,6 @@ abstract class _IntegrationTestAndroidOption
required final String browserstackAccessKey,
required final File apk,
required final File testSuite,
final String? customId,
final List<String> devices,
final bool networkLogs,
final bool deviceLogs}) = _$IntegrationTestAndroidOptionImpl;
Expand All @@ -298,8 +278,6 @@ abstract class _IntegrationTestAndroidOption
@override
File get testSuite;
@override
String? get customId;
@override
List<String> get devices;
@override
bool get networkLogs;
Expand Down
25 changes: 13 additions & 12 deletions lib/src/integration_test/option/integration_test_ios_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
required String browserstackAccessKey,
required File testPackage,
String? customId,
required List<String> devices,
@Default(true) bool networkLogs,
@Default(true) bool deviceLogs,
}) = _IntegrationTestIosOption;
Expand All @@ -24,17 +25,12 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
List<String> arguments,
) async {
final parser = ArgParser()
..addOption(IntegrationTestParameter.browserstackUserParam)
..addOption(IntegrationTestParameter.browserstackAccessKeyParam)
..addOption(IntegrationTestParameter.testPackagePathParam)
..addOption(
IntegrationTestParameter.browserstackUserParam,
mandatory: true,
)
..addOption(
IntegrationTestParameter.browserstackAccessKeyParam,
mandatory: true,
)
..addOption(
IntegrationTestParameter.testPackagePathParam,
mandatory: true,
IntegrationTestParameter.devicesParam,
defaultsTo: "iPhone 14 Plus-16",
)
..addOption(IntegrationTestParameter.customIdParam);

Expand All @@ -43,9 +39,16 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
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 @@ -57,6 +60,4 @@ class IntegrationTestIosOption with _$IntegrationTestIosOption {
String get basicAuthValue {
return "Basic ${base64Encode(utf8.encode("$browserstackUsername:$browserstackAccessKey"))}";
}

List<String> get devices => ["iPhone 14 Plus-16"];
}
Loading

0 comments on commit f595fff

Please sign in to comment.