[PR #397] [MERGED] feat: Groundwork for testable iOS swift code #1432

Closed
opened 2026-04-24 23:58:24 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf-app/pull/397
Author: @ronaldheft
Created: 9/22/2022
Status: Merged
Merged: 9/23/2022
Merged by: @advplyr

Base: masterHead: ios-player-seek-back-time-fixes


📝 Commits (3)

  • 890852b refactor: Pull out seek back calculation into testable class
  • cdfbbcb refactor: Use refactored seek back time class
  • 2dbce1e fix: Negative currentTime after seek back

📊 Changes

5 files changed (+269 additions, -28 deletions)

View changed files

📝 ios/App/App.xcodeproj/project.pbxproj (+166 -1)
📝 ios/App/App.xcodeproj/xcshareddata/xcschemes/App.xcscheme (+11 -0)
ios/App/AudiobookshelfUnitTests/Shared/player/util/PlayerTimeUtilsTests.swift (+44 -0)
📝 ios/App/Shared/player/AudioPlayer.swift (+1 -27)
ios/App/Shared/player/util/PlayerTimeUtils.swift (+47 -0)

📄 Description

This PR is laying the groundwork for writing Swift unit tests:

  • Refactors the seek back time logic into a testable PlayerTimeUtils class
  • Writes a set of unit tests against PlayerTimeUtils
    • The can be run with Test build mode in Xcode
  • Fixes a bug with the seek back logic that was discovered with the unit tests
    • The currentTime could go negative if first starting the book

Going forward, I will be aiming to write unit tests for all code. While I expect it will take time to get everything tested, I want to start somewhere!

Expect some additional PRs in the future, but not immediately:

  • Adding the ability to run the unit tests from the command line via npm
  • A GitHub Action to automatically run the unit test suite for all PRs

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf-app/pull/397 **Author:** [@ronaldheft](https://github.com/ronaldheft) **Created:** 9/22/2022 **Status:** ✅ Merged **Merged:** 9/23/2022 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `ios-player-seek-back-time-fixes` --- ### 📝 Commits (3) - [`890852b`](https://github.com/advplyr/audiobookshelf-app/commit/890852bef5adb3c140f8f6aa03022cd549823bcb) refactor: Pull out seek back calculation into testable class - [`cdfbbcb`](https://github.com/advplyr/audiobookshelf-app/commit/cdfbbcbf8ae01024fd7a429a572c15eefa41e779) refactor: Use refactored seek back time class - [`2dbce1e`](https://github.com/advplyr/audiobookshelf-app/commit/2dbce1e3bb19b513c5033874d73683a9ec4c8577) fix: Negative currentTime after seek back ### 📊 Changes **5 files changed** (+269 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `ios/App/App.xcodeproj/project.pbxproj` (+166 -1) 📝 `ios/App/App.xcodeproj/xcshareddata/xcschemes/App.xcscheme` (+11 -0) ➕ `ios/App/AudiobookshelfUnitTests/Shared/player/util/PlayerTimeUtilsTests.swift` (+44 -0) 📝 `ios/App/Shared/player/AudioPlayer.swift` (+1 -27) ➕ `ios/App/Shared/player/util/PlayerTimeUtils.swift` (+47 -0) </details> ### 📄 Description This PR is laying the groundwork for writing Swift unit tests: * Refactors the seek back time logic into a testable `PlayerTimeUtils` class * Writes a set of unit tests against `PlayerTimeUtils` * The can be run with `Test` build mode in Xcode * Fixes a bug with the seek back logic that was discovered with the unit tests * The `currentTime` could go negative if first starting the book Going forward, I will be aiming to write unit tests for all code. While I expect it will take time to get everything tested, I want to start somewhere! Expect some additional PRs in the future, but not immediately: * Adding the ability to run the unit tests from the command line via npm * A GitHub Action to automatically run the unit test suite for all PRs --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-24 23:58:24 +02:00
adam closed this issue 2026-04-24 23:58:24 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf-app#1432