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 19d1977 commit e97b1d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.github.lookupgroup27.lookup.ui.googlemap

import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.test.core.app.ApplicationProvider
import androidx.core.content.ContextCompat
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.lookupgroup27.lookup.model.location.LocationProvider
import com.github.lookupgroup27.lookup.model.post.PostsRepository
import com.github.lookupgroup27.lookup.model.profile.ProfileRepository
Expand All @@ -15,11 +18,13 @@ import com.github.lookupgroup27.lookup.ui.profile.ProfileViewModel
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.mock
import org.mockito.Mockito.`when`

// This test the UI behaviour of the GoogleMap screen before granting the location permission
@RunWith(AndroidJUnit4::class)
class GoogleMapKtTest2 {
private lateinit var navigationActions: NavigationActions
private lateinit var locationProvider: LocationProvider
Expand All @@ -32,7 +37,8 @@ class GoogleMapKtTest2 {

@Before
fun setUp() {
val context = ApplicationProvider.getApplicationContext<Context>()
val mockContext = mock(Context::class.java)

// Mock NavigationActions
navigationActions = mock(NavigationActions::class.java)
postsRepository = mock(PostsRepository::class.java)
Expand All @@ -42,6 +48,8 @@ class GoogleMapKtTest2 {

// Setup to return the map route as current
`when`(navigationActions.currentRoute()).thenReturn(Screen.GOOGLE_MAP)
`when`(ContextCompat.checkSelfPermission(mockContext, Manifest.permission.ACCESS_FINE_LOCATION))
.thenReturn(PackageManager.PERMISSION_DENIED)

// Set the Compose content to GoogleMapScreen
composeTestRule.setContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ fun GoogleMapScreen(
Image(
painter = painterResource(id = R.drawable.landing_screen_bckgrnd),
contentDescription = "Background",
modifier =
Modifier.fillMaxSize()
.testTag("background_image")
.blur(20.dp)
.testTag("background_image"),
modifier = Modifier.fillMaxSize().testTag("background_image").blur(20.dp),
contentScale = ContentScale.Crop)

Button(
Expand Down

0 comments on commit e97b1d2

Please sign in to comment.