Convert utils gestures/, traversal/ and core node utilities to Kotlin (with characterization tests)#38
Open
jonathandasilvasantos wants to merge 2 commits into
Conversation
…m-default - Pin Gradle 8.13 via wrapper (AGP 8.11.1 requires >= 8.13; the repo ships no wrapper, so builds depend on whichever system Gradle is installed). - Bump ndkVersion 21.4.7075529 -> 27.2.12479018 in the braille modules: NDK r21 has no darwin-arm64 toolchain and fails on Apple Silicon hosts with "Unknown host CPU architecture: arm64". - Compile Kotlin with -Xjvm-default=all so Kotlin interface defaults are emitted as real Java default methods (required for Java implementers of interfaces that migrate to Kotlin).
Mechanical, behavior-preserving Java -> Kotlin conversion of 41 files: the full gestures/ package (GestureMatcher base, GestureManifold, factory and all 18 matchers), the full traversal/ package (ordered + directional strategies, WorkingTree, utils), and the core node utilities (AccessibilityNodeInfoUtils, Role, FocusFinder, WebInterfaceUtils, AccessibilityNodeInfoRef, ScrollableNodeInfo). Every file was converted under a characterization-test harness: 123 new JUnit/Robolectric tests were written against the original Java sources first, then re-run unchanged against the converted Kotlin, pinning the observable behavior (state machines, timeouts, slops, traversal order, focus rules). All public signatures are preserved for Java callers via @JvmStatic/@JvmField/const; package-private members map to internal; @autovalue classes are hand-written value classes with identical APIs. No behavior change intended. Full APK (phone + wear) builds; the whole unit-test suite passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR converts 41 Java files in the
utilsmodule to Kotlin, with zero intended behavior change:gestures/package —GestureMatcherbase,GestureManifold,GestureMatcherFactoryand all 18 matchers (MultiTap,Swipe, multi-finger, second-finger/split-tap, touch-explore accelerators);traversal/package —OrderedTraversalStrategy/Controller,DirectionalTraversalStrategy,WorkingTree,ReorderedChildrenIterator,TraversalStrategyUtils;AccessibilityNodeInfoUtils,Role,FocusFinder,WebInterfaceUtils,AccessibilityNodeInfoRef,ScrollableNodeInfo.Methodology: characterization tests first
The repository ships no unit tests, so each file was converted under a test harness built for this purpose:
shouldFocusNode, speaking-node semantics), scroll-direction fallbacks, and edge-case contracts (e.g.roundForProgressPercentnever rounding to 0/100 inside the open interval;isScrollabledeliberately ignoring the node flag).Compatibility
@JvmStatic,@JvmFieldfor theFILTER_*fields,const val;-Xjvm-default=allso Kotlin interface defaults remain real Java default methods).internal;@AutoValuenested classes are hand-written value classes with identical APIs (accessors,create()factories, AutoValue-formatequals/hashCode/toString).phoneandwearflavors; the complete unit-test suite passes.The first commit contains build prerequisites only: a pinned Gradle 8.13 wrapper (AGP 8.11.1 requires ≥ 8.13), an NDK bump to 27.2 for the braille modules (r21 cannot run on Apple Silicon hosts), and the
-Xjvm-default=allcompiler flag.Happy to split this into smaller PRs (per package), adjust conventions, or sign whatever CLA process applies.