broken changes

This commit is contained in:
Mark Gregory
2026-11-05 17:06:40 +00:00
parent 9da6d2fdcd
commit 8cffb40f17
3 changed files with 169 additions and 35 deletions
+32
View File
@@ -1998,6 +1998,27 @@ extension KJamsCloneTests {
XCTAssertNil(system.error);XCTAssertNil(system.pendingReplacement);XCTAssertEqual(system.songs.count,1)
XCTAssertNotEqual(system.a.song?.id,999);XCTAssertFalse(system.a.player.playing)
}
@MainActor func testSequentialAndConcurrentFinderDropsLoadBothDecksIncludingDuplicates() async throws {
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
defer { try? FileManager.default.removeItem(at:root) }
let system = DJSystem(storageURL:root);defer { system.a.unload();system.b.unload() }
let first = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/Demo.mp3"))
let second = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/TestTrack.wav"))
system.requestFileLoad([first],into:"A")
XCTAssertTrue(system.importing)
system.requestFileLoad([second],into:"B")
for _ in 0..<500 { if system.b.song != nil,!system.importing { break };try await Task.sleep(nanoseconds:10_000_000) }
XCTAssertNotNil(system.a.song);XCTAssertNotNil(system.b.song,system.error ?? system.status)
let original = system.a.song?.id
XCTAssertNotEqual(system.b.song?.id,original)
system.requestFileLoad([first],into:"B")
for _ in 0..<300 { if !system.importing { break };try await Task.sleep(nanoseconds:10_000_000) }
XCTAssertEqual(system.b.song?.id,original,"Dropping a previously imported file onto the other deck still loads it")
XCTAssertEqual(system.a.song?.id,original);XCTAssertNil(system.error)
XCTAssertTrue(system.acceptDrop([system.dragReference(try XCTUnwrap(original)).provider()],into:"A"))
try await Task.sleep(nanoseconds:50_000_000)
XCTAssertEqual(system.a.song?.id,original)
}
@MainActor func testArtworkSelectsTrackJPGAndLoadsFromOriginalFolder() async throws {
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true);defer { try? FileManager.default.removeItem(at:root) }
@@ -2080,6 +2101,12 @@ extension KJamsCloneTests {
XCTAssertEqual(try DJAudioRouting.channelMap(channels:4,first:0),[0,1,-1,-1])
XCTAssertThrowsError(try DJAudioRouting.channelMap(channels:2,first:2))
let device = DJAudioDevice(id:1,uid:"controller",name:"Controller",outputChannels:4)
XCTAssertEqual(device.stereoPairs,[0,2])
let preset = DJAudioRouting.controllerPreset(device,mode:"Internal")
XCTAssertEqual(preset.main.firstChannel,0);XCTAssertEqual(preset.cue.firstChannel,2)
let external = DJAudioRouting.controllerPreset(device,mode:"External")
XCTAssertEqual(external.deckA.firstChannel,0);XCTAssertEqual(external.deckB.firstChannel,2)
XCTAssertNoThrow(try external.validate(devices:[device],defaultID:1))
var routing = DJAudioRouting();routing.main.uid = device.uid;routing.cue = .init(uid:device.uid,firstChannel:2)
XCTAssertNoThrow(try routing.validate(devices:[device],defaultID:1))
routing.cue.firstChannel = 0;XCTAssertThrowsError(try routing.validate(devices:[device],defaultID:1))
@@ -2089,6 +2116,7 @@ extension KJamsCloneTests {
}
@MainActor func testAudioOutputsAndActualFourChannelRoutingWhenInterfaceAttached() async throws {
let outputs = DJAudioDevice.outputs()
print("DJ audio discovery:",outputs.map { "\($0.name) [\($0.outputChannels) out / \($0.inputChannels) in]" }.joined(separator:", "))
XCTAssertFalse(outputs.isEmpty,"CoreAudio should expose available Mac and USB outputs")
guard let controller = outputs.first(where:{$0.name.localizedCaseInsensitiveContains("MixTrack Go") && $0.outputChannels >= 4}) else { throw XCTSkip("Four-channel Mixtrack Go is not attached") }
let player = Player(persistsMix:false)
@@ -2108,6 +2136,10 @@ extension KJamsCloneTests {
window.contentView = host;window.setFrameOrigin(NSPoint(x:-10000,y:-10000));window.orderFront(nil)
defer { window.orderOut(nil);window.contentView = nil }
try await Task.sleep(nanoseconds:150_000_000);host.layoutSubtreeIfNeeded()
func descendants(_ view: NSView) -> [NSView] { [view]+view.subviews.flatMap{descendants($0)} }
let menus = descendants(host).compactMap{$0 as? NSPopUpButton}
for menu in menus { menu.menu?.update() }
XCTAssertTrue(menus.contains{$0.itemTitles.contains("ch 1–2") && $0.itemTitles.contains("ch 3–4")},"Native channel menus expose both pairs from the attached Numark")
if let rep = host.bitmapImageRepForCachingDisplay(in:host.bounds) { host.cacheDisplay(in:host.bounds,to:rep);try XCTUnwrap(rep.representation(using:.png,properties:[:])).write(to:URL(fileURLWithPath:"/private/tmp/kjmix-xml-mappings/audio-routing.png")) }
}
func testXMLStandardLEDOutputHonoursOverridesAndInversion() throws {