[android] - rework test to use query activity, fix attempt to render without surface crash

This commit is contained in:
tobrun
2019-04-11 14:50:36 +02:00
committed by Tobrun
parent 6c2948d3e6
commit 58696a0704
7 changed files with 62 additions and 20 deletions

View File

@@ -0,0 +1,30 @@
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.feature.QueryRenderedFeaturesBoxCountActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
/**
* Regression test that validates reopening an Activity and querying the map before surface recreation #14394
*/
@RunWith(AndroidJUnit4::class)
class QueryRenderedFeaturesBoxCountTest : BaseIntegrationTest() {
@get:Rule
var activityRule: ActivityTestRule<QueryRenderedFeaturesBoxCountActivity> =
ActivityTestRule(QueryRenderedFeaturesBoxCountActivity::class.java)
@Test
@LargeTest
fun reopenQueryRendererFeaturesActivity() {
device.waitForIdle()
device.pressHome()
device.waitForIdle()
device.launchActivity(activityRule.activity, QueryRenderedFeaturesBoxCountActivity::class.java)
device.waitForIdle()
}
}

View File

@@ -608,7 +608,8 @@
<activity
android:name=".activity.feature.QueryRenderedFeaturesBoxCountActivity"
android:description="@string/description_query_rendered_features_box_count"
android:label="@string/activity_query_rendered_features_box_count">
android:label="@string/activity_query_rendered_features_box_count"
android:launchMode="singleInstance">
<meta-data
android:name="@string/category"
android:value="@string/category_features" />

View File

@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.feature;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
@@ -89,6 +90,11 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {
protected void onStart() {
super.onStart();
mapView.onStart();
if (mapboxMap != null) {
// Regression test for #14394
mapboxMap.queryRenderedFeatures(new PointF(0,0));
}
}
@Override

View File

@@ -1,10 +1,8 @@
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
import android.graphics.PointF;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
@@ -14,7 +12,6 @@ import com.mapbox.mapboxsdk.testapp.R;
public class SimpleMapActivity extends AppCompatActivity {
private MapView mapView;
private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -22,22 +19,15 @@ public class SimpleMapActivity extends AppCompatActivity {
setContentView(R.layout.activity_map_simple);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(
new Style.Builder().fromUrl(Style.MAPBOX_STREETS)
);
});
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(
new Style.Builder().fromUrl(Style.MAPBOX_STREETS)
));
}
@Override
protected void onStart() {
super.onStart();
mapView.onStart();
if (mapboxMap != null) {
// Regression test for #14394
mapboxMap.queryRenderedFeatures(new PointF(0,0));
}
}
@Override