blob: ca8451a24b7db6bc5e542da8fe222d56a2ddd936 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.mapbox.mapboxsdk.snapshotter
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import junit.framework.Assert
import junit.framework.Assert.assertNotNull
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
/**
* Integration test that validates if a snapshotter creation
*/
@RunWith(AndroidJUnit4::class)
class MapSnapshotterTest {
@Rule
@JvmField
var rule = ActivityTestRule(FeatureOverviewActivity::class.java)
private val countDownLatch = CountDownLatch(1)
@Test
fun mapSnapshotter() {
rule.activity.runOnUiThread {
val options = MapSnapshotter.Options(512, 512)
.withPixelRatio(1.0f)
.withStyle(Style.SATELLITE_STREETS)
.withCameraPosition(
CameraPosition.Builder()
.zoom(12.0)
.target(LatLng(51.145495, 5.742234))
.build()
)
val mapSnapshotter = MapSnapshotter(rule.activity, options)
mapSnapshotter.start({
assertNotNull(it)
assertNotNull(it.bitmap)
countDownLatch.countDown()
}, {
Assert.fail(it)
})
}
if (!countDownLatch.await(30, TimeUnit.SECONDS)) {
throw TimeoutException()
}
}
}
|