Let element enterprise be able to configure id for mapTiler. (#4446)
* Let element enterprise configure the ids for maptiler service. * Disable location sharing and location viewer is the service is not available. * Fix compilation issue on connected test * Do not allow to reload the map if the mapId is not available. * Update screenshots * Rename file. * Better to inject a string provider here, so we can unit test DefaultLocationService. --------- Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
@@ -49,6 +49,7 @@ dependencies {
|
||||
testImplementation(projects.libraries.testtags)
|
||||
testImplementation(projects.services.analytics.test)
|
||||
testImplementation(projects.features.messages.test)
|
||||
testImplementation(projects.services.toolbox.test)
|
||||
testImplementation(projects.tests.testutils)
|
||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.location.impl
|
||||
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.features.location.api.LocationService
|
||||
import io.element.android.features.location.api.R
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultLocationService @Inject constructor(
|
||||
private val stringProvider: StringProvider,
|
||||
) : LocationService {
|
||||
override fun isServiceAvailable(): Boolean {
|
||||
return stringProvider.getString(R.string.maptiler_api_key).isNotEmpty()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.location.impl
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.features.location.api.R
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import org.junit.Test
|
||||
|
||||
class DefaultLocationServiceTest {
|
||||
@Test
|
||||
fun `if apiKey is empty, isServiceAvailable should return false`() {
|
||||
val fakeStringProvider = FakeStringProvider(
|
||||
defaultResult = ""
|
||||
)
|
||||
val locationService = DefaultLocationService(
|
||||
stringProvider = fakeStringProvider,
|
||||
)
|
||||
assertThat(locationService.isServiceAvailable()).isFalse()
|
||||
assertThat(fakeStringProvider.lastResIdParam).isEqualTo(R.string.maptiler_api_key)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if apiKey is not empty, isServiceAvailable should return true`() {
|
||||
val locationService = DefaultLocationService(
|
||||
stringProvider = FakeStringProvider(
|
||||
defaultResult = "aKey"
|
||||
)
|
||||
)
|
||||
assertThat(locationService.isServiceAvailable()).isTrue()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user