[android] - update dependencies, target SDK, support library (#15135)
This commit is contained in:
@@ -27,6 +27,7 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
|
||||
import com.mapbox.mapboxsdk.utils.BitmapUtils
|
||||
import kotlin.math.abs
|
||||
import org.hamcrest.CoreMatchers.`is`
|
||||
import org.hamcrest.CoreMatchers.notNullValue
|
||||
import org.hamcrest.Matchers.equalTo
|
||||
@@ -37,7 +38,6 @@ import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import kotlin.math.abs
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LocationLayerControllerTest : EspressoTest() {
|
||||
@@ -77,10 +77,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
@@ -105,10 +107,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
@@ -134,10 +138,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.renderMode = RenderMode.COMPASS
|
||||
component.forceLocationUpdate(location)
|
||||
@@ -163,10 +169,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.renderMode = RenderMode.GPS
|
||||
component.forceLocationUpdate(location)
|
||||
@@ -192,10 +200,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
component.isLocationComponentEnabled = false
|
||||
@@ -222,10 +232,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
@@ -253,10 +265,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
@@ -290,22 +304,30 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build())
|
||||
component.forceLocationUpdate(location)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
uiController.loopMainThreadForAtLeast(150)
|
||||
|
||||
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
|
||||
assertThat(
|
||||
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE),
|
||||
`is`(true)
|
||||
)
|
||||
|
||||
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
|
||||
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
|
||||
assertThat(
|
||||
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE),
|
||||
`is`(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
executeComponentTest(componentAction)
|
||||
@@ -321,10 +343,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
@@ -333,9 +357,9 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
|
||||
|
||||
val options = component.locationComponentOptions
|
||||
.toBuilder()
|
||||
.layerBelow("road-label")
|
||||
.build()
|
||||
.toBuilder()
|
||||
.layerBelow("road-label")
|
||||
.build()
|
||||
|
||||
component.applyStyle(options)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
@@ -355,10 +379,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build())
|
||||
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
@@ -386,10 +412,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
uiController.loopMainThreadForAtLeast(100)
|
||||
var show = true
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, mapboxMap.style!!)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, mapboxMap.style!!)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
pushSourceUpdates(styleChangeIdlingResource) {
|
||||
component.isLocationComponentEnabled = show
|
||||
show = !show
|
||||
@@ -414,19 +442,23 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
|
||||
component.forceLocationUpdate(location)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
uiController.loopMainThreadForAtLeast(ACCURACY_RADIUS_ANIMATION_DURATION)
|
||||
|
||||
assertEquals(Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/,
|
||||
assertEquals(
|
||||
Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/,
|
||||
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0]
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f
|
||||
)
|
||||
}
|
||||
}
|
||||
executeComponentTest(componentAction)
|
||||
@@ -442,10 +474,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
|
||||
@@ -455,15 +489,23 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController.loopMainThreadForAtLeast(300)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
|
||||
assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
|
||||
Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
|
||||
Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
|
||||
`is`(true))
|
||||
|
||||
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
|
||||
assertThat(
|
||||
Math.abs(expectedRadius - mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat()) < 0.1,
|
||||
`is`(true))
|
||||
Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
|
||||
Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
|
||||
Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
|
||||
`is`(true)
|
||||
)
|
||||
|
||||
val expectedRadius =
|
||||
Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
|
||||
assertThat(
|
||||
Math.abs(
|
||||
expectedRadius - mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(
|
||||
PROPERTY_ACCURACY_RADIUS
|
||||
).toFloat()
|
||||
) < 0.1,
|
||||
`is`(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
executeComponentTest(componentAction)
|
||||
@@ -479,10 +521,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
|
||||
@@ -493,14 +537,21 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
|
||||
assertThat(
|
||||
abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
|
||||
abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
|
||||
abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
|
||||
`is`(true))
|
||||
abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
|
||||
abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
|
||||
`is`(true)
|
||||
)
|
||||
|
||||
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
|
||||
val expectedRadius =
|
||||
Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
|
||||
assertThat(
|
||||
Math.abs(expectedRadius - mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat()) < 0.1,
|
||||
`is`(true))
|
||||
Math.abs(
|
||||
expectedRadius - mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(
|
||||
PROPERTY_ACCURACY_RADIUS
|
||||
).toFloat()
|
||||
) < 0.1,
|
||||
`is`(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
executeComponentTest(componentAction)
|
||||
@@ -516,10 +567,12 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build())
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
.build()
|
||||
)
|
||||
component.isLocationComponentEnabled = true
|
||||
component.forceLocationUpdate(location)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
|
||||
@@ -5,8 +5,8 @@ import android.support.test.espresso.UiController
|
||||
import android.support.test.espresso.ViewAction
|
||||
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import android.view.View
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import org.hamcrest.Matcher
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.support.test.espresso.IdlingResource
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment
|
||||
|
||||
class OnMapFragmentReadyIdlingResource(fragment: SupportMapFragment?) : IdlingResource, OnMapReadyCallback {
|
||||
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
|
||||
private var resourceCallback: IdlingResource.ResourceCallback? = null
|
||||
|
||||
init {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
fragment?.getMapAsync(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getName(): String {
|
||||
return javaClass.simpleName
|
||||
}
|
||||
|
||||
override fun isIdleNow(): Boolean {
|
||||
return this::mapboxMap.isInitialized
|
||||
}
|
||||
|
||||
override fun registerIdleTransitionCallback(resourceCallback: IdlingResource.ResourceCallback) {
|
||||
this.resourceCallback = resourceCallback
|
||||
}
|
||||
|
||||
override fun onMapReady(mapboxMap: MapboxMap) {
|
||||
this.mapboxMap = mapboxMap
|
||||
resourceCallback?.onTransitionToIdle()
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,18 @@ import android.support.test.espresso.ViewAction
|
||||
import android.support.test.espresso.matcher.ViewMatchers
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
|
||||
import org.hamcrest.Matcher
|
||||
|
||||
object GesturesUiTestUtils {
|
||||
|
||||
private const val DEFAULT_GESTURE_DURATION = 500L
|
||||
|
||||
fun pinch(startSpan: Float, endSpan: Float, center: PointF? = null, duration: Long = DEFAULT_GESTURE_DURATION): ViewAction {
|
||||
fun pinch(
|
||||
startSpan: Float,
|
||||
endSpan: Float,
|
||||
center: PointF? = null,
|
||||
duration: Long = DEFAULT_GESTURE_DURATION
|
||||
): ViewAction {
|
||||
return object : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return ViewMatchers.isEnabled()
|
||||
@@ -40,7 +44,13 @@ object GesturesUiTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
fun quickScale(deltaY: Float, startPoint: PointF? = null, withVelocity: Boolean = true, duration: Long = DEFAULT_GESTURE_DURATION, interrupt: Boolean = false): ViewAction {
|
||||
fun quickScale(
|
||||
deltaY: Float,
|
||||
startPoint: PointF? = null,
|
||||
withVelocity: Boolean = true,
|
||||
duration: Long = DEFAULT_GESTURE_DURATION,
|
||||
interrupt: Boolean = false
|
||||
): ViewAction {
|
||||
return object : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> = ViewMatchers.isEnabled()
|
||||
|
||||
@@ -59,7 +69,13 @@ object GesturesUiTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
fun move(deltaX: Float, deltaY: Float, startPoint: PointF? = null, withVelocity: Boolean = true, duration: Long = DEFAULT_GESTURE_DURATION): ViewAction {
|
||||
fun move(
|
||||
deltaX: Float,
|
||||
deltaY: Float,
|
||||
startPoint: PointF? = null,
|
||||
withVelocity: Boolean = true,
|
||||
duration: Long = DEFAULT_GESTURE_DURATION
|
||||
): ViewAction {
|
||||
return object : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> = ViewMatchers.isEnabled()
|
||||
|
||||
@@ -85,7 +101,8 @@ object GesturesUiTestUtils {
|
||||
val viewWidth = view.width * view.scaleX
|
||||
return PointF(
|
||||
(locationOnScreen[0] + viewWidth / 2).toInt().toFloat(),
|
||||
(locationOnScreen[1] + viewHeight / 2).toInt().toFloat())
|
||||
(locationOnScreen[1] + viewHeight / 2).toInt().toFloat()
|
||||
)
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/46443628/9126211
|
||||
@@ -147,15 +164,19 @@ object GesturesUiTestUtils {
|
||||
|
||||
try {
|
||||
// Step 1
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_DOWN, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 2
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_POINTER_DOWN + (pp2.id shl MotionEvent.ACTION_POINTER_INDEX_SHIFT), 2,
|
||||
properties, pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
properties, pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 3, 4
|
||||
@@ -187,9 +208,11 @@ object GesturesUiTestUtils {
|
||||
pointerCoords[0] = pc1
|
||||
pointerCoords[1] = pc2
|
||||
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_MOVE, 2, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
}
|
||||
|
||||
@@ -202,23 +225,34 @@ object GesturesUiTestUtils {
|
||||
pointerCoords[1] = pc2
|
||||
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_POINTER_UP + (pp2.id shl MotionEvent.ACTION_POINTER_INDEX_SHIFT), 2, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 6
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_UP, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
} catch (ex: InjectEventSecurityException) {
|
||||
throw RuntimeException("Could not perform pinch", ex)
|
||||
}
|
||||
}
|
||||
|
||||
private fun performQuickScale(uiController: UiController, startPoint: PointF, endPoint: PointF, withVelocity: Boolean, duration: Long, interrupt: Boolean) {
|
||||
private fun performQuickScale(
|
||||
uiController: UiController,
|
||||
startPoint: PointF,
|
||||
endPoint: PointF,
|
||||
withVelocity: Boolean,
|
||||
duration: Long,
|
||||
interrupt: Boolean
|
||||
) {
|
||||
val eventMinInterval: Long = 10
|
||||
val tapDownMinInterval: Long = 40 // ViewConfiguration#DOUBLE_TAP_MIN_TIME = 40
|
||||
val startTime = SystemClock.uptimeMillis()
|
||||
@@ -252,23 +286,29 @@ object GesturesUiTestUtils {
|
||||
*/
|
||||
try {
|
||||
// Step 1
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_DOWN, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 2
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_UP, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 3
|
||||
eventTime += tapDownMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_DOWN, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 4
|
||||
@@ -293,9 +333,11 @@ object GesturesUiTestUtils {
|
||||
|
||||
pointerCoords[0] = pc1
|
||||
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_MOVE, if (interrupted) 2 else 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
if (interrupt && i == moveEventNumber / 2) {
|
||||
@@ -320,9 +362,11 @@ object GesturesUiTestUtils {
|
||||
pointerCoords[1] = pc2
|
||||
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_POINTER_DOWN + (pp2.id shl MotionEvent.ACTION_POINTER_INDEX_SHIFT), 2,
|
||||
properties, pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
properties, pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
interrupted = true
|
||||
}
|
||||
@@ -330,24 +374,34 @@ object GesturesUiTestUtils {
|
||||
|
||||
if (!withVelocity) {
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_MOVE, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
}
|
||||
|
||||
// Step 5
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_UP, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
} catch (ex: InjectEventSecurityException) {
|
||||
throw RuntimeException("Could not perform quick scale", ex)
|
||||
}
|
||||
}
|
||||
|
||||
private fun performMove(uiController: UiController, startPoint: PointF, endPoint: PointF, withVelocity: Boolean, duration: Long) {
|
||||
private fun performMove(
|
||||
uiController: UiController,
|
||||
startPoint: PointF,
|
||||
endPoint: PointF,
|
||||
withVelocity: Boolean,
|
||||
duration: Long
|
||||
) {
|
||||
val eventMinInterval: Long = 10
|
||||
val startTime = SystemClock.uptimeMillis()
|
||||
var eventTime = startTime
|
||||
@@ -378,9 +432,11 @@ object GesturesUiTestUtils {
|
||||
*/
|
||||
try {
|
||||
// Step 1
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_DOWN, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
|
||||
// Step 2
|
||||
@@ -403,25 +459,31 @@ object GesturesUiTestUtils {
|
||||
|
||||
pointerCoords[0] = pc1
|
||||
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_MOVE, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
}
|
||||
|
||||
if (!withVelocity) {
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_MOVE, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
}
|
||||
|
||||
// Step 3
|
||||
eventTime += eventMinInterval
|
||||
event = MotionEvent.obtain(startTime, eventTime,
|
||||
event = MotionEvent.obtain(
|
||||
startTime, eventTime,
|
||||
MotionEvent.ACTION_UP, 1, properties,
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
pointerCoords, 0, 0, 1f, 1f, 0, 0, 0, 0
|
||||
)
|
||||
injectMotionEventToUiController(uiController, event)
|
||||
} catch (ex: InjectEventSecurityException) {
|
||||
throw RuntimeException("Could not perform quick scale", ex)
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.support.test.espresso.UiController
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.PixelTestActivity
|
||||
import org.junit.Assert.*
|
||||
|
||||
@@ -6,12 +6,12 @@ import com.mapbox.geojson.Point
|
||||
import com.mapbox.mapboxsdk.log.Logger
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
|
||||
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
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Integration test that validates downloading an offline region from a point geometry at zoomlevel 17
|
||||
|
||||
@@ -6,15 +6,15 @@ 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 java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
import junit.framework.Assert.assertNotNull
|
||||
import org.junit.Assert
|
||||
import org.junit.Ignore
|
||||
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
|
||||
|
||||
@@ -7,14 +7,14 @@ import com.mapbox.mapboxsdk.maps.MapView
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
import junit.framework.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
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
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ImageMissingTest : AppCenter() {
|
||||
|
||||
@@ -11,14 +11,14 @@ import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
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
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class RemoveUnusedImagesTest : AppCenter() {
|
||||
|
||||
@@ -5,11 +5,11 @@ import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.offline.OfflineManager
|
||||
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import org.junit.Assert
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class CacheTest {
|
||||
|
||||
@@ -9,13 +9,13 @@ import com.mapbox.mapboxsdk.offline.OfflineRegion
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
|
||||
import com.mapbox.mapboxsdk.testapp.utils.FileUtils
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.AppCenter
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import junit.framework.Assert
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@@ -13,7 +14,6 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestName
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.CountDownLatch
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
open class FileSourceMapTest : AppCenter() {
|
||||
|
||||
@@ -6,11 +6,11 @@ import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.AppCenter
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.junit.*
|
||||
import org.junit.rules.TestName
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class FileSourceStandaloneTest : AppCenter() {
|
||||
|
||||
@@ -4,9 +4,9 @@ import android.app.Activity
|
||||
import android.support.annotation.WorkerThread
|
||||
import com.mapbox.mapboxsdk.AppCenter
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import junit.framework.Assert
|
||||
import java.io.File
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import junit.framework.Assert
|
||||
|
||||
class FileSourceTestUtils(private val activity: Activity) : AppCenter() {
|
||||
val originalPath = FileSource.getResourcesCachePath(activity)
|
||||
|
||||
@@ -6,11 +6,11 @@ import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
|
||||
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
|
||||
import java.util.*
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* CRUD tests around Image
|
||||
|
||||
Reference in New Issue
Block a user