diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils')
3 files changed, 0 insertions, 157 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt deleted file mode 100644 index 3cb9e51bf7..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.mapbox.mapboxsdk.location.utils - -import android.content.Context -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.location.LocationComponent -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Style -import org.hamcrest.Matcher - -class LocationComponentAction( - private val mapboxMap: MapboxMap, - private val onPerformLocationComponentAction: OnPerformLocationComponentAction -) : ViewAction { - - override fun getConstraints(): Matcher<View> { - return isDisplayed() - } - - override fun getDescription(): String { - return javaClass.simpleName - } - - override fun perform(uiController: UiController, view: View) { - onPerformLocationComponentAction.onLocationComponentAction( - mapboxMap.locationComponent, - mapboxMap, - mapboxMap.style!!, - uiController, - view.context) - } - - interface OnPerformLocationComponentAction { - fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, style: Style, uiController: UiController, context: Context) - } -}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt deleted file mode 100644 index 18da6d1d10..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.mapbox.mapboxsdk.location.utils - -import android.graphics.Bitmap -import android.graphics.Canvas -import android.graphics.drawable.BitmapDrawable -import android.graphics.drawable.Drawable -import android.location.Location -import android.os.Handler -import android.os.Looper -import com.mapbox.geojson.Feature -import com.mapbox.mapboxsdk.geometry.LatLng -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.style.layers.Property -import com.mapbox.mapboxsdk.style.sources.GeoJsonSource - -fun MapboxMap.querySourceFeatures(sourceId: String): List<Feature> { - return this.style!!.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList() -} - -fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<Feature> { - val latLng = LatLng(location.latitude, location.longitude) - val point = this.projection.toScreenLocation(latLng) - return this.queryRenderedFeatures(point, layerId) -} - -fun MapboxMap.isLayerVisible(layerId: String): Boolean { - return this.style!!.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!! -} - -class MapboxTestingUtils { - companion object { - - /** - * Used to increase style load time for stress testing. - */ - const val MAPBOX_HEAVY_STYLE = "asset://heavy_style.json" - - private const val DATA_PUSH_INTERVAL = 1L - - /** - * Pushes data updates every [DATA_PUSH_INTERVAL] milliseconds until the style has been loaded, - * checked with [StyleChangeIdlingResource]. - */ - fun pushSourceUpdates(styleChangeIdlingResource: StyleChangeIdlingResource, update: () -> Unit) { - val mainHandler = Handler(Looper.getMainLooper()) - val runnable = object : Runnable { - override fun run() { - update.invoke() - if (!styleChangeIdlingResource.isIdleNow) { - mainHandler.postDelayed(this, DATA_PUSH_INTERVAL) - } - } - } - - if (!styleChangeIdlingResource.isIdleNow) { - if (Looper.myLooper() == Looper.getMainLooper()) { - runnable.run() - } else { - mainHandler.post(runnable) - } - } - } - } -} - -fun MapboxMap.addImageFromDrawable(string: String, drawable: Drawable) { - val bitmapFromDrawable = getBitmapFromDrawable(drawable) - this.style!!.addImage(string, bitmapFromDrawable) -} - -private fun getBitmapFromDrawable(drawable: Drawable): Bitmap { - if (drawable is BitmapDrawable) return drawable.bitmap - val bitmap = Bitmap.createBitmap(drawable.intrinsicWidth, - drawable.intrinsicHeight, Bitmap.Config.ARGB_8888) - val canvas = Canvas(bitmap) - drawable.setBounds(0, 0, canvas.width, canvas.height) - drawable.draw(canvas) - return bitmap -}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt deleted file mode 100644 index 050535f6df..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.mapbox.mapboxsdk.location.utils - -import android.support.test.espresso.IdlingResource -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Style - -/** - * Resource, that's idling until the provided style is loaded. - * Remember to add any espresso action (like view assertion) after the [waitForStyle] call - * for the test to keep running. - */ -class StyleChangeIdlingResource : IdlingResource { - - private var callback: IdlingResource.ResourceCallback? = null - private var isIdle = true - - override fun getName(): String { - return javaClass.simpleName - } - - override fun isIdleNow(): Boolean { - return isIdle - } - - override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) { - this.callback = callback - } - - private fun setIdle() { - isIdle = true - callback?.onTransitionToIdle() - } - - fun waitForStyle(mapboxMap: MapboxMap, styleUrl: String) { - isIdle = false - mapboxMap.setStyle(Style.Builder().fromUrl(styleUrl)) { - setIdle() - } - } -}
\ No newline at end of file |