diff --git a/.travis.yml b/.travis.yml index 2f1438d..a61a93f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ matrix: - platform-tools - build-tools-28.0.3 - android-28 + - android-29 - extra-android-m2repository - extra-google-m2repository - extra-google-android-support diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 63ff368..13f1265 100755 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -11,5 +11,5 @@ # Publish 1. Bump up versions in these files: *ios/testfairy.podspec*, *android/build.gradle*, *pubspec.yaml*, *example/pubspec.yaml*, *CHANGELOG.md*. -2. Run `dartfmt -w lib example/lib example/test example/test_driver` +2. Run `dartfmt -w lib example/lib example/test example/test_driver example/integration_test` 3. Publish to pub. diff --git a/android-ci.sh b/android-ci.sh index 1a0b765..014b2b0 100644 --- a/android-ci.sh +++ b/android-ci.sh @@ -2,6 +2,7 @@ set -e # prepare yes | sdkmanager "platforms;android-28" +yes | sdkmanager "platforms;android-29" wget https://services.gradle.org/distributions/gradle-3.5-bin.zip unzip -qq gradle-3.5-bin.zip export GRADLE_HOME=$PWD/gradle-3.5 @@ -19,4 +20,5 @@ cd .. ../flutter/bin/flutter analyze $PWD/lib #../flutter/bin/flutter analyze $PWD/example/lib #../flutter/bin/flutter analyze $PWD/example/test -#../flutter/bin/flutter analyze $PWD/example/test_driver \ No newline at end of file +#../flutter/bin/flutter analyze $PWD/example/test_driver +#../flutter/bin/flutter analyze $PWD/example/integration_test \ No newline at end of file diff --git a/android/src/main/java/com/testfairy/flutter/TestfairyFlutterPlugin.java b/android/src/main/java/com/testfairy/flutter/TestfairyFlutterPlugin.java index 2ca76e8..a0c16cc 100755 --- a/android/src/main/java/com/testfairy/flutter/TestfairyFlutterPlugin.java +++ b/android/src/main/java/com/testfairy/flutter/TestfairyFlutterPlugin.java @@ -315,6 +315,7 @@ public void onMethodCall(MethodCall call, Result result) { case "hideWidget": hideWidget(); result.success(null); + break; default: result.notImplemented(); break; diff --git a/example/integration_test/app_integration_test.dart b/example/integration_test/app_integration_test.dart new file mode 100644 index 0000000..118f315 --- /dev/null +++ b/example/integration_test/app_integration_test.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +// ignore: avoid_relative_lib_imports +import '../lib/main.dart' as app; + +void main() { + group('Testfairy Plugin Tests', () { + Finder findByValueKey(String keyName) { + final ValueKey key = ValueKey(keyName); + return find.byKey(key); + } + + final Finder errorTextFinder = findByValueKey('errorMessage'); + final Finder testingFinder = findByValueKey('testing'); + final Finder scrollerFinder = findByValueKey('scroller'); + + setUpAll(() async { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + }); + + // Helper test builder: + // 1. Scrolls and finds a button that runs a test case. + // 2. Before waiting the test to complete, allows you to inject additional logic. + // 3. Waits for test completion. + // 4. Asserts failure if error is found. + void testfairyTest( + String testName, Finder testButtonFinder, Function testCaseFunction, + {bool scroll = true}) { + testWidgets(testName, (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + + if (scroll) { + await tester.scrollUntilVisible(testButtonFinder, 40, + scrollable: scrollerFinder, + maxScrolls: 100, + duration: const Duration(seconds: 10)); + } + + await tester.tap(testButtonFinder); + + await testCaseFunction(); + + bool testingFinderStillFinds = tester.any(testingFinder); + for (int i = 0; i < 10; i++) { + testingFinderStillFinds = tester.any(testingFinder); + + if (!testingFinderStillFinds) { + break; + } + + await Future.delayed(const Duration(seconds: 1)); + } + + expect(testingFinderStillFinds, false); + + tester.element(errorTextFinder); + + final String x = + (errorTextFinder.evaluate().single.widget as Text).data ?? + 'No error yet'; + print('$testName: $x'); + + expect(x, 'No error yet.'); + }); + } + + // Helper test builder: + // 1. Scrolls and finds a button that runs a test case. + // 2. Waits for test completion. + // 3. Asserts failure if error is found. + void testfairyTestSimple(String testName, Finder testButtonFinder, + {bool scroll = true}) { + testfairyTest(testName, testButtonFinder, () async {}, scroll: scroll); + } + + // Test cases (implement a button that starts the test on ui, find and tap it with a finder) + testfairyTestSimple('Lifecycle Test', findByValueKey('lifecycleTests'), + scroll: false); + testfairyTestSimple( + 'Server Endpoint Test', findByValueKey('serverEndpointTest')); + testfairyTestSimple('Feedback Tests', findByValueKey('feedbackTests')); + testfairyTestSimple( + 'Feedback Shake Test', findByValueKey('feedbackShakeTest')); + testfairyTestSimple('Version Test', findByValueKey('versionTest')); + testfairyTestSimple('Session Url Test', findByValueKey('sessionUrlTest')); + testfairyTestSimple( + 'Add Checkpoint Test', findByValueKey('addCheckpointTest')); + testfairyTestSimple('Add Event Test', findByValueKey('addEventTest')); + testfairyTestSimple('Identity Tests', findByValueKey('identityTests')); + testfairyTestSimple('Log Tests', findByValueKey('logTests')); + testfairyTestSimple( + 'Developer Options Tests', findByValueKey('developerOptionsTests')); + testfairyTestSimple('Network Log Tests', findByValueKey('networkLogTests')); + testfairyTestSimple( + 'Disable Auto Update Tests', findByValueKey('disableAutoUpdateTests')); +// testfairyTestSimple('Feedback Options Tests', findByValueKey('feedbackOptionsTests')); + }); +} diff --git a/example/lib/main.dart b/example/lib/main.dart index 30e7a0f..d0dd967 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -26,7 +26,7 @@ void main() { // Call `await TestFairy.begin()` or any other setup code here. // await TestFairy.setMaxSessionLength(60); - await TestFairy.begin(APP_TOKEN); +// await TestFairy.begin(APP_TOKEN); // await TestFairy.installFeedbackHandler(APP_TOKEN); // runApp(TestfairyExampleApp()); diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ca84815..02a1997 100755 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: 'none' version: 2.0.7 environment: - sdk: ">=2.10.0 <3.0.0" + sdk: ">=2.12.0-31.0.dev <3.0.0" flutter: ">=1.22.0 <2.0.0" dependencies: @@ -13,12 +13,13 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.2 # These exist for testing and should never be included by TestFairy SDK http: any dev_dependencies: + integration_test: ^1.0.0 flutter_test: sdk: flutter diff --git a/example/test_driver/app_test.dart b/example/test_driver/app_test.dart index 247624e..fc62891 100755 --- a/example/test_driver/app_test.dart +++ b/example/test_driver/app_test.dart @@ -57,7 +57,7 @@ void main() { if (scroll) { await driver.scrollUntilVisible(scrollerFinder, testButtonFinder, - alignment: 0.5, timeout: const Duration(seconds: 10)); + alignment: 0.5, timeout: const Duration(seconds: 10), dxScroll: 10, dyScroll: 10); } await driver.tap(testButtonFinder, timeout: timeout); diff --git a/ios-ci.sh b/ios-ci.sh index ee2ac56..d99fe25 100644 --- a/ios-ci.sh +++ b/ios-ci.sh @@ -35,5 +35,6 @@ cd .. #../flutter/bin/flutter analyze $PWD/example/lib #../flutter/bin/flutter analyze $PWD/example/test #../flutter/bin/flutter analyze $PWD/example/test_driver +#../flutter/bin/flutter analyze $PWD/example/integration_test diff --git a/pubspec.yaml b/pubspec.yaml index 2428f36..54e7a41 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 2.0.7 homepage: https://testfairy.com environment: - sdk: ">=2.10.0 <3.0.0" + sdk: ">=2.12.0-31.0.dev <3.0.0" flutter: ">=1.22.0 <2.0.0" dependencies: diff --git a/test.sh b/test-with-driver.sh similarity index 100% rename from test.sh rename to test-with-driver.sh diff --git a/test-with-integration-android.sh b/test-with-integration-android.sh new file mode 100755 index 0000000..eff330f --- /dev/null +++ b/test-with-integration-android.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +pushd example +pushd android + +# flutter build generates files in android/ for building the app +flutter build apk --enable-experiment=non-nullable --no-sound-null-safety +./gradlew app:assembleAndroidTest +./gradlew app:assembleDebug -Ptarget=integration_test/app_integration_test.dart + +popd +popd \ No newline at end of file