Testing
Test coverage and how to run tests in Scanly v1.0.22.
For edge-to-edge changes, check Welcome, Settings › Language, and the full-screen image and PDF previews with gesture and three-button navigation. Include a landscape display cutout and verify that controls stay inside the safe area. Check older Android for transparent system bars and Android 15 or later for the enforced layout.
Running tests
# Unit tests (no device required)
./gradlew.bat testDebugUnitTest
# Instrumented tests (device/emulator required)
./gradlew.bat connectedDebugAndroidTest
# Lint
./gradlew.bat lintDebug
Unit tests (app/src/test/)
83 JVM test source files (73 test classes plus 10 in-memory repository fakes under testing/) cover core logic:
| Area | Test files |
|---|---|
| ML / geometry | DocumentCornerQuadTest, DocumentQuadPolicyTest, DocumentGatePolicyTest, CornerRegressionDecoderTest, BookPageQuadAnalyzerTest, AutomaticDocumentModelSelectionPolicyTest, PerspectiveQuadMathTest, CropQuadEditorTest |
| Processing | AdaptivePageFilterTuningTest, PageFilterPresetTest, PageFilterAdjustmentsTest |
| Camera | CaptureStabilityTrackerTest, DocumentGateStabilityTrackerTest, StableCornerSelectorTest, CaptureFrameQualityAnalyzerTest, CameraOverlayMapperTest, CameraPermissionSupportTest, ScanSessionScreenTest |
| UI / layout | AdaptiveLayoutTest, PreviewImageSizerTest, ZoomableImageStateTest, OnboardingLayoutModeTest, WelcomeLanguageMatchTest (welcome-screen language search) |
| Formatting | StorageFormatterTest, DocumentPresentationFormatterTest, DocumentPreviewPathResolverTest |
| Domain models | DocumentCornerModelTest, ExportDestinationTest, PageFilterPresetTest, PdfExportOptionsTest |
| Feature logic | LibraryUiStateTest, DocumentDetailSelectionResolverTest, PageImagePreviewSelectionResolverTest, SuggestDocumentTitleUseCaseTest, DocumentSplitPartsTest, ScanlyLaunchActionTest, LibraryCardPresentationTest, DocumentPageTilePresentationTest |
| Page text search | LibrarySearchRankerTest, NameMatcherTest, RecentSearchesTest, SearchQueryTest, SnippetParserTest, SpellingSuggesterTest, DocumentKindClassifierTest, TextReflowTest |
| Signing | InkStrokeBuilderTest, SignGeometryTest, SignMarkCodecTest, SignEditorControllerTest, SignOverlayGeometryTest |
| Flow / use case | DocumentLibraryFlowTest, ScanSessionAndPageEditFlowTest, ExportAndClearDataFlowTest, ToolsSettingsAndLaunchActionFlowTest |
| Updates | AppUpdateDialogCooldownTest, ReleaseMarkdownParserTest, AppVersionComparatorTest, GitHubAppUpdateRepositoryTest, PlayInAppUpdatePolicyTest |
| Export | PdfPageLayoutResolverTest |
| Tools presentation | PdfReaderPresentationTest, PdfToolPresentationTest, QrToolPresentationTest, PdfSplitPlanTest (split range parsing, every-N and extract plans) |
| Navigation | PdfToolSourceArgumentTest (PDF tool source argument encode/decode) |
Placement convention
Mirror the source package:
app/src/test/java/in/c1ph3rj/scanly/{matching/package}/YourTest.kt
Instrumented tests (app/src/androidTest/)
| File | Coverage |
|---|---|
ScanlyDeviceUiTest.kt | Real MainActivity: onboarding → Home, Library / Tools / Settings chrome, QR generate preview |
AppLocaleDeviceTest.kt | Locale resources, immediate switching on Welcome, pending and applied choices in Settings, System default and saved language after activity recreation |
ScanlyDeviceUiRobot.kt | Shared Compose/UiAutomator helpers for the device UI suite |
WelcomeScreenTest.kt | Welcome screen: logo and phone-language default, language pick and search, one- and two-pane layouts at phone, small-phone, landscape and tablet sizes, flow order and Back |
OnboardingScreenTest.kt | Compose UI test for onboarding screen |
OpenCvPageFilterProcessorTest.kt | Device-side OpenCV filter engine checks (flatten, color marks, preview/save parity) |
ExampleInstrumentedTest.kt | Package name smoke test |
LibraryRedesignTest.kt | Library screen layout and key actions |
Device UI tests use Android Test Orchestrator and clear app data between cases. Full run/install instructions: running-and-testing.md.
JVM flow tests (domain/usecase/)
These call shipped use cases with in-memory fakes (no device):
| File | Coverage |
|---|---|
DocumentLibraryFlowTest | Document/group lifecycle, library visibility, page reorder/delete |
ScanSessionAndPageEditFlowTest | Scan add vs retake routes, import cap, crop/filter/adjust |
ExportAndClearDataFlowTest | PDF/ZIP export, export-cache cleanup, clear-all-data |
ToolsSettingsAndLaunchActionFlowTest | QR, PDF toolkit, prefs/onboarding, launch-action redirects |
Coverage gaps
Still not covered on-device or with real I/O (prioritized):
- Persistence integration — Room migrations, repository round-trips
- Export end-to-end — PDF/ZIP bytes from the real exporter and save-to-destination
- Page-text recognition integration — bundled ML Kit recognition and background indexing on representative scans
- Capture instrumented — Camera session on device (gate + multi-model path)
- Settings DataStore — preference round-trips against real DataStore (JVM tests cover use-case persistence against an in-memory settings store)
What to test when contributing
| Change type | Minimum verification |
|---|---|
| Geometry / processing math | Unit test |
| ML policy (gate, quad, book, auto-select) | Unit test for pure policy helpers |
| ViewModel state logic | Unit test for resolvers/state |
| New use case | Unit test if non-trivial |
| UI layout | Screenshot or instrumented test for critical flows |
| Shell navigation / onboarding | ScanlyDeviceUiTest on a connected device |
| Room migration | Manual test on device with old schema data |
| User-facing feature | Update docs + manual device verification |
Related docs
- running-and-testing.md — install the app, emulator/adb, JVM and device UI suites
- setup.md — build commands
- conventions.md — code placement rules
- ../../CONTRIBUTING.md — contribution expectations