tv-anarchy/Tests/TVAnarchyCoreTests/WinampSkinLoaderTests.swift
Natalie 4a2ceb9781 feat(offline): inline star-to-keep and trash-to-cull on cache rows
Surface the existing pin (keep-from-cull) and per-file delete actions as
visible inline buttons on each offline cache row instead of context-menu-only:
a star toggles protection from auto-cull (and restore-if-missing), a trash
culls that file early. Aligns wording/icons to the star metaphor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 00:12:41 -04:00

75 lines
No EOL
2.8 KiB
Swift

import XCTest
@testable import TVAnarchyCore
final class WinampSkinLoaderTests: XCTestCase {
private var tmp: URL!
override func setUp() {
super.setUp()
tmp = FileManager.default.temporaryDirectory
.appendingPathComponent("tv-anarchy-skin-test-\(UUID().uuidString)", isDirectory: true)
try? FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
setenv("TV_ANARCHY_STATE_DIR", tmp.path, 1)
}
override func tearDown() {
unsetenv("TV_ANARCHY_STATE_DIR")
try? FileManager.default.removeItem(at: tmp)
super.tearDown()
}
private var bundledWSZ: URL {
URL(fileURLWithPath: #filePath)
.deletingLastPathComponent()
.deletingLastPathComponent()
.deletingLastPathComponent()
.appendingPathComponent("Sources/TVAnarchy/Resources/base-2.91.wsz")
}
func testInstallBaseSkin() throws {
XCTAssertTrue(FileManager.default.fileExists(atPath: bundledWSZ.path))
let pkg = try WinampSkinLoader.install(wszURL: bundledWSZ, displayName: "Base 2.91")
XCTAssertTrue(pkg.isPlayerCompatible)
XCTAssertEqual(pkg.displayName, "Base 2.91")
XCTAssertTrue(pkg.availableSheets.contains("CBUTTONS"))
XCTAssertTrue(pkg.availableSheets.contains("POSBAR"))
XCTAssertTrue(pkg.availableSheets.contains("MAIN"))
XCTAssertFalse(pkg.visColors.isEmpty)
XCTAssertNotNil(WinampSkinSprites.rect(sheet: "CBUTTONS", name: "MAIN_PLAY_BUTTON"))
}
func testReloadInstalledSkin() throws {
let pkg = try WinampSkinLoader.install(wszURL: bundledWSZ)
let loaded = WinampSkinLoader.loadInstalled(id: pkg.id, displayName: pkg.displayName)
XCTAssertEqual(loaded?.id, pkg.id)
XCTAssertEqual(loaded?.displayName, pkg.displayName)
}
func testParseVisColors() {
let colors = WinampSkinLoader.parseVisColors("255,0,0\n0,255,0/comment")
XCTAssertEqual(colors.count, 2)
XCTAssertEqual(colors[0], WinampRGB(r: 255, g: 0, b: 0))
XCTAssertEqual(colors[1], WinampRGB(r: 0, g: 255, b: 0))
}
func testParsePledit() {
let style = WinampSkinLoader.parsePledit("""
Normal=#C0C0C0
Current=#00FF00
NormalBG=#000000
""")
XCTAssertEqual(style.normal?.r, 0xC0)
XCTAssertEqual(style.current?.g, 0xFF)
XCTAssertEqual(style.normalBG?.b, 0)
}
func testWinampSkinSettingsPersist() {
var s = SettingsStore.load()
s.winampSkinId = "abc123"
s.winampSkinName = "Llama Amp"
SettingsStore.save(s)
let disk = SettingsStore.load()
XCTAssertEqual(disk.winampSkinId, "abc123")
XCTAssertEqual(disk.winampSkinName, "Llama Amp")
}
}