Add a way to override default homeserver.
This commit is contained in:
parent
c9890d3073
commit
05f61b8779
14 changed files with 145 additions and 121 deletions
|
|
@ -13,6 +13,7 @@ import io.element.android.libraries.matrix.api.core.SessionId
|
|||
interface EnterpriseService {
|
||||
val isEnterpriseBuild: Boolean
|
||||
suspend fun isEnterpriseUser(sessionId: SessionId): Boolean
|
||||
fun defaultHomeserver(): String?
|
||||
|
||||
fun semanticColorsLight(): SemanticColors
|
||||
fun semanticColorsDark(): SemanticColors
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class DefaultEnterpriseService @Inject constructor() : EnterpriseService {
|
|||
|
||||
override suspend fun isEnterpriseUser(sessionId: SessionId) = false
|
||||
|
||||
override fun defaultHomeserver() = null
|
||||
|
||||
override fun semanticColorsLight(): SemanticColors = compoundColorsLight
|
||||
|
||||
override fun semanticColorsDark(): SemanticColors = compoundColorsDark
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ class DefaultEnterpriseServiceTest {
|
|||
assertThat(defaultEnterpriseService.isEnterpriseBuild).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `defaultHomeserver should return null`() {
|
||||
val defaultEnterpriseService = DefaultEnterpriseService()
|
||||
assertThat<String?>(defaultEnterpriseService.defaultHomeserver()).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isEnterpriseUser always return false`() = runTest {
|
||||
val defaultEnterpriseService = DefaultEnterpriseService()
|
||||
|
|
|
|||
20
features/enterprise/test/build.gradle.kts
Normal file
20
features/enterprise/test/build.gradle.kts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.features.enterprise.test"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.features.enterprise.api)
|
||||
implementation(libs.compound)
|
||||
implementation(projects.libraries.matrix.api)
|
||||
implementation(projects.tests.testutils)
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.enterprise.test
|
||||
|
||||
import io.element.android.compound.tokens.generated.SemanticColors
|
||||
import io.element.android.features.enterprise.api.EnterpriseService
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.tests.testutils.lambda.lambdaError
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
|
||||
class FakeEnterpriseService(
|
||||
override val isEnterpriseBuild: Boolean = false,
|
||||
private val isEnterpriseUserResult: (SessionId) -> Boolean = { lambdaError() },
|
||||
private val defaultHomeserverResult: () -> String? = { A_FAKE_HOMESERVER },
|
||||
private val semanticColorsLightResult: () -> SemanticColors = { lambdaError() },
|
||||
private val semanticColorsDarkResult: () -> SemanticColors = { lambdaError() },
|
||||
) : EnterpriseService {
|
||||
override suspend fun isEnterpriseUser(sessionId: SessionId): Boolean = simulateLongTask {
|
||||
isEnterpriseUserResult(sessionId)
|
||||
}
|
||||
|
||||
override fun defaultHomeserver(): String? {
|
||||
return defaultHomeserverResult()
|
||||
}
|
||||
|
||||
override fun semanticColorsLight(): SemanticColors {
|
||||
return semanticColorsLightResult()
|
||||
}
|
||||
|
||||
override fun semanticColorsDark(): SemanticColors {
|
||||
return semanticColorsDarkResult()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val A_FAKE_HOMESERVER = "a_fake_homeserver"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue