asserting-bounds-and-dimensions

Assert Jetpack Compose layout dimensions and positions using dp-typed bounds checks.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill asserting-bounds-and-dimensions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: asserting-bounds-and-dimensions
Source: https://github.com/skydoves/android-testing-skills/tree/main/compose/assertions/asserting-bounds-and-dimensions
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill asserting-bounds-and-dimensions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of unreliable Compose UI assertions by helping you verify layout sizes, positions, padding, and touch-target dimensions in dp with the framework’s expected tolerance model.

Core Features & Use Cases

  • dp-typed size and position assertions: Use APIs like assertWidthIsEqualTo, assertHeightIsAtLeast, and assertPositionInRootIsEqualTo instead of pixel math.
  • clipped vs unclipped bounds correctness: Use getUnclippedBoundsInRoot() for layout math (padding/gap/alignment) and getBoundsInRoot() only for what users see after clipping.
  • touch-target verification: Use assertTouchWidthIsEqualTo / assertTouchHeightIsEqualTo to validate tap accessibility rather than visual bounds.
  • alignment line and link bounds support: Read baseline via getAlignmentLinePosition and inspect annotated text ranges with getFirstLinkBounds.

Quick Start

Use this skill to assert a composable’s width/height and its position in the root using the dp-typed assertions and unclipped bounds for padding math.

Frequently Asked Questions about asserting-bounds-and-dimensions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I assert Jetpack Compose layout dimensions in dp instead of pixels?

Assert Jetpack Compose layout dimensions in dp by using assertions like `assertWidthIsEqualTo` and `assertHeightIsAtLeast` combined with `Dp.assertIsEqualTo`, which applies the framework's default half-dp tolerance model for reliable UI testing.

What is the difference between getUnclippedBoundsInRoot and getBoundsInRoot in Compose UI tests?

Use `getUnclippedBoundsInRoot()` for layout math like padding and gap calculations, and `getBoundsInRoot()` only for verifying visible clipped results to ensure accurate layout bounds assertions in Compose UI tests.

How do I verify touch target accessibility in Jetpack Compose UI tests?

Verify touch target accessibility in Jetpack Compose by using `assertTouchWidthIsEqualTo` and `assertTouchHeightIsEqualTo` to validate tap accessibility dimensions rather than relying on visual bounds.

Can I check absolute position and alignment lines in Compose layout tests?

Check absolute position in the root using `assertPositionInRootIsEqualTo`, and read baseline positions via `getAlignmentLinePosition` to validate alignment lines within your Compose layout tests.

Why are my Compose layout assertions failing due to pixel math and tolerance issues?

Compose layout assertions fail when using pixel-based semantics instead of dp-typed bounds with the expected half-dp tolerance model; switching to `Dp.assertIsEqualTo` resolves unreliable UI test measurements.