Skip to content

Commit

Permalink
Fix more and more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Oct 3, 2024
1 parent de931f7 commit 54bb9c0
Show file tree
Hide file tree
Showing 23 changed files with 251 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import io.element.android.tests.testutils.consumeItemsUntilPredicate
import io.element.android.tests.testutils.lambda.any
import io.element.android.tests.testutils.lambda.lambdaError
import io.element.android.tests.testutils.lambda.lambdaRecorder
import io.element.android.tests.testutils.lambda.lambdaSuspendRecorder
import io.element.android.tests.testutils.lambda.value
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
Expand Down Expand Up @@ -145,7 +146,7 @@ class LoggedInPresenterTest {

@Test
fun `present - ensure default pusher is registered with default provider`() = runTest {
val lambda = lambdaRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
val lambda = lambdaSuspendRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
Result.success(Unit)
}
val sessionVerificationService = FakeSessionVerificationService(
Expand Down Expand Up @@ -178,7 +179,7 @@ class LoggedInPresenterTest {

@Test
fun `present - ensure default pusher is registered with default provider - fail to register`() = runTest {
val lambda = lambdaRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
val lambda = lambdaSuspendRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
Result.failure(AN_EXCEPTION)
}
val sessionVerificationService = FakeSessionVerificationService(
Expand Down Expand Up @@ -211,7 +212,7 @@ class LoggedInPresenterTest {

@Test
fun `present - ensure current provider is registered with current distributor`() = runTest {
val lambda = lambdaRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
val lambda = lambdaSuspendRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
Result.success(Unit)
}
val sessionVerificationService = FakeSessionVerificationService(
Expand Down Expand Up @@ -256,7 +257,7 @@ class LoggedInPresenterTest {

@Test
fun `present - if current push provider does not have current distributor, the first one is used`() = runTest {
val lambda = lambdaRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
val lambda = lambdaSuspendRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
Result.success(Unit)
}
val sessionVerificationService = FakeSessionVerificationService(
Expand Down Expand Up @@ -422,7 +423,7 @@ class LoggedInPresenterTest {

@Test
fun `present - case two push providers but first one does not have distributor - second one will be used`() = runTest {
val lambda = lambdaRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
val lambda = lambdaSuspendRecorder<MatrixClient, PushProvider, Distributor, Result<Unit>> { _, _, _ ->
Result.success(Unit)
}
val sessionVerificationService = FakeSessionVerificationService(
Expand Down
5 changes: 4 additions & 1 deletion features/cachecleaner/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import extension.setupAnvil

/*
* Copyright 2023, 2024 New Vector Ltd.
*
Expand All @@ -7,13 +9,14 @@

plugins {
id("io.element.android-library")
alias(libs.plugins.anvil)
}

android {
namespace = "io.element.android.features.cachecleaner.api"
}

setupAnvil()

dependencies {
implementation(projects.libraries.architecture)
implementation(libs.androidx.startup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,7 @@ class CallScreenPresenterTest {
assertThat(initialState.isInWidgetMode).isTrue()
assertThat(widgetProvider.getWidgetCalled).isTrue()
assertThat(widgetDriver.runCalledCount).isEqualTo(1)
// Called several times because of the recomposition
analyticsLambda.assertions().isCalledExactly(2)
.withSequence(
listOf(value(MobileScreen.ScreenName.RoomCall)),
listOf(value(MobileScreen.ScreenName.RoomCall))
)
analyticsLambda.assertions().isCalledOnce().with(value(MobileScreen.ScreenName.RoomCall))
sendCallNotificationIfNeededLambda.assertions().isCalledOnce()
}
}
Expand Down
5 changes: 4 additions & 1 deletion features/enterprise/impl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import extension.setupAnvil

/*
* Copyright 2024 New Vector Ltd.
*
Expand All @@ -6,13 +8,14 @@
*/
plugins {
id("io.element.android-library")
alias(libs.plugins.anvil)
}

android {
namespace = "io.element.android.features.enterprise.impl"
}

setupAnvil()

dependencies {
implementation(projects.anvilannotations)
api(projects.features.enterprise.api)
Expand Down
5 changes: 4 additions & 1 deletion features/ftue/test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import extension.setupAnvil

/*
* Copyright 2024 New Vector Ltd.
*
Expand All @@ -7,14 +9,15 @@

plugins {
id("io.element.android-compose-library")
alias(libs.plugins.anvil)
id("kotlin-parcelize")
}

android {
namespace = "io.element.android.features.ftue.test"
}

setupAnvil()

dependencies {
implementation(projects.features.ftue.api)
implementation(projects.tests.testutils)
Expand Down
1 change: 0 additions & 1 deletion features/licenses/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import extension.setupAnvil
plugins {
id("io.element.android-compose-library")
id("kotlin-parcelize")
alias(libs.plugins.anvil)
alias(libs.plugins.kotlin.serialization)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class WebViewMessageInterceptor(
}

override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
request ?: return super.shouldOverrideUrlLoading(view, request)
request ?: return false
// Load the URL in a Chrome Custom Tab, and return true to cancel the load
onOpenExternalUrl(request.url.toString())
return true
Expand Down
5 changes: 4 additions & 1 deletion features/migration/impl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import extension.setupAnvil

/*
* Copyright 2024 New Vector Ltd.
*
Expand All @@ -7,13 +9,14 @@

plugins {
id("io.element.android-compose-library")
alias(libs.plugins.anvil)
}

android {
namespace = "io.element.android.features.migration.impl"
}

setupAnvil()

dependencies {
implementation(projects.features.migration.api)
implementation(projects.libraries.architecture)
Expand Down
1 change: 0 additions & 1 deletion features/roomdirectory/impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import extension.setupAnvil

plugins {
id("io.element.android-compose-library")
alias(libs.plugins.anvil)
id("kotlin-parcelize")
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Project
android_gradle_plugin = "8.7.0"
kotlin = "2.0.20"
kotlinpoetKsp = "1.17.0"
kotlinpoetKsp = "1.18.1"
ksp = "2.0.20-1.0.25"
firebaseAppDistribution = "5.0.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package io.element.android.libraries.designsystem.theme.components.bottomsheet

import androidx.compose.animation.core.DecayAnimationSpec
import androidx.compose.animation.core.SpringSpec
import androidx.compose.animation.core.exponentialDecay
import androidx.compose.foundation.ExperimentalFoundationApi
Expand Down Expand Up @@ -296,13 +295,9 @@ internal object AnchoredDraggableDefaults {
/**
* The default animation used by [AnchoredDraggableState].
*/
@get:ExperimentalMaterial3Api
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
@ExperimentalMaterial3Api
val SnapAnimationSpec = SpringSpec<Float>()

@get:ExperimentalMaterial3Api
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
@ExperimentalMaterial3Api
val DecayAnimationSpec = exponentialDecay<Float>()
}
5 changes: 4 additions & 1 deletion libraries/mediapickers/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import extension.setupAnvil

/*
* Copyright 2023, 2024 New Vector Ltd.
*
Expand All @@ -7,9 +9,10 @@

plugins {
id("io.element.android-compose-library")
alias(libs.plugins.anvil)
}

setupAnvil()

android {
namespace = "io.element.android.libraries.mediapickers.api"

Expand Down
5 changes: 4 additions & 1 deletion libraries/mediapickers/test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import extension.setupAnvil

/*
* Copyright 2023, 2024 New Vector Ltd.
*
Expand All @@ -7,9 +9,10 @@

plugins {
id("io.element.android-compose-library")
alias(libs.plugins.anvil)
}

setupAnvil()

android {
namespace = "io.element.android.libraries.mediapickers.test"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import io.element.android.libraries.pushproviders.api.PushHandler
import io.element.android.tests.testutils.lambda.lambdaError

class FakePushHandler(
private val handleResult: (PushData) -> Unit = { lambdaError() }
private val handleResult: suspend (PushData) -> Unit = { lambdaError() }
) : PushHandler {
override suspend fun handle(pushData: PushData) {
handleResult(pushData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.element.android.libraries.push.test.test.FakePushHandler
import io.element.android.libraries.pushproviders.api.PushData
import io.element.android.libraries.pushproviders.api.PushHandler
import io.element.android.tests.testutils.lambda.lambdaRecorder
import io.element.android.tests.testutils.lambda.lambdaSuspendRecorder
import io.element.android.tests.testutils.lambda.value
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
Expand All @@ -31,7 +32,7 @@ import org.robolectric.RobolectricTestRunner
class VectorFirebaseMessagingServiceTest {
@Test
fun `test receiving invalid data`() = runTest {
val lambda = lambdaRecorder<PushData, Unit>(ensureNeverCalled = true) { }
val lambda = lambdaSuspendRecorder<PushData, Unit>(ensureNeverCalled = true) { }
val vectorFirebaseMessagingService = createVectorFirebaseMessagingService(
pushHandler = FakePushHandler(handleResult = lambda)
)
Expand All @@ -40,7 +41,7 @@ class VectorFirebaseMessagingServiceTest {

@Test
fun `test receiving valid data`() = runTest {
val lambda = lambdaRecorder<PushData, Unit> { }
val lambda = lambdaSuspendRecorder<PushData, Unit> { }
val vectorFirebaseMessagingService = createVectorFirebaseMessagingService(
pushHandler = FakePushHandler(handleResult = lambda)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import io.element.android.libraries.pushproviders.api.PushHandler
import io.element.android.libraries.pushproviders.unifiedpush.registration.EndpointRegistrationHandler
import io.element.android.libraries.pushproviders.unifiedpush.registration.RegistrationResult
import io.element.android.tests.testutils.lambda.lambdaRecorder
import io.element.android.tests.testutils.lambda.lambdaSuspendRecorder
import io.element.android.tests.testutils.lambda.value
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
Expand Down Expand Up @@ -50,7 +51,7 @@ class VectorUnifiedPushMessagingReceiverTest {
@Test
fun `onMessage valid invoke the push handler`() = runTest {
val context = InstrumentationRegistry.getInstrumentation().context
val pushHandlerResult = lambdaRecorder<PushData, Unit> {}
val pushHandlerResult = lambdaSuspendRecorder<PushData, Unit> {}
val vectorUnifiedPushMessagingReceiver = createVectorUnifiedPushMessagingReceiver(
pushHandler = FakePushHandler(
handleResult = pushHandlerResult
Expand All @@ -75,7 +76,7 @@ class VectorUnifiedPushMessagingReceiverTest {
@Test
fun `onMessage invalid does not invoke the push handler`() = runTest {
val context = InstrumentationRegistry.getInstrumentation().context
val pushHandlerResult = lambdaRecorder<PushData, Unit> {}
val pushHandlerResult = lambdaSuspendRecorder<PushData, Unit> {}
val vectorUnifiedPushMessagingReceiver = createVectorUnifiedPushMessagingReceiver(
pushHandler = FakePushHandler(
handleResult = pushHandlerResult
Expand All @@ -97,7 +98,7 @@ class VectorUnifiedPushMessagingReceiverTest {
storeUpEndpointResult = storeUpEndpointResult,
)
val endpointRegistrationHandler = EndpointRegistrationHandler()
val handleResult = lambdaRecorder<String, String, String, Result<Unit>> { _, _, _ -> Result.success(Unit) }
val handleResult = lambdaSuspendRecorder<String, String, String, Result<Unit>> { _, _, _ -> Result.success(Unit) }
val unifiedPushNewGatewayHandler = FakeUnifiedPushNewGatewayHandler(
handleResult = handleResult
)
Expand Down Expand Up @@ -137,7 +138,7 @@ class VectorUnifiedPushMessagingReceiverTest {
storeUpEndpointResult = storeUpEndpointResult,
)
val endpointRegistrationHandler = EndpointRegistrationHandler()
val handleResult = lambdaRecorder<String, String, String, Result<Unit>> { _, _, _ -> Result.failure(AN_EXCEPTION) }
val handleResult = lambdaSuspendRecorder<String, String, String, Result<Unit>> { _, _, _ -> Result.failure(AN_EXCEPTION) }
val unifiedPushNewGatewayHandler = FakeUnifiedPushNewGatewayHandler(
handleResult = handleResult
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package io.element.android.libraries.roomselect.impl

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
Expand All @@ -22,6 +23,7 @@ import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
import io.element.android.libraries.matrix.api.roomlist.RoomSummary
import io.element.android.libraries.roomselect.api.RoomSelectMode
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList

Expand Down Expand Up @@ -50,7 +52,7 @@ class RoomSelectPresenter @AssistedInject constructor(

val roomSummaryDetailsList by dataSource.roomSummaries.collectAsState(initial = persistentListOf())

val searchResults by remember {
val searchResults by remember<State<SearchBarResultState<ImmutableList<RoomSummary>>>> {
derivedStateOf {
when {
roomSummaryDetailsList.isNotEmpty() -> SearchBarResultState.Results(roomSummaryDetailsList.toImmutableList())
Expand Down
4 changes: 2 additions & 2 deletions plugins/src/main/kotlin/extension/CommonExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package extension
import Versions
import com.android.build.api.dsl.CommonExtension
import isEnterpriseBuild
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import java.io.File

Expand Down Expand Up @@ -44,12 +43,13 @@ fun CommonExtension<*, *, *, *, *, *>.androidConfig(project: Project) {
}
checkDependencies = false
abortOnError = true
ignoreTestSources = true
ignoreTestFixturesSources = true
checkGeneratedSources = false
}
}

fun CommonExtension<*, *, *, *, *, *>.composeConfig(libs: LibrariesForLibs) {
fun CommonExtension<*, *, *, *, *, *>.composeConfig() {

buildFeatures {
compose = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
androidConfig(project)
composeConfig(libs)
composeConfig()
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

android {
androidConfig(project)
composeConfig(libs)
composeConfig()
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
Expand Down
Loading

0 comments on commit 54bb9c0

Please sign in to comment.