Fix moar ktlint issues

This commit is contained in:
Benoit Marty 2024-01-11 09:41:14 +01:00 committed by Benoit Marty
parent 378692f743
commit 72a363c244
27 changed files with 69 additions and 53 deletions

View file

@ -85,7 +85,8 @@ fun RoomPrivacyOption(
.align(Alignment.CenterVertically) .align(Alignment.CenterVertically)
.size(48.dp), .size(48.dp),
selected = isSelected, selected = isSelected,
onClick = null // null recommended for accessibility with screenreaders // null recommended for accessibility with screenreaders
onClick = null
) )
} }
} }

View file

@ -34,7 +34,7 @@ class OidcUrlParser @Inject constructor() {
* `io.element:/callback?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB` * `io.element:/callback?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB`
*/ */
fun parse(url: String): OidcAction? { fun parse(url: String): OidcAction? {
if (url.startsWith(OidcConfig.redirectUri).not()) return null if (url.startsWith(OidcConfig.REDIRECT_URI).not()) return null
if (url.contains("error=access_denied")) return OidcAction.GoBack if (url.contains("error=access_denied")) return OidcAction.GoBack
if (url.contains("code=")) return OidcAction.Success(url) if (url.contains("code=")) return OidcAction.Success(url)

View file

@ -201,7 +201,8 @@ private fun HomeserverData.toAccountProvider(): AccountProvider {
return AccountProvider( return AccountProvider(
url = homeserverUrl, url = homeserverUrl,
subtitle = if (isMatrixOrg) stringResource(id = R.string.screen_change_account_provider_matrix_org_subtitle) else null, subtitle = if (isMatrixOrg) stringResource(id = R.string.screen_change_account_provider_matrix_org_subtitle) else null,
isPublic = isMatrixOrg, // There is no need to know for other servers right now // There is no need to know for other servers right now
isPublic = isMatrixOrg,
isMatrixOrg = isMatrixOrg, isMatrixOrg = isMatrixOrg,
isValid = isWellknownValid, isValid = isWellknownValid,
supportSlidingSync = supportSlidingSync, supportSlidingSync = supportSlidingSync,

View file

@ -38,21 +38,21 @@ class OidcUrlParserTest {
@Test @Test
fun `test cancel url`() { fun `test cancel url`() {
val sut = OidcUrlParser() val sut = OidcUrlParser()
val aCancelUrl = OidcConfig.redirectUri + "?error=access_denied&state=IFF1UETGye2ZA8pO" val aCancelUrl = OidcConfig.REDIRECT_URI + "?error=access_denied&state=IFF1UETGye2ZA8pO"
assertThat(sut.parse(aCancelUrl)).isEqualTo(OidcAction.GoBack) assertThat(sut.parse(aCancelUrl)).isEqualTo(OidcAction.GoBack)
} }
@Test @Test
fun `test success url`() { fun `test success url`() {
val sut = OidcUrlParser() val sut = OidcUrlParser()
val aSuccessUrl = OidcConfig.redirectUri + "?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB" val aSuccessUrl = OidcConfig.REDIRECT_URI + "?state=IFF1UETGye2ZA8pO&code=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB"
assertThat(sut.parse(aSuccessUrl)).isEqualTo(OidcAction.Success(aSuccessUrl)) assertThat(sut.parse(aSuccessUrl)).isEqualTo(OidcAction.Success(aSuccessUrl))
} }
@Test @Test
fun `test unknown url`() { fun `test unknown url`() {
val sut = OidcUrlParser() val sut = OidcUrlParser()
val anUnknownUrl = OidcConfig.redirectUri + "?state=IFF1UETGye2ZA8pO&goat=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB" val anUnknownUrl = OidcConfig.REDIRECT_URI + "?state=IFF1UETGye2ZA8pO&goat=y6X1GZeqA3xxOWcTeShgv8nkgFJXyzWB"
Assert.assertThrows(IllegalStateException::class.java) { Assert.assertThrows(IllegalStateException::class.java) {
assertThat(sut.parse(anUnknownUrl)) assertThat(sut.parse(anUnknownUrl))
} }

View file

@ -130,7 +130,8 @@ internal fun ExpandableBottomSheetScaffold(
contentOverflows = contentHeight > maxHeight contentOverflows = contentHeight > maxHeight
val peekHeight = min( val peekHeight = min(
maxHeight, // prevent the sheet from expanding beyond the screen // prevent the sheet from expanding beyond the screen
maxHeight,
contentHeight contentHeight
) )

View file

@ -416,8 +416,9 @@ private fun MessageEventBubbleContent(
onMentionClicked: (Mention) -> Unit, onMentionClicked: (Mention) -> Unit,
eventSink: (TimelineEvents) -> Unit, eventSink: (TimelineEvents) -> Unit,
@SuppressLint("ModifierParameter") @SuppressLint("ModifierParameter")
// need to rename this modifier to prevent linter false positives
@Suppress("ModifierNaming") @Suppress("ModifierNaming")
bubbleModifier: Modifier = Modifier, // need to rename this modifier to prevent linter false positives bubbleModifier: Modifier = Modifier,
) { ) {
// Long clicks are not not automatically propagated from a `clickable` // Long clicks are not not automatically propagated from a `clickable`
// to its `combinedClickable` parent so we do it manually // to its `combinedClickable` parent so we do it manually
@ -462,10 +463,12 @@ private fun MessageEventBubbleContent(
onClick = onTimestampClicked, onClick = onTimestampClicked,
onLongClick = ::onTimestampLongClick, onLongClick = ::onTimestampLongClick,
modifier = Modifier modifier = Modifier
.padding(horizontal = 4.dp, vertical = 4.dp) // Outer padding // Outer padding
.padding(horizontal = 4.dp, vertical = 4.dp)
.background(ElementTheme.colors.bgSubtleSecondary, RoundedCornerShape(10.0.dp)) .background(ElementTheme.colors.bgSubtleSecondary, RoundedCornerShape(10.0.dp))
.align(Alignment.BottomEnd) .align(Alignment.BottomEnd)
.padding(horizontal = 4.dp, vertical = 2.dp) // Inner padding // Inner padding
.padding(horizontal = 4.dp, vertical = 2.dp)
) )
} }
TimestampPosition.Aligned -> TimestampPosition.Aligned ->

View file

@ -95,7 +95,8 @@ fun EventDebugInfoView(
.fillMaxWidth() .fillMaxWidth()
.padding(padding) // Window insets .padding(padding) // Window insets
.consumeWindowInsets(padding) .consumeWindowInsets(padding)
.padding(horizontal = 16.dp) // Internal padding // Internal padding
.padding(horizontal = 16.dp)
) { ) {
item { item {
Column(Modifier.padding(vertical = 10.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { Column(Modifier.padding(vertical = 10.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {

View file

@ -17,6 +17,6 @@
package io.element.android.features.onboarding.impl package io.element.android.features.onboarding.impl
object OnBoardingConfig { object OnBoardingConfig {
const val canLoginWithQrCode = false const val CAN_LOGIN_WITH_QR_CODE = false
const val canCreateAccount = false const val CAN_CREATE_ACCOUNT = false
} }

View file

@ -33,8 +33,8 @@ class OnBoardingPresenter @Inject constructor(
override fun present(): OnBoardingState { override fun present(): OnBoardingState {
return OnBoardingState( return OnBoardingState(
isDebugBuild = buildMeta.buildType != BuildType.RELEASE, isDebugBuild = buildMeta.buildType != BuildType.RELEASE,
canLoginWithQrCode = OnBoardingConfig.canLoginWithQrCode, canLoginWithQrCode = OnBoardingConfig.CAN_LOGIN_WITH_QR_CODE,
canCreateAccount = OnBoardingConfig.canCreateAccount, canCreateAccount = OnBoardingConfig.CAN_CREATE_ACCOUNT,
) )
} }
} }

View file

@ -56,7 +56,8 @@ private fun CrashDetectionContent(
) { ) {
ConfirmationDialog( ConfirmationDialog(
title = stringResource(id = CommonStrings.action_report_bug), title = stringResource(id = CommonStrings.action_report_bug),
content = stringResource(id = R.string.crash_detection_dialog_content, /* TODO App name */ "Element"), // TODO: Replace with app name
content = stringResource(id = R.string.crash_detection_dialog_content, "Element"),
submitText = stringResource(id = CommonStrings.action_yes), submitText = stringResource(id = CommonStrings.action_yes),
cancelText = stringResource(id = CommonStrings.action_no), cancelText = stringResource(id = CommonStrings.action_no),
onCancelClicked = onNoClicked, onCancelClicked = onNoClicked,

View file

@ -56,7 +56,8 @@ internal fun BlockUserSection(state: RoomMemberDetailsState, modifier: Modifier
val event = when (state.isBlocked.prevData) { val event = when (state.isBlocked.prevData) {
true -> RoomMemberDetailsEvents.UnblockUser(needsConfirmation = false) true -> RoomMemberDetailsEvents.UnblockUser(needsConfirmation = false)
false -> RoomMemberDetailsEvents.BlockUser(needsConfirmation = false) false -> RoomMemberDetailsEvents.BlockUser(needsConfirmation = false)
null -> /*Should not happen */ RoomMemberDetailsEvents.ClearBlockUserError // null case Should not happen
null -> RoomMemberDetailsEvents.ClearBlockUserError
} }
state.eventSink(event) state.eventSink(event)
}, },

View file

@ -140,11 +140,11 @@ class SecureBackupSetupPresenterTest {
) )
) )
val createdState = awaitItem() val createdState = awaitItem()
assertThat(createdState.setupState).isEqualTo(SetupState.Created(FakeEncryptionService.fakeRecoveryKey)) assertThat(createdState.setupState).isEqualTo(SetupState.Created(FakeEncryptionService.FAKE_RECOVERY_KEY))
assertThat(createdState.recoveryKeyViewState).isEqualTo( assertThat(createdState.recoveryKeyViewState).isEqualTo(
RecoveryKeyViewState( RecoveryKeyViewState(
recoveryKeyUserStory = RecoveryKeyUserStory.Change, recoveryKeyUserStory = RecoveryKeyUserStory.Change,
formattedRecoveryKey = FakeEncryptionService.fakeRecoveryKey, formattedRecoveryKey = FakeEncryptionService.FAKE_RECOVERY_KEY,
inProgress = false, inProgress = false,
) )
) )

View file

@ -58,7 +58,8 @@ class RecoveryKeyVisualTransformationTest {
@Test @Test
fun `RecoveryKeyOffsetMapping computes correct transformedToOriginal values`() { fun `RecoveryKeyOffsetMapping computes correct transformedToOriginal values`() {
val sut = RecoveryKeyVisualTransformation.RecoveryKeyOffsetMapping("" /* Not used by transformedToOriginal */) // text parameter is not used by transformedToOriginal
val sut = RecoveryKeyVisualTransformation.RecoveryKeyOffsetMapping("")
assertThat(sut.transformedToOriginal(0)).isEqualTo(0) assertThat(sut.transformedToOriginal(0)).isEqualTo(0)
assertThat(sut.transformedToOriginal(1)).isEqualTo(1) assertThat(sut.transformedToOriginal(1)).isEqualTo(1)
assertThat(sut.transformedToOriginal(2)).isEqualTo(2) assertThat(sut.transformedToOriginal(2)).isEqualTo(2)

View file

@ -17,5 +17,5 @@
package io.element.android.libraries.matrix.api.auth package io.element.android.libraries.matrix.api.auth
object OidcConfig { object OidcConfig {
const val redirectUri = "io.element:/callback" const val REDIRECT_URI = "io.element:/callback"
} }

View file

@ -21,7 +21,7 @@ import org.matrix.rustcomponents.sdk.OidcConfiguration
val oidcConfiguration: OidcConfiguration = OidcConfiguration( val oidcConfiguration: OidcConfiguration = OidcConfiguration(
clientName = "Element", clientName = "Element",
redirectUri = OidcConfig.redirectUri, redirectUri = OidcConfig.REDIRECT_URI,
clientUri = "https://element.io", clientUri = "https://element.io",
logoUri = "https://element.io/mobile-icon.png", logoUri = "https://element.io/mobile-icon.png",
tosUri = "https://element.io/acceptable-use-policy-terms", tosUri = "https://element.io/acceptable-use-policy-terms",
@ -29,9 +29,7 @@ val oidcConfiguration: OidcConfiguration = OidcConfiguration(
contacts = listOf( contacts = listOf(
"support@element.io", "support@element.io",
), ),
/** // Some homeservers/auth issuers don't support dynamic client registration, and have to be registered manually
* Some homeservers/auth issuers don't support dynamic client registration, and have to be registered manually
*/
staticRegistrations = mapOf( staticRegistrations = mapOf(
"https://id.thirdroom.io/realms/thirdroom" to "elementx", "https://id.thirdroom.io/realms/thirdroom" to "elementx",
), ),

View file

@ -84,7 +84,7 @@ class FakeEncryptionService : EncryptionService {
} }
override suspend fun resetRecoveryKey(): Result<String> = simulateLongTask { override suspend fun resetRecoveryKey(): Result<String> = simulateLongTask {
return Result.success(fakeRecoveryKey) return Result.success(FAKE_RECOVERY_KEY)
} }
override suspend fun enableRecovery(waitForBackupsToUpload: Boolean): Result<Unit> = simulateLongTask { override suspend fun enableRecovery(waitForBackupsToUpload: Boolean): Result<Unit> = simulateLongTask {
@ -108,6 +108,6 @@ class FakeEncryptionService : EncryptionService {
} }
companion object { companion object {
const val fakeRecoveryKey = "fake" const val FAKE_RECOVERY_KEY = "fake"
} }
} }

View file

@ -33,7 +33,7 @@ class FakeNotificationSettingsService(
initialOneToOneDefaultMode: RoomNotificationMode = RoomNotificationMode.ALL_MESSAGES, initialOneToOneDefaultMode: RoomNotificationMode = RoomNotificationMode.ALL_MESSAGES,
initialEncryptedOneToOneDefaultMode: RoomNotificationMode = RoomNotificationMode.ALL_MESSAGES, initialEncryptedOneToOneDefaultMode: RoomNotificationMode = RoomNotificationMode.ALL_MESSAGES,
) : NotificationSettingsService { ) : NotificationSettingsService {
private var _notificationSettingsStateFlow = MutableStateFlow(Unit) private val notificationSettingsStateFlow = MutableStateFlow(Unit)
private var defaultGroupRoomNotificationMode: RoomNotificationMode = initialGroupDefaultMode private var defaultGroupRoomNotificationMode: RoomNotificationMode = initialGroupDefaultMode
private var defaultEncryptedGroupRoomNotificationMode: RoomNotificationMode = initialEncryptedGroupDefaultMode private var defaultEncryptedGroupRoomNotificationMode: RoomNotificationMode = initialEncryptedGroupDefaultMode
private var defaultOneToOneRoomNotificationMode: RoomNotificationMode = initialOneToOneDefaultMode private var defaultOneToOneRoomNotificationMode: RoomNotificationMode = initialOneToOneDefaultMode
@ -49,7 +49,7 @@ class FakeNotificationSettingsService(
private var setAtRoomError: Throwable? = null private var setAtRoomError: Throwable? = null
private var canHomeServerPushEncryptedEventsToDeviceResult = Result.success(true) private var canHomeServerPushEncryptedEventsToDeviceResult = Result.success(true)
override val notificationSettingsChangeFlow: SharedFlow<Unit> override val notificationSettingsChangeFlow: SharedFlow<Unit>
get() = _notificationSettingsStateFlow get() = notificationSettingsStateFlow
override suspend fun getRoomNotificationSettings(roomId: RoomId, isEncrypted: Boolean, isOneToOne: Boolean): Result<RoomNotificationSettings> { override suspend fun getRoomNotificationSettings(roomId: RoomId, isEncrypted: Boolean, isOneToOne: Boolean): Result<RoomNotificationSettings> {
return Result.success( return Result.success(
@ -94,7 +94,7 @@ class FakeNotificationSettingsService(
defaultGroupRoomNotificationMode = mode defaultGroupRoomNotificationMode = mode
} }
} }
_notificationSettingsStateFlow.emit(Unit) notificationSettingsStateFlow.emit(Unit)
return Result.success(Unit) return Result.success(Unit)
} }
@ -105,7 +105,7 @@ class FakeNotificationSettingsService(
} else { } else {
roomNotificationModeIsDefault = false roomNotificationModeIsDefault = false
roomNotificationMode = mode roomNotificationMode = mode
_notificationSettingsStateFlow.emit(Unit) notificationSettingsStateFlow.emit(Unit)
Result.success(Unit) Result.success(Unit)
} }
} }
@ -117,7 +117,7 @@ class FakeNotificationSettingsService(
} }
roomNotificationModeIsDefault = true roomNotificationModeIsDefault = true
roomNotificationMode = defaultEncryptedGroupRoomNotificationMode roomNotificationMode = defaultEncryptedGroupRoomNotificationMode
_notificationSettingsStateFlow.emit(Unit) notificationSettingsStateFlow.emit(Unit)
return Result.success(Unit) return Result.success(Unit)
} }

View file

@ -49,9 +49,11 @@ class PushersManager @Inject constructor(
suspend fun testPush() { suspend fun testPush() {
pushGatewayNotifyRequest.execute( pushGatewayNotifyRequest.execute(
PushGatewayNotifyRequest.Params( PushGatewayNotifyRequest.Params(
url = "TODO", // unifiedPushHelper.getPushGateway() ?: return, // unifiedPushHelper.getPushGateway() ?: return
url = "TODO",
appId = PushConfig.PUSHER_APP_ID, appId = PushConfig.PUSHER_APP_ID,
pushKey = "TODO", // unifiedPushHelper.getEndpointOrToken().orEmpty(), // unifiedPushHelper.getEndpointOrToken().orEmpty()
pushKey = "TODO",
eventId = TEST_EVENT_ID eventId = TEST_EVENT_ID
) )
) )
@ -86,10 +88,13 @@ class PushersManager @Inject constructor(
SetHttpPusherData( SetHttpPusherData(
pushKey = pushKey, pushKey = pushKey,
appId = PushConfig.PUSHER_APP_ID, appId = PushConfig.PUSHER_APP_ID,
profileTag = DEFAULT_PUSHER_FILE_TAG + "_" /* TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())*/, // TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())
lang = "en", // TODO localeProvider.current().language, profileTag = DEFAULT_PUSHER_FILE_TAG + "_",
// TODO localeProvider.current().language
lang = "en",
appDisplayName = buildMeta.applicationName, appDisplayName = buildMeta.applicationName,
deviceDisplayName = "MyDevice", // TODO getDeviceInfoUseCase.execute().displayName().orEmpty(), // TODO getDeviceInfoUseCase.execute().displayName().orEmpty()
deviceDisplayName = "MyDevice",
url = gateway, url = gateway,
defaultPayload = createDefaultPayload(pushClientSecret.getSecretForUser(userId)) defaultPayload = createDefaultPayload(pushClientSecret.getSecretForUser(userId))
) )

View file

@ -21,8 +21,8 @@ object UnifiedPushConfig {
* It is the push gateway for UnifiedPush. * It is the push gateway for UnifiedPush.
* Note: default_push_gateway_http_url should have path '/_matrix/push/v1/notify' * Note: default_push_gateway_http_url should have path '/_matrix/push/v1/notify'
*/ */
const val default_push_gateway_http_url: String = "https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify" const val DEFAULT_PUSH_GATEWAY_HTTP_URL: String = "https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify"
const val index = 1 const val INDEX = 1
const val name = "UnifiedPush" const val NAME = "UnifiedPush"
} }

View file

@ -29,7 +29,7 @@ class UnifiedPushGatewayResolver @Inject constructor(
private val coroutineDispatchers: CoroutineDispatchers, private val coroutineDispatchers: CoroutineDispatchers,
) { ) {
suspend fun getGateway(endpoint: String): String? { suspend fun getGateway(endpoint: String): String? {
val gateway = UnifiedPushConfig.default_push_gateway_http_url val gateway = UnifiedPushConfig.DEFAULT_PUSH_GATEWAY_HTTP_URL
val url = URL(endpoint) val url = URL(endpoint)
val port = if (url.port != -1) ":${url.port}" else "" val port = if (url.port != -1) ":${url.port}" else ""
val customBase = "${url.protocol}://${url.host}$port" val customBase = "${url.protocol}://${url.host}$port"

View file

@ -41,7 +41,7 @@ class UnifiedPushNewGatewayHandler @Inject constructor(
Timber.w("Unable to retrieve session") Timber.w("Unable to retrieve session")
} }
val userDataStore = userPushStoreFactory.create(userId) val userDataStore = userPushStoreFactory.create(userId)
if (userDataStore.getPushProviderName() == UnifiedPushConfig.name) { if (userDataStore.getPushProviderName() == UnifiedPushConfig.NAME) {
matrixAuthenticationService.restoreSession(userId).getOrNull()?.use { client -> matrixAuthenticationService.restoreSession(userId).getOrNull()?.use { client ->
pusherSubscriber.registerPusher(client, endpoint, pushGateway) pusherSubscriber.registerPusher(client, endpoint, pushGateway)
} }

View file

@ -35,8 +35,8 @@ class UnifiedPushProvider @Inject constructor(
private val unRegisterUnifiedPushUseCase: UnregisterUnifiedPushUseCase, private val unRegisterUnifiedPushUseCase: UnregisterUnifiedPushUseCase,
private val pushClientSecret: PushClientSecret, private val pushClientSecret: PushClientSecret,
) : PushProvider { ) : PushProvider {
override val index = UnifiedPushConfig.index override val index = UnifiedPushConfig.INDEX
override val name = UnifiedPushConfig.name override val name = UnifiedPushConfig.NAME
override fun getDistributors(): List<Distributor> { override fun getDistributors(): List<Distributor> {
val distributors = UnifiedPush.getDistributors(context) val distributors = UnifiedPush.getDistributors(context)

View file

@ -138,7 +138,8 @@ fun RoomSelectView(
LazyColumn { LazyColumn {
item { item {
SelectedRoomsHelper( SelectedRoomsHelper(
isForwarding = false, // TODO state.isForwarding, // TODO state.isForwarding
isForwarding = false,
selectedRooms = state.selectedRooms selectedRooms = state.selectedRooms
) )
} }

View file

@ -93,7 +93,7 @@ private constructor(
private fun createOutputBuffer(sampleRate: SampleRate): ShortArray { private fun createOutputBuffer(sampleRate: SampleRate): ShortArray {
val bufferSizeInShorts = AudioRecord.getMinBufferSize( val bufferSizeInShorts = AudioRecord.getMinBufferSize(
sampleRate.hz, sampleRate.HZ,
config.format.channelMask, config.format.channelMask,
config.format.encoding config.format.encoding
) )

View file

@ -19,6 +19,6 @@ package io.element.android.libraries.voicerecorder.impl.audio
import io.element.android.opusencoder.configuration.SampleRate as LibOpusOggSampleRate import io.element.android.opusencoder.configuration.SampleRate as LibOpusOggSampleRate
data object SampleRate { data object SampleRate {
const val hz = 48_000 const val HZ = 48_000
fun asEncoderModel() = LibOpusOggSampleRate.Rate48kHz fun asEncoderModel() = LibOpusOggSampleRate.Rate48kHz
} }

View file

@ -37,10 +37,11 @@ object VoiceRecorderModule {
return AudioConfig( return AudioConfig(
format = AudioFormat.Builder() format = AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT) .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(sampleRate.hz) .setSampleRate(sampleRate.HZ)
.setChannelMask(AudioFormat.CHANNEL_IN_MONO) .setChannelMask(AudioFormat.CHANNEL_IN_MONO)
.build(), .build(),
bitRate = 24_000, // 24 kbps // 24 kbps
bitRate = 24_000,
sampleRate = sampleRate, sampleRate = sampleRate,
source = MediaRecorder.AudioSource.MIC, source = MediaRecorder.AudioSource.MIC,
) )

View file

@ -141,8 +141,9 @@ class VoiceRecorderImplTest {
), ),
encoder = FakeEncoder(fakeFileSystem), encoder = FakeEncoder(fakeFileSystem),
config = AudioConfig( config = AudioConfig(
format = AUDIO_FORMAT, format = audioFormat,
bitRate = 24_000, // 24 kbps // 24 kbps
bitRate = 24_000,
sampleRate = SampleRate, sampleRate = SampleRate,
source = MediaRecorder.AudioSource.MIC, source = MediaRecorder.AudioSource.MIC,
), ),
@ -156,7 +157,7 @@ class VoiceRecorderImplTest {
companion object { companion object {
const val FILE_ID: String = "recording" const val FILE_ID: String = "recording"
const val FILE_PATH = "voice_recordings/$FILE_ID.ogg" const val FILE_PATH = "voice_recordings/$FILE_ID.ogg"
private lateinit var AUDIO_FORMAT: AudioFormat private lateinit var audioFormat: AudioFormat
// FakeEncoder doesn't actually encode, it just writes the data to the file // FakeEncoder doesn't actually encode, it just writes the data to the file
private const val ENCODED_DATA = "[32767, 32767, 32767][32767, 32767, 32767]" private const val ENCODED_DATA = "[32767, 32767, 32767][32767, 32767, 32767]"
@ -170,7 +171,7 @@ class VoiceRecorderImplTest {
@BeforeClass @BeforeClass
@JvmStatic @JvmStatic
fun initAudioFormat() { fun initAudioFormat() {
AUDIO_FORMAT = mockk() audioFormat = mockk()
} }
} }
} }