Skip to content

Commit

Permalink
Merge pull request #20 from Entikore/update_dependencies
Browse files Browse the repository at this point in the history
Bumped dependencies
  • Loading branch information
Entikore committed Jun 24, 2023
2 parents 6028d68 + 533ff9c commit c1073a1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
33 changes: 17 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ plugins {
id("org.jetbrains.kotlin.kapt")
id("dagger.hilt.android.plugin")
id("org.jlleitschuh.gradle.ktlint") version "11.1.0"
id("com.google.devtools.ksp").version("1.6.10-1.0.4")
}

android {
compileSdk = 33
compileSdk = 34

defaultConfig {
applicationId = "de.entikore.cyclopenten"
minSdk = 24
targetSdk = 33
targetSdk = 34
versionCode = 1
versionName = "1.0"

Expand Down Expand Up @@ -69,25 +70,25 @@ dependencies {
val androidTestVersion = "1.5.0"
val androidTestJunitVersion = "1.1.5"
val archCoreVersion = "2.2.0"
val composeVersion = "1.4.1"
val coroutineVersion = "1.6.4"
val composeVersion = "1.4.3"
val coroutineVersion = "1.7.1"
val espressoVersion = "3.5.1"
val hiltVersion = "2.45"
val hiltVersion = "2.46.1"
val lifecycleVersion = "2.6.1"
val mockitoKotlinVersion = "4.1.0"
val moshiVersion = "1.14.0"
val navigationTestVersion = "2.5.3"
val mockitoKotlinVersion = "5.0.0"
val moshiVersion = "1.15.0"
val navigationTestVersion = "2.6.0"
val roomVersion = "2.5.1"

// App dependencies
implementation("com.jakewharton.timber:timber:5.0.1")
implementation("com.squareup.moshi:moshi:$moshiVersion")
implementation("com.squareup.moshi:moshi-kotlin:$moshiVersion")
kapt("com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion")
ksp("com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion")
implementation("com.google.code.gson:gson:2.10.1")

// Architecture Components
implementation("androidx.core:core-ktx:1.10.0")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.room:room-runtime:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")
Expand All @@ -102,9 +103,9 @@ dependencies {
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")

// Jetpack Compose
implementation("androidx.activity:activity-compose:1.7.0")
implementation("androidx.activity:activity-compose:1.7.2")
implementation("androidx.compose.ui:ui:$composeVersion")
implementation("androidx.compose.runtime:runtime-livedata:1.5.0-alpha02")
implementation("androidx.compose.runtime:runtime-livedata:1.6.0-alpha01")
implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion")
implementation("androidx.compose.material:material:$composeVersion")
implementation("androidx.compose.material:material-icons-extended:$composeVersion")
Expand All @@ -116,12 +117,12 @@ dependencies {
testImplementation("androidx.arch.core:core-testing:$archCoreVersion")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutineVersion")
testImplementation("org.robolectric:robolectric:4.9.2")
testImplementation("org.robolectric:robolectric:4.10.3")
testImplementation("androidx.navigation:navigation-testing:$navigationTestVersion")
testImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
testImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
testImplementation("androidx.test.espresso:espresso-intents:$espressoVersion")
testImplementation("com.google.truth:truth:1.1.3")
testImplementation("com.google.truth:truth:1.1.5")
testImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
testImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion")

Expand All @@ -146,9 +147,9 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
androidTestImplementation("androidx.test.espresso:espresso-intents:$espressoVersion")
androidTestImplementation("androidx.test.espresso.idling:idling-concurrent:$espressoVersion")
androidTestImplementation("org.robolectric:annotations:4.9.2")
androidTestImplementation("org.robolectric:annotations:4.10.3")
implementation("androidx.test.espresso:espresso-idling-resource:$espressoVersion")
androidTestImplementation("org.mockito:mockito-android:5.1.1")
androidTestImplementation("org.mockito:mockito-android:5.4.0")
androidTestImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import de.entikore.cyclopenten.GoodUnitTestData
import de.entikore.cyclopenten.MainCoroutineRule
import de.entikore.cyclopenten.data.FakeRepository
import de.entikore.cyclopenten.data.Result
import de.entikore.cyclopenten.data.UserPreferences
import de.entikore.cyclopenten.domain.usecases.DeleteSaveGameUseCase
import de.entikore.cyclopenten.domain.usecases.GetChemicalElementsUseCase
import de.entikore.cyclopenten.domain.usecases.GetSaveGameUseCase
Expand All @@ -16,13 +17,16 @@ import de.entikore.cyclopenten.ui.theme.ColorTheme
import de.entikore.cyclopenten.util.Constants.SCORE_INCREASE_EASY_DIFF
import de.entikore.cyclopenten.util.Constants.SCORE_INCREASE_HARD_DIFF
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.mock
import org.mockito.Mockito.`when`
import org.mockito.junit.MockitoJUnitRunner

@ExperimentalCoroutinesApi
Expand Down Expand Up @@ -58,6 +62,15 @@ class GameViewModelTest {
soundEffectPreferenceUseCase = mock(SoundEffectPreferenceUseCase::class.java)
savedStateHandle = mock(SavedStateHandle::class.java)

// soundEffectPreferenceUseCase gets invoked on viewmodel init
mainCoroutineRule.launch {
`when`(soundEffectPreferenceUseCase.invoke()).thenReturn(
flow {
UserPreferences(musicOn = false, soundEffectOn = false)
}
)
}

viewModel = GameViewModel(
getChemicalElementsUseCaseTest,
getSaveGameUseCase,
Expand All @@ -84,7 +97,7 @@ class GameViewModelTest {
answerOptions = firstElement.choices
)
expectedGameState.setDifficulty(false)

advanceUntilIdle()
assertThat(viewModel.gameState.value).isEqualTo(expectedGameState)
}

Expand All @@ -104,12 +117,14 @@ class GameViewModelTest {
answerOptions = firstElement.choices
)
gameStateBeforeReset.setDifficulty(false)
advanceUntilIdle()
// check current game state is as expected
assertThat(viewModel.gameState.value).isEqualTo(gameStateBeforeReset)

viewModel.resetGameState()

val defaultGameScreenState = GameScreenState()
advanceUntilIdle()
assertThat(viewModel.gameState.value).isEqualTo(defaultGameScreenState)
}

Expand All @@ -127,7 +142,6 @@ class GameViewModelTest {
viewModel.evaluateAnswer(rightAnswer)

advanceUntilIdle()

assertThat(viewModel.gameState.value.score).isEqualTo(SCORE_INCREASE_EASY_DIFF)
}

Expand All @@ -140,6 +154,7 @@ class GameViewModelTest {
val currentScore = currentGameState.score
val difficulty = currentGameState.hardDifficulty
// difficulty is hard, score should be incremented by 10
advanceUntilIdle()
assertThat(difficulty).isTrue()
assertThat(currentScore).isEqualTo(0)

Expand All @@ -159,6 +174,7 @@ class GameViewModelTest {
val currentLives = currentGameState.lives
val currentLostLives = currentGameState.lostLives
val difficulty = currentGameState.hardDifficulty
advanceUntilIdle()
// difficulty is easy, score should be incremented by 10
assertThat(difficulty).isFalse()
assertThat(currentScore).isEqualTo(0)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
id("com.android.application") version "8.0.0" apply false
id("com.android.library") version "8.0.0" apply false
id("com.android.application") version "8.0.2" apply false
id("com.android.library") version "8.0.2" apply false
id("com.google.dagger.hilt.android") version "2.45" apply false
}

Expand Down

0 comments on commit c1073a1

Please sign in to comment.