Skip to content

Commit

Permalink
Use constant for roboelectric runner API
Browse files Browse the repository at this point in the history
  • Loading branch information
LionZXY committed Nov 5, 2024
1 parent 7430de4 commit d811556
Show file tree
Hide file tree
Showing 32 changed files with 63 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object ApkConfig {

const val TARGET_SDK_VERSION = 35
const val COMPILE_SDK_VERSION = 35
const val ROBOELECTRIC_SDK_VERSION = 34

private const val DEBUG_VERSION = "DEBUG_VERSION"

Expand Down
1 change: 1 addition & 0 deletions components/bridge/dao/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {

// Testing
testImplementation(projects.components.core.test)
testImplementation(projects.components.core.buildKonfig)
testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.mockito.kotlin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.flipperdevices.bridge.dao.impl.api.key

import android.content.Context
import android.os.Build
import android.os.Looper
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperKeyContent
Expand All @@ -11,9 +9,9 @@ import com.flipperdevices.bridge.dao.impl.converters.StubMD5Converter
import com.flipperdevices.bridge.dao.impl.md5.MD5FileProviderImpl
import com.flipperdevices.bridge.dao.impl.model.DatabaseKeyContent
import com.flipperdevices.core.FlipperStorageProvider
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.test.FlipperStorageProviderTestRule
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import kotlinx.coroutines.test.runTest
import okio.Path
Expand All @@ -30,19 +28,14 @@ import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowLooper

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class DatabaseKeyContentConverterTest {

private lateinit var context: Context

@get:Rule
val storageProviderRule = FlipperStorageProviderTestRule()
private lateinit var storageProvider: FlipperStorageProvider

@Before
fun setUp() {
context = mockk()

storageProvider = storageProviderRule.flipperStorageProvider

mockkStatic(Looper::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.flipperdevices.bridge.dao.impl.api.key

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.impl.comparator.FileComparator
import com.flipperdevices.core.FlipperStorageProvider
import com.flipperdevices.core.sourceOrEmpty
Expand All @@ -13,9 +12,7 @@ import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class FileComparatorTest {
private lateinit var fileComparator: FileComparator

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.flipperdevices.bridge.dao.impl.api.key

import android.os.Build
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperFile
import com.flipperdevices.bridge.dao.api.model.FlipperFilePath
import com.flipperdevices.bridge.dao.api.model.FlipperKey
import com.flipperdevices.bridge.dao.api.model.FlipperKeyContent
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.storage.AndroidFlipperStorageProvider
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
Expand Down Expand Up @@ -39,7 +39,7 @@ private val EXAMPLE_FLIPPER_KEY = FlipperKey(
)

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class ShouldSynchronizeHelperTest {
@Test
fun `edit name of key`() = runTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.flipperdevices.bridge.dao.impl.md5

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperKeyContent
import com.flipperdevices.bridge.dao.impl.comparator.FileComparator
import com.flipperdevices.core.FlipperStorageProvider
Expand All @@ -12,9 +11,7 @@ import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class MD5FileProviderTest {
private lateinit var context: Context

Expand Down
1 change: 1 addition & 0 deletions components/bridge/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {

// Testing
testImplementation(projects.components.core.test)
testImplementation(projects.components.core.buildKonfig)
testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.mockito.kotlin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.api.scanner.DiscoveredBluetoothDevice
import com.flipperdevices.bridge.api.scanner.FlipperScanner
import com.flipperdevices.core.buildkonfig.BuildKonfig
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
Expand All @@ -30,7 +31,7 @@ import org.robolectric.annotation.Config
import org.robolectric.util.ReflectionHelpers

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class FlipperScannerImplTest {
private lateinit var scanner: BluetoothLeScannerCompat
private lateinit var bluetoothAdapter: BluetoothAdapter
Expand Down
1 change: 1 addition & 0 deletions components/bridge/service/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies {
implementation(libs.dagger)

testImplementation(projects.components.core.test)
testImplementation(projects.components.core.buildKonfig)
testImplementation(libs.junit)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.ktx.testing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.flipperdevices.bridge.service.impl.provider

import android.content.Context
import android.content.ServiceConnection
import android.os.Build
import androidx.datastore.core.DataStore
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.arkivanov.essenty.lifecycle.LifecycleOwner
Expand All @@ -11,6 +10,7 @@ import com.flipperdevices.bridge.service.api.FlipperServiceApi
import com.flipperdevices.bridge.service.api.provider.FlipperBleServiceConsumer
import com.flipperdevices.bridge.service.impl.FlipperService
import com.flipperdevices.bridge.service.impl.FlipperServiceBinder
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.preference.pb.Settings
import com.flipperdevices.core.test.TimberRule
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -32,7 +32,7 @@ import org.mockito.kotlin.verify
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class FlipperServiceProviderTest {
private lateinit var applicationContext: Context
private lateinit var subject: FlipperServiceProviderImpl
Expand Down
1 change: 1 addition & 0 deletions components/bridge/synchronization/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies {

// Testing
testImplementation(projects.components.core.test)
testImplementation(projects.components.core.buildKonfig)
testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.ktx.testing)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.flipperdevices.bridge.synchronization.impl.repository.favorites

import android.content.Context
import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.delegates.FavoriteApi
import com.flipperdevices.bridge.dao.api.model.FlipperFile
Expand All @@ -17,6 +16,7 @@ import com.flipperdevices.bridge.synchronization.impl.repository.manifest.Manife
import com.flipperdevices.bridge.synchronization.impl.repository.manifest.ManifestStorage
import com.flipperdevices.bridge.synchronization.impl.repository.manifest.ManifestStorageImpl
import com.flipperdevices.bridge.synchronization.impl.utils.detailedProgressWrapperTrackerStub
import com.flipperdevices.core.buildkonfig.BuildKonfig
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
Expand All @@ -31,7 +31,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class FavoriteSynchronizationTestSingle {
@get:Rule
val folder = TemporaryFolder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.flipperdevices.bridge.synchronization.impl.repository.manifest

import android.content.Context
import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperFilePath
import com.flipperdevices.bridge.synchronization.impl.model.KeyWithHash
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.test.readTestAsset
import io.mockk.every
import io.mockk.mockk
Expand All @@ -21,7 +21,7 @@ import org.robolectric.annotation.Config
import java.io.File

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class ManifestStorageTest {
@get:Rule
var folder = TemporaryFolder()
Expand Down
6 changes: 6 additions & 0 deletions components/core/build-konfig/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.flipperdevices.buildlogic.ApkConfig
import com.flipperdevices.buildlogic.ApkConfig.CURRENT_FLAVOR_TYPE

plugins {
Expand Down Expand Up @@ -26,4 +27,9 @@ buildConfig {
"LOGGING_PENDING_COMMANDS",
CURRENT_FLAVOR_TYPE.loggingPendingCommands
)
buildConfigField(
Integer::class.java,
"ROBOELECTRIC_SDK_VERSION",
ApkConfig.ROBOELECTRIC_SDK_VERSION
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.flipperdevices.core.ktx.jre

fun <T> MutableList<T>.safeRemoveFirst() {
if (this.isNotEmpty()) {
this.removeAt(0)
}
}

fun <T> MutableList<T>.safeRemoveLast() {
if (this.isNotEmpty()) {
this.removeAt(this.size - 1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.flipperdevices.faphub.screenshotspreview.impl.viewmodel

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Bitmap.Config
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Paint
Expand All @@ -21,7 +22,6 @@ import java.util.Date
import java.util.Locale
import javax.inject.Inject
import com.flipperdevices.core.ui.res.R as DesignSystem
import android.graphics.Bitmap.Config

private const val SCREENSHOT_FILE_PREFIX = "flpr"
private const val TIMEFORMAT = "yyyy-MM-dd-HH-mm-ss"
Expand Down
1 change: 1 addition & 0 deletions components/firstpair/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {

// Testing
testImplementation(projects.components.core.test)
testImplementation(projects.components.core.buildKonfig)
testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.ktx.testing)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.flipperdevices.firstpair.impl.viewmodels.connecting

import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.api.manager.ktx.state.ConnectionState
import com.flipperdevices.bridge.api.manager.ktx.state.FlipperSupportedState
import com.flipperdevices.bridge.api.manager.ktx.stateAsFlow
import com.flipperdevices.bridge.api.scanner.DiscoveredBluetoothDevice
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.test.TimberRule
import com.flipperdevices.core.test.mockScope
import com.flipperdevices.core.ui.lifecycle.DecomposeViewModelCoroutineScopeProvider
Expand All @@ -31,7 +31,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class PairDeviceViewModelTest {
@get:Rule
var timberRule = TimberRule()
Expand Down
1 change: 1 addition & 0 deletions components/infrared/editor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {
implementation(libs.kotlin.immutable.collections)

// Testing
testImplementation(projects.components.core.buildKonfig)
testImplementation(projects.components.core.test)
testImplementation(libs.junit)
testImplementation(libs.mockk)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.flipperdevices.infrared.editor.viewmodel

import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperFileFormat
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.test.readTestAssetString
import com.flipperdevices.infrared.editor.core.model.InfraredRemote
import com.flipperdevices.infrared.editor.core.parser.InfraredKeyParser
Expand All @@ -12,7 +12,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class InfraredKeyParserTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.flipperdevices.infrared.editor.viewmodel

import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperFile
import com.flipperdevices.bridge.dao.api.model.FlipperFileFormat
import com.flipperdevices.bridge.dao.api.model.FlipperFilePath
import com.flipperdevices.bridge.dao.api.model.FlipperKey
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.test.readTestAssetString
import com.flipperdevices.infrared.editor.core.parser.InfraredKeyParser
import com.flipperdevices.infrared.editor.model.InfraredEditorState
Expand All @@ -16,7 +16,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class InfraredStateParserTest {

@Test
Expand Down
1 change: 1 addition & 0 deletions components/keyparser/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {

// Testing
testImplementation(projects.components.core.test)
testImplementation(projects.components.core.buildKonfig)
testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.ktx.testing)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.flipperdevices.keyparser.impl

import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.flipperdevices.bridge.dao.api.model.FlipperFile
import com.flipperdevices.bridge.dao.api.model.FlipperFileFormat
import com.flipperdevices.bridge.dao.api.model.FlipperFilePath
import com.flipperdevices.bridge.dao.api.model.FlipperKey
import com.flipperdevices.bridge.dao.api.model.FlipperKeyContent
import com.flipperdevices.core.buildkonfig.BuildKonfig
import com.flipperdevices.core.test.readTestAsset
import com.flipperdevices.core.test.readTestAssetString
import com.flipperdevices.keyparser.api.model.FlipperKeyParsed
Expand All @@ -18,7 +18,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [BuildKonfig.ROBOELECTRIC_SDK_VERSION])
class InfraredParserTest {
private val underTest = InfraredParser()

Expand Down
Loading

0 comments on commit d811556

Please sign in to comment.