diff --git a/android/app/build.gradle b/android/app/build.gradle index 191d884db1..d2c61d6a86 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -51,6 +51,8 @@ android { versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true + testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner" + testInstrumentationRunnerArguments clearPackageData: "true" } signingConfigs { @@ -75,6 +77,9 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + testOptions { + execution "ANDROIDX_TEST_ORCHESTRATOR" + } } flutter { @@ -88,6 +93,7 @@ dependencies { androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation 'androidx.multidex:multidex:2.0.1' + androidTestUtil "androidx.test:orchestrator:1.5.1" } apply plugin: 'com.google.gms.google-services' diff --git a/android/app/src/androidTest/java/app/twake/android/chat/MainActivityTest.java b/android/app/src/androidTest/java/app/twake/android/chat/MainActivityTest.java new file mode 100644 index 0000000000..2f3f1ffcd6 --- /dev/null +++ b/android/app/src/androidTest/java/app/twake/android/chat/MainActivityTest.java @@ -0,0 +1,34 @@ +package app.twake.android.chat; + +import androidx.test.platform.app.InstrumentationRegistry; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import pl.leancode.patrol.PatrolJUnitRunner; + +@RunWith(Parameterized.class) +public class MainActivityTest { + @Parameters(name = "{0}") + public static Object[] testCases() { + PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); + // replace "MainActivity.class" with "io.flutter.embedding.android.FlutterActivity.class" + // if in AndroidManifest.xml in manifest/application/activity you have + // android:name="io.flutter.embedding.android.FlutterActivity" + instrumentation.setUp(MainActivity.class); + instrumentation.waitForPatrolAppService(); + return instrumentation.listDartTests(); + } + + public MainActivityTest(String dartTestName) { + this.dartTestName = dartTestName; + } + + private final String dartTestName; + + @Test + public void runDartTest() { + PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); + instrumentation.runDartTest(dartTestName); + } +} diff --git a/pubspec.lock b/pubspec.lock index 4ef7431479..2aba13470c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -563,6 +563,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.2" + dispose_scope: + dependency: transitive + description: + name: dispose_scope + sha256: "48ec38ca2631c53c4f8fa96b294c801e55c335db5e3fb9f82cede150cfe5a2af" + url: "https://pub.dev" + source: hosted + version: "2.1.0" dynamic_color: dependency: "direct main" description: @@ -2172,6 +2180,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.1" + patrol: + dependency: "direct dev" + description: + name: patrol + sha256: "7e7c346890fa234af948fbdf024e09e80142deef7aef572dead1001446ca853c" + url: "https://pub.dev" + source: hosted + version: "3.13.1" + patrol_finders: + dependency: transitive + description: + name: patrol_finders + sha256: "6dfa07aa951f1d769f0a736f4fd4eb63d99ef32931aaaa39e0d24126ddfe9cd9" + url: "https://pub.dev" + source: hosted + version: "2.5.1" + patrol_log: + dependency: transitive + description: + name: patrol_log + sha256: fb67013a5305cfd30a374cce3c5ea5a99613335d8cf31c250ecb0dda75deec21 + url: "https://pub.dev" + source: hosted + version: "0.2.1" permission_handler: dependency: "direct main" description: @@ -3401,5 +3433,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.5.0-259.0.dev <4.0.0" - flutter: ">=3.19.3" + dart: ">=3.5.0 <4.0.0" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index c719deb07e..3236b7dda7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -229,6 +229,7 @@ dev_dependencies: msix: ^3.6.2 translations_cleaner: ^0.0.5 mockito: 5.4.4 + patrol: 3.13.1 flutter_launcher_icons: @@ -325,4 +326,9 @@ dependency_overrides: cider: link_template: - tag: https://github.com/linagora/twake-on-matrix/releases/tag/%tag% # initial release link template \ No newline at end of file + tag: https://github.com/linagora/twake-on-matrix/releases/tag/%tag% # initial release link template + +patrol: + app_name: Twake Chat + android: + package_name: app.twake.android.chat \ No newline at end of file