diff --git a/packages/widget_toolkit/example/android/app/build.gradle b/packages/widget_toolkit/example/android/app/build.gradle index 8598ca66..beeb105a 100644 --- a/packages/widget_toolkit/example/android/app/build.gradle +++ b/packages/widget_toolkit/example/android/app/build.gradle @@ -51,6 +51,8 @@ android { targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName + testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner" + testInstrumentationRunnerArguments clearPackageData: "true" } buildTypes { @@ -60,6 +62,9 @@ android { signingConfig signingConfigs.debug } } + testOptions { + execution "ANDROIDX_TEST_ORCHESTRATOR" + } } flutter { @@ -68,4 +73,5 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + androidTestUtil "androidx.test:orchestrator:1.4.2" } diff --git a/packages/widget_toolkit/example/android/app/src/androidTest/java/com/primeholding/example/MainActivityTest.java b/packages/widget_toolkit/example/android/app/src/androidTest/java/com/primeholding/example/MainActivityTest.java new file mode 100644 index 00000000..c7142da9 --- /dev/null +++ b/packages/widget_toolkit/example/android/app/src/androidTest/java/com/primeholding/example/MainActivityTest.java @@ -0,0 +1,33 @@ +package com.primeholding.example; // replace "com.example.myapp" with your app's package + +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 your AndroidManifest is using: 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); + } +} \ No newline at end of file diff --git a/packages/widget_toolkit/example/integration_test/tests/edit_fields_test.dart b/packages/widget_toolkit/example/integration_test/tests/edit_fields_test.dart index 7f3ea217..5e60c260 100644 --- a/packages/widget_toolkit/example/integration_test/tests/edit_fields_test.dart +++ b/packages/widget_toolkit/example/integration_test/tests/edit_fields_test.dart @@ -6,7 +6,7 @@ void main() { final patrolBaseConfig = PatrolBaseConfig(); patrolBaseConfig.patrol('TextFieldDialog debug test', ($) async { - const testInput = 'Test Input'; + const testInput = 'Test'; final editFieldsPage = EditFieldsPage($); @@ -17,6 +17,7 @@ void main() { await editFieldsPage.tapFirstNameDialog(); await editFieldsPage.setFirstName(testInput); await editFieldsPage.tapSaveButton(); + //Check that the keyboard is displayed await Future.delayed(const Duration(seconds: 30)); }); }