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:

AreaTest files
ML / geometryDocumentCornerQuadTest, DocumentQuadPolicyTest, DocumentGatePolicyTest, CornerRegressionDecoderTest, BookPageQuadAnalyzerTest, AutomaticDocumentModelSelectionPolicyTest, PerspectiveQuadMathTest, CropQuadEditorTest
ProcessingAdaptivePageFilterTuningTest, PageFilterPresetTest, PageFilterAdjustmentsTest
CameraCaptureStabilityTrackerTest, DocumentGateStabilityTrackerTest, StableCornerSelectorTest, CaptureFrameQualityAnalyzerTest, CameraOverlayMapperTest, CameraPermissionSupportTest, ScanSessionScreenTest
UI / layoutAdaptiveLayoutTest, PreviewImageSizerTest, ZoomableImageStateTest, OnboardingLayoutModeTest, WelcomeLanguageMatchTest (welcome-screen language search)
FormattingStorageFormatterTest, DocumentPresentationFormatterTest, DocumentPreviewPathResolverTest
Domain modelsDocumentCornerModelTest, ExportDestinationTest, PageFilterPresetTest, PdfExportOptionsTest
Feature logicLibraryUiStateTest, DocumentDetailSelectionResolverTest, PageImagePreviewSelectionResolverTest, SuggestDocumentTitleUseCaseTest, DocumentSplitPartsTest, ScanlyLaunchActionTest, LibraryCardPresentationTest, DocumentPageTilePresentationTest
Page text searchLibrarySearchRankerTest, NameMatcherTest, RecentSearchesTest, SearchQueryTest, SnippetParserTest, SpellingSuggesterTest, DocumentKindClassifierTest, TextReflowTest
SigningInkStrokeBuilderTest, SignGeometryTest, SignMarkCodecTest, SignEditorControllerTest, SignOverlayGeometryTest
Flow / use caseDocumentLibraryFlowTest, ScanSessionAndPageEditFlowTest, ExportAndClearDataFlowTest, ToolsSettingsAndLaunchActionFlowTest
UpdatesAppUpdateDialogCooldownTest, ReleaseMarkdownParserTest, AppVersionComparatorTest, GitHubAppUpdateRepositoryTest, PlayInAppUpdatePolicyTest
ExportPdfPageLayoutResolverTest
Tools presentationPdfReaderPresentationTest, PdfToolPresentationTest, QrToolPresentationTest, PdfSplitPlanTest (split range parsing, every-N and extract plans)
NavigationPdfToolSourceArgumentTest (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/)

FileCoverage
ScanlyDeviceUiTest.ktReal MainActivity: onboarding → Home, Library / Tools / Settings chrome, QR generate preview
AppLocaleDeviceTest.ktLocale resources, immediate switching on Welcome, pending and applied choices in Settings, System default and saved language after activity recreation
ScanlyDeviceUiRobot.ktShared Compose/UiAutomator helpers for the device UI suite
WelcomeScreenTest.ktWelcome 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.ktCompose UI test for onboarding screen
OpenCvPageFilterProcessorTest.ktDevice-side OpenCV filter engine checks (flatten, color marks, preview/save parity)
ExampleInstrumentedTest.ktPackage name smoke test
LibraryRedesignTest.ktLibrary 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):

FileCoverage
DocumentLibraryFlowTestDocument/group lifecycle, library visibility, page reorder/delete
ScanSessionAndPageEditFlowTestScan add vs retake routes, import cap, crop/filter/adjust
ExportAndClearDataFlowTestPDF/ZIP export, export-cache cleanup, clear-all-data
ToolsSettingsAndLaunchActionFlowTestQR, PDF toolkit, prefs/onboarding, launch-action redirects

Coverage gaps

Still not covered on-device or with real I/O (prioritized):

  1. Persistence integration — Room migrations, repository round-trips
  2. Export end-to-end — PDF/ZIP bytes from the real exporter and save-to-destination
  3. Page-text recognition integration — bundled ML Kit recognition and background indexing on representative scans
  4. Capture instrumented — Camera session on device (gate + multi-model path)
  5. 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 typeMinimum verification
Geometry / processing mathUnit test
ML policy (gate, quad, book, auto-select)Unit test for pure policy helpers
ViewModel state logicUnit test for resolvers/state
New use caseUnit test if non-trivial
UI layoutScreenshot or instrumented test for critical flows
Shell navigation / onboardingScanlyDeviceUiTest on a connected device
Room migrationManual test on device with old schema data
User-facing featureUpdate docs + manual device verification

View source on GitHub · Markdown