diff --git a/.github/workflows/code-integration.yml b/.github/workflows/code-integration.yml index 12b0a3d4..6979c1d5 100644 --- a/.github/workflows/code-integration.yml +++ b/.github/workflows/code-integration.yml @@ -17,6 +17,10 @@ jobs: integration_tests_android: name: 🤖 Android Tests runs-on: ubuntu-latest + strategy: + matrix: + api-level: [ 23, 35 ] + target: [ default ] timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -35,9 +39,36 @@ jobs: echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - - uses: reactivecircus/android-emulator-runner@v2 + - name: Gradle cache + uses: gradle/actions/setup-gradle@v4 + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache with: - api-level: 29 + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} + - name: Create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: x86_64 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + script: echo "Generated AVD snapshot for caching." + - name: Run integration test + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + arch: x86_64 + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true script: flutter test integration_test working-directory: flutter_secure_storage/example @@ -59,5 +90,8 @@ jobs: os: iOS os_version: ">=18.1" model: "iPhone 15" + - run: flutter pub get + - run: flutter build ios --simulator --target=integration_test/app_test.dart + working-directory: flutter_secure_storage/example - run: flutter test integration_test working-directory: flutter_secure_storage/example \ No newline at end of file diff --git a/flutter_secure_storage/example/integration_test/app_test.dart b/flutter_secure_storage/example/integration_test/app_test.dart index a5ae8c72..bc98ff68 100644 --- a/flutter_secure_storage/example/integration_test/app_test.dart +++ b/flutter_secure_storage/example/integration_test/app_test.dart @@ -78,9 +78,11 @@ void main() { }); } +Duration duration = const Duration(milliseconds: 300); + Future _setupHomePage(WidgetTester tester) async { await tester.pumpWidget(const MaterialApp(home: HomePage())); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); final pageObject = HomePageObject(tester); await pageObject.deleteAll(); return pageObject; @@ -112,7 +114,7 @@ class HomePageObject { final textField = find.byKey(const Key('value_field')); expect(textField, findsOneWidget, reason: 'Value text field not found'); await tester.enterText(textField, newValue); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); await _tap(find.byKey(const Key('save'))); } @@ -142,11 +144,11 @@ class HomePageObject { final textField = find.byKey(const Key('key_field')); expect(textField, findsOneWidget); await tester.enterText(textField, keyWidget.data!); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); // Confirm the action await tester.tap(find.text('OK')); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); // Verify the SnackBar message final expectedText = 'Contains Key: $expectedResult'; @@ -168,11 +170,11 @@ class HomePageObject { final textField = find.byKey(const Key('key_field')); expect(textField, findsOneWidget); await tester.enterText(textField, keyWidget.data!); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); // Confirm the action await tester.tap(find.text('OK')); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); // Verify the SnackBar message expect(find.text('value: $expectedValue'), findsOneWidget); @@ -213,6 +215,6 @@ class HomePageObject { reason: 'Widget not found for tapping: $finder', ); await tester.tap(finder); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(duration); } }