Fix tests

This commit is contained in:
Lucas Lima 2020-06-20 10:01:07 -03:00
parent a95aab43d2
commit a1bf70c563
No known key found for this signature in database
GPG key ID: 0259A3F43EC1027A
56 changed files with 85 additions and 44 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 867 B

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 907 B

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 990 B

After

Width:  |  Height:  |  Size: 1,001 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -37,3 +37,27 @@ class SavesRepository @Inject constructor(
private const val MAX_STORAGE = 15
}
}
class MemorySavesRepository : ISavesRepository {
private var memoryList = mutableListOf<Save>()
private var maxSavesStorage = -1
override suspend fun getAllSaves(): List<Save> = memoryList.toList()
override suspend fun fetchCurrentSave(): Save? = memoryList.lastOrNull()
override suspend fun loadFromId(id: Int): Save? = memoryList.find { it.uid == id }
override suspend fun saveGame(save: Save): Long? {
if (maxSavesStorage - 1 > 0) {
memoryList = memoryList.subList(0, maxSavesStorage - 1)
}
memoryList.add(save)
return memoryList.count().toLong()
}
override fun setLimit(maxSavesStorage: Int) {
this.maxSavesStorage = maxSavesStorage
memoryList = memoryList.subList(0, maxSavesStorage)
}
}

View file

@ -19,3 +19,14 @@ class StatsRepository(
return statsDao.insertAll(stats).firstOrNull()
}
}
class MemoryStatsRepository : IStatsRepository {
private val memoryStats = mutableListOf<Stats>()
override suspend fun getAllStats(): List<Stats> = memoryStats.toList()
override suspend fun addStats(stats: Stats): Long? {
memoryStats.add(stats)
return memoryStats.count().toLong()
}
}

View file

@ -42,3 +42,9 @@ class HapticFeedbackInteractor(
}
}
}
class DisabledIHapticFeedbackInteractor : IHapticFeedbackInteractor {
override fun toggleFlagFeedback() { }
override fun explosionFeedback() { }
}

View file

@ -0,0 +1,17 @@
package dev.lucasnlm.antimine.common.level.di
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
class FixedMinefieldRepository : IMinefieldRepository {
override fun fromDifficulty(
difficulty: Difficulty,
dimensionRepository: IDimensionRepository,
preferencesRepository: IPreferencesRepository
) = Minefield(9, 9, 9)
override fun randomSeed(): Long = 200
}

View file

@ -5,18 +5,17 @@ import android.content.Context
import androidx.lifecycle.MutableLiveData
import dagger.Module
import dagger.Provides
import dev.lucasnlm.antimine.common.level.database.models.Save
import dev.lucasnlm.antimine.common.level.database.models.Stats
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.mocks.FixedDimensionRepository
import dev.lucasnlm.antimine.common.level.models.Event
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.ISavesRepository
import dev.lucasnlm.antimine.common.level.repository.IStatsRepository
import dev.lucasnlm.antimine.common.level.repository.MemorySavesRepository
import dev.lucasnlm.antimine.common.level.repository.MemoryStatsRepository
import dev.lucasnlm.antimine.common.level.repository.MinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.Size
import dev.lucasnlm.antimine.common.level.utils.Clock
import dev.lucasnlm.antimine.common.level.utils.DisabledIHapticFeedbackInteractor
import dev.lucasnlm.antimine.common.level.utils.IHapticFeedbackInteractor
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModelFactory
import dev.lucasnlm.antimine.core.analytics.AnalyticsManager
@ -61,54 +60,20 @@ class TestLevelModule(
fun provideDimensionRepository(
context: Context,
preferencesRepository: IPreferencesRepository
): IDimensionRepository = object : IDimensionRepository {
override fun areaSize(): Float = 50.0f
override fun areaSizeWithPadding(): Float = 52.0f
override fun displaySize(): Size = Size(50 * 15, 50 * 30)
override fun actionBarSize(): Int = 50
}
): IDimensionRepository = FixedDimensionRepository()
@Provides
fun provideSavesRepository(): ISavesRepository = object : ISavesRepository {
override suspend fun getAllSaves(): List<Save> = listOf()
override suspend fun fetchCurrentSave(): Save? = null
override suspend fun loadFromId(id: Int): Save? = null
override suspend fun saveGame(save: Save): Long? = null
override fun setLimit(maxSavesStorage: Int) { }
}
fun provideSavesRepository(): ISavesRepository = MemorySavesRepository()
@Provides
fun provideMinefieldRepository(): IMinefieldRepository = object : IMinefieldRepository {
override fun fromDifficulty(
difficulty: Difficulty,
dimensionRepository: IDimensionRepository,
preferencesRepository: IPreferencesRepository
) = Minefield(9, 9, 9)
override fun randomSeed(): Long = 200
}
fun provideMinefieldRepository(): IMinefieldRepository = FixedMinefieldRepository()
@Provides
fun provideStatsRepository(): IStatsRepository = object : IStatsRepository {
override suspend fun getAllStats(): List<Stats> = listOf()
override suspend fun addStats(stats: Stats): Long? = null
}
fun provideStatsRepository(): IStatsRepository = MemoryStatsRepository()
@Provides
fun provideHapticFeedbackInteractor(
application: Application,
preferencesRepository: IPreferencesRepository
): IHapticFeedbackInteractor = object : IHapticFeedbackInteractor {
override fun toggleFlagFeedback() { }
override fun explosionFeedback() { }
}
): IHapticFeedbackInteractor = DisabledIHapticFeedbackInteractor()
}

View file

@ -0,0 +1,18 @@
package dev.lucasnlm.antimine.common.level.mocks
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.Size
class FixedDimensionRepository() : IDimensionRepository {
override fun areaSize(): Float = 50.0f
override fun areaSizeWithPadding(): Float {
return areaSize() + 2 * areaSeparator()
}
override fun areaSeparator(): Float = 1.0f
override fun displaySize(): Size = Size(50 * 15, 50 * 30)
override fun actionBarSize(): Int = 50
}