11import XCTest
22
3- // Text-entry target acquisition: choosing the element a `type`/`fill` will address and getting
4- // focus onto it — the one-shot tap witness, the post-tap stabilization, and the
5- // `focusTextInputForTextEntry` entry point the command layer calls. Whether that target is ready
6- // is RunnerTests+TextEntryReadiness.swift's question, and this file asks it rather than answering
7- // it.
83extension RunnerTests {
94 /// Books the tap as the address for the next bare `type`. `element` is a text input the caller
105 /// classified BEFORE dispatching, or nil when the tap hit nothing worth typing into; that is the whole
@@ -71,7 +66,6 @@ extension RunnerTests {
7166#if os( tvOS )
7267 return TextEntryStabilization ( element : target , focusConfirmed : true )
7368#else
74- let latest = target
7569 let keyboardVisibleAtEntry = keyboardVisibleBeforeTap ?? isKeyboardVisible ( app : app )
7670 let deadline = Date ( ) . addingTimeInterval ( TextEntryTiming . focusTimeout )
7771 while Date ( ) < deadline {
@@ -81,16 +75,16 @@ extension RunnerTests {
8175 // focusedTextInput is intentionally nil on iOS; treat the keyboard transitioning to
8276 // visible after our tap as the focus-moved signal. Don't fast-path when it was already up.
8377 if keyboardBecameVisible ( app : app , wasVisibleAtEntry : keyboardVisibleAtEntry ) {
84- return TextEntryStabilization ( element : latest , focusConfirmed : true )
78+ return TextEntryStabilization ( element : target , focusConfirmed : true )
8579 }
8680#if os( iOS )
87- if let latest , keyboardFocusConfirmed ( app : app , element : latest ) {
88- return TextEntryStabilization ( element : latest , focusConfirmed : true )
81+ if let target , keyboardFocusConfirmed ( app : app , element : target ) {
82+ return TextEntryStabilization ( element : target , focusConfirmed : true )
8983 }
9084#endif
9185 sleepFor ( TextEntryTiming . pollInterval )
9286 }
93- return TextEntryStabilization ( element : latest , focusConfirmed : false )
87+ return TextEntryStabilization ( element : target , focusConfirmed : false )
9488#endif
9589 }
9690
@@ -156,10 +150,9 @@ extension RunnerTests {
156150 refreshPoint : requestedPoint ,
157151 prefersFocusedElement : false
158152 )
159- let concreteTargetReady = keyboardVisibleBeforeTap && readyTarget . element != nil
160- let element = stabilized . focusConfirmed || concreteTargetReady
161- ? ( stabilized . element ?? target )
162- : ( waitForTextEntryReadiness ( app : app , target : readyTarget ) ?? stabilized . element ?? target )
153+ let element = stabilized . focusConfirmed
154+ ? readyTarget . element
155+ : ( waitForTextEntryReadiness ( app : app , target : readyTarget ) ?? readyTarget . element )
163156 return TextEntryTarget (
164157 element : element ,
165158 refreshPoint : textEntryRefreshPoint ( for : element , fallbackTo : requestedPoint ) ,
@@ -191,10 +184,4 @@ extension RunnerTests {
191184 }
192185 return CGPoint ( x : frame . midX , y : frame . midY )
193186 }
194-
195- /// A focus-moved signal for iOS text entry, where `focusedTextInput` is intentionally nil.
196- /// The software keyboard TRANSITIONING from hidden (at entry) to visible means the field we
197- /// just tapped gained first-responder. If the keyboard was ALREADY up (e.g. back-to-back
198- /// fills into different fields), its visibility is not evidence focus moved to the new field,
199- /// so callers must keep waiting rather than typing into the previously-focused field.
200187}
0 commit comments