[android] keep strong callback reference and use application context during cache path change

This commit is contained in:
Łukasz Paczos
2019-05-09 15:06:43 +02:00
committed by Łukasz Paczos
parent e0f32000df
commit 0f599ce804
4 changed files with 71 additions and 51 deletions

View File

@@ -36,12 +36,12 @@ open class FileSourceMapTest {
fun changeResourcesPathWhileMapVisible() {
val latch = CountDownLatch(1)
rule.activity.runOnUiThread {
FileSource.setResourcesCachePath(rule.activity, fileSourceTestUtils.testPath, object : FileSource.ResourcesCachePathChangeCallback {
override fun onSuccess(path: String?) {
FileSource.setResourcesCachePath(fileSourceTestUtils.testPath, object : FileSource.ResourcesCachePathChangeCallback {
override fun onSuccess(path: String) {
Assert.fail("Requested resources change while the map is running should fail")
}
override fun onError(message: String?) {
override fun onError(message: String) {
Assert.assertEquals("Cannot set path, file source is activated."
+ " Make sure that the map or a resources download is not running.", message)
latch.countDown()

View File

@@ -33,14 +33,13 @@ class FileSourceTestUtils(private val activity: Activity) {
val latch = CountDownLatch(1)
activity.runOnUiThread {
FileSource.setResourcesCachePath(
activity,
path,
object : FileSource.ResourcesCachePathChangeCallback {
override fun onSuccess(path: String?) {
override fun onSuccess(path: String) {
latch.countDown()
}
override fun onError(message: String?) {
override fun onError(message: String) {
Assert.fail("Resource path change failed - path: $path, message: $message")
}
})