Update more dependencies and remove RepositoryInstrumentedTest
This commit is contained in:
@@ -82,8 +82,8 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.2.10"
|
||||
implementation 'androidx.core:core-ktx:1.17.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.3.20"
|
||||
implementation 'androidx.core:core-ktx:1.18.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.7.1'
|
||||
implementation "androidx.compose.material3:material3:1.4.0"
|
||||
implementation 'com.google.android.play:review:2.0.2'
|
||||
@@ -101,20 +101,20 @@ dependencies {
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.10.0'
|
||||
implementation 'androidx.compose.material:material-icons-extended:1.7.8'
|
||||
implementation "com.google.accompanist:accompanist-systemuicontroller:0.36.0"
|
||||
implementation 'androidx.activity:activity-compose:1.12.3'
|
||||
implementation "androidx.compose.ui:ui:1.10.2"
|
||||
implementation "androidx.compose.ui:ui-tooling-preview:1.10.2"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.10.2"
|
||||
implementation 'androidx.activity:activity-compose:1.13.0'
|
||||
implementation "androidx.compose.ui:ui:1.10.6"
|
||||
implementation "androidx.compose.ui:ui-tooling-preview:1.10.6"
|
||||
implementation "androidx.compose.runtime:runtime-livedata:1.10.6"
|
||||
implementation "androidx.navigation:navigation-compose:2.9.7"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.10.0"
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
|
||||
implementation "com.google.dagger:hilt-android:2.59"
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.10.2"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:1.10.2"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.10.2"
|
||||
ksp "com.google.dagger:hilt-compiler:2.59"
|
||||
implementation "com.google.dagger:hilt-android:2.59.2"
|
||||
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.10.6"
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:1.10.6"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:1.10.6"
|
||||
ksp "com.google.dagger:hilt-compiler:2.59.2"
|
||||
annotationProcessor "androidx.room:room-compiler:2.8.4"
|
||||
implementation "androidx.room:room-runtime:2.8.4"
|
||||
ksp "androidx.room:room-compiler:2.8.4"
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import me.zobrist.tichucounter.data.AppDatabase
|
||||
import me.zobrist.tichucounter.data.GameDao
|
||||
import me.zobrist.tichucounter.data.RoundDao
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.Assert.*
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.runner.RunWith
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class RepositoryInstrumentedTest {
|
||||
private lateinit var gameDao: GameDao
|
||||
private lateinit var roundDao: RoundDao
|
||||
private lateinit var repository: GameRepository
|
||||
private lateinit var db: AppDatabase
|
||||
|
||||
@BeforeEach
|
||||
fun createDb() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
db = Room.inMemoryDatabaseBuilder(
|
||||
context, AppDatabase::class.java
|
||||
).build()
|
||||
roundDao = db.roundDao()
|
||||
gameDao = db.gameDao()
|
||||
|
||||
repository = GameRepository(gameDao, roundDao)
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@Throws(IOException::class)
|
||||
fun closeDb() {
|
||||
db.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun gameInitialisation() = runTest {
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
assertEquals("TeamA", it.game.nameA)
|
||||
assertEquals("TeamB", it.game.nameB)
|
||||
assertTrue(it.game.active)
|
||||
assertEquals(0, it.rounds.count())
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
@Throws(Exception::class)
|
||||
fun modifyNames() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.updateActiveTeamName(nameA = "aaa")
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
assertEquals("aaa", it.game.nameA)
|
||||
assertEquals("TeamB", it.game.nameB)
|
||||
}
|
||||
|
||||
repository.updateActiveTeamName(nameB = "bbb")
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
assertEquals("aaa", it.game.nameA)
|
||||
assertEquals("bbb", it.game.nameB)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun newGame() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(6, it.count())
|
||||
|
||||
var uid: Long = 1
|
||||
it.forEach { game ->
|
||||
assertEquals(uid++, game.game.uid)
|
||||
assertEquals(0, game.rounds.count())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
@Throws(Exception::class)
|
||||
fun setActive() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
val filtered = it.filter { it.game.active }
|
||||
assertEquals(1, filtered.count())
|
||||
assertEquals(6, filtered.first().game.uid)
|
||||
}
|
||||
|
||||
repository.setActive(2)
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
val filtered = it.filter { it.game.active }
|
||||
assertEquals(1, filtered.count())
|
||||
assertEquals(2, filtered.first().game.uid)
|
||||
}
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
@Throws(Exception::class)
|
||||
fun addRoundToActiveGame() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
val filtered = it.filter { it.rounds.isNotEmpty() }
|
||||
assertEquals(1, filtered.count())
|
||||
assertEquals(6, filtered.first().rounds.count())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun lastRound() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
repository.newGame()
|
||||
|
||||
assertNull(repository.getLastRound())
|
||||
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
|
||||
var lastRound = repository.getLastRound()
|
||||
assertEquals(6, lastRound?.scoreA)
|
||||
assertEquals(6, lastRound?.scoreB)
|
||||
|
||||
repository.deleteLastRound()
|
||||
|
||||
lastRound = repository.getLastRound()
|
||||
assertEquals(5, lastRound?.scoreA)
|
||||
assertEquals(5, lastRound?.scoreB)
|
||||
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
repository.deleteLastRound()
|
||||
|
||||
assertNull(repository.getLastRound())
|
||||
|
||||
// No error thrown
|
||||
repository.deleteLastRound()
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
@Throws(Exception::class)
|
||||
fun deleteInactive() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
for (i in 1..6) {
|
||||
repository.newGame()
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
}
|
||||
assertEquals(6 * 6, roundDao.getAll().count())
|
||||
|
||||
repository.deleteAllInactive()
|
||||
|
||||
// Consists of two transactions. Delete games then delete rounds.
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(1, it.count())
|
||||
assertEquals(6, it.first().rounds.count())
|
||||
}
|
||||
assertEquals(6, roundDao.getAll().count())
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
@Throws(Exception::class)
|
||||
fun deleteById() = runTest {
|
||||
|
||||
repository.getActiveGameFlow().take(1).collect {
|
||||
}
|
||||
|
||||
for (i in 1..6) {
|
||||
repository.newGame()
|
||||
repository.addRoundToActiveGame(1, 1)
|
||||
repository.addRoundToActiveGame(2, 2)
|
||||
repository.addRoundToActiveGame(3, 3)
|
||||
repository.addRoundToActiveGame(4, 4)
|
||||
repository.addRoundToActiveGame(5, 5)
|
||||
repository.addRoundToActiveGame(6, 6)
|
||||
}
|
||||
|
||||
// Non existing Id
|
||||
repository.deleteGame(10)
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(7, it.count())
|
||||
}
|
||||
|
||||
// Non existing Id
|
||||
val toDelete: Long = 3
|
||||
repository.deleteGame(toDelete)
|
||||
|
||||
repository.getAllWithRoundFlow().take(1).collect() { it ->
|
||||
assertEquals(6, it.count())
|
||||
assertEquals(0, it.count { it.game.uid == toDelete })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ fun DismissibleHistoryListItem(
|
||||
{
|
||||
SwipeToDismissBoxValue.EndToStart -> onDeleteClicked(game.game.uid)
|
||||
SwipeToDismissBoxValue.StartToEnd -> onOpenClicked(game.game.uid)
|
||||
else -> false
|
||||
else -> {}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ buildscript {
|
||||
|
||||
plugins {
|
||||
id 'com.google.dagger.hilt.android' version '2.59' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '2.2.10' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '2.3.20' apply false
|
||||
id 'com.google.devtools.ksp' version '2.3.5' apply false
|
||||
id 'org.jetbrains.kotlin.plugin.compose' version '2.2.10' apply false
|
||||
id 'org.jetbrains.kotlin.plugin.compose' version '2.3.20' apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
||||
@@ -20,7 +20,6 @@ android.enableJetifier=false
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
android.nonTransitiveRClass=true
|
||||
android.usesSdkInManifest.disallowed=false
|
||||
android.uniquePackageNames=false
|
||||
android.dependency.useConstraints=true
|
||||
android.r8.strictFullModeForKeepRules=false
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-all.zip
|
||||
|
||||
Reference in New Issue
Block a user