Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension RunnerTests {
reusingFocusedInput: Bool = false,
tapContext: SynthesizedCoordinateContext? = nil
) throws -> TextEntryTarget {
let contentTranslation = liveContentTranslation(app: app)
let contentTranslation = liveContentTranslation(app: app, reusing: tapContext)
guard let x, let y else {
let softwareKeyboardVisible = isKeyboardVisible(app: app)
if !softwareKeyboardVisible, let rememberedTarget = rememberedTextEntryTarget(contentTranslation: contentTranslation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,16 @@ extension RunnerTests {
guard case .success(let translation) = read else { return .unknown }
return translation
}

/// The content vector of the window `context` already resolved for this command, so a text entry
/// does not query the windows twice. A context without its own resolved window (a sole-screen
/// frame, an unreadable tree) or one booked on a lit panel proves no window origin, so it reads.
func liveContentTranslation(app: XCUIApplication, reusing context: SynthesizedCoordinateContext?) -> TextEntryContentTranslation {
guard let context, context.resolvedWindow != nil, !context.treeUnreadable, requestLitPanel == nil else {
return liveContentTranslation(app: app)
}
let window = context.geometry.windowOnScreen.rect
return SnapshotContentTranslation.offset(reportedBox: CGRect(origin: .zero, size: window.size), viewportBox: window)
.map { .known($0) } ?? TextEntryContentTranslation.none
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension RunnerTests {
// A replacement with no input at the point has nothing to bind to: its clear and its typed
// text would reach the app-level first responder, so an empty point and a lookup that cannot
// answer both refuse here, each under its own reason.
let contentTranslation = liveContentTranslation(app: activeApp)
let contentTranslation = liveContentTranslation(app: activeApp, reusing: treeContext)
let inputAtPoint: TextInputAtPoint
let inputsAtPoint: [ResolvedTextEntryInput]
switch try coordinateTapTextInputIdentityAt(app: activeApp, x: x, y: y, contentTranslation: contentTranslation) {
Expand Down
Loading