@@ -109,6 +109,8 @@ @interface AgentDeviceRunnerViewController : UIViewController
109109@property (nonatomic , assign ) NSTimeInterval textEntryBurstMinGap;
110110@property (nonatomic , assign ) NSTimeInterval textEntryAcknowledgeWindowSeconds;
111111@property (nonatomic , strong ) NSLayoutConstraint *textEntryFieldTop;
112+ @property (nonatomic , weak ) UITextField *textEntryField;
113+ @property (nonatomic , weak ) UITextField *mixedTextInputField;
112114@property (nonatomic , assign ) BOOL alertFixtureStarted;
113115@property (nonatomic , strong ) NSTimer *alertActivationBusyBackstop;
114116@property (nonatomic , strong ) NSTimer *alertBannerRepost;
@@ -545,20 +547,38 @@ - (void)agentDeviceTextEntryDidChange:(UITextField *)textField {
545547 }
546548 if ((codeComplete && [arguments containsObject: @" --agent-device-text-entry-auto-submit" ]) ||
547549 (textField.text .length > 0 && [arguments containsObject: @" --agent-device-text-entry-replace-after-input" ])) {
548- UITextField *nextScreenField = [[UITextField alloc ] initWithFrame: textField.frame];
549- if (![arguments containsObject: @" --agent-device-text-entry-unnamed-input" ]) {
550- nextScreenField.accessibilityIdentifier = @" agent-device-auto-submit-next-screen-input" ;
551- }
552- nextScreenField.borderStyle = UITextBorderStyleRoundedRect;
553- [textField.superview addSubview: nextScreenField];
554- [textField removeFromSuperview ];
555- [nextScreenField becomeFirstResponder ];
550+ [self replaceTextEntryFieldWithNextScreenInput: textField];
556551 } else if (codeComplete &&
557552 [arguments containsObject: @" --agent-device-text-entry-auto-submit-without-successor" ]) {
558553 [textField removeFromSuperview ];
559554 }
560555}
561556
557+ - (void )replaceTextEntryFieldWithNextScreenInput : (UITextField *)textField {
558+ UITextField *nextScreenField = [[UITextField alloc ] initWithFrame: textField.frame];
559+ if (![NSProcessInfo .processInfo.arguments containsObject: @" --agent-device-text-entry-unnamed-input" ]) {
560+ nextScreenField.accessibilityIdentifier = @" agent-device-auto-submit-next-screen-input" ;
561+ }
562+ nextScreenField.borderStyle = UITextBorderStyleRoundedRect;
563+ [textField.superview addSubview: nextScreenField];
564+ [textField removeFromSuperview ];
565+ [nextScreenField becomeFirstResponder ];
566+ }
567+
568+ // The same navigation as `replace-after-input`, landing when a test presses the button instead of on
569+ // an edit, so the test decides which runner step it lands between.
570+ - (void )agentDeviceTextEntryReplaceDidPress : (UIButton *)sender {
571+ (void )sender;
572+ if (self.textEntryField .superview != nil ) {
573+ [self replaceTextEntryFieldWithNextScreenInput: self .textEntryField];
574+ }
575+ }
576+
577+ - (void )agentDeviceMixedTextInputRemoveFieldDidPress : (UIButton *)sender {
578+ (void )sender;
579+ [self .mixedTextInputField removeFromSuperview ];
580+ }
581+
562582// Stops answering the element-type query that found it, the moment it takes focus, under
563583// `--agent-device-text-entry-unqueryable-on-focus`. #3060's Flutter password field reaches this shape
564584// because its two accessibility channels disagree once focused — `TextField` through the legacy
@@ -689,6 +709,31 @@ - (void)viewDidLoad {
689709 }
690710 }
691711
712+ // A text field ahead of two search fields among all text inputs. Removing the text field moves the
713+ // second search field into the first one's position among all text inputs, but not among search
714+ // fields. A search bar's field reads as a search field; a bare `UISearchTextField` reads as a text
715+ // field.
716+ if ([NSProcessInfo .processInfo.arguments containsObject: @" --agent-device-mixed-text-inputs" ]) {
717+ UITextField *field = [[UITextField alloc ] initWithFrame: CGRectMake (40 , 120 , 260 , 44 )];
718+ field.accessibilityIdentifier = @" mixed-text" ;
719+ field.borderStyle = UITextBorderStyleRoundedRect;
720+ [self .view addSubview: field];
721+ self.mixedTextInputField = field;
722+ for (NSUInteger index = 0 ; index < 2 ; index++) {
723+ UISearchBar *search = [[UISearchBar alloc ] initWithFrame: CGRectMake (40 , 180 + index * 60 , 260 , 44 )];
724+ search.searchTextField .accessibilityIdentifier = @[@" mixed-search-a" , @" mixed-search-b" ][index];
725+ [self .view addSubview: search];
726+ }
727+ UIButton *removeField = [UIButton buttonWithType: UIButtonTypeSystem];
728+ removeField.frame = CGRectMake (40 , 320 , 260 , 44 );
729+ removeField.accessibilityIdentifier = @" mixed-remove-text" ;
730+ [removeField setTitle: @" Remove text field" forState: UIControlStateNormal];
731+ [removeField addTarget: self
732+ action: @selector (agentDeviceMixedTextInputRemoveFieldDidPress: )
733+ forControlEvents: UIControlEventTouchUpInside];
734+ [self .view addSubview: removeField];
735+ }
736+
692737 if ([NSProcessInfo .processInfo.arguments containsObject: @" --agent-device-text-entry-regression" ]) {
693738 BOOL digitCountValue =
694739 [NSProcessInfo .processInfo.arguments containsObject: @" --agent-device-text-entry-digit-count-value" ];
@@ -738,6 +783,7 @@ - (void)viewDidLoad {
738783 forControlEvents: UIControlEventEditingChanged];
739784 textField.translatesAutoresizingMaskIntoConstraints = NO ;
740785 [self .view addSubview: textField];
786+ self.textEntryField = textField;
741787 self.textEntryFieldTop = [textField.topAnchor constraintEqualToAnchor: label.bottomAnchor
742788 constant: AgentDeviceTextEntryFieldTopInset];
743789 [NSLayoutConstraint activateConstraints: @[
@@ -800,6 +846,21 @@ - (void)viewDidLoad {
800846 ]];
801847 [self updateTapWitnessStatus ];
802848 }
849+ if ([NSProcessInfo .processInfo.arguments containsObject: @" --agent-device-text-entry-replace-on-request" ]) {
850+ // Above the title, so the software keyboard never covers it.
851+ UIButton *replace = [UIButton buttonWithType: UIButtonTypeSystem];
852+ replace.accessibilityIdentifier = @" agent-device-text-entry-replace" ;
853+ [replace setTitle: @" Replace input" forState: UIControlStateNormal];
854+ replace.translatesAutoresizingMaskIntoConstraints = NO ;
855+ [replace addTarget: self
856+ action: @selector (agentDeviceTextEntryReplaceDidPress: )
857+ forControlEvents: UIControlEventTouchUpInside];
858+ [self .view addSubview: replace];
859+ [NSLayoutConstraint activateConstraints: @[
860+ [replace.centerXAnchor constraintEqualToAnchor: self .view.centerXAnchor],
861+ [replace.bottomAnchor constraintEqualToAnchor: label.topAnchor constant: -24 ],
862+ ]];
863+ }
803864 if ([NSProcessInfo .processInfo.arguments containsObject: @" --agent-device-text-entry-unqueryable-on-focus" ]) {
804865 self.textEntryFocusWitness = [[UILabel alloc ] init ];
805866 self.textEntryFocusWitness .accessibilityIdentifier = @" agent-device-text-entry-focus" ;
0 commit comments