Repository: android/nowinandroid
File: app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/interests2pane/InterestsListDetailScreenTest.kt (Kotlin)

Code before:
                    DeviceConfigurationOverride(override = sizeOverride) {
                        NiaTheme {
                            // Back press should not be handled by the two pane layout, and thus
                            // "fall through" to this BackHandler.
                            BackHandler {
                                unhandledBackPress = true
                            }
                            InterestsListDetailScreen(windowAdaptiveInfo = adaptiveInfo)
                        }
                    }
                }
            }

            val firstTopic = runBlocking {
                topicsRepository.getTopics().first().first()
            }
            onNodeWithText(firstTopic.name).performClick()

            Espresso.pressBack()

            assertTrue(unhandledBackPress)
        }
    }

    @Test
    fun notExpandedWidth_backPressFromTopicDetail_showsListPane() {
        composeTestRule.apply {
            setContent {
                with(TestDeviceConfig.Compact) {
                    DeviceConfigurationOverride(override = sizeOverride) {
                        NiaTheme {
                            InterestsListDetailScreen(windowAdaptiveInfo = adaptiveInfo)
                        }
                    }
                }
            }

            val firstTopic = runBlocking {
                topicsRepository.getTopics().first().first()
            }
            onNodeWithText(firstTopic.name).performClick()

            Espresso.pressBack()

            onNodeWithTag(listPaneTag).assertIsDisplayed()
            onNodeWithText(placeholderText).assertIsNotDisplayed()
            onNodeWithTag(firstTopic.testTag).assertIsNotDisplayed()
        }
    }
}


Review comment (suggestion):
Nit: I think all `notExpandedWidth` be `compactWidth`, which is more descriptive, since `notExpandedWidth` could also mean `mediumWidth`
```suggestion
    fun compactWidth_backPressFromTopicDetail_showsListPane() {
```

Code after:
                    DeviceConfigurationOverride(override = sizeOverride) {
                        NiaTheme {
                            // Back press should not be handled by the two pane layout, and thus
                            // "fall through" to this BackHandler.
                            BackHandler {
                                unhandledBackPress = true
                            }
                            InterestsListDetailScreen(windowAdaptiveInfo = adaptiveInfo)
                        }
                    }
                }
            }

            val firstTopic = getTopics().first()
            onNodeWithText(firstTopic.name).performClick()

            Espresso.pressBack()

            assertTrue(unhandledBackPress)
        }
    }

    @Test
    fun compactWidth_backPressFromTopicDetail_showsListPane() {
        composeTestRule.apply {
            setContent {
                with(TestDeviceConfig.Compact) {
                    DeviceConfigurationOverride(override = sizeOverride) {
                        NiaTheme {
                            InterestsListDetailScreen(windowAdaptiveInfo = adaptiveInfo)
                        }
                    }
                }
            }

            val firstTopic = getTopics().first()
            onNodeWithText(firstTopic.name).performClick()

            Espresso.pressBack()

            onNodeWithTag(listPaneTag).assertIsDisplayed()
            onNodeWithText(placeholderText).assertIsNotDisplayed()
            onNodeWithTag(firstTopic.testTag).assertIsNotDisplayed()
        }
    }
}