test: Add more unit tests and integration tests#518
Merged
Conversation
Extract the notification reply decision logic (canReply, shouldReply, isSupportedPackage, canSendReplyNow, isGroupMessageAndReplyAllowed) into a standalone NotificationReplyDecider class that accepts its dependencies via constructor, making it unit-testable. Tests cover: service gating, package filtering, old notification rejection, group message rules, cooldown enforcement, self-reply prevention, and contact whitelist/blacklist filtering.
Integration tests using real SharedPreferences, real Room database, and real StatusBarNotification objects on device/emulator. Tests the full decision pipeline including: - Service enabled/disabled with real prefs - WhatsApp/Telegram package filtering - Old notification rejection - Group message rules - Cooldown enforcement with real Room DB entries - Self-reply prevention - Contact whitelist/blacklist filtering with real prefs - Full canReply + shouldReply pipeline scenarios Uses real StatusBarNotification constructor instead of Mockito to avoid compatibility issues with newer Android API levels.
Add isAdded/binding null checks in Retrofit onResponse and onFailure callbacks to prevent IllegalStateException when the fragment detaches before the network response arrives. Also add onDestroyView to null out ViewBinding reference. Restores the recreation instrumentation test that was previously removed as a workaround.
Add jacocoCoverageVerification task with 5% minimum instruction coverage for testable model/utility classes. Excludes UI classes (activities, fragments, adapters) that cannot be unit-tested. Threshold is conservative due to Robolectric tests not contributing to JaCoCo offline instrumentation.
Verify base URLs, converter factories, singleton behavior, and error parsing for all three Retrofit instances (GitHub, OpenAI, Atomatic AI).
…sts) Test ServiceUtils singleton and the Settings.Secure notification listener enabled check logic used by MainFragment.isListenerEnabled().
AppsAdapter: item count, view type resolution, data preservation. ContactListAdapter: item count, view types, checkpoint/restore, custom name insertion, filter availability.
Verify launch, toolbar, root layout, fragment container, fragment loading, and activity recreation.
Verify the notification intent handler launches without crashing for various intent configurations: no extras, valid package, null package, and empty package. Activity calls finish() in onCreate so tests verify no-crash behavior rather than UI assertions.
spuday90
approved these changes
Mar 26, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.