Skip to content

Commit

Permalink
Revert "fix: remove landscape tests from profile tests"
Browse files Browse the repository at this point in the history
This reverts commit f2b8e03.

revert commit
  • Loading branch information
Ismaillat committed Dec 20, 2024
1 parent f2b8e03 commit dcb5152
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.github.lookupgroup27.lookup.R
import com.github.lookupgroup27.lookup.model.profile.ProfileRepository
import com.github.lookupgroup27.lookup.ui.navigation.LIST_TOP_LEVEL_DESTINATION
Expand Down Expand Up @@ -179,4 +182,42 @@ class ProfileKtTest {
// Verify that no further interactions (including `navigateTo()`) occurred
Mockito.verifyNoMoreInteractions(mockNavigationActions)
}

@Test
fun testProfileScreenIsScrollableAndFullyVisibleInLandscape() {
// Set the device to landscape orientation
setLandscapeOrientation()

// Launch the ProfileScreen in landscape mode
composeTestRule.setContent {
ProfileScreen(
navigationActions = mockNavigationActions, avatarViewModel = mockAvatarViewModel)
}

// Check that main elements are displayed after scrolling in landscape mode
composeTestRule
.onNodeWithContentDescription(getResourceString(R.string.profile_profile_icon_description))
.assertExists()
composeTestRule
.onNodeWithText(getResourceString(R.string.profile_personal_info_button))
.performScrollTo()
.assertExists()
composeTestRule
.onNodeWithText(getResourceString(R.string.profile_collection_button))
.performScrollTo()
.assertExists()

// Reset orientation to portrait after the test
resetOrientation()
}

private fun setLandscapeOrientation() {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
device.setOrientationLeft()
}

private fun resetOrientation() {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
device.setOrientationNatural()
}
}

0 comments on commit dcb5152

Please sign in to comment.