broken changes
This commit is contained in:
@@ -1733,6 +1733,14 @@ extension KJamsCloneTests {
|
||||
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-dj-native.png")) }
|
||||
XCTAssertEqual(model.dj.a.player.currentSongID,id);XCTAssertEqual(model.dj.b.player.currentSongID,id)
|
||||
XCTAssertFalse(model.dj.a.player.playing);XCTAssertNil(model.player.currentSongID)
|
||||
let settings = NSHostingView(rootView:StudioSettingsDialog(model:model).preferredColorScheme(.dark))
|
||||
settings.frame = NSRect(x:0,y:0,width:760,height:680)
|
||||
let settingsWindow = NSWindow(contentRect:settings.frame,styleMask:[.borderless],backing:.buffered,defer:false)
|
||||
settingsWindow.appearance = NSAppearance(named:.darkAqua);settingsWindow.contentView = settings
|
||||
settingsWindow.setFrameOrigin(NSPoint(x:-10000,y:-10000));settingsWindow.orderFront(nil)
|
||||
defer { settingsWindow.orderOut(nil);settingsWindow.contentView = nil }
|
||||
try await Task.sleep(nanoseconds:200_000_000);settings.layoutSubtreeIfNeeded()
|
||||
if let rep = settings.bitmapImageRepForCachingDisplay(in:settings.bounds) { settings.cacheDisplay(in:settings.bounds,to:rep);try XCTUnwrap(rep.representation(using:.png,properties:[:])).write(to:URL(fileURLWithPath:"/private/tmp/kjmix-settings-native.png")) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1799,3 +1807,48 @@ extension KJamsCloneTests {
|
||||
XCTAssertNotEqual(model.dragReference(track.id).library,model.dj.dragReference(track.id).library)
|
||||
}
|
||||
}
|
||||
|
||||
extension KJamsCloneTests {
|
||||
func testMediaByteCopyRepairsPartialFileWithoutCopyingSourcePermissions() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let source = root.appendingPathComponent("Read-only original.mp3"),destination = root.appendingPathComponent("Managed.mp3")
|
||||
let bytes = Data(repeating:0x42,count:2_200_000);try bytes.write(to:source)
|
||||
try FileManager.default.setAttributes([.posixPermissions:0o444],ofItemAtPath:source.path)
|
||||
try Data().write(to:destination)
|
||||
let hash = try MediaByteCopy.digest(source)
|
||||
try MediaByteCopy.copy(source,to:destination,expectedHash:hash)
|
||||
XCTAssertEqual(try Data(contentsOf:destination),bytes)
|
||||
XCTAssertTrue(FileManager.default.isWritableFile(atPath:destination.path))
|
||||
XCTAssertEqual(try FileManager.default.attributesOfItem(atPath:source.path)[.posixPermissions] as? NSNumber,NSNumber(value:0o444))
|
||||
XCTAssertThrowsError(try MediaByteCopy.copy(source,to:destination,expectedHash:"wrong"))
|
||||
XCTAssertEqual(try Data(contentsOf:destination),bytes,"A failed verification must preserve the existing destination")
|
||||
XCTAssertThrowsError(try MediaByteCopy.copy(source,to:root.appendingPathComponent("Cancelled.mp3"),expectedHash:hash,cancelled:{true}))
|
||||
XCTAssertFalse(FileManager.default.fileExists(atPath:root.appendingPathComponent("Cancelled.mp3").path))
|
||||
XCTAssertFalse(try FileManager.default.contentsOfDirectory(atPath:root.path).contains{$0.hasPrefix(".kjmix-import-")})
|
||||
}
|
||||
func testRetryImportRepairsEmptyRegisteredAudioAndGraphicsCopies() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let fixture = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/Demo.mp3"))
|
||||
let db = try Library(url:root.appendingPathComponent("Library.sqlite")),importer = Importer(media:root.appendingPathComponent("Media"))
|
||||
let ids = try importer.run([fixture],library:db),song = try XCTUnwrap(try db.songs().first)
|
||||
try Data().write(to:URL(fileURLWithPath:song.audio))
|
||||
if let graphics = song.cdg { try Data().write(to:URL(fileURLWithPath:graphics)) }
|
||||
XCTAssertEqual(try importer.run([fixture],library:db),ids)
|
||||
XCTAssertEqual(try db.songs().count,1)
|
||||
XCTAssertEqual(try MediaByteCopy.digest(URL(fileURLWithPath:song.audio)),try MediaByteCopy.digest(fixture))
|
||||
if let graphics = song.cdg { XCTAssertTrue(MediaByteCopy.nonempty(URL(fileURLWithPath:graphics))) }
|
||||
}
|
||||
@MainActor func testEmptyAudioShowsRepairInstructionInsteadOfCoreAudioError() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let file = root.appendingPathComponent("Empty.mp3");try Data().write(to:file)
|
||||
let player = Player(waveformCacheDirectory:root.appendingPathComponent("Waveforms"),persistsMix:false)
|
||||
XCTAssertThrowsError(try player.load(.init(id:1,title:"Empty",audio:file.path,cdg:nil,rating:0,plays:0),startPlaying:false)) { error in XCTAssertTrue(error.localizedDescription.contains("Reimport the original media")) }
|
||||
XCTAssertFalse(player.playing);XCTAssertNil(player.currentSongID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user