-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Drops semantics query when app is not attached #52040
base: main
Are you sure you want to change the base?
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -873,8 +873,9 @@ private native void nativeDispatchSemanticsAction( | |||
@UiThread | |||
public void setSemanticsEnabled(boolean enabled) { | |||
ensureRunningOnMainThread(); | |||
ensureAttachedToNative(); | |||
nativeSetSemanticsEnabled(nativeShellHolderId, enabled); | |||
if (isAttached()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @reidbaker is there a good way to test this?
Things i have tried:
- make nativeSetSemanticsEnabled public and mock it using mockito.
- I try creating a public method that just call
nativeSetSemanticsEnabled
and use spy to mock the instance.
both of them throws UnSatisfiedLink error on nativeSetSemanticsEnabled
. The only way I can think of is to extends the entire FlutterJNI and override method to do nothing, but I am wondering if that is preferred or is there any other way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this pr does not have a test I cant see what testing environment you are using. My guess is that if your test contains whatever dependency has nativeSetSemanticsEnabled then the issue is that your c code needs to run on an android device (or maybe with robolectric).
I also found this chromium documentation https://www.chromium.org/developers/testing/android-tests/testing-android-code-that-crosses-the-c-java-boundary/ that suggest that a spy is the correct solution.
@chunhtai I am going through my pr requests and found this. I believe you are not waiting on me if that is the case let me know. |
no, I have some other ideas to test this code. I will let you know once this pr is ready |
Is seems automatic test may send a11y query before the engine is attached. Add a guard to guard against it.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.