iOS: CarPlay (#420)
A CarPlay scene beside the phone's: In Progress, Unread and Shows as
CPListTemplates from ipx's API, read with the player's credentials, and
a pick played through the same Playback, so it resumes from the saved
place, saves as it goes and marks read at 90%. Now Playing is the
system's template over Playback's now-playing info.
When the car starts a different episode the page is sent
{t:"replaced"} and closes its player bar. Left open, the bar would have
gone on as the old episode while the host's clock belonged to the new
one, saving that time and marking the wrong item read.
The badge's fetch moves into API.get, which CarPlay shares. Build 13.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
36
ios/Tests/CarTests.swift
Normal file
36
ios/Tests/CarTests.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import XCTest
|
||||
@testable import iPX
|
||||
|
||||
final class CarTests: XCTestCase {
|
||||
private func episode(_ json: String) throws -> CarEpisode {
|
||||
try JSONDecoder().decode(CarEpisode.self, from: Data(json.utf8))
|
||||
}
|
||||
|
||||
func testAnItemReadsAsTheAPISendsIt() throws {
|
||||
let e = try episode("""
|
||||
{"guid":"g","feed_id":"f","title":null,"link":null,"image":null,"duration":1800,"position":600,
|
||||
"read":false,"flagged":false,"enclosures":[
|
||||
{"id":7,"feed_id":"f","guid":"g","url":"https://x/v.mp4","mime":"video/mp4","state":"done"},
|
||||
{"id":8,"feed_id":"f","guid":"g","url":"https://x/Show%20Ep%201.mp3","mime":"audio/mpeg","state":"done"}]}
|
||||
""")
|
||||
XCTAssertEqual(e.audio?.id, 8, "a video is passed over for the sound")
|
||||
XCTAssertEqual(e.name, "Show Ep 1", "untitled is named by its file")
|
||||
XCTAssertEqual(e.left, "20 min left")
|
||||
}
|
||||
|
||||
func testNothingToPlayIsNotListed() throws {
|
||||
let e = try episode(#"{"guid":"g","feed_id":"f","title":"A post","position":0,"enclosures":[]}"#)
|
||||
XCTAssertNil(e.audio)
|
||||
XCTAssertNil(e.left, "not started")
|
||||
XCTAssertNil(e.item(feedTitle: "F", feedImage: nil, kept: []))
|
||||
}
|
||||
|
||||
func testTheFileIsTheOneThePageWouldPlay() {
|
||||
let plain = CarEpisode.Enclosure(id: 4, url: "u", mime: nil, deadair: nil)
|
||||
let trimmed = CarEpisode.Enclosure(id: 5, url: "u", mime: nil, deadair: 90)
|
||||
XCTAssertEqual(CarEpisode.path(of: plain, kept: []), "/media/4")
|
||||
XCTAssertEqual(CarEpisode.path(of: trimmed, kept: []), "/media/5/deadair.m3u8")
|
||||
XCTAssertEqual(CarEpisode.path(of: trimmed, kept: ["/media/5/deadair"]), "/media/5/deadair",
|
||||
"the copy on the phone, connection or not")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user