importer chnges

This commit is contained in:
Mark Gregory
2026-11-05 11:16:29 +00:00
parent 87cdb42af9
commit 97662bf4bf
8 changed files with 117 additions and 13 deletions
+19
View File
@@ -387,6 +387,25 @@ final class KJamsCloneTests: XCTestCase {
try await model.undoNameChanges();XCTAssertFalse(model.canUndoNames);XCTAssertEqual(model.songs.first?.title,"Artist | Title [Clean]")
XCTAssertEqual(model.songs.first?.id,id)
}
@MainActor func testActualReinterpretationApplyButtonUpdatesSelectedSong() async throws {
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
defer { try? FileManager.default.removeItem(at:root) }
let model = AppModel(storageURL:root)
let id = try XCTUnwrap(model.library).add(title:"SF285-01 - Artist - Title",audio:"/demo.mp3",cdg:nil);try model.refresh()
let host = NSHostingView(rootView:ReinterpretNamesSheet(model:model,ids:[id]).frame(width:1000,height:800).background(Color(nsColor:.windowBackgroundColor)).preferredColorScheme(.light))
host.frame = NSRect(x:0,y:0,width:1000,height:800)
let window = NSWindow(contentRect:host.frame,styleMask:[.borderless],backing:.buffered,defer:false)
window.isReleasedWhenClosed = false;window.appearance = NSAppearance(named:.aqua);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:500_000_000);host.layoutSubtreeIfNeeded()
if let rep = host.bitmapImageRepForCachingDisplay(in:host.bounds) { host.cacheDisplay(in:host.bounds,to:rep);try rep.representation(using:.png,properties:[:])!.write(to:URL(fileURLWithPath:"/tmp/kjmix-reinterpret-ui-test.png")) }
for type in [NSEvent.EventType.leftMouseDown,.leftMouseUp] {
let event = try XCTUnwrap(NSEvent.mouseEvent(with:type,location:NSPoint(x:910,y:800-678),modifierFlags:[],timestamp:ProcessInfo.processInfo.systemUptime,windowNumber:window.windowNumber,context:nil,eventNumber:0,clickCount:1,pressure:type == .leftMouseDown ? 1 : 0));NSApp.sendEvent(event)
}
for _ in 0..<100 { if model.songs.first?.title == "Title" { break };try await Task.sleep(nanoseconds:20_000_000) }
XCTAssertEqual(model.songs.first?.title,"Title");XCTAssertEqual(model.songs.first?.artist,"Artist");XCTAssertEqual(model.songs.first?.trackNumber,"01");XCTAssertTrue(model.canUndoNames)
try await Task.sleep(nanoseconds:100_000_000)
}
func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] }
func testPresetTileXORAndInvalidCoordinates() {
var d = CDGDecoder()