removed unwanted bar now with waveforms, major updates
This commit is contained in:
@@ -2918,4 +2918,40 @@ extension KJamsCloneTests {
|
||||
XCTAssertNotNil(try WaveformCache.load(audio:URL(fileURLWithPath:song.audio),directory:target.appendingPathComponent("Waveforms")))
|
||||
}
|
||||
|
||||
func testStorageCopyCancellationBetweenChunksKeepsOriginalAndRemovesStaging() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true)
|
||||
let source = root.appendingPathComponent("Source.bin"),destination = root.appendingPathComponent("Destination.bin")
|
||||
try Data(repeating:0x5A,count:4*1024*1024).write(to:source)
|
||||
let hash = try ManagedMediaStorage.hash(source,cancelled:{false}).map{String(format:"%02x",$0)}.joined()
|
||||
var cancelled = false,bytes: Int64 = 0
|
||||
XCTAssertThrowsError(try MediaByteCopy.copy(source,to:destination,expectedHash:hash,cancelled:{cancelled},bytesCopied:{ count in bytes = count;cancelled = true })) { error in XCTAssertTrue(error is CancellationError) }
|
||||
XCTAssertEqual(bytes,1_048_576)
|
||||
XCTAssertTrue(FileManager.default.fileExists(atPath:source.path));XCTAssertFalse(FileManager.default.fileExists(atPath:destination.path))
|
||||
XCTAssertEqual(try FileManager.default.contentsOfDirectory(atPath:root.path),["Source.bin"])
|
||||
}
|
||||
func testDJStorageReportsAndCancelsBeforeDiscovery() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
var cancelled = false,updates = [String]()
|
||||
XCTAssertThrowsError(try DJStorageMove.run(database:root.appendingPathComponent("Library.sqlite"),defaultRoot:root,destination:root.appendingPathComponent("Destination"),cancelled:{cancelled},progress:{ updates.append($0.current);cancelled = true })) { error in XCTAssertTrue(error is CancellationError) }
|
||||
XCTAssertEqual(updates.first,"Checking DJ storage…")
|
||||
XCTAssertFalse(FileManager.default.fileExists(atPath:root.appendingPathComponent("Destination").path))
|
||||
}
|
||||
@MainActor func testDJStorageDialogAppearsWithoutParentModelChange() async throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let model = AppModel(storageURL:root)
|
||||
let host = NSHostingView(rootView:StudioSettingsDialog(model:model,scope:"DJ",category:"Library"))
|
||||
let window = NSWindow(contentRect:NSRect(x:0,y:0,width:900,height:750),styleMask:[.titled],backing:.buffered,defer:false)
|
||||
window.contentView = host;window.setFrameOrigin(NSPoint(x:-10000,y:-10000));window.orderFront(nil)
|
||||
defer { model.dj.storageProgress = nil;window.orderOut(nil);window.contentView = nil }
|
||||
try await Task.sleep(nanoseconds:100_000_000)
|
||||
model.dj.storageProgress = .init(current:"Preparing DJ storage move…")
|
||||
for _ in 0..<100 where window.sheets.isEmpty { try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertFalse(window.sheets.isEmpty,"The DJ child model must present progress immediately without an unrelated AppModel refresh")
|
||||
model.dj.storageProgress = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user