summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2017-06-09 12:05:54 +0200
committerGitHub <noreply@github.com>2017-06-09 12:05:54 +0200
commit6ec5e4f8cdb98227db11e5989376c31832ca2048 (patch)
tree666de95e35b73f4c6f851e9c243c29fe74ce4465 /platform
parentfa972fad60e58e5b8f9f9622f508e9732c8c9ffd (diff)
downloadqtlocation-mapboxgl-6ec5e4f8cdb98227db11e5989376c31832ca2048.tar.gz
Cherry picks to release branch (#9230)
* [ios][macos] test remove source in use * [android] test remove source in use * [core] check source usage before remove * [core] ensure layer::accept works with non-void return values on gcc * [android] - remove upgrade runtime exceptions (#9191)
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java18
-rw-r--r--platform/darwin/test/MGLStyleTests.mm16
3 files changed, 36 insertions, 16 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index d00da4c155..9a1f2fc515 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -67,8 +67,6 @@ public class MapView extends FrameLayout {
private MapboxMap mapboxMap;
private MapCallback mapCallback;
- private boolean onStartCalled;
- private boolean onStopCalled;
private MapGestureDetector mapGestureDetector;
private MapKeyListener mapKeyListener;
@@ -233,7 +231,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onStart() {
- onStartCalled = true;
mapboxMap.onStart();
ConnectivityReceiver.instance(getContext()).activate();
}
@@ -243,11 +240,7 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onResume() {
- if (!onStartCalled) {
- // TODO: 26/10/16, can be removed after 5.0.0 release
- throw new IllegalStateException("MapView#onStart() was not called. "
- + "You must call this method from the parent's {@link Activity#onStart()} or {@link Fragment#onStart()}.");
- }
+ // replaced by onStart in v5.0.0
}
/**
@@ -255,7 +248,7 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onPause() {
- // replaced by onStop in v5.0.0, keep around for future development
+ // replaced by onStop in v5.0.0
}
/**
@@ -263,7 +256,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onStop() {
- onStopCalled = true;
mapboxMap.onStop();
ConnectivityReceiver.instance(getContext()).deactivate();
}
@@ -273,12 +265,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onDestroy() {
- if (!onStopCalled) {
- // TODO: 26/10/16, can be removed after 5.0.0 release
- throw new IllegalStateException("MapView#onStop() was not called. "
- + "You must call this method from the parent's {@link Activity#onStop()} or {@link Fragment#onStop()}.");
- }
-
destroyed = true;
nativeMapView.terminateContext();
nativeMapView.terminateDisplay();
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
index a1c46903bf..a37615aadc 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
@@ -12,6 +12,7 @@ import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
+import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
@@ -223,6 +224,23 @@ public class RuntimeStyleTests extends BaseActivityTest {
assertEquals("http://mapbox.com/my-file.json", source.getUrl());
}
+ @Test
+ public void testRemoveSourceInUse() {
+ validateTestSetup();
+
+ onView(withId(R.id.mapView)).perform(new BaseViewAction() {
+
+ @Override
+ public void perform(UiController uiController, View view) {
+ mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
+ mapboxMap.addLayer(new LineLayer("my-layer", "my-source"));
+ mapboxMap.removeSource("my-source");
+ assertNotNull(mapboxMap.getSource("my-source"));
+ }
+
+ });
+ }
+
/**
* https://github.com/mapbox/mapbox-gl-native/issues/7973
*/
diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm
index f80d5776f0..d93483ea6e 100644
--- a/platform/darwin/test/MGLStyleTests.mm
+++ b/platform/darwin/test/MGLStyleTests.mm
@@ -240,6 +240,22 @@
XCTAssertTrue([[self.style sourceWithIdentifier:shapeSource.identifier] isMemberOfClass:[MGLVectorSource class]]);
}
+- (void)testRemovingSourceInUse {
+ // Add a raster source
+ MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"some-identifier" tileURLTemplates:@[] options:nil];
+ [self.style addSource:rasterSource];
+
+ // Add a layer using it
+ MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fillLayer" source:rasterSource];
+ [self.style addLayer:fillLayer];
+
+ // Attempt to remove the raster source
+ [self.style removeSource:rasterSource];
+
+ // Ensure it is still there
+ XCTAssertTrue([[self.style sourceWithIdentifier:rasterSource.identifier] isMemberOfClass:[MGLRasterSource class]]);
+}
+
- (void)testLayers {
NSArray<MGLStyleLayer *> *initialLayers = self.style.layers;
if ([initialLayers.firstObject.identifier isEqualToString:@"com.mapbox.annotations.points"]) {