-
Notifications
You must be signed in to change notification settings - Fork 25
Add troubleshooting documentation and integration tests for MissingPluginException #117
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
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
be48faa
Initial plan
Copilot 5dd5670
Handle MissingPluginException gracefully by returning null
Copilot 7d84505
Update README with null return value documentation
Copilot ff6cdd4
Revert MissingPluginException handling changes
Copilot ae748a0
Add comprehensive troubleshooting and integration tests for MissingPl…
Copilot 21132a8
Format integration test to comply with 80-char line length
Copilot 4fa8d9e
Fix integration test workflow and add test driver
Copilot 5d2c706
Fix formatting and use correct integration test command
Copilot 5640941
dart format
nohli 011003a
pub get
nohli f872ee1
Update integration test api levels
nohli d36ed97
Update integration test profile
nohli 7a8af60
Change syntax
nohli 814ed18
Downgrade max api level
nohli 5367bf4
Print available devices
nohli 909770a
Reduce timeout
nohli e1d4b5b
Remove upload step
nohli 0096d7f
Use matrix for device type
nohli e391a89
Improve naming
nohli b579f1b
Remove whitespace
nohli 496a86a
Move troubleshooting to bottom
nohli 3603cb4
Remove device print
nohli 9de1cb8
Update readme
nohli 5f5f532
Update readme
nohli 5321cd1
Bump version to 0.5.1 and update changelog
Copilot e69d3d3
pub get
nohli d761f3f
Update readme
nohli e832c0b
Update changelog
nohli a8a52ed
Sort parameters, minor refactoring
nohli a0e0d95
Sort parameters
nohli f36f842
Add test for non-Android platforms
nohli caa4f94
Use variable for mock test result
nohli 8f5c4b5
dart format
nohli dd090db
Add platform to test name
nohli abbbd66
Update example/integration_test/android_id_test.dart
nohli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Integration Tests (Android) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| integration_test: | ||
| name: Integration test on Android API ${{ matrix.api-level }} - ${{ matrix.profile }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| api-level: [24, 26, 28, 30, 32, 34, 35] | ||
| profile: [medium_phone] | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup Java | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 17 | ||
|
|
||
| - name: Install Flutter | ||
| uses: subosito/flutter-action@v2 | ||
| with: | ||
| channel: stable | ||
|
|
||
| - name: Disable analytics | ||
| run: flutter config --no-analytics | ||
|
|
||
| - name: Flutter pub get | ||
| run: | | ||
| flutter pub get | ||
| cd example | ||
| flutter pub get | ||
|
|
||
| - name: Enable emulator hardware acceleration (KVM) | ||
| run: | | ||
| 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 | ||
|
|
||
| - name: Boot emulator and run integration tests | ||
| uses: reactivecircus/android-emulator-runner@v2 | ||
| with: | ||
| api-level: ${{ matrix.api-level }} | ||
| profile: ${{ matrix.profile }} | ||
| arch: x86_64 | ||
| script: | | ||
| cd example && flutter test integration_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import 'package:android_id/android_id.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
|
|
||
| void main() { | ||
| IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| group('AndroidId Plugin Integration Tests', () { | ||
| const androidIdPlugin = AndroidId(); | ||
|
|
||
| testWidgets( | ||
| 'getId should not throw MissingPluginException on Android', | ||
| (WidgetTester tester) async { | ||
| // This test verifies that the plugin is properly registered | ||
| // and does not throw MissingPluginException when called on Android | ||
|
|
||
| String? androidId; | ||
|
|
||
| // Should not throw MissingPluginException | ||
| androidId = await androidIdPlugin.getId(); | ||
|
|
||
| // On Android, we should get a non-null ID | ||
| // On other platforms, we should get null | ||
| expect( | ||
| androidId, | ||
| isNotNull, | ||
| reason: 'Android ID should be available on Android devices/emulators', | ||
| ); | ||
|
|
||
| // Android ID should be a hex string | ||
| expect( | ||
| androidId, | ||
| matches(RegExp(r'^[0-9a-f]+$')), | ||
| reason: 'Android ID should be a hexadecimal string', | ||
| ); | ||
|
|
||
| // Android ID should be 16 characters (64-bit hex) | ||
| expect( | ||
| androidId?.length, | ||
| equals(16), | ||
| reason: 'Android ID should be 16 hex characters (64-bit)', | ||
nohli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| testWidgets( | ||
| 'getId should return consistent value', | ||
| (WidgetTester tester) async { | ||
| // Call getId multiple times and verify it returns the same value | ||
| final id1 = await androidIdPlugin.getId(); | ||
| final id2 = await androidIdPlugin.getId(); | ||
|
|
||
| expect( | ||
| id1, | ||
| equals(id2), | ||
| reason: 'Android ID should be consistent across multiple calls', | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| testWidgets( | ||
| 'getId should work after hot restart', | ||
| (WidgetTester tester) async { | ||
| // This test verifies that the plugin remains registered and functional | ||
| // after pumping frames. Note: Hot restart cannot be simulated in integration tests. | ||
|
|
||
| final id = await androidIdPlugin.getId(); | ||
| expect(id, isNotNull); | ||
|
|
||
| // Pump frames to simulate app lifecycle | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| // Should still work | ||
| final idAfter = await androidIdPlugin.getId(); | ||
| expect(idAfter, equals(id)); | ||
| }, | ||
| ); | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,5 @@ dev_dependencies: | |
| flutter_lints: ^6.0.0 | ||
| flutter_test: | ||
| sdk: flutter | ||
| integration_test: | ||
| sdk: flutter | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ topics: | |
| - android | ||
| - native | ||
|
|
||
| version: 0.5.0 | ||
| version: 0.5.1 | ||
|
|
||
| environment: | ||
| sdk: '>=3.0.0 <4.0.0' | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.