Sync build 64 manual reader and qualification tests

This commit is contained in:
Brian Holman committed 2026-11-14 08:35:30 -07:00
1 parent 8236ca17c6
commit 4abc194001
5 files changed
+272 -76

No files matched your search

+7 -7
View File
@@ -1477,9 +1477,9 @@
"sha256": "88d79ec55224f10526f13f769051ccaca3dcb1aa9b8b322453068e21ebae6758"
},
"platforms/macos/App/SoftwareLibraryManual.swift": {
"bytes": 20922,
"bytes": 23366,
"mode": "0644",
"sha256": "0fee8fa02746dffab23b95424bef626a0bde5b3ba4677183ea8f73cc29ff524b"
"sha256": "6015e7c10259ff2b695a89002dd189d6a3b93418d0dafff55094a3ab00325ddd"
},
"platforms/macos/App/SoftwareLibraryModel.swift": {
"bytes": 54804,
@@ -3092,9 +3092,9 @@
"sha256": "1156150ca854eac302bf64ad177b95b490ac6b0da24dc40814ccf26bad2de925"
},
"platforms/macos/Tests/SoftwareLibraryManualTests.swift": {
"bytes": 11045,
"bytes": 16659,
"mode": "0644",
"sha256": "2db6776f141792edb63222efa82aafaedac6230a4cb3b8c57825bed691ebf4b6"
"sha256": "319c2c716052f14ec34fbd0d38821ebdaa77bb59a58f46541482885ba651edd9"
},
"platforms/macos/Tests/SoftwareLibraryPersonalTests.swift": {
"bytes": 29119,
@@ -3217,14 +3217,14 @@
"sha256": "2c86f35bc0d0d0f898583a4bc8f1dc5004ac065b2f55df41976cd50e90533c97"
},
"platforms/macos/UITests/InteractionTests.swift": {
"bytes": 333203,
"bytes": 335595,
"mode": "0644",
"sha256": "1b526e1be1ab9095d7de9b4d66a68095eaa288c1b5ca2fdba3d6991bfd4d09c0"
"sha256": "2a17d4b2fcee5845bbabe4b35ea732d2dfc9c54906666c1268b0e2e0710353ff"
},
"platforms/macos/VCC.xcodeproj/project.pbxproj": {
"bytes": 180154,
"mode": "0644",
"sha256": "6cabd50774087899af4d3c844d1fa3e8101eb440b2e54dc809fd86bbd919812f"
"sha256": "52979940cd638a315f56377eebede21f83141cff125bb2e29f4d88ade19bc5ba"
},
"platforms/macos/VCC.xcodeproj/xcshareddata/xcschemes/VCCCoreChecks.xcscheme": {
"bytes": 2337,
+114 -56
View File
@@ -101,19 +101,26 @@ final class SoftwareLibraryManualModel: ObservableObject {
@Published var page = 1
@Published var searchText = ""
@Published var searchMessage = ""
let pdfView = PDFView()
let pdfView = SoftwareManualPDFView()
private var task: Task<Void, Never>?
private var directory: URL?
private var companion: (any CompanionLibraryAccess)?
#if !VCC_COMPANION_CLIENT
var continuity: LibraryContinuityStore?
private var savedPosition: LibraryReadingPosition?
#endif
private var positionTracking: [NSObjectProtocol] = []
private var lastPositionSave = Date.distantPast
private var restoringPosition = false
@Published private(set) var readingReady = false
func open(_ asset: SoftwareLibraryAsset, directory: URL, companion: (any CompanionLibraryAccess)? = nil) {
if self.asset?.id == asset.id && (document != nil || text != nil) { return }
let retained = self.asset?.id == asset.id && (document != nil || text != nil)
if retained && (readingReady || pdfView.whenLaidOut != nil) { return }
saveReadingPosition(force: true)
stopPositionTracking()
#if !VCC_COMPANION_CLIENT
savedPosition = companion == nil ? continuity?.reading(for: "software-manual:" + asset.id) : nil
#endif
if retained { return }
task?.cancel(); self.asset = asset; self.directory = directory; self.companion = companion
document = nil; pdfView.document = nil; text = nil; textView.string = ""; page = 1; searchText = ""; searchMessage = ""; error = nil; loading = true
task = Task {
@@ -147,7 +154,7 @@ final class SoftwareLibraryManualModel: ObservableObject {
text = decoded; textView.string = decoded
} else {
guard let loaded = PDFDocument(url: local), !loaded.isLocked, loaded.pageCount > 0 else { throw SoftwareLibraryManualCache.Failure.response }
document = loaded; pdfView.document = loaded; pdfView.autoScales = true
document = loaded; pdfView.document = loaded
}
loading = false
} catch is CancellationError { }
@@ -156,9 +163,9 @@ final class SoftwareLibraryManualModel: ObservableObject {
}
func cancel() { saveReadingPosition(force: true); task?.cancel(); loading = false; stopPositionTracking() }
func retry() { if let asset, let directory { open(asset, directory: directory, companion: companion) } }
func goToPage() {
func goToPage(_ number: Int? = nil) {
guard let document else { return }
page = min(max(page, 1), document.pageCount)
page = min(max(number ?? page, 1), document.pageCount)
if let target = document.page(at: page - 1) { pdfView.go(to: target) }
}
func findNext() {
@@ -168,67 +175,106 @@ final class SoftwareLibraryManualModel: ObservableObject {
if let selection { pdfView.setCurrentSelection(selection, animate: false); pdfView.go(to: selection); searchMessage = "" }
else { searchMessage = "No matching text. Scanned pages may not contain searchable text." }
}
func stopPositionTracking() {
private func stopPositionTracking() {
if readingReady { readingReady = false }
pdfView.whenLaidOut = nil
for token in positionTracking { NotificationCenter.default.removeObserver(token) }
positionTracking = []
}
func restoreReadingPosition() {
#if !VCC_COMPANION_CLIENT
guard companion == nil, let asset, let continuity else { return }
let identity = asset.id
let saved = continuity.reading(for: "software-manual:" + identity)
restoringPosition = true
DispatchQueue.main.async { [weak self] in
guard let self, self.asset?.id == identity else { return }
defer { self.restoringPosition = false; self.trackReadingPosition() }
if let saved, let document = self.document {
let index = min(max(0,saved.page-1),document.pageCount-1)
self.page = index+1
if let page = document.page(at: index) {
self.pdfView.autoScales = saved.autoScales ?? true
if saved.autoScales == false, let zoom = saved.zoom { self.pdfView.scaleFactor = min(10,max(0.1,zoom)) }
let bounds = page.bounds(for: self.pdfView.displayBox)
self.pdfView.go(to: PDFDestination(page: page, at: CGPoint(x: bounds.minX + bounds.width * saved.horizontalOffset,
y: bounds.minY + bounds.height * saved.offset)))
guard !readingReady, let asset else { return }
if let document {
pdfView.whenLaidOut = { [weak self] in
guard let self, self.document === document, self.pdfView.document === document else { return }
self.pdfView.autoScales = true
var number = 1
#if !VCC_COMPANION_CLIENT
if let saved = self.savedPosition {
number = min(max(1, saved.page), document.pageCount)
if saved.autoScales == false, let zoom = saved.zoom {
self.pdfView.autoScales = false
self.pdfView.scaleFactor = min(10, max(0.1, zoom))
}
}
} else if let saved, let clip = self.textView.enclosingScrollView?.contentView {
let height = max(0,self.textView.bounds.height - clip.bounds.height)
clip.scroll(to: NSPoint(x: 0,y: height * saved.offset))
self.textView.enclosingScrollView?.reflectScrolledClipView(clip)
#endif
self.pdfView.layoutDocumentView()
self.goToPage(number)
#if !VCC_COMPANION_CLIENT
if let saved = self.savedPosition, let target = document.page(at: number - 1) {
let bounds = target.bounds(for: self.pdfView.displayBox)
let point = CGPoint(x: bounds.minX + bounds.width * saved.horizontalOffset,
y: bounds.minY + bounds.height * saved.offset)
self.pdfView.go(to: PDFDestination(page: target, at: point))
}
#endif
self.trackReadingPosition()
}
pdfView.needsLayout = true
} else if text != nil {
DispatchQueue.main.async { [weak self] in
guard let self, self.asset?.id == asset.id, self.text != nil,
let clip = self.textView.enclosingScrollView?.contentView else { return }
#if !VCC_COMPANION_CLIENT
if let saved = self.savedPosition {
let height = max(0, self.textView.bounds.height - clip.bounds.height)
clip.scroll(to: NSPoint(x: 0, y: height * saved.offset))
self.textView.enclosingScrollView?.reflectScrolledClipView(clip)
}
#endif
self.trackReadingPosition()
}
}
#endif
}
private func trackReadingPosition() {
stopPositionTracking()
guard !readingReady else { return }
readingReady = true
for name in [Notification.Name.PDFViewPageChanged, .PDFViewScaleChanged] {
positionTracking.append(NotificationCenter.default.addObserver(forName: name, object: pdfView, queue: .main) { [weak self] _ in
Task { @MainActor [weak self] in self?.saveReadingPosition(force: true) }
Task { @MainActor [weak self] in self?.updateReadingPosition(force: true) }
})
}
let clip = document == nil ? textView.enclosingScrollView?.contentView : pdfView.documentView?.enclosingScrollView?.contentView
if let clip {
clip.postsBoundsChangedNotifications = true
positionTracking.append(NotificationCenter.default.addObserver(forName: NSView.boundsDidChangeNotification, object: clip, queue: .main) { [weak self] _ in
Task { @MainActor [weak self] in self?.saveReadingPosition() }
Task { @MainActor [weak self] in self?.updateReadingPosition() }
})
}
}
func saveReadingPosition(force: Bool = false) {
#if !VCC_COMPANION_CLIENT
guard !restoringPosition, companion == nil, let asset, let continuity, document != nil || text != nil,
force || Date().timeIntervalSince(lastPositionSave) >= 1 else { return }
lastPositionSave = Date()
var position = LibraryReadingPosition(documentID: asset.id,page: page)
if let document, let destination = pdfView.currentDestination, let current = destination.page {
position.page = document.index(for: current)+1
let bounds = current.bounds(for: pdfView.displayBox)
position.offset = bounds.height > 0 ? min(1,max(0,(destination.point.y-bounds.minY)/bounds.height)) : 0
position.horizontalOffset = bounds.width > 0 ? min(1,max(0,(destination.point.x-bounds.minX)/bounds.width)) : 0
position.zoom = pdfView.scaleFactor; position.autoScales = pdfView.autoScales
} else if let clip = textView.enclosingScrollView?.contentView {
position.offset = min(1,max(0,clip.bounds.minY / max(1,textView.bounds.height - clip.bounds.height)))
private func updateReadingPosition(force: Bool = false) {
guard readingReady else { return }
if let document, let current = pdfView.currentDestination?.page, current.document === document {
let index = document.index(for: current)
if (0..<document.pageCount).contains(index), page != index + 1 { page = index + 1 }
}
saveReadingPosition(force: force)
}
private func saveReadingPosition(force: Bool = false) {
#if !VCC_COMPANION_CLIENT
guard readingReady, companion == nil, let asset, let continuity,
force || Date().timeIntervalSince(lastPositionSave) >= 1 else { return }
var position = LibraryReadingPosition(documentID: asset.id, page: page)
if let document {
guard let destination = pdfView.currentDestination, let current = destination.page,
current.document === document else { return }
let index = document.index(for: current)
let bounds = current.bounds(for: pdfView.displayBox)
let point = destination.point
let scale = pdfView.scaleFactor
guard bounds.minX.isFinite, bounds.minY.isFinite, bounds.width.isFinite, bounds.height.isFinite,
bounds.width > 0, bounds.height > 0, point.x.isFinite, point.y.isFinite,
scale.isFinite, scale > 0, (0..<document.pageCount).contains(index) else { return }
position.page = index + 1
position.offset = min(1, max(0, (point.y - bounds.minY) / bounds.height))
position.horizontalOffset = min(1, max(0, (point.x - bounds.minX) / bounds.width))
position.zoom = scale; position.autoScales = pdfView.autoScales
} else if text != nil, let clip = textView.enclosingScrollView?.contentView {
position.offset = min(1,max(0,clip.bounds.minY / max(1,textView.bounds.height - clip.bounds.height)))
} else { return }
lastPositionSave = Date()
continuity.setReading(position, for: "software-manual:" + asset.id)
#endif
}
@@ -252,26 +298,26 @@ struct SoftwareLibraryManualView: View {
Button { model.pdfView.zoomIn(nil) } label: { Image(systemName: "plus.magnifyingglass") }.help("Zoom in").accessibilityLabel("Zoom in")
Button("Fit Page") { model.pdfView.autoScales = true }.accessibilityIdentifier("manual-fit")
}
}.padding(12)
}.disabled(model.document != nil && !model.readingReady).padding(12)
if let document = model.document {
HStack {
Button { model.pdfView.goToPreviousPage(nil) } label: { Image(systemName: "chevron.left") }.help("Previous page").accessibilityLabel("Previous page").disabled(model.page <= 1)
Button { model.goToPage(model.page - 1) } label: { Image(systemName: "chevron.left") }.help("Previous page").accessibilityLabel("Previous page").disabled(model.page <= 1)
TextField("Page", value: $model.page, format: .number).frame(width: 45).onSubmit { model.goToPage() }.accessibilityLabel("Page number")
Text("of \(document.pageCount)").foregroundStyle(.secondary)
Button { model.pdfView.goToNextPage(nil) } label: { Image(systemName: "chevron.right") }.help("Next page").accessibilityLabel("Next page").disabled(model.page >= document.pageCount)
Button { model.goToPage(model.page + 1) } label: { Image(systemName: "chevron.right") }.help("Next page").accessibilityLabel("Next page").disabled(model.page >= document.pageCount)
Spacer()
TextField("Find in manual", text: $model.searchText).frame(maxWidth: 230).onSubmit { model.findNext() }.accessibilityIdentifier("manual-search")
Button("Find Next") { model.findNext() }.disabled(model.searchText.isEmpty)
}.padding(.horizontal, 12).padding(.bottom, 10)
}.disabled(!model.readingReady).padding(.horizontal, 12).padding(.bottom, 10)
}
Divider()
if model.document != nil {
HStack(spacing: 0) {
if showPages { ManualPages(view: model.pdfView).frame(width: 115) }
ManualPDF(view: model.pdfView).accessibilityIdentifier("manual-pdf").onAppear { model.restoreReadingPosition() }
ManualPDF(view: model.pdfView).id(model.asset?.id).accessibilityIdentifier("manual-pdf").onAppear { model.restoreReadingPosition() }
}
} else if model.text != nil {
ManualText(view: model.textView).accessibilityIdentifier("manual-text").onAppear { model.restoreReadingPosition() }
ManualText(view: model.textView).id(model.asset?.id).accessibilityIdentifier("manual-text").onAppear { model.restoreReadingPosition() }
} else if model.loading {
VStack(spacing: 12) { ProgressView("Downloading manual…"); Button("Cancel") { model.cancel() } }.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
@@ -292,13 +338,25 @@ struct SoftwareLibraryManualView: View {
}
}.font(.caption).padding(10)
}.frame(minWidth: 620, minHeight: 480)
.onReceive(NotificationCenter.default.publisher(for: .PDFViewPageChanged, object: model.pdfView)) { _ in
if let page = model.pdfView.currentPage, let document = model.document { model.page = document.index(for: page) + 1 }
model.saveReadingPosition(force: true)
}
.onDisappear { model.cancel() }
}
}
// PDFKit chooses its fit scale from the attached view's viewport. Its document and
// scale notifications before that layout do not represent a reading position.
final class SoftwareManualPDFView: PDFView {
var whenLaidOut: (() -> Void)?
override func layout() {
super.layout()
guard whenLaidOut != nil, window != nil, !bounds.isEmpty else { return }
DispatchQueue.main.async { [weak self] in
guard let self, self.window != nil, !self.bounds.isEmpty else { return }
let restore = self.whenLaidOut
self.whenLaidOut = nil
restore?()
}
}
}
private struct ManualPDF: NSViewRepresentable {
let view: PDFView
func makeNSView(context: Context) -> PDFView {
@@ -1,20 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import XCTest
import PDFKit
import SwiftUI
import CryptoKit
@MainActor
final class SoftwareLibraryManualTests: XCTestCase {
private func fixture() throws -> (SoftwareLibraryAsset, Data) {
private func fixture(id: String = "manual", pages: Int = 2, size: NSSize = NSSize(width: 300, height: 500)) throws -> (SoftwareLibraryAsset, Data) {
let pdf = PDFDocument()
for _ in 0..<2 {
let image = NSImage(size: NSSize(width: 300, height: 500))
image.lockFocus(); NSColor.white.setFill(); NSRect(x: 0, y: 0, width: 300, height: 500).fill(); image.unlockFocus()
for _ in 0..<pages {
let image = NSImage(size: size)
image.lockFocus(); NSColor.white.setFill(); NSRect(origin: .zero, size: size).fill(); image.unlockFocus()
pdf.insert(try XCTUnwrap(PDFPage(image: image)), at: pdf.pageCount)
}
let bytes = try XCTUnwrap(pdf.dataRepresentation())
let hash = SHA256.hash(data: bytes).map { String(format: "%02x", $0) }.joined()
var asset = SoftwareLibraryAsset(id: "manual", name: "Manual", kind: "manual", sourceURL: URL(string: "https://colorcomputerarchive.com/repo/Documents/Manuals/Games/Manual.pdf")!, sha256: hash, byteSize: Int64(bytes.count), credit: "Color Computer Archive", matchStatus: "accepted", matchReason: "Reviewed")
var asset = SoftwareLibraryAsset(id: id, name: "Manual", kind: "manual", sourceURL: URL(string: "https://colorcomputerarchive.com/repo/Documents/Manuals/Games/Manual.pdf")!, sha256: hash, byteSize: Int64(bytes.count), credit: "Color Computer Archive", matchStatus: "accepted", matchReason: "Reviewed")
asset.manualURL = URL(string: "https://vccplus.brianholman.com/dl/software/CoCoLibrary/Documents/Manuals/Games/Manual.pdf")
return (asset, bytes)
}
@@ -98,6 +99,110 @@ final class SoftwareLibraryManualTests: XCTestCase {
model.page = 999; model.goToPage(); XCTAssertEqual(model.page, 2)
model.page = -1; model.goToPage(); XCTAssertEqual(model.page, 1)
}
func testFreshPDFStartsAtCoverAndRestoresOnlyTheSavedReadingPosition() async throws {
// At PDFKit's default scale this viewport fits more than two of the
// small pages. Its midpoint and the top of its first page can disagree.
let (asset, bytes) = try fixture(pages: 4, size: NSSize(width: 320, height: 294))
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(at: root) }
try bytes.write(to: root.appendingPathComponent(try XCTUnwrap(asset.sha256) + ".pdf"))
let key = "software-manual:" + asset.id
let frame = NSRect(x: 0, y: 0, width: 900, height: 850)
func waitFor(_ message: String, _ condition: () -> Bool) async throws {
let deadline = ContinuousClock.now + .seconds(8)
while !condition() {
guard ContinuousClock.now < deadline else {
XCTFail(message)
throw CocoaError(.fileReadUnknown)
}
try await Task.sleep(for: .milliseconds(10))
}
}
func attach(_ model: SoftwareLibraryManualModel) -> NSWindow {
let window = NSWindow(contentRect: frame, styleMask: [.titled], backing: .buffered, defer: false)
let host = NSHostingView(rootView: SoftwareLibraryManualView(model: model))
window.contentView = host
host.layoutSubtreeIfNeeded()
window.displayIfNeeded()
return window
}
let saved: LibraryReadingPosition
do {
let model = SoftwareLibraryManualModel()
let store = LibraryContinuityStore(directory: root)
model.continuity = store
let window = attach(model)
defer { window.contentView = nil }
XCTAssertNil(store.reading(for: key))
model.open(asset, directory: root)
try await waitFor("Fresh PDF did not fit its cover in the attached reader") {
model.pdfView.window === window && model.pdfView.autoScales &&
model.pdfView.scaleFactor > 1 && model.pdfView.currentDestination?.page != nil
}
XCTAssertEqual(model.page, 1)
let document = try XCTUnwrap(model.document)
XCTAssertTrue(model.pdfView.currentDestination?.page === document.page(at: 0))
model.goToPage(model.page + 1)
try await waitFor("Next skipped the second page") {
model.page == 2 && model.pdfView.currentDestination?.page === document.page(at: 1)
}
model.goToPage(model.page - 1)
try await waitFor("Previous did not return to the cover") {
model.page == 1 && model.pdfView.currentDestination?.page === document.page(at: 0)
}
model.pdfView.autoScales = false
model.pdfView.scaleFactor = 4
let second = try XCTUnwrap(document.page(at: 1))
model.pdfView.go(to: PDFDestination(page: second, at: CGPoint(x: 60, y: 205)))
try await waitFor("The user-selected location was not observed") { model.page == 2 }
model.cancel()
await store.flush()
saved = try XCTUnwrap(store.reading(for: key))
XCTAssertEqual(saved.page, 2)
XCTAssertEqual(saved.autoScales, false)
XCTAssertEqual(try XCTUnwrap(saved.zoom), 4, accuracy: 0.01)
XCTAssertGreaterThan(saved.offset, 0.1)
XCTAssertLessThan(saved.offset, 0.95)
}
// Closing a different reader while its PDF has loaded but the view has
// not been attached must not replace the last real position.
let unopened = SoftwareLibraryManualModel()
let previousStore = LibraryContinuityStore(directory: root)
unopened.continuity = previousStore
unopened.open(asset, directory: root)
try await waitFor("Detached PDF failed to open") { unopened.document != nil }
unopened.cancel()
XCTAssertEqual(previousStore.reading(for: key), saved)
let restored = SoftwareLibraryManualModel()
let reopenedStore = LibraryContinuityStore(directory: root)
restored.continuity = reopenedStore
XCTAssertEqual(reopenedStore.reading(for: key), saved)
let window = attach(restored)
defer { window.contentView = nil }
restored.open(asset, directory: root)
try await waitFor("Stored PDF page and zoom were lost during attachment") {
restored.page == 2 && !restored.pdfView.autoScales &&
abs(restored.pdfView.scaleFactor - 4) < 0.01
}
let (other, otherBytes) = try fixture(id: "another-manual", pages: 3)
try otherBytes.write(to: root.appendingPathComponent(try XCTUnwrap(other.sha256) + ".pdf"))
restored.open(other, directory: root)
try await waitFor("Switching manuals did not open a fitted cover") {
restored.readingReady && restored.page == 1 && restored.pdfView.autoScales
}
XCTAssertEqual(restored.document?.pageCount, 3)
let reopened = try XCTUnwrap(reopenedStore.reading(for: key))
XCTAssertEqual(reopened.page, saved.page)
XCTAssertEqual(reopened.horizontalOffset, saved.horizontalOffset, accuracy: 0.01)
XCTAssertEqual(reopened.offset, saved.offset, accuracy: 0.01)
}
func testCompanionManualChecksRegularFileBeforeOpening() async throws {
let (asset, bytes) = try fixture()
let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
+38 -5
View File
@@ -75,8 +75,16 @@ final class InteractionTests: XCTestCase {
&& frame.width > 0 && frame.height > 0
var pending = [try app.snapshot()]
while let owned = pending.popLast() {
if finite, owned.elementType == .window,
interruption.elementType == .window, owned.frame == frame {
// AppKit exposes native alerts, sheets and the Caps Lock
// indicator as non-window containers. Require the same
// immutable identity inside this app's own snapshot;
// geometry alone must not accept another app's dialog.
let containers: [XCUIElement.ElementType] = [.window, .dialog, .sheet, .alert]
if finite, containers.contains(interruption.elementType),
owned.elementType == interruption.elementType,
owned.frame == frame,
owned.identifier == interruption.identifier,
owned.label == interruption.label {
// Leave owned modal interaction to the test's explicit
// control. Do not dismiss or claim to handle it here.
return false
@@ -88,6 +96,15 @@ final class InteractionTests: XCTestCase {
// Only a fresh absence check can establish that it vanished.
}
if !element.exists { return false }
let detail = XCTAttachment(string: "Interruption:\n" + element.debugDescription
+ "\n\nIsolated application:\n" + app.debugDescription)
detail.name = "Unowned interruption and isolated-app hierarchy"
detail.lifetime = .keepAlways
self.add(detail)
let screen = XCTAttachment(screenshot: XCUIScreen.main.screenshot())
screen.name = "Whole desktop at unowned interruption"
screen.lifetime = .keepAlways
self.add(screen)
XCTFail("An unexpected window interrupted the isolated test; leave it for its owner.")
return true
}
@@ -3927,6 +3944,8 @@ extension InteractionTests {
let shot = XCTAttachment(screenshot: library.screenshot())
shot.name = "Software Library — light appearance and format filter"; shot.lifetime = .keepAlways; add(shot)
app.typeKey(.escape, modifierFlags: [])
XCTAssertTrue(library.buttons["Clear filters"].exists,
"The live format choice remains active before entering a global search")
search.click(); app.typeText("Mega-Bug")
let cartridge = library.buttons["library-title-0e1c55f0a29a52d91d28903454654bd7"]
XCTAssertTrue(cartridge.waitForExistence(timeout: 5))
@@ -3936,7 +3955,10 @@ extension InteractionTests {
}
XCTAssertEqual(XCTWaiter.wait(for: [XCTNSPredicateExpectation(predicate: oneResult, object: nil)], timeout: 5), .completed)
cartridge.click()
XCTAssertTrue(library.buttons["Clear filters"].exists)
XCTAssertFalse(library.buttons["Clear filters"].exists,
"Entering a global search clears the preceding collection's narrower filters")
let heading = library.descendants(matching: .any)["library-heading"].firstMatch
XCTAssertTrue((heading.value as? String ?? heading.label).contains("Search Results"))
let after = session()
XCTAssertEqual(after[0], before[0]); XCTAssertEqual(after[2], before[2]); XCTAssertEqual(after[3], before[3])
XCTAssertGreaterThan(after[1], before[1])
@@ -4590,7 +4612,18 @@ extension InteractionTests {
XCTAssertEqual(search.frame.minY - library.frame.minY, searchY, accuracy: 2)
search.click(); app.typeText("Pred")
}
library.buttons["Browse All Titles"].click()
let heading = library.descendants(matching: .any)["library-heading"].firstMatch
XCTAssertTrue((heading.value as? String ?? heading.label).contains("Search Results"),
"Typing in the header starts a global search even from an empty collection")
XCTAssertTrue(firstCover.waitForExistence(timeout: 8))
// A global search has results, so its earlier empty-state action is no
// longer a valid click target. Explicitly return to an empty collection
// before exercising that action and its query reset.
library.buttons["library-scope-installed"].click()
XCTAssertTrue(library.staticTexts["No matching titles"].waitForExistence(timeout: 8))
let browse = library.buttons["Browse All Titles"]
XCTAssertTrue(browse.waitForExistence(timeout: 8)); XCTAssertTrue(browse.isHittable)
browse.click()
XCTAssertEqual(search.value as? String, "")
XCTAssertTrue(firstCover.waitForExistence(timeout: 8))
library.buttons["library-category-Cartridges"].click()
@@ -5018,7 +5051,7 @@ extension InteractionTests {
let log = (try? String(contentsOf: folder.appendingPathComponent("drag-trace.txt"))) ?? ""
return log.contains("perform file-count=1") && matches(cover, red: false)
}, object: nil)
XCTAssertEqual(XCTWaiter.wait(for: [delivered], timeout: 180), .completed)
XCTAssertEqual(XCTWaiter.wait(for: [delivered], timeout: 600), .completed)
} else {
source.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).press(forDuration: 0.25,
thenDragTo: cover.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)), withVelocity: .slow, thenHoldForDuration: 1)
@@ -694,7 +694,7 @@ DE524C5CEEB7201C899C173E = { isa = PBXBuildFile; fileRef = 2DDBE7F7A3DE72AD67CB6
"CEEB1C09197841D54A6AD5E8" = { "isa" = "PBXBuildFile"; "fileRef" = "2ECB4508563F3873B436B9EE"; };
"3AE8BC7E4A8F296EB0B7AEFD" = { "isa" = "PBXFileReference"; "lastKnownFileType" = "folder"; "path" = "Resources/About"; "sourceTree" = "<group>"; };
"370CBA86395A91DC191231AB" = { "isa" = "PBXBuildFile"; "fileRef" = "3AE8BC7E4A8F296EB0B7AEFD"; };
"53AAABD74B976C180137280A" = { "isa" = "XCBuildConfiguration"; "name" = "UITesting"; "buildSettings" = { "INFOPLIST_KEY_VCCCompanionProtocolVersion" = "1"; "COPY_PHASE_STRIP" = "NO"; "LD_RUNPATH_SEARCH_PATHS" = ( "$(inherited)", "@executable_path/../Frameworks" ); "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG VCC_UI_TESTING"; "DEBUG_INFORMATION_FORMAT" = "dwarf"; "VCC_BUILD_CONTENT_PROFILE" = "source"; "VCC_SOURCE_ROM_DIR" = ""; "MARKETING_VERSION" = "3.7.0"; "INFOPLIST_FILE" = "App/Info.plist"; "ENABLE_TESTABILITY" = "YES"; "GENERATE_INFOPLIST_FILE" = "YES"; "ENABLE_USER_SCRIPT_SANDBOXING" = "NO"; "SWIFT_OBJC_BRIDGING_HEADER" = "$(SRCROOT)/Bridge/VCCMac-Bridging-Header.h"; "INFOPLIST_KEY_CFBundleDisplayName" = "VCC OSS UI Tests"; "GCC_OPTIMIZATION_LEVEL" = "0"; "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; "PRODUCT_NAME" = "VCC Plus OSS"; "PRODUCT_MODULE_NAME" = "VCCMac"; "OTHER_LDFLAGS" = "$(inherited) -larchive -framework Network"; "INFOPLIST_KEY_LSApplicationCategoryType" = "public.app-category.entertainment"; "PRODUCT_BUNDLE_IDENTIFIER" = "com.brianholman.vccplus.oss.mac.uitesting"; "CURRENT_PROJECT_VERSION" = "63"; }; };
"53AAABD74B976C180137280A" = { "isa" = "XCBuildConfiguration"; "name" = "UITesting"; "buildSettings" = { "INFOPLIST_KEY_VCCCompanionProtocolVersion" = "1"; "COPY_PHASE_STRIP" = "NO"; "LD_RUNPATH_SEARCH_PATHS" = ( "$(inherited)", "@executable_path/../Frameworks" ); "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG VCC_UI_TESTING"; "DEBUG_INFORMATION_FORMAT" = "dwarf"; "VCC_BUILD_CONTENT_PROFILE" = "source"; "VCC_SOURCE_ROM_DIR" = ""; "MARKETING_VERSION" = "3.7.0"; "INFOPLIST_FILE" = "App/Info.plist"; "ENABLE_TESTABILITY" = "YES"; "GENERATE_INFOPLIST_FILE" = "YES"; "ENABLE_USER_SCRIPT_SANDBOXING" = "NO"; "SWIFT_OBJC_BRIDGING_HEADER" = "$(SRCROOT)/Bridge/VCCMac-Bridging-Header.h"; "INFOPLIST_KEY_CFBundleDisplayName" = "VCC OSS UI Tests"; "GCC_OPTIMIZATION_LEVEL" = "0"; "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; "PRODUCT_NAME" = "VCC Plus OSS"; "PRODUCT_MODULE_NAME" = "VCCMac"; "OTHER_LDFLAGS" = "$(inherited) -larchive -framework Network"; "INFOPLIST_KEY_LSApplicationCategoryType" = "public.app-category.entertainment"; "PRODUCT_BUNDLE_IDENTIFIER" = "com.brianholman.vccplus.oss.mac.uitesting"; "CURRENT_PROJECT_VERSION" = "64"; }; };
"4478F567020A87952E7BF5BE" = { "isa" = "XCBuildConfiguration"; "name" = "UITesting"; "buildSettings" = { "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG"; "PRODUCT_NAME" = "VCCCore"; "DEBUG_INFORMATION_FORMAT" = "dwarf"; "GCC_OPTIMIZATION_LEVEL" = "0"; "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; "SKIP_INSTALL" = "YES"; "ENABLE_TESTABILITY" = "YES"; "EXECUTABLE_PREFIX" = "lib"; "GCC_PREPROCESSOR_DEFINITIONS" = ( "$(inherited)", "USE_DEBUG_TESTS=false" ); }; };
"6E5C730B0C1F6F8D5EB8881A" = { "isa" = "XCBuildConfiguration"; "name" = "UITesting"; "buildSettings" = { "ONLY_ACTIVE_ARCH" = "NO"; "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG"; "DEBUG_INFORMATION_FORMAT" = "dwarf"; "CLANG_ENABLE_MODULES" = "YES"; "CODE_SIGN_IDENTITY" = "-"; "MACOSX_DEPLOYMENT_TARGET" = "14.0"; "CLANG_CXX_LANGUAGE_STANDARD" = "c++17"; "ENABLE_TESTABILITY" = "YES"; "GCC_OPTIMIZATION_LEVEL" = "0"; "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; "ARCHS" = "$(ARCHS_STANDARD)"; "HEADER_SEARCH_PATHS" = ( "$(inherited)", "$(SRCROOT)/../../src/core", "$(SRCROOT)/../../src" ); "SDKROOT" = "macosx"; "SWIFT_VERSION" = "5.0"; "CODE_SIGN_STYLE" = "Manual"; "DEVELOPMENT_TEAM" = ""; "VCC_BUILD_CONTENT_PROFILE" = "source"; "CLANG_ENABLE_OBJC_ARC" = "YES"; "CLANG_CXX_LIBRARY" = "libc++"; }; };
"9D61CCD0757A3005AF102148" = { "isa" = "XCBuildConfiguration"; "name" = "UITesting"; "buildSettings" = { "LD_RUNPATH_SEARCH_PATHS" = ( "$(inherited)", "$(PLATFORM_DIR)/Developer/Library/Frameworks" ); "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG"; "DEBUG_INFORMATION_FORMAT" = "dwarf"; "ENABLE_TESTABILITY" = "YES"; "GENERATE_INFOPLIST_FILE" = "YES"; "SWIFT_OBJC_BRIDGING_HEADER" = "$(SRCROOT)/Bridge/VCCMac-Bridging-Header.h"; "GCC_OPTIMIZATION_LEVEL" = "0"; "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; "PRODUCT_NAME" = "VCCCoreTests"; "OTHER_LDFLAGS" = ( "$(inherited)", "-larchive", "-framework", "Network", "-framework", "XCTest" ); "FRAMEWORK_SEARCH_PATHS" = ( "$(inherited)", "$(PLATFORM_DIR)/Developer/Library/Frameworks" ); "PRODUCT_BUNDLE_IDENTIFIER" = "com.brianholman.vccplus.oss.mac.coretests"; "GCC_PREPROCESSOR_DEFINITIONS" = ( "$(inherited)", "DEBUG=1" ); }; };
@@ -1699,7 +1699,7 @@ CF5FFC06DB9D6CE02797B0DB,
"INFOPLIST_KEY_CFBundleDisplayName" = "VCC Plus OSS";
"INFOPLIST_FILE" = "App/Info.plist";
"VCC_BUILD_CONTENT_PROFILE" = "source"; "VCC_SOURCE_ROM_DIR" = ""; "MARKETING_VERSION" = "3.7.0";
"CURRENT_PROJECT_VERSION" = "63";
"CURRENT_PROJECT_VERSION" = "64";
"LD_RUNPATH_SEARCH_PATHS" = ( "$(inherited)", "@executable_path/../Frameworks" );
"GCC_OPTIMIZATION_LEVEL" = "0";
"SWIFT_OPTIMIZATION_LEVEL" = "-Onone";
@@ -1720,7 +1720,7 @@ CF5FFC06DB9D6CE02797B0DB,
"INFOPLIST_KEY_CFBundleDisplayName" = "VCC Plus OSS";
"INFOPLIST_FILE" = "App/Info.plist";
"VCC_BUILD_CONTENT_PROFILE" = "source"; "VCC_SOURCE_ROM_DIR" = ""; "MARKETING_VERSION" = "3.7.0";
"CURRENT_PROJECT_VERSION" = "63";
"CURRENT_PROJECT_VERSION" = "64";
"LD_RUNPATH_SEARCH_PATHS" = ( "$(inherited)", "@executable_path/../Frameworks" );
"GCC_OPTIMIZATION_LEVEL" = "2";
"SWIFT_OPTIMIZATION_LEVEL" = "-O";