Repository navigation
Conversation
rcadeaux
force-pushed
the
rcadeaux/different-screens-tools
branch
from
November 11, 2026 19:23
fad1b16 to
b2586a2
Compare
rcadeaux
force-pushed
the
rcadeaux/different-screens-tools
branch
from
November 21, 2026 06:41
0782548 to
be4b8b6
Compare
This branch has not been deployed
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.
Code snippets are for:
The Espresso Device test snippets (
android_compose_testing_different_screens_espresso_device_tabletopandandroid_compose_testing_different_screens_requires_device_mode) and the Window Testing Views snippet (android_compose_testing_different_screens_window_testing_views) on the guide page referenceR.id.playerandR.id.media_controlsinsideonView(withId(...))assertions and will not compile without those view ID resources. Two<item type="id" />entries (media_controlsandplayer) were added in a standalone values resource file (compose/snippets/src/main/res/values/different_screens_ids.xml) outside any snippet region so the Kotlin snippets compile without modifying any existing snippet file.List of modifications:
compose/snippets/src/androidTest/java/com/example/compose/snippets/test/differentscreens/DifferentScreensToolsSnippets.kt(isolated in thecom.example.compose.snippets.test.differentscreenssub-package so top-level test helper classes such asMainActivitydo not collide with sibling testing pages):android_compose_testing_different_screens_device_configuration_override(DeviceConfigurationOverride.ForcedSizeCompose test)android_compose_testing_different_screens_robolectric_config(@Config(qualifiers = "w1000dp-h1000dp-480dpi")Robolectric screenshot test class)android_compose_testing_different_screens_robolectric_set_qualifiers(RuntimeEnvironment.setQualifiersRobolectric test snippet)android_compose_testing_different_screens_width_annotations(@TestExpandedWidthand@TestCompactWidthcustom annotations)android_compose_testing_different_screens_filtered_test_class(MyTestClassusing@TestExpandedWidthand@TestCompactWidth)android_compose_testing_different_screens_espresso_device_tabletop(onDevice().setTabletopMode()Espresso Device test)android_compose_testing_different_screens_requires_device_mode(@RequiresDeviceModeannotations withTABLETOPandBOOK)android_compose_testing_different_screens_requires_display(@RequiresDisplay(EXPANDED, COMPACT)annotation test)android_compose_testing_different_screens_resize_display_compact(onDevice().setDisplaySize(WidthSizeClass.COMPACT, HeightSizeClass.COMPACT)test)android_compose_testing_different_screens_resize_display_expanded(onDevice().setDisplaySize(WidthSizeClass.EXPANDED, HeightSizeClass.EXPANDED)test)android_compose_testing_different_screens_state_restoration_tester(StateRestorationTester.emulateSavedInstanceStateRestore()Compose test)android_compose_testing_different_screens_foldable_preview(@Previewcomposable usingFoldingFeaturefromandroidx.window.testing.layout)android_compose_testing_different_screens_window_testing_compose(MediaControlsFoldingFeatureTestfoldable test with Compose)android_compose_testing_different_screens_window_testing_views(MediaControlsFoldingFeatureTestfoldable test with Views)class NiaAppScreenSizesScreenshotTests { ... }inandroid_compose_testing_different_screens_robolectric_configand the same-line destructuring declaration ellipsisval (width, height, dpi) = ...inandroid_compose_testing_different_screens_robolectric_set_qualifiersin[START_EXCLUDE silent]block-comment twins backed by compiling declarations (class NiaAppScreenSizesScreenshotTestsandval (width, height, dpi) = Triple(1000, 1000, 480)) so the rendered output matches the guide page verbatim. Because{ ... }(a class body) and= ...(a destructuring declaration) carry no explicit declared type or provenance comment, this pattern is noted here so the docs team can confirm it.importlines insideandroid_compose_testing_different_screens_window_testing_composeand the 5 instructionalimportlines insideandroid_compose_testing_different_screens_window_testing_views(// import androidx.window...) because Kotlin only permitsimportdirectives at the top of a file, while the real imports are declared at the file header so the code compiles../gradlew :compose:snippets:spotlessApplyformatting while preserving@Composable private fun FoldablePreview() =on a single line to match the guide page.androidx.test.espresso:espresso-deviceandandroidx.window:window-testingtogradle/libs.versions.toml, and addedlibs.androidx.test.espresso.device,libs.androidx.test.ext.junit.ktx,libs.androidx.window.testing, andlibs.robolectrictocompose/snippets/build.gradle.kts(alphabetized) so all testing APIs resolve.<item name="media_controls" type="id" />and<item name="player" type="id" />incompose/snippets/src/main/res/values/different_screens_ids.xmloutside any snippet region. Required for the Kotlin snippets to compile.Snippets not migrated:
android { testOptions { managedDevices { devices { ... } } } }) because it is a Gradle Managed Devices configuration block inbuild.gradlerather than Kotlin source code.$ ./gradlew pixelTabletApi30DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation='com.sample.TestExpandedWidth') because it is a command-line shell command.$ ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation='com.sample.TestExpandedWidth') because it is a command-line shell command.