Add instrumentation tests for query rendered features (#7127)

* [android] - add tests for query rendered features

* move initialising camera to xml
This commit is contained in:
Tobrun
2016-11-28 10:35:47 +01:00
committed by GitHub
parent 507ecef946
commit e94b3d944b
10 changed files with 283 additions and 29 deletions

View File

@@ -49,8 +49,6 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {
@Override
public void onMapReady(final MapboxMap mapboxMap) {
QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap;
selectionBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -71,12 +69,8 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {
debugOutput(features);
}
});
//Little taste of home
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
}
});
}
private void debugOutput(List<Feature> features) {

View File

@@ -51,9 +51,6 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity
@Override
public void onMapReady(final MapboxMap mapboxMap) {
QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap;
//Add a fill layer to display stuff on
selectionBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -84,9 +81,6 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity
.withProperties(fillColor(Color.RED)));
}
});
//Little taste of home
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
}
});

View File

@@ -12,8 +12,6 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
@@ -72,7 +70,6 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi
mapboxMap.addImage("test-icon", BitmapFactory.decodeResource(getResources(), R.drawable.mapbox_marker_icon_default));
mapboxMap.addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
selectionBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -92,15 +89,10 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi
String.format("%s features in box", features.size()),
Toast.LENGTH_SHORT);
toast.show();
}
});
//Little taste of home
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
}
});
}
private String readRawResource(@RawRes int rawResource) throws IOException {

View File

@@ -18,7 +18,6 @@ import android.widget.TextView;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -82,9 +81,6 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
mapboxMap.selectMarker(marker);
}
});
//Little taste of home
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
}
});

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -14,7 +15,10 @@
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar" />
android:layout_below="@id/toolbar"
app:mapbox_cameraTargetLat="52.0907"
app:mapbox_cameraTargetLng="5.1214"
app:mapbox_cameraZoom="16" />
<FrameLayout
android:id="@+id/selection_box"

View File

@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"/>
android:layout_below="@id/toolbar"
app:mapbox_cameraTargetLat="52.0907"
app:mapbox_cameraTargetLng="5.1214"
app:mapbox_cameraZoom="16" />
</RelativeLayout>