[android] - add ktlint, optimise code for ktlint validation
This commit is contained in:
15
Makefile
15
Makefile
@@ -791,21 +791,26 @@ android-gfxinfo:
|
||||
test-code-android:
|
||||
node platform/android/scripts/generate-test-code.js
|
||||
|
||||
# Runs checkstyle and lint on the Android code
|
||||
# Runs checkstyle and lint on the java code
|
||||
.PHONY: android-check
|
||||
android-check : android-checkstyle run-android-nitpick android-lint-sdk android-lint-test-app
|
||||
android-check : android-checkstyle run-android-nitpick android-lint-sdk android-lint-test-app android-ktlint
|
||||
|
||||
# Runs checkstyle on the Android code
|
||||
# Runs checkstyle on the java code
|
||||
.PHONY: android-checkstyle
|
||||
android-checkstyle: platform/android/gradle/configuration.gradle
|
||||
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDK:checkstyle :MapboxGLAndroidSDKTestApp:checkstyle
|
||||
|
||||
# Runs lint on the Android SDK code
|
||||
# Runs checkstyle on the kotlin code
|
||||
.PHONY: android-ktlint
|
||||
android-ktlint:
|
||||
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none ktlint
|
||||
|
||||
# Runs lint on the Android SDK java code
|
||||
.PHONY: android-lint-sdk
|
||||
android-lint-sdk: platform/android/gradle/configuration.gradle
|
||||
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDK:lint
|
||||
|
||||
# Runs lint on the Android test app code
|
||||
# Runs lint on the Android test app java code
|
||||
.PHONY: android-lint-test-app
|
||||
android-lint-test-app: platform/android/gradle/configuration.gradle
|
||||
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none :MapboxGLAndroidSDKTestApp:lint
|
||||
|
||||
2
platform/android/.editorconfig
Normal file
2
platform/android/.editorconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
[*.{kt,kts}]
|
||||
indent_size=2
|
||||
@@ -529,4 +529,4 @@ private fun <E> SparseArray<E>.contains(listener: AnimationsValueChangeListener<
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class LoggerTest {
|
||||
fun verbosityLogLevelIgnore() {
|
||||
Logger.setVerbosity(Logger.DEBUG)
|
||||
Logger.v(TAG, MESSAGE)
|
||||
verify(exactly = 0){ logger.v(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.v(TAG, MESSAGE) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -42,7 +42,7 @@ class LoggerTest {
|
||||
fun debugLogLevelIgnore() {
|
||||
Logger.setVerbosity(Logger.WARN)
|
||||
Logger.d(TAG, MESSAGE)
|
||||
verify(exactly = 0){ logger.d(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.d(TAG, MESSAGE) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,7 +56,7 @@ class LoggerTest {
|
||||
fun warnLogLevelIgnore() {
|
||||
Logger.setVerbosity(Logger.ERROR)
|
||||
Logger.w(TAG, MESSAGE)
|
||||
verify(exactly = 0){ logger.w(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.w(TAG, MESSAGE) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,7 +70,7 @@ class LoggerTest {
|
||||
fun errorLogLevelIgnore() {
|
||||
Logger.setVerbosity(Logger.NONE)
|
||||
Logger.e(TAG, MESSAGE)
|
||||
verify(exactly = 0){ logger.e(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.e(TAG, MESSAGE) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,10 +80,10 @@ class LoggerTest {
|
||||
Logger.d(TAG, MESSAGE)
|
||||
Logger.w(TAG, MESSAGE)
|
||||
Logger.e(TAG, MESSAGE)
|
||||
verify(exactly = 0){ logger.v(TAG, MESSAGE) }
|
||||
verify(exactly = 0){ logger.d(TAG, MESSAGE) }
|
||||
verify(exactly = 0){ logger.w(TAG, MESSAGE) }
|
||||
verify(exactly = 0){ logger.e(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.v(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.d(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.w(TAG, MESSAGE) }
|
||||
verify(exactly = 0) { logger.e(TAG, MESSAGE) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -287,7 +287,7 @@ class StyleTest {
|
||||
|
||||
@Test
|
||||
fun testAddImage() {
|
||||
val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
|
||||
val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
|
||||
val builder = Style.Builder().fromUrl(Style.SATELLITE).withImage("id", bitmap)
|
||||
mapboxMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.SATELLITE }
|
||||
@@ -408,4 +408,4 @@ class StyleTest {
|
||||
Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,9 @@ class KeepDetector : Detector(), SourceCodeScanner, FileScanner {
|
||||
context.report(ISSUE_NOT_KEPT, node,
|
||||
context.getNameLocation(node),
|
||||
"This method contains native references and will be minified.")
|
||||
} else if (node.isConstructor
|
||||
&& node.parameterList.parameters.find { it.type == PsiType.LONG && it.name!!.contains("native") } != null
|
||||
&& checkKeepAnnotation(node)) {
|
||||
} else if (node.isConstructor &&
|
||||
node.parameterList.parameters.find { it.type == PsiType.LONG && it.name!!.contains("native") } != null &&
|
||||
checkKeepAnnotation(node)) {
|
||||
context.report(ISSUE_NOT_KEPT, node,
|
||||
context.getNameLocation(node as UElement),
|
||||
"This constructor might contain native references and will be minified. " +
|
||||
|
||||
@@ -8,7 +8,6 @@ abstract class AppCenter {
|
||||
@get:Rule
|
||||
var reportHelper = Factory.getReportHelper()!!
|
||||
|
||||
|
||||
@After
|
||||
open fun afterTest() {
|
||||
reportHelper.label(javaClass.simpleName)
|
||||
|
||||
@@ -8,4 +8,4 @@ class InstrumentationRunner : AndroidJUnitRunner() {
|
||||
override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application {
|
||||
return super.newApplication(cl, InstrumentationApplication::class.java.name, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,5 +140,4 @@ class CameraUpdateFactoryTest : BaseTest() {
|
||||
assertEquals("tilt should match:", 40.0, cameraPosition.tilt, 0.1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import org.junit.Before
|
||||
|
||||
const val TIMEOUT_UI_SEARCH_WAIT = 5000L
|
||||
|
||||
abstract class BaseIntegrationTest : AppCenter(){
|
||||
abstract class BaseIntegrationTest : AppCenter() {
|
||||
|
||||
protected lateinit var device: UiDevice
|
||||
|
||||
|
||||
@@ -3,15 +3,8 @@ package com.mapbox.mapboxsdk.integration
|
||||
import android.support.test.filters.LargeTest
|
||||
import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import android.support.test.uiautomator.By
|
||||
import android.support.test.uiautomator.SearchCondition
|
||||
import android.support.test.uiautomator.UiSelector
|
||||
import android.support.test.uiautomator.Until
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.activity.fragment.FragmentBackStackActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
|
||||
import kotlinx.android.synthetic.main.activity_backstack_fragment.view.*
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
|
||||
/**
|
||||
* Regression test that validates reopening an Activity with a GLSurfaceView
|
||||
*/
|
||||
@@ -27,4 +26,4 @@ class GLSurfaceViewReopenTest : BaseIntegrationTest() {
|
||||
device.launchActivity(activityRule.activity, SimpleMapActivity::class.java)
|
||||
device.waitForIdle()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import android.support.test.filters.LargeTest
|
||||
import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.integration
|
||||
import android.support.test.filters.LargeTest
|
||||
import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -27,4 +27,4 @@ class QueryRenderedFeaturesBoxCountTest : BaseIntegrationTest() {
|
||||
device.launchActivity(activityRule.activity, QueryRenderedFeaturesBoxCountActivity::class.java)
|
||||
device.waitForIdle()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,10 @@ package com.mapbox.mapboxsdk.integration
|
||||
import android.support.test.filters.LargeTest
|
||||
import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.textureview.TextureViewDebugModeActivity
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.lang.Thread.sleep
|
||||
|
||||
/**
|
||||
* Regression test that validates reopening an Activity with a TextureView
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.integration
|
||||
import android.support.test.filters.LargeTest
|
||||
import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.TextureRecyclerViewActivity
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -5,8 +5,6 @@ import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import android.support.test.uiautomator.UiSelector
|
||||
import com.mapbox.mapboxsdk.testapp.activity.fragment.ViewPagerActivity
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -54,7 +54,6 @@ class LocationComponentTest : EspressoTest() {
|
||||
|
||||
private lateinit var locationComponentActivationOptions: LocationComponentActivationOptions
|
||||
|
||||
|
||||
override fun validateTestSetup() {
|
||||
super.validateTestSetup()
|
||||
assertThat(mapboxMap.style, notNullValue())
|
||||
@@ -71,8 +70,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvided() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
@@ -93,9 +97,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.locationComponentOptions(
|
||||
@@ -131,9 +139,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponent_doesntInitializeEngineWhenNullProvided() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.locationEngine(null)
|
||||
@@ -170,8 +182,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun settingMapStyleImmediatelyBeforeLoadingComponent_throwsInvalidStyle() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
|
||||
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
@@ -188,9 +205,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponent_doesntShowUntilFirstLocationFix() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -222,10 +243,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponentOptions_disablingStaleStateDoesWorkCorrectly() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -258,9 +282,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponentOptions_loadsForegroundBitmapFromNameOption() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -306,9 +334,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -343,9 +375,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponentOptions_customIconNameRevertsToDefault() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -379,9 +415,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun locationComponentOptions_customGpsIconNameChangeBackWithMode() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -414,9 +454,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun stillStaleAfterResuming() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -451,9 +495,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun stillNotStaleAfterResuming() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -483,9 +531,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
val rgbaColor = ColorUtils.colorToRgbaString(color)
|
||||
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
locationComponentActivationOptions = LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -516,9 +568,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -541,9 +597,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun disablingComponentHidesPuck() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -568,9 +628,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun disablingComponentAndChangingStyleAllowsToEnableAgain() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -592,9 +656,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_isDisabledOnStart() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.onStop()
|
||||
component.onStart()
|
||||
|
||||
@@ -619,9 +687,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_keepsEnabledWhenStoppedAndStarted() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -641,8 +713,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_keepsDisabledWhenStoppedAndStarted() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
@@ -663,8 +740,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_ableToChangeStyleAfterResuming() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -685,8 +767,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_interruptedDuringStyleChange() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -705,8 +792,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_forceLocationUpdateAfterStopped() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -726,8 +818,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -750,8 +847,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun lifecycle_lifecycleChangeRightAfterStyleReload() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -781,8 +883,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun mapChange_settingComponentStyle() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -810,8 +917,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun mapChange_forcingLocation() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -836,8 +948,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun mapChange_settingMapStyleBeforeComponentCreation() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
|
||||
@@ -868,8 +985,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
fun animators_layerBearingCorrect() {
|
||||
validateTestSetup()
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -896,8 +1018,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_cameraLatLngBearingCorrect() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -932,8 +1059,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_cameraBearingCorrect() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -971,8 +1103,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_cameraNoneCorrect() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1011,8 +1148,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_focalPointAdjustment() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1033,8 +1175,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_dontZoomWhileNotTracking() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1056,8 +1203,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_zoomWhileTracking() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1079,8 +1231,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Ignore
|
||||
fun animators_zoomWhileTrackingCanceledOnModeChange() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1103,8 +1260,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_dontZoomWhileStopped() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1130,8 +1292,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Ignore
|
||||
fun animators_cancelZoomWhileTracking() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1154,8 +1321,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_dontTiltWhileNotTracking() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1177,8 +1349,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_tiltWhileTracking() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1200,8 +1377,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Ignore
|
||||
fun animators_tiltWhileTrackingCanceledOnModeChange() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1224,8 +1406,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun animators_dontTiltWhileStopped() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1250,8 +1437,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Ignore
|
||||
fun animators_cancelTiltWhileTracking() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1273,8 +1465,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun cameraPositionAdjustedToTrackingModeWhenComponentEnabled() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1301,8 +1498,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun cameraPositionSnappedToTargetIfExceedsThreshold() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1330,8 +1532,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun compassEngine_onComponentInitializedDefaultIsProvided() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -1347,8 +1554,13 @@ class LocationComponentTest : EspressoTest() {
|
||||
@Test
|
||||
fun compassEngine_changesWhenNewProvided() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
|
||||
@@ -35,6 +35,7 @@ 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() {
|
||||
@@ -67,8 +68,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun renderModeNormal_sourceDoesGetAdded() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -90,8 +96,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun renderModeNormal_trackingNormalLayersDoGetAdded() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -114,8 +125,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun renderModeCompass_bearingLayersDoGetAdded() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -138,8 +154,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun renderModeGps_navigationLayersDoGetAdded() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -162,8 +183,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun dontShowPuckWhenRenderModeSetAndComponentDisabled() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -187,8 +213,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -213,8 +244,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun onMapChange_locationComponentLayersDoGetRedrawn() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -245,8 +281,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun whenStyleChanged_continuesUsingStaleIcons() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -271,8 +312,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun whenStyleChanged_isDisabled_hasLayerBelow_staysHidden() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -300,8 +346,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun whenStyleChanged_staleStateChanges() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -323,8 +374,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun whenStyleChanged_layerVisibilityUpdates() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
uiController.loopMainThreadForAtLeast(100)
|
||||
var show = true
|
||||
@@ -349,8 +405,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun accuracy_visibleWithNewLocation() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -372,8 +433,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun accuracy_visibleWhenCameraEased() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -387,10 +453,9 @@ 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,
|
||||
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*/
|
||||
@@ -405,8 +470,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun accuracy_visibleWhenCameraMoved() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -419,9 +489,10 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom))
|
||||
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,
|
||||
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))
|
||||
|
||||
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
|
||||
@@ -436,8 +507,13 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
@Test
|
||||
fun applyStyle_layerBelow_restoreLayerVisibility() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
style: Style, uiController: UiController, context: Context) {
|
||||
override fun onLocationComponentAction(
|
||||
component: LocationComponent,
|
||||
mapboxMap: MapboxMap,
|
||||
style: Style,
|
||||
uiController: UiController,
|
||||
context: Context
|
||||
) {
|
||||
component.activateLocationComponent(LocationComponentActivationOptions
|
||||
.builder(context, style)
|
||||
.useDefaultLocationEngine(false)
|
||||
@@ -467,4 +543,4 @@ class LocationLayerControllerTest : EspressoTest() {
|
||||
private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) {
|
||||
onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,10 @@ import com.mapbox.mapboxsdk.location.LocationComponent
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import org.hamcrest.Matcher
|
||||
|
||||
class LocationComponentAction(private val mapboxMap: MapboxMap,
|
||||
private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction {
|
||||
class LocationComponentAction(
|
||||
private val mapboxMap: MapboxMap,
|
||||
private val onPerformLocationComponentAction: OnPerformLocationComponentAction
|
||||
) : ViewAction {
|
||||
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return isDisplayed()
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
|
||||
import android.location.Location
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.support.test.espresso.UiController
|
||||
import com.mapbox.geojson.Feature
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.location.utils
|
||||
import android.support.test.espresso.IdlingResource
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import java.util.logging.Handler
|
||||
|
||||
/**
|
||||
* Resource, that's idling until the provided style is loaded.
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.style.layers.Layer
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
abstract class BaseLayerTest : AppCenter(){
|
||||
abstract class BaseLayerTest : AppCenter() {
|
||||
private lateinit var nativeMapView: NativeMap
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -95,7 +95,6 @@ class NativeMapViewTest : AppCenter() {
|
||||
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
fun testBearingDefault() {
|
||||
@@ -160,7 +159,7 @@ class NativeMapViewTest : AppCenter() {
|
||||
@UiThreadTest
|
||||
fun testLatLngForPixel() {
|
||||
val expected = LATLNG_TEST
|
||||
nativeMapView.setLatLng(LATLNG_TEST,0)
|
||||
nativeMapView.setLatLng(LATLNG_TEST, 0)
|
||||
val actual = nativeMapView.latLngForPixel(
|
||||
PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
|
||||
)
|
||||
@@ -367,11 +366,11 @@ class NativeMapViewTest : AppCenter() {
|
||||
class DummyRenderer(context: Context) : MapRenderer(context, null) {
|
||||
|
||||
override fun requestRender() {
|
||||
//no-op
|
||||
// no-op
|
||||
}
|
||||
|
||||
override fun queueEvent(runnable: Runnable?) {
|
||||
//no-op
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class TransformTest: EspressoTest() {
|
||||
class TransformTest : EspressoTest() {
|
||||
|
||||
companion object {
|
||||
val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0,12.0), 12.0)!!
|
||||
val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0, 12.0), 12.0)!!
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -23,7 +23,7 @@ class TransformTest: EspressoTest() {
|
||||
val expectedCameraPosition = mapboxMap.cameraPosition
|
||||
|
||||
mapboxMap.moveCamera(initialCameraUpdate)
|
||||
mapboxMap.setPadding(250,250,0,0)
|
||||
mapboxMap.setPadding(250, 250, 0, 0)
|
||||
mapboxMap.scrollBy(400.0f, 0.0f)
|
||||
val actualCameraPosition = mapboxMap.cameraPosition
|
||||
|
||||
|
||||
@@ -384,9 +384,8 @@ class VisibleRegionTest : BaseTest() {
|
||||
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
|
||||
)
|
||||
|
||||
|
||||
for (bearing in 45 until 360 step 45) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
|
||||
val visibleRegion = mapboxMap.projection.visibleRegion
|
||||
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
|
||||
}
|
||||
@@ -398,7 +397,7 @@ class VisibleRegionTest : BaseTest() {
|
||||
validateTestSetup()
|
||||
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
|
||||
val d = Math.min(mapboxMap.width, mapboxMap.height) / 4;
|
||||
val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
|
||||
val latLngs = listOf(
|
||||
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
|
||||
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
|
||||
@@ -408,9 +407,8 @@ class VisibleRegionTest : BaseTest() {
|
||||
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
|
||||
)
|
||||
|
||||
|
||||
for (bearing in 45 until 360 step 45) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
|
||||
val visibleRegion = mapboxMap.projection.visibleRegion
|
||||
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.support.test.rule.ActivityTestRule
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.AppCenter
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import com.mapbox.mapboxsdk.testapp.action.WaitAction
|
||||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.MapInDialogActivity
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ImageMissingTest : AppCenter(){
|
||||
class ImageMissingTest : AppCenter() {
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
@@ -152,4 +152,4 @@ class ImageMissingTest : AppCenter(){
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class RemoveUnusedImagesTest : AppCenter() {
|
||||
rule.runOnUiThread {
|
||||
mapView = rule.activity.findViewById(R.id.mapView)
|
||||
mapView.getMapAsync {
|
||||
mapboxMap = it;
|
||||
mapboxMap = it
|
||||
mapboxMap.setStyle(Style.Builder().fromJson(styleJson))
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class RemoveUnusedImagesTest : AppCenter() {
|
||||
var callbackLatch = CountDownLatch(2)
|
||||
rule.runOnUiThread {
|
||||
mapView.addOnStyleImageMissingListener {
|
||||
mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
|
||||
mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
|
||||
}
|
||||
|
||||
// Remove layer and source, so that rendered tiles are no longer used, therefore, map must
|
||||
@@ -69,7 +69,7 @@ class RemoveUnusedImagesTest : AppCenter() {
|
||||
}
|
||||
}
|
||||
|
||||
if(!latch.await(5, TimeUnit.SECONDS) && !callbackLatch.await(5, TimeUnit.SECONDS)){
|
||||
if (!latch.await(5, TimeUnit.SECONDS) && !callbackLatch.await(5, TimeUnit.SECONDS)) {
|
||||
throw TimeoutException()
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class RemoveUnusedImagesTest : AppCenter() {
|
||||
fun testRemoveUnusedImagesDefaultListener() {
|
||||
rule.runOnUiThread {
|
||||
mapView.addOnStyleImageMissingListener {
|
||||
mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
|
||||
mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
|
||||
}
|
||||
|
||||
// Remove layer and source, so that rendered tiles are no longer used, thus
|
||||
@@ -97,7 +97,7 @@ class RemoveUnusedImagesTest : AppCenter() {
|
||||
}
|
||||
}
|
||||
|
||||
if(!latch.await(5, TimeUnit.SECONDS)){
|
||||
if (!latch.await(5, TimeUnit.SECONDS)) {
|
||||
throw TimeoutException()
|
||||
}
|
||||
}
|
||||
@@ -160,4 +160,4 @@ class RemoveUnusedImagesTest : AppCenter() {
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,13 @@ package com.mapbox.mapboxsdk.testapp.maps
|
||||
|
||||
import android.support.test.espresso.UiController
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import com.mapbox.mapboxsdk.maps.MapView
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
|
||||
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
|
||||
@@ -85,5 +85,4 @@ class CacheTest {
|
||||
}
|
||||
countDownLatch.await()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,8 @@ open class FileSourceMapTest : AppCenter() {
|
||||
}
|
||||
|
||||
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)
|
||||
Assert.assertEquals("Cannot set path, file source is activated." +
|
||||
" Make sure that the map or a resources download is not running.", message)
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -32,11 +32,11 @@ class LatLngBoundsActivity : AppCompatActivity() {
|
||||
private lateinit var bounds: LatLngBounds
|
||||
|
||||
private val peekHeight by lazy {
|
||||
375.toPx(this) //375dp
|
||||
375.toPx(this) // 375dp
|
||||
}
|
||||
|
||||
private val additionalPadding by lazy {
|
||||
32.toPx(this) //32dp
|
||||
32.toPx(this) // 32dp
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -160,8 +160,6 @@ class LatLngBoundsActivity : AppCompatActivity() {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun Int.toPx(context: Context): Int = (this * context.resources.displayMetrics.density).toInt()
|
||||
|
||||
fun Int.toPx(context: Context): Int = (this * context.resources.displayMetrics.density).toInt()
|
||||
@@ -63,4 +63,4 @@ class PixelTestActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
super.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import android.widget.TextView
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
@@ -127,7 +126,8 @@ class NestedViewPagerActivity : AppCompatActivity() {
|
||||
options.camera(CameraPosition.Builder().target(LatLng(62.326440, 92.764913)).zoom(3.0).build())
|
||||
val fragment = SupportMapFragment.newInstance(options)
|
||||
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.DARK) }
|
||||
return fragment }
|
||||
return fragment
|
||||
}
|
||||
3 -> {
|
||||
return EmptyFragment.newInstance()
|
||||
}
|
||||
@@ -135,7 +135,8 @@ class NestedViewPagerActivity : AppCompatActivity() {
|
||||
options.camera(CameraPosition.Builder().target(LatLng(-25.007786, 133.623852)).zoom(3.0).build())
|
||||
val fragment = SupportMapFragment.newInstance(options)
|
||||
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.SATELLITE) }
|
||||
return fragment }
|
||||
return fragment
|
||||
}
|
||||
5 -> {
|
||||
return EmptyFragment.newInstance()
|
||||
}
|
||||
@@ -162,4 +163,4 @@ class NestedViewPagerActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG ="Mbgl-SnapshotActivity"
|
||||
const val TAG = "Mbgl-SnapshotActivity"
|
||||
const val LOG_MESSAGE = "OnSnapshot"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class LocationFragmentActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
//noop
|
||||
// noop
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@@ -172,4 +172,4 @@ class LocationFragmentActivity : AppCompatActivity() {
|
||||
return textView
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,4 +151,4 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class OverlayMapActivity : AppCompatActivity() {
|
||||
class OverlayView(context: Context) : View(context) {
|
||||
|
||||
private lateinit var paint: Paint
|
||||
|
||||
|
||||
@SuppressLint("DrawAllocation") // only happens once
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
super.onDraw(canvas)
|
||||
@@ -83,4 +83,4 @@ class OverlayMapActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,4 @@ class TextureRecyclerViewActivity : GLSurfaceRecyclerViewActivity() {
|
||||
override fun getMapItemLayoutId(): Int {
|
||||
return R.layout.item_map_texture
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class ChangeResourcesCachePathActivity : AppCompatActivity(),
|
||||
|
||||
offlineManager.listOfflineRegions(object : OfflineManager.ListOfflineRegionsCallback {
|
||||
override fun onList(offlineRegions: Array<out OfflineRegion>?) {
|
||||
Logger.i(TAG, "Number of saved offline regions in the new path: ${offlineRegions?.size.toString()}")
|
||||
Logger.i(TAG, "Number of saved offline regions in the new path: ${offlineRegions?.size}")
|
||||
}
|
||||
|
||||
override fun onError(error: String?) {
|
||||
|
||||
@@ -145,7 +145,8 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
|
||||
if (status.completedResourceCount > status.requiredResourceCount &&
|
||||
previousCompletedResourceCount <= status.requiredResourceCount) {
|
||||
previousCompletedResourceCount <= status.requiredResourceCount
|
||||
) {
|
||||
logMessage("FAILURE! Completed > required")
|
||||
}
|
||||
}
|
||||
@@ -279,11 +280,9 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@@ -293,17 +292,19 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun validCoordinates(latitudeNorth: Double, longitudeEast: Double, latitudeSouth: Double,
|
||||
longitudeWest: Double): Boolean {
|
||||
private fun validCoordinates(
|
||||
latitudeNorth: Double,
|
||||
longitudeEast: Double,
|
||||
latitudeSouth: Double,
|
||||
longitudeWest: Double
|
||||
): Boolean {
|
||||
if (latitudeNorth < -90 || latitudeNorth > 90) {
|
||||
return false
|
||||
} else if (longitudeEast < -180 || longitudeEast > 180) {
|
||||
@@ -315,4 +316,4 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,4 +144,4 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import android.os.Looper
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import com.mapbox.mapboxsdk.offline.OfflineManager
|
||||
import com.mapbox.mapboxsdk.storage.FileSource
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import junit.framework.Assert.assertTrue
|
||||
import kotlinx.android.synthetic.main.activity_cache_management.*
|
||||
|
||||
@@ -171,11 +171,17 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
* @param touchAreaMaxX maximum value of X-axis motion event
|
||||
* @param touchAreaMaxY maximum value of Y-axis motion event
|
||||
*/
|
||||
class DraggableSymbolsManager(mapView: MapView, private val mapboxMap: MapboxMap,
|
||||
private val symbolsCollection: FeatureCollection,
|
||||
private val symbolsSource: GeoJsonSource, private val symbolsLayerId: String,
|
||||
private val touchAreaShiftX: Int = 0, private val touchAreaShiftY: Int = 0,
|
||||
private val touchAreaMaxX: Int = mapView.width, private val touchAreaMaxY: Int = mapView.height) {
|
||||
class DraggableSymbolsManager(
|
||||
mapView: MapView,
|
||||
private val mapboxMap: MapboxMap,
|
||||
private val symbolsCollection: FeatureCollection,
|
||||
private val symbolsSource: GeoJsonSource,
|
||||
private val symbolsLayerId: String,
|
||||
private val touchAreaShiftY: Int = 0,
|
||||
private val touchAreaShiftX: Int = 0,
|
||||
private val touchAreaMaxX: Int = mapView.width,
|
||||
private val touchAreaMaxY: Int = mapView.height
|
||||
) {
|
||||
|
||||
private val androidGesturesManager: AndroidGesturesManager = AndroidGesturesManager(mapView.context, false)
|
||||
private var draggedSymbolId: String? = null
|
||||
@@ -322,4 +328,4 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
|
||||
private fun MapboxMap.queryRenderedSymbols(latLng: LatLng, layerId: String): List<Feature> {
|
||||
return this.queryRenderedFeatures(this.projection.toScreenLocation(latLng), layerId)
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ class FileUtils {
|
||||
override fun doInBackground(vararg strings: String): Boolean? {
|
||||
val assetName = strings[0]
|
||||
val destinationPath = strings[1]
|
||||
|
||||
contextWeakReference.get()?.let {
|
||||
try {
|
||||
copyAsset(it, assetName, destinationPath)
|
||||
|
||||
@@ -26,6 +26,7 @@ allprojects {
|
||||
// Snapshot repository
|
||||
// maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' }
|
||||
}
|
||||
apply from: "${rootDir}/gradle/ktlint.gradle"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
@@ -34,5 +35,4 @@ subprojects {
|
||||
|
||||
// Load build system information. If this file does not exist, run
|
||||
// `make platform/android/gradle/configuration.gradle`
|
||||
apply from: "${rootDir}/gradle/configuration.gradle"
|
||||
apply from: "${rootDir}/gradle/download-schema.gradle"
|
||||
apply from: "${rootDir}/gradle/configuration.gradle"
|
||||
@@ -33,7 +33,8 @@ ext {
|
||||
gms : '16.0.0',
|
||||
soLoader : '0.6.0',
|
||||
jacoco : '0.8.3',
|
||||
appcenter : '1.4'
|
||||
appcenter : '1.4',
|
||||
ktlint : '0.33.0'
|
||||
]
|
||||
|
||||
dependenciesList = [
|
||||
@@ -82,6 +83,7 @@ ext {
|
||||
lint : "com.android.tools.lint:lint:${versions.lint}",
|
||||
lintApi : "com.android.tools.lint:lint-api:${versions.lint}",
|
||||
lintChecks : "com.android.tools.lint:lint-checks:${versions.lint}",
|
||||
lintTests : "com.android.tools.lint:lint-tests:${versions.lint}"
|
||||
lintTests : "com.android.tools.lint:lint-tests:${versions.lint}",
|
||||
ktlint : "com.pinterest:ktlint:${versions.ktlint}"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
task downloadSchema(type: Copy) {
|
||||
def address='https://mapbox.s3.amazonaws.com/mapbox-gl-native/event-schema/mobile-event-schemas.jsonl.gz'
|
||||
def target='MapboxGLAndroidSDK/src/test/resources/'
|
||||
|
||||
new File(target + "${address.tokenize('/')[-1]}").withOutputStream { out ->
|
||||
new URL(address).withInputStream { from -> out << from }
|
||||
}
|
||||
}
|
||||
27
platform/android/gradle/ktlint.gradle
Normal file
27
platform/android/gradle/ktlint.gradle
Normal file
@@ -0,0 +1,27 @@
|
||||
apply from: "${rootDir}/gradle/dependencies.gradle"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
configurations {
|
||||
ktlint
|
||||
}
|
||||
|
||||
dependencies {
|
||||
ktlint dependenciesList.ktlint
|
||||
}
|
||||
|
||||
task ktlint(type: JavaExec, group: "verification") {
|
||||
description = "Check Kotlin code style."
|
||||
classpath = configurations.ktlint
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
args "src/**/*.kt"
|
||||
}
|
||||
|
||||
task ktlintFormat(type: JavaExec, group: "formatting") {
|
||||
description = "Fix Kotlin code style deviations."
|
||||
classpath = configurations.ktlint
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
args "-F", "src/**/*.kt"
|
||||
}
|
||||
Reference in New Issue
Block a user