Fixing deprecation messages (issue 1607) (#2654)

This commit is contained in:
Eric Smith
2024-07-30 18:22:21 -04:00
committed by GitHub
parent f40b5e045b
commit 090f7fd3d6
71 changed files with 959 additions and 1140 deletions

View File

@@ -192,7 +192,7 @@ class LocationComponentTest : EspressoTest() {
uiController: UiController,
context: Context
) {
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.activateLocationComponent(
LocationComponentActivationOptions
@@ -677,7 +677,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
component.isLocationComponentEnabled = false
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.isLocationComponentEnabled = true
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -823,7 +823,7 @@ class LocationComponentTest : EspressoTest() {
.build()
)
component.isLocationComponentEnabled = true
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.onStop()
component.onStart()
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -910,7 +910,7 @@ class LocationComponentTest : EspressoTest() {
)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.onStop()
TestingAsyncUtils.waitForLayer(uiController, mapView)
component.onStart()

View File

@@ -30,10 +30,10 @@ import org.maplibre.android.testapp.utils.TestingAsyncUtils
import org.maplibre.android.utils.BitmapUtils
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.notNullValue
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThat
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -504,7 +504,7 @@ class LocationLayerControllerTest : EspressoTest() {
`is`(true)
)
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(
@@ -676,7 +676,7 @@ class LocationLayerControllerTest : EspressoTest() {
assertThat(
Math.abs(zoom - maplibreMap.cameraPosition.zoom) < 0.1 &&
Math.abs(target.latitude - maplibreMap.cameraPosition.target!!.latitude) < 0.1 &&
Math.abs(target!!.longitude - maplibreMap.cameraPosition.target!!.longitude) < 0.1,
Math.abs(target.longitude - maplibreMap.cameraPosition.target!!.longitude) < 0.1,
`is`(true)
)
@@ -722,7 +722,7 @@ class LocationLayerControllerTest : EspressoTest() {
assertThat(
abs(zoom - maplibreMap.cameraPosition.zoom) < 0.1 &&
abs(target.latitude - maplibreMap.cameraPosition.target!!.latitude) < 0.1 &&
abs(target!!.longitude - maplibreMap.cameraPosition.target!!.longitude) < 0.1,
abs(target.longitude - maplibreMap.cameraPosition.target!!.longitude) < 0.1,
`is`(true)
)

View File

@@ -3,6 +3,8 @@ package org.maplibre.android.testapp.offline
import android.content.Context
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import java.io.IOException
import java.util.concurrent.CountDownLatch
import org.junit.After
@@ -50,6 +52,7 @@ class OfflineManagerTest : AppCenter() {
latch.await()
}
@OptIn(ExperimentalCoroutinesApi::class)
@Test(timeout = 30_000)
fun combinedTest() {
@@ -59,18 +62,19 @@ class OfflineManagerTest : AppCenter() {
val latch1 = CountDownLatch(1)
rule.activity.runOnUiThread {
FileUtils.CopyFileFromAssetsTask(
rule.activity,
object : FileUtils.OnFileCopiedFromAssetsListener {
override fun onFileCopiedFromAssets() {
latch1.countDown()
}
override fun onError() {
throw IOException("Unable to copy DB file.")
}
}
).execute(TEST_DB_FILE_NAME, FileSource.getResourcesCachePath(rule.activity))
var copied = false
runTest {
copied = FileUtils.copyFileFromAssetsTask(
rule.activity,
TEST_DB_FILE_NAME,
FileSource.getResourcesCachePath(rule.activity)
)
}
if (copied) {
latch1.countDown()
} else {
throw IOException("Unable to copy DB file.")
}
}
latch1.await()

View File

@@ -26,7 +26,7 @@ class ImageTest : EspressoTest() {
fun testAddGetImage() {
validateTestSetup()
MapLibreMapAction.invoke(maplibreMap) { uiController, maplibreMap ->
val drawable = rule.activity.resources.getDrawable(R.drawable.ic_launcher_round)
val drawable = rule.activity.resources.getDrawable(R.drawable.ic_launcher_round, null)
assertTrue(drawable is BitmapDrawable)
val bitmapSet = (drawable as BitmapDrawable).bitmap