Skip to content

Commit 75c6d55

Browse files
Merge pull request #879 from juliansteenbakker/test/integration-test
test: add android caching, multi sdk testing
2 parents 8c41642 + 13a583a commit 75c6d55

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

.github/workflows/code-integration.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
integration_tests_android:
1818
name: 🤖 Android Tests
1919
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
api-level: [ 23, 35 ]
23+
target: [ default ]
2024
timeout-minutes: 30
2125
steps:
2226
- uses: actions/checkout@v4
@@ -35,9 +39,36 @@ jobs:
3539
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
3640
sudo udevadm control --reload-rules
3741
sudo udevadm trigger --name-match=kvm
38-
- uses: reactivecircus/android-emulator-runner@v2
42+
- name: Gradle cache
43+
uses: gradle/actions/setup-gradle@v4
44+
- name: AVD cache
45+
uses: actions/cache@v4
46+
id: avd-cache
3947
with:
40-
api-level: 29
48+
path: |
49+
~/.android/avd/*
50+
~/.android/adb*
51+
key: avd-${{ matrix.api-level }}
52+
- name: Create AVD and generate snapshot for caching
53+
if: steps.avd-cache.outputs.cache-hit != 'true'
54+
uses: reactivecircus/android-emulator-runner@v2
55+
with:
56+
api-level: ${{ matrix.api-level }}
57+
target: ${{ matrix.target }}
58+
arch: x86_64
59+
force-avd-creation: false
60+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
61+
disable-animations: false
62+
script: echo "Generated AVD snapshot for caching."
63+
- name: Run integration test
64+
uses: reactivecircus/android-emulator-runner@v2
65+
with:
66+
api-level: ${{ matrix.api-level }}
67+
target: ${{ matrix.target }}
68+
arch: x86_64
69+
force-avd-creation: false
70+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
71+
disable-animations: true
4172
script: flutter test integration_test
4273
working-directory: flutter_secure_storage/example
4374

@@ -59,5 +90,8 @@ jobs:
5990
os: iOS
6091
os_version: ">=18.1"
6192
model: "iPhone 15"
93+
- run: flutter pub get
94+
- run: flutter build ios --simulator --target=integration_test/app_test.dart
95+
working-directory: flutter_secure_storage/example
6296
- run: flutter test integration_test
6397
working-directory: flutter_secure_storage/example

flutter_secure_storage/example/integration_test/app_test.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ void main() {
7878
});
7979
}
8080

81+
Duration duration = const Duration(milliseconds: 300);
82+
8183
Future<HomePageObject> _setupHomePage(WidgetTester tester) async {
8284
await tester.pumpWidget(const MaterialApp(home: HomePage()));
83-
await tester.pumpAndSettle();
85+
await tester.pumpAndSettle(duration);
8486
final pageObject = HomePageObject(tester);
8587
await pageObject.deleteAll();
8688
return pageObject;
@@ -112,7 +114,7 @@ class HomePageObject {
112114
final textField = find.byKey(const Key('value_field'));
113115
expect(textField, findsOneWidget, reason: 'Value text field not found');
114116
await tester.enterText(textField, newValue);
115-
await tester.pumpAndSettle();
117+
await tester.pumpAndSettle(duration);
116118

117119
await _tap(find.byKey(const Key('save')));
118120
}
@@ -142,11 +144,11 @@ class HomePageObject {
142144
final textField = find.byKey(const Key('key_field'));
143145
expect(textField, findsOneWidget);
144146
await tester.enterText(textField, keyWidget.data!);
145-
await tester.pumpAndSettle();
147+
await tester.pumpAndSettle(duration);
146148

147149
// Confirm the action
148150
await tester.tap(find.text('OK'));
149-
await tester.pumpAndSettle();
151+
await tester.pumpAndSettle(duration);
150152

151153
// Verify the SnackBar message
152154
final expectedText = 'Contains Key: $expectedResult';
@@ -168,11 +170,11 @@ class HomePageObject {
168170
final textField = find.byKey(const Key('key_field'));
169171
expect(textField, findsOneWidget);
170172
await tester.enterText(textField, keyWidget.data!);
171-
await tester.pumpAndSettle();
173+
await tester.pumpAndSettle(duration);
172174

173175
// Confirm the action
174176
await tester.tap(find.text('OK'));
175-
await tester.pumpAndSettle();
177+
await tester.pumpAndSettle(duration);
176178

177179
// Verify the SnackBar message
178180
expect(find.text('value: $expectedValue'), findsOneWidget);
@@ -213,6 +215,6 @@ class HomePageObject {
213215
reason: 'Widget not found for tapping: $finder',
214216
);
215217
await tester.tap(finder);
216-
await tester.pumpAndSettle();
218+
await tester.pumpAndSettle(duration);
217219
}
218220
}

0 commit comments

Comments
 (0)