Skip to content

Commit

Permalink
fix: fix enable button test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismaillat committed Dec 18, 2024
1 parent e97b1d2 commit 0765f0a
Showing 3 changed files with 35 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -61,15 +61,13 @@ class GoogleMapScreenTest {

// Pass the mock MutableState to LocationProvider
locationProvider = LocationProvider(context, mockCurrentLocation)

// Set the Compose content to GoogleMapScreen
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel)
}
}

@Test
fun mapScreenDisplaysCorrectly() {
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel)
}

// Verify that the GoogleMapScreen is displayed
composeTestRule.onNodeWithTag("googleMapScreen").assertIsDisplayed()
@@ -80,6 +78,10 @@ class GoogleMapScreenTest {

@Test
fun cameraPositionIsUpdatedOnLocationChange() {
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel)
}

val fakeLocation = LatLng(37.7749, -122.4194) // Example coordinates for San Francisco

// Simulate location update
@@ -101,6 +103,10 @@ class GoogleMapScreenTest {

@Test
fun buttonsAreDisplayedCorrectly() {
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel)
}

// Verify that the "Auto Center On" button is displayed
composeTestRule.onNodeWithText("Auto Center On").assertIsDisplayed()

@@ -110,6 +116,10 @@ class GoogleMapScreenTest {

@Test
fun autoCenteringButtonsFunctionality() {
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel)
}

// Click the "Auto Center Off" button to disable auto-centering
composeTestRule.onNodeWithText("Auto Center Off").performClick()

@@ -150,6 +160,9 @@ class GoogleMapScreenTest {

@Test
fun floatingActionButtonDisplaysAndNavigatesToCameraCapture() {
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel)
}
// Mock the FirebaseAuth instance
mockAuth = org.mockito.kotlin.mock()
whenever(mockAuth.currentUser).thenReturn(null) // Can change this to test different scenarios
@@ -167,4 +180,18 @@ class GoogleMapScreenTest {
verify(navigationActions).navigateTo(Screen.AUTH)
}
}

@Test
fun testEnableLocationButtonIsDisplayed() {
composeTestRule.setContent {
GoogleMapScreen(navigationActions, postsViewModel, profileViewModel, true)
}

// Verify the UI elements are displayed
composeTestRule.onNodeWithTag("background_image").assertExists() // Verify image is displayed
composeTestRule
.onNodeWithTag("enable_location_button")
.assertExists() // Verify button is displayed
composeTestRule.onNodeWithText("Enable Location").assertExists() // Verify button text
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -48,7 +48,8 @@ private const val NUMBER_OF_STARS: Int = 3
fun GoogleMapScreen(
navigationActions: NavigationActions,
postsViewModel: PostsViewModel = viewModel(),
profileViewModel: ProfileViewModel = viewModel()
profileViewModel: ProfileViewModel = viewModel(),
testNoLoca: Boolean = false
) {
val context = LocalContext.current
val locationProvider = LocationProviderSingleton.getInstance(context)
@@ -138,7 +139,7 @@ fun GoogleMapScreen(
content = { padding ->
Column {
// Check and request permission
if (!hasLocationPermission) {
if (!hasLocationPermission || testNoLoca) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Image(
painter = painterResource(id = R.drawable.landing_screen_bckgrnd),

0 comments on commit 0765f0a

Please sign in to comment.