ReadingOrder

Reading-order checks from frame geometry alone, shared by Compose tests, instrumentation tests, and device drivers.

Rows are compared by vertical center with an exclusive tolerance. Horizontal order compares centers and does not require frames to be disjoint. Unusable frames and nonpositive or nonfinite tolerances never match.

Properties

Link copied to clipboard
const val DEFAULT_ROW_TOLERANCE: Float = 1.0f

The default row tolerance: one unit of the frames' coordinate space.

Functions

Link copied to clipboard
fun <K : Comparable<K>> firstAdjacentPair(frames: Map<K, Frame>, successor: (K) -> K, rowTolerance: Float = DEFAULT_ROW_TOLERANCE): Pair<Frame, Frame>?

Finds the first pair of frames, in ascending key order, whose key and successor share a row.

Link copied to clipboard
fun follows(second: Frame, first: Frame, direction: ReadingDirection, rowTolerance: Float = DEFAULT_ROW_TOLERANCE): Boolean

Returns whether second is read after first on the same row.

Link copied to clipboard
fun sharesRow(first: Frame, second: Frame, tolerance: Float = DEFAULT_ROW_TOLERANCE): Boolean

Returns whether two frames' vertical centers differ by less than tolerance.