From f3916632c9b7a22982940ff10ce96d68cc9ab27c Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Fri, 24 Nov 2023 11:10:07 +0100 Subject: [PATCH] more clean ups --- dev/e2e_app/android/app/build.gradle | 4 +- .../android/app/src/main/AndroidManifest.xml | 2 +- dev/e2e_app/integration_test/common.dart | 2 +- dev/e2e_app/lib/main.dart | 14 ++-- dev/e2e_app/lib/scrolling_screen.dart | 2 +- dev/e2e_app/pubspec.yaml | 4 +- .../patrol/example/android/app/build.gradle | 18 ----- .../android/app/src/main/AndroidManifest.xml | 2 +- .../example/integration_test/done_test.dart | 71 ------------------- .../example/integration_test/main_test.dart | 65 +++++++++++++++++ packages/patrol/example/pubspec.yaml | 6 +- 11 files changed, 83 insertions(+), 107 deletions(-) delete mode 100644 packages/patrol/example/integration_test/done_test.dart create mode 100644 packages/patrol/example/integration_test/main_test.dart diff --git a/dev/e2e_app/android/app/build.gradle b/dev/e2e_app/android/app/build.gradle index cb9dd3f5c3..9aff81a2e9 100644 --- a/dev/e2e_app/android/app/build.gradle +++ b/dev/e2e_app/android/app/build.gradle @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdk 33 - namespace "pl.leancode.patrol.example" + namespace "pl.leancode.patrol.e2e_app" kotlinOptions { jvmTarget = "1.8" @@ -38,7 +38,7 @@ android { } defaultConfig { - applicationId "pl.leancode.patrol.example" + applicationId "pl.leancode.patrol.e2e_app" minSdk 21 targetSdk 33 versionCode flutterVersionCode.toInteger() diff --git a/dev/e2e_app/android/app/src/main/AndroidManifest.xml b/dev/e2e_app/android/app/src/main/AndroidManifest.xml index b1fb866e61..0fc4be994e 100644 --- a/dev/e2e_app/android/app/src/main/AndroidManifest.xml +++ b/dev/e2e_app/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + xmlns:tools="http://schemas.android.com/tools"> diff --git a/dev/e2e_app/integration_test/common.dart b/dev/e2e_app/integration_test/common.dart index 6cdfff56e0..75ed61f962 100644 --- a/dev/e2e_app/integration_test/common.dart +++ b/dev/e2e_app/integration_test/common.dart @@ -1,6 +1,6 @@ +import 'package:e2e_app/main.dart' as app_main; import 'package:flutter_test/flutter_test.dart'; import 'package:patrol/patrol.dart'; -import 'package:patrol_example/main.dart' as app_main; export 'package:flutter_test/flutter_test.dart'; export 'package:patrol/patrol.dart'; diff --git a/dev/e2e_app/lib/main.dart b/dev/e2e_app/lib/main.dart index 1c378b738a..363aefb648 100644 --- a/dev/e2e_app/lib/main.dart +++ b/dev/e2e_app/lib/main.dart @@ -1,12 +1,12 @@ +import 'package:e2e_app/loading_screen.dart'; +import 'package:e2e_app/location_screen.dart'; +import 'package:e2e_app/notifications_screen.dart'; +import 'package:e2e_app/overlay_screen.dart'; +import 'package:e2e_app/permissions_screen.dart'; +import 'package:e2e_app/scrolling_screen.dart'; +import 'package:e2e_app/webview_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_timezone/flutter_timezone.dart'; -import 'package:patrol_example/loading_screen.dart'; -import 'package:patrol_example/location_screen.dart'; -import 'package:patrol_example/notifications_screen.dart'; -import 'package:patrol_example/overlay_screen.dart'; -import 'package:patrol_example/permissions_screen.dart'; -import 'package:patrol_example/scrolling_screen.dart'; -import 'package:patrol_example/webview_screen.dart'; import 'package:timezone/data/latest.dart' as tz_data; import 'package:timezone/timezone.dart' as tz; diff --git a/dev/e2e_app/lib/scrolling_screen.dart b/dev/e2e_app/lib/scrolling_screen.dart index 9989d206ea..49849d7729 100644 --- a/dev/e2e_app/lib/scrolling_screen.dart +++ b/dev/e2e_app/lib/scrolling_screen.dart @@ -1,5 +1,5 @@ +import 'package:e2e_app/keys.dart'; import 'package:flutter/material.dart'; -import 'package:patrol_example/keys.dart'; class ScrollingScreen extends StatelessWidget { const ScrollingScreen({super.key}); diff --git a/dev/e2e_app/pubspec.yaml b/dev/e2e_app/pubspec.yaml index e1a6acf695..6b5ab9bb63 100644 --- a/dev/e2e_app/pubspec.yaml +++ b/dev/e2e_app/pubspec.yaml @@ -1,4 +1,4 @@ -name: example +name: e2e_app description: A new Flutter project. publish_to: none version: 1.0.0+1 @@ -31,6 +31,6 @@ flutter: patrol: app_name: Patrol example android: - package_name: pl.leancode.patrol.example + package_name: pl.leancode.patrol.e2e_app ios: bundle_id: pl.leancode.patrol.Example diff --git a/packages/patrol/example/android/app/build.gradle b/packages/patrol/example/android/app/build.gradle index d670c8f325..5e72966cdf 100644 --- a/packages/patrol/example/android/app/build.gradle +++ b/packages/patrol/example/android/app/build.gradle @@ -50,7 +50,6 @@ android { targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - multiDexEnabled true testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner" testInstrumentationRunnerArguments clearPackageData: "true" } @@ -61,26 +60,9 @@ android { buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } - - flavorDimensions "default" - - productFlavors { - dev { - dimension "default" - resValue "string", "app_name", "DEV Challenge" - applicationIdSuffix ".dev" - } - - prod { - dimension "default" - resValue "string", "app_name", "Challenge" - } - } } flutter { diff --git a/packages/patrol/example/android/app/src/main/AndroidManifest.xml b/packages/patrol/example/android/app/src/main/AndroidManifest.xml index 4e9f6487fe..c42ca1d16f 100644 --- a/packages/patrol/example/android/app/src/main/AndroidManifest.xml +++ b/packages/patrol/example/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ ((box) => box.color == color) - .scrollTo() - .tap(); - } - - await $('Ready!').tap(); - - // Why doesn't it work? - // await $(ElevatedButton).$(Center).$('Fluttercon').tap(); - - await $(PTElevatedButton) - .which((widget) => widget.caption == 'Fluttercon') - .tap(); - - await $(ListTile).containing($(Icons.flutter_dash)).$('click').tap(); - - await $(ElevatedButton) - .which( - (widget) => widget.enabled, - ) - .at(2) - .scrollTo() - .tap(); - - if (await $.native.isPermissionDialogVisible()) { - await $.native.grantPermissionWhenInUse(); - } - - await $.native.pressHome(); - await $.native.openNotifications(); - - // wait for notification to show up - await Future.delayed(const Duration(seconds: 5)); - - await $.native.openNotifications(); - - await $.native.tapOnNotificationByIndex(0); - - await $.pumpAndSettle(); - - expect($('Congratulations!'), findsOneWidget); - }, - ); -} diff --git a/packages/patrol/example/integration_test/main_test.dart b/packages/patrol/example/integration_test/main_test.dart new file mode 100644 index 0000000000..1b65dd0103 --- /dev/null +++ b/packages/patrol/example/integration_test/main_test.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:patrol/patrol.dart'; +import 'package:patrol_challenge/main.dart'; +import 'package:patrol_challenge/pages/quiz/form_page.dart'; +import 'package:patrol_challenge/ui/components/button/elevated_button.dart'; +import 'package:patrol_challenge/ui/style/colors.dart'; + +void main() { + patrolTest('main flow', ($) async { + await $.pumpWidgetAndSettle(const MyApp()); + + await $('Go to the quiz').tap(); + + await $('Start').tap(); + + await $(TextField).enterText('text'); + + final colors = [PTColors.lcYellow, PTColors.lcBlack, PTColors.lcWhite]; + + for (final color in colors) { + await $(SelectableBox) + .which((box) => box.color == color) + .scrollTo() + .tap(); + } + + await $('Ready!').tap(); + + // Why doesn't it work? + // await $(ElevatedButton).$(Center).$('Fluttercon').tap(); + + await $(PTElevatedButton) + .which((widget) => widget.caption == 'Fluttercon') + .tap(); + + await $(ListTile).containing($(Icons.flutter_dash)).$('click').tap(); + + await $(ElevatedButton) + .which( + (widget) => widget.enabled, + ) + .at(2) + .scrollTo() + .tap(); + + if (await $.native.isPermissionDialogVisible()) { + await $.native.grantPermissionWhenInUse(); + } + + await $.native.pressHome(); + await $.native.openNotifications(); + + // wait for notification to show up + await Future.delayed(const Duration(seconds: 5)); + + await $.native.openNotifications(); + + await $.native.tapOnNotificationByIndex(0); + + await $.pumpAndSettle(); + + expect($('Congratulations!'), findsOneWidget); + }); +} diff --git a/packages/patrol/example/pubspec.yaml b/packages/patrol/example/pubspec.yaml index 9eb3f0fbb2..2448f00ead 100644 --- a/packages/patrol/example/pubspec.yaml +++ b/packages/patrol/example/pubspec.yaml @@ -32,7 +32,8 @@ dev_dependencies: flutter_test: sdk: flutter leancode_lint: ^6.0.0 - patrol: ^2.3.1 + patrol: + path: .. flutter_launcher_icons: android: 'launcher_icon' @@ -60,8 +61,7 @@ flutter: weight: 600 patrol: - flavor: dev android: package_name: com.example.patrol_challenge ios: - bundle_id: pl.leancode.patrol.challenge.dev + bundle_id: pl.leancode.patrol.challenge