Skip to content

Stop changing the text when the field's delegate rejects it - #2196

Open
rootkiller6788 wants to merge 1132 commits into
google:masterfrom
rootkiller6788:fix-replacetext-delegate-rejection
Open

rootkiller6788 wants to merge 1132 commits into
google:masterfrom
rootkiller6788:fix-replacetext-delegate-rejection

Conversation

@rootkiller6788

Copy link
Copy Markdown

While looking at ActionForReplaceText I noticed the delegate check for shouldChangeCharactersInRange only populated an error and kept going: it still called setText and the block still returned YES. In practice that means a text field whose delegate rejects the new text gets its value forcibly replaced AND the interaction reports a failure - the opposite of what the error message says.

Fix: when the delegate says no, skip the setText (and the change/end notifications that go with it) and fail the action. The normal path is unchanged.

I couldn't run the iOS functional tests locally (no Mac), but traced the flow against GREYActionBlock/GREYElementInteraction to confirm the error-populated-but-YES path was the problem.

tirodkar and others added 30 commits January 24, 2023 18:49
PiperOrigin-RevId: 504431702
…ed integer bitfield

Fixes -Wsingle-bit-bitfield-constant-conversion error:

GREYTouchInjector.m:342:28: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
  flags._firstTouchForView = 1;

PiperOrigin-RevId: 505790790
Convert 1-bit signed char bitfield _firstTouchForView to 1-bit unsigned integer bitfield

Fixes -Wsingle-bit-bitfield-constant-conversion error:...

***

PiperOrigin-RevId: 506466493
…ed char bitfield

Fixes -Wsingle-bit-bitfield-constant-conversion error:

GREYTouchInjector.m:342:28: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
  flags._firstTouchForView = 1;

PiperOrigin-RevId: 506678702
PiperOrigin-RevId: 507627781
Once switching to UIScene API to verify app orientation, there's no need to invoke orientation setter, and UIScene orientation will give the actual orientation value after calling XCUIDevice setOrientation:.

The orientation setter on UIScene also denies the request if the application is in multi-window mode that will break the test.

PiperOrigin-RevId: 508467771
PiperOrigin-RevId: 509287028
Replace application.windows for deprecation of iOS 14 since min version is being bumped to iOS 15.

PiperOrigin-RevId: 509603650
PiperOrigin-RevId: 510514933
The rotation API now gives the precise message when input argument is invalid, or post verification on device orientation fails.

Also remove the versioning check for pre-16 in functional tests because no one is using rotation API with `.faceDown` and `.faceUp`.

PiperOrigin-RevId: 511936085
PiperOrigin-RevId: 512678204
…ndicator.

EarlGrey synchronization will wait for the scroll view indicator to dismiss after scrolling. This extra latency may slow down the UI flow. By turning on the new config, test won't spend the extra time for the synchronization.

PiperOrigin-RevId: 515401070
…tapCount`.

[tapCount](https://developer.apple.com/documentation/uikit/uitouch/1618132-tapcount?language=objc) in UITouch is used by custom gesture recognizers to detect multi-taps. So EarlGrey's instant tap actions are all moved to the new synthetic API to mimic the physical tap actions.

PiperOrigin-RevId: 516272754
PiperOrigin-RevId: 516645040
application.windows is causing a deprecation warning for min deployment target increase for chrome on iOS. Silence this warning.

PiperOrigin-RevId: 517502705
The UIView animation filed at the same time will cause synchronization gap when the first animation completes but the second animation doesn't start (with a delay).

This is because animations share the same tracking object, so the state is not tracked correctly. Using independent tracking object solves the issue.

PiperOrigin-RevId: 520092650
PiperOrigin-RevId: 520776666
PiperOrigin-RevId: 520961717
PiperOrigin-RevId: 522670840
PiperOrigin-RevId: 523172969
PiperOrigin-RevId: 523783587
PiperOrigin-RevId: 525868998
PiperOrigin-RevId: 528011279
PiperOrigin-RevId: 532189097
Swift error loses enum information when being sent across the process via eDO, so people cannot test the Swift error handling via eDO. However, users should still be able to get the information from that error, and this change will allow the error's `errorDescription` being printed within the test failure.

PiperOrigin-RevId: 532333571
Name of recommended function was incorrect. The function is called grey_scrollToContentEdge.

PiperOrigin-RevId: 533232923
PiperOrigin-RevId: 534129208
The failed synchronization will check idling resources again and list the uncompleted idling resources. This iteration should be called on main thread because some idling resources, e.g., GREYWKWebViewIdlingResource, access views' properties.

PiperOrigin-RevId: 536457193
mebrianlin and others added 30 commits February 3, 2026 16:44
Introduces `GREYExecuteBlockWithConfigurationOverride` to execute a block with a specific configuration key temporarily set to a new value, restoring the original value afterward. Adds `GREYExecuteWithSynchronizationDisabled` as a convenience macro to disable synchronization for a block of code.

Updates tests that changes config temporarily to use the new functions. A couple of tests that did not restore the config afterwards have also been updated to avoid config value leaking to other tests.

PiperOrigin-RevId: 865102840
On iOS 26, the `XCUIElement` found as the descendant of an activity sheet is a `StaticText` with `hittable` property as `false/NO`, and calling `-tap` on it causes an Objective-C exception that's not catchable from Swift. Solution is to instead get the center point of the text label as a `XCUICoordinate` and call `-tap` on that instead, which doesn't require updates from existing tests.

PiperOrigin-RevId: 869218423
PiperOrigin-RevId: 869725624
There are some animations with infinity duration in iOS 26, which is automatically capped to 10 sec when the default config is used. This is usually fine, as the default interaction timeout is 30 sec. However, keyboard operations use a separate timeout, which is exactly 10 sec. This causes the app to not idle before the keyboard operation is complete.

Having two sets of timeouts for element interaction is confusing. Consolidate them to use the same timeout.

PiperOrigin-RevId: 872004798
…YDispatchQueueTracker.

The __block attribute is only allowed on local variables. Clang's recent update started reporting this as an error.

PiperOrigin-RevId: 890051192
… is linked in.

In some circumstances, using a non-nil key in a call to addAnimation:forKey: can cause the
animation to behave differently, resulting in the animation not executing.

This change avoids the problem by using a separate NSMapTable (with weak references to the
animation) to track these animations instead of overloading the CoreAnimation key behavior
for EarlGrey tracking.  By using weak values, when the animation goes away, the entry in
the map table will eventually get compacted out of existence by the map table.

PiperOrigin-RevId: 895450792
…tially appeared to solve.

PiperOrigin-RevId: 897978462
Using method_getTypeEncoding is the modern and direct way to retrieve
the type encoding of a method, avoiding the deprecated
method_getDescription.

PiperOrigin-RevId: 930701794
These need to be at least 25 in Xcode 27. Selected the min from the dropdowns in Xcode.

PiperOrigin-RevId: 931350910
### Why

* **Missing Files in Test Rig**: The `FunctionalTestRig` app target was failing to compile and link because newly added `SceneDelegate` files in the filesystem were missing from the Xcode project configuration.
* **Missing Linker Dependencies**: The `FunctionalTestRig` app target lacked a link dependency on `AppFramework.framework` and proper search paths, causing undefined symbol errors for `GREYUILibUtils`.

### What

* **Added SceneDelegate to Project**: Added `SceneDelegate.m` and `SceneDelegate.h` file references and compile sources build phase entries to the `FunctionalTestRig` target in `FunctionalTests.xcodeproj`.
* **Linked AppFramework**: Added `AppFramework.framework` to the `Link Binary With Libraries` phase and configured recursive `USER_HEADER_SEARCH_PATHS` in `FunctionalTestRig` target to resolve `GREYUILibUtils` compilation and linking.

PiperOrigin-RevId: 932501776
### Why

* **Strict Compiler Warning Fixes**: Xcode 27 introduced stricter checks that promoted implicit type conversions to errors (e.g. `-Wimplicit-int-float-conversion` and `-Wsign-conversion`), breaking the compilation of several core utility files.

### What

* **Resolved Implicit Conversions**: Added explicit `CGFloat` and `double` casts to resolve implicit integer-to-floating-point conversions in:
  * `GREYVisibilityCheckerTarget.m`
  * `GREYThoroughVisibilityChecker.m`
  * `CGGeometry+GREYUI.m`
  * `GREYPathGestureUtils.m`
* **Resolved Sign Mismatch**: Changed `integerValue` to `unsignedIntegerValue` in `GREYAppState.m` to match the unsigned `NS_OPTIONS` type of `GREYAppState`.

PiperOrigin-RevId: 932590228
Introduce thread-safe double-checked locking using @synchronized(self) in InstrumentSurrogateDelegate to prevent concurrent swizzling crashes.

PiperOrigin-RevId: 933334887
- No longer gate the synchronization of view navigations by iOS versions, as otherwise seeing flakiness when running on Xcode 27.
- Passing `animated:YES` during navigation stack resets causes the test to crash sometimes. This is a teardown and we are not testing EarlGrey synchronization as part of this, so simply disable animation here.
- Trait matching when selecting tabs using raw text matchers (`GREYText`) causes error that multiple elements are matched. Switched to using more specific matcher.
- Per-test `[self tapBackButton]` calls at the end of test methods were redundant with centralized teardown logic.

PiperOrigin-RevId: 934429414
"space" has been replaced with " " in iOS 26 when Liquid Glass is enabled. This change makes checking for special keys more robust and handles LG change.

PiperOrigin-RevId: 934441967
- No longer gate the synchronization of view navigations by iOS versions, as otherwise seeing flakiness when running on Xcode 27.
- Passing `animated:YES` during navigation stack resets causes the test to crash sometimes. This is a teardown and we are not testing EarlGrey synchronization as part of this, so simply disable animation here.
- Trait matching when selecting tabs using raw text matchers (`GREYText`) causes error that multiple elements are matched. Switched to using more specific matcher.
- Per-test `[self tapBackButton]` calls at the end of test methods were redundant with centralized teardown logic.

PiperOrigin-RevId: 934605869
PiperOrigin-RevId: 939804027
- Expose eDistantObject proxy request headers (EDOClassMessage, EDOClientService, EDOHostPort) in Swift bridging headers.
- Decorate EarlGreyCompatibleSwiftClass with explicit @objc attribute to preserve runtime class metadata across process boundaries.
- Update Xcode project target search paths and compile sources.

PiperOrigin-RevId: 944029715
- Passing `animated:YES` during navigation stack resets causes the test to crash sometimes. This is a teardown and we are not testing EarlGrey synchronization as part of this, so simply disable animation here.
- Trait matching when selecting tabs using raw text matchers (`GREYText`) causes error that multiple elements are matched. Switched to using more specific matcher.
- Per-test `[self tapBackButton]` calls at the end of test methods were redundant with centralized teardown logic.

PiperOrigin-RevId: 944718968
PiperOrigin-RevId: 945809120
Update the test to rotate right before the screenshot, so the action to test is closer to the assertion. This prevents an issue when the test is run on a smaller screen, as the `openTestViewNamed:` will scroll too much at once, past the view we intend to tap, causing an EarlGrey error.

PiperOrigin-RevId: 947122055
On iOS 27+, EarlGrey overrides touch responders to SwiftUI gestures. For List row buttons using default styling, they rely on UIKit cell selection rather than SwiftUI gestures. EarlGrey was finding the outer scroll view's drag gesture instead and overriding the touch responder to it, preventing cell selection.

This patch stops EarlGrey from searching for responders past the boundaries of UICollectionView, UITableView, or the root UIHostingView on iOS 27+ (matching classes containing "UIHostingView"), allowing UIKit to correctly select list cells.

PiperOrigin-RevId: 947284780
…ate.

When an interaction times out while the app is in kGREYPendingScreenRotation
state (e.g., during device rotation tests with 0s timeout), StringFromAppState
returns an empty description array, triggering a fatal assertion:
"Did we forget to describe some states?".

This adds the missing description string for kGREYPendingScreenRotation.

PiperOrigin-RevId: 947381562
Use the default timeout for system alert to reduce flakiness. Update EarlGrey application launch timeout tracking to preventing interfering with XCTest watchdog.

PiperOrigin-RevId: 949187148
- Log shouldAutorotate and supportedInterfaceOrientations when a view controller appears.
- Add recovery suggestion in rotateInterfaceToOrientation:error: advising to check if orientation is locked.

PiperOrigin-RevId: 949305809
…ate is not running.

PiperOrigin-RevId: 964182390
Move the call to waitForKeyboardToAppear outside of the tap action's conditional block so that it executes regardless of whether the tap action was performed. Also update the error message and functional test expectation to match.

PiperOrigin-RevId: 968274343
`shouldAutorotate` is deprecated in iOS 16.0

PiperOrigin-RevId: 968644886

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.