Skip to content

test(downloadmanager): Phase 7 - add tests for download manager module#3611

Open
ksalhab89 wants to merge 2 commits intoquran:mainfrom
ksalhab89:feature/testing-phase7
Open

test(downloadmanager): Phase 7 - add tests for download manager module#3611
ksalhab89 wants to merge 2 commits intoquran:mainfrom
ksalhab89:feature/testing-phase7

Conversation

@ksalhab89
Copy link
Copy Markdown
Contributor

@ksalhab89 ksalhab89 commented Apr 4, 2026

Summary

  • Add 45 new tests for feature:downloadmanager (previously 0 tests, 27 source files)
  • 8 tests for AudioManagerPresenter (flow mapping, sorting, filtering)
  • 37 tests for SheikhAudioPresenter (download/remove flows, selection state, dialog state, file operations, edge cases)
  • 5 new fakes, zero Mockito usage
  • Minor production changes: added open modifier to QariDownloadInfoSource interface method and AudioCacheInvalidator for testability

New fakes

Fake Interface
FakeQariDownloadInfoSource QariDownloadInfoSource
FakeDownloader Downloader
FakeQuranFileManager QuranFileManager
FakeAudioCacheInvalidator AudioCacheInvalidator
FakeAudioExtensionDecider AudioExtensionDecider

Test coverage highlights

  • SheikhAudioPresenter: download orchestration (skip already-downloaded, database-only), gapless vs gapped file removal, dialog state machine, selection toggle/clear, download status event mapping (progress/done/error/cancel)
  • AudioManagerPresenter: sort by name, empty list, mapping from QariDownloadInfo to UI model
  • File operations tested with temp directories, cleaned up in @after

Test plan

  • ./gradlew :feature:downloadmanager:testDebugUnitTest
  • ./gradlew :app:testMadaniDebugUnitTest (no regressions)
  • grep -rn "@Mock" feature/downloadmanager/src/test returns empty

- Add AudioManagerPresenterTest (8 tests)
- Add SheikhAudioPresenterTest (37 tests)
- Create fakes: FakeAudioCacheInvalidator, FakeAudioExtensionDecider,
  FakeDownloader, FakeQariDownloadInfoSource, FakeQuranFileManager
- Refactor presenters to depend on QariDownloadInfoSource interface
  instead of concrete QariDownloadInfoManager
- Add downloadedQariInfo() to QariDownloadInfoSource interface
- Open AudioCacheInvalidator class/method for test subclassing
- Add test dependencies to build.gradle.kts
- Zero Mockito usage
- Extract AudioCacheInvalidatorInterface; revert open class hack
- Separate FakeQariDownloadInfoSource flows (downloadedQariInfo vs filtered)
- AudioManagerPresenterTest uses emitFiltered() for correct method coverage
- Add missing test: sheikhInfo emits nothing for unknown qariId
- Add missing test: download no-op when all suras downloaded + downloadDatabase=false
- Fix misleading test name: gapped removal, not gapless
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant