Skip to content

test: add android caching, multi sdk testing #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions .github/workflows/code-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
16 changes: 9 additions & 7 deletions flutter_secure_storage/example/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ void main() {
});
}

Duration duration = const Duration(milliseconds: 300);

Future<HomePageObject> _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;
Expand Down Expand Up @@ -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')));
}
Expand Down Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -213,6 +215,6 @@ class HomePageObject {
reason: 'Widget not found for tapping: $finder',
);
await tester.tap(finder);
await tester.pumpAndSettle();
await tester.pumpAndSettle(duration);
}
}
Loading