Search in sources :

Example 6 with Expression

use of com.mapbox.mapboxsdk.style.expressions.Expression in project mapbox-plugins-android by mapbox.

the class CircleManagerTest method testInitializationOnStyleReload.

@Test
public void testInitializationOnStyleReload() {
    circleManager = new CircleManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
    verify(style).addSource(geoJsonSource);
    verify(style).addLayer(circleLayer);
    assertTrue(circleManager.dataDrivenPropertyUsageMap.size() > 0);
    for (Boolean value : circleManager.dataDrivenPropertyUsageMap.values()) {
        assertFalse(value);
    }
    verify(circleLayer).setProperties(circleManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
    verify(draggableAnnotationController).onSourceUpdated();
    verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
    Expression filter = Expression.literal(false);
    circleManager.setFilter(filter);
    ArgumentCaptor<MapView.OnDidFinishLoadingStyleListener> loadingArgumentCaptor = ArgumentCaptor.forClass(MapView.OnDidFinishLoadingStyleListener.class);
    verify(mapView).addOnDidFinishLoadingStyleListener(loadingArgumentCaptor.capture());
    loadingArgumentCaptor.getValue().onDidFinishLoadingStyle();
    ArgumentCaptor<Style.OnStyleLoaded> styleLoadedArgumentCaptor = ArgumentCaptor.forClass(Style.OnStyleLoaded.class);
    verify(mapboxMap).getStyle(styleLoadedArgumentCaptor.capture());
    Style newStyle = mock(Style.class);
    when(newStyle.isFullyLoaded()).thenReturn(true);
    GeoJsonSource newSource = mock(GeoJsonSource.class);
    when(coreElementProvider.getSource(null)).thenReturn(newSource);
    CircleLayer newLayer = mock(CircleLayer.class);
    when(coreElementProvider.getLayer()).thenReturn(newLayer);
    styleLoadedArgumentCaptor.getValue().onStyleLoaded(newStyle);
    verify(newStyle).addSource(newSource);
    verify(newStyle).addLayer(newLayer);
    assertTrue(circleManager.dataDrivenPropertyUsageMap.size() > 0);
    for (Boolean value : circleManager.dataDrivenPropertyUsageMap.values()) {
        assertFalse(value);
    }
    verify(newLayer).setProperties(circleManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
    verify(circleLayer).setFilter(filter);
    verify(draggableAnnotationController, times(2)).onSourceUpdated();
    verify(newSource).setGeoJson(any(FeatureCollection.class));
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) Expression(com.mapbox.mapboxsdk.style.expressions.Expression) MapView(com.mapbox.mapboxsdk.maps.MapView) Style(com.mapbox.mapboxsdk.maps.Style) Test(org.junit.Test)

Example 7 with Expression

use of com.mapbox.mapboxsdk.style.expressions.Expression in project mapbox-plugins-android by mapbox.

the class FillManagerTest method testFillLayerFilter.

@Test
public void testFillLayerFilter() {
    fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
    Expression expression = Expression.eq(Expression.get("test"), "selected");
    verify(fillLayer, times(0)).setFilter(expression);
    fillManager.setFilter(expression);
    verify(fillLayer, times(1)).setFilter(expression);
    when(fillLayer.getFilter()).thenReturn(expression);
    assertEquals(expression, fillManager.getFilter());
    assertEquals(expression, fillManager.layerFilter);
}
Also used : Expression(com.mapbox.mapboxsdk.style.expressions.Expression) Test(org.junit.Test)

Example 8 with Expression

use of com.mapbox.mapboxsdk.style.expressions.Expression in project mapbox-plugins-android by mapbox.

the class FillManagerTest method testInitializationOnStyleReload.

@Test
public void testInitializationOnStyleReload() {
    fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
    verify(style).addSource(geoJsonSource);
    verify(style).addLayer(fillLayer);
    assertTrue(fillManager.dataDrivenPropertyUsageMap.size() > 0);
    for (Boolean value : fillManager.dataDrivenPropertyUsageMap.values()) {
        assertFalse(value);
    }
    verify(fillLayer).setProperties(fillManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
    verify(draggableAnnotationController).onSourceUpdated();
    verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
    Expression filter = Expression.literal(false);
    fillManager.setFilter(filter);
    ArgumentCaptor<MapView.OnDidFinishLoadingStyleListener> loadingArgumentCaptor = ArgumentCaptor.forClass(MapView.OnDidFinishLoadingStyleListener.class);
    verify(mapView).addOnDidFinishLoadingStyleListener(loadingArgumentCaptor.capture());
    loadingArgumentCaptor.getValue().onDidFinishLoadingStyle();
    ArgumentCaptor<Style.OnStyleLoaded> styleLoadedArgumentCaptor = ArgumentCaptor.forClass(Style.OnStyleLoaded.class);
    verify(mapboxMap).getStyle(styleLoadedArgumentCaptor.capture());
    Style newStyle = mock(Style.class);
    when(newStyle.isFullyLoaded()).thenReturn(true);
    GeoJsonSource newSource = mock(GeoJsonSource.class);
    when(coreElementProvider.getSource(null)).thenReturn(newSource);
    FillLayer newLayer = mock(FillLayer.class);
    when(coreElementProvider.getLayer()).thenReturn(newLayer);
    styleLoadedArgumentCaptor.getValue().onStyleLoaded(newStyle);
    verify(newStyle).addSource(newSource);
    verify(newStyle).addLayer(newLayer);
    assertTrue(fillManager.dataDrivenPropertyUsageMap.size() > 0);
    for (Boolean value : fillManager.dataDrivenPropertyUsageMap.values()) {
        assertFalse(value);
    }
    verify(newLayer).setProperties(fillManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
    verify(fillLayer).setFilter(filter);
    verify(draggableAnnotationController, times(2)).onSourceUpdated();
    verify(newSource).setGeoJson(any(FeatureCollection.class));
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) Expression(com.mapbox.mapboxsdk.style.expressions.Expression) MapView(com.mapbox.mapboxsdk.maps.MapView) Style(com.mapbox.mapboxsdk.maps.Style) Test(org.junit.Test)

Example 9 with Expression

use of com.mapbox.mapboxsdk.style.expressions.Expression in project mapbox-plugins-android by mapbox.

the class SymbolManagerTest method testSymbolLayerFilter.

@Test
public void testSymbolLayerFilter() {
    symbolManager = new SymbolManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
    Expression expression = Expression.eq(Expression.get("test"), "selected");
    verify(symbolLayer, times(0)).setFilter(expression);
    symbolManager.setFilter(expression);
    verify(symbolLayer, times(1)).setFilter(expression);
    when(symbolLayer.getFilter()).thenReturn(expression);
    assertEquals(expression, symbolManager.getFilter());
    assertEquals(expression, symbolManager.layerFilter);
}
Also used : Expression(com.mapbox.mapboxsdk.style.expressions.Expression) Test(org.junit.Test)

Example 10 with Expression

use of com.mapbox.mapboxsdk.style.expressions.Expression in project mapbox-plugins-android by mapbox.

the class SymbolManagerTest method testInitializationOnStyleReload.

@Test
public void testInitializationOnStyleReload() {
    symbolManager = new SymbolManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
    verify(style).addSource(geoJsonSource);
    verify(style).addLayer(symbolLayer);
    assertTrue(symbolManager.dataDrivenPropertyUsageMap.size() > 0);
    for (Boolean value : symbolManager.dataDrivenPropertyUsageMap.values()) {
        assertFalse(value);
    }
    verify(symbolLayer).setProperties(symbolManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
    verify(draggableAnnotationController).onSourceUpdated();
    verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
    Expression filter = Expression.literal(false);
    symbolManager.setFilter(filter);
    ArgumentCaptor<MapView.OnDidFinishLoadingStyleListener> loadingArgumentCaptor = ArgumentCaptor.forClass(MapView.OnDidFinishLoadingStyleListener.class);
    verify(mapView).addOnDidFinishLoadingStyleListener(loadingArgumentCaptor.capture());
    loadingArgumentCaptor.getValue().onDidFinishLoadingStyle();
    ArgumentCaptor<Style.OnStyleLoaded> styleLoadedArgumentCaptor = ArgumentCaptor.forClass(Style.OnStyleLoaded.class);
    verify(mapboxMap).getStyle(styleLoadedArgumentCaptor.capture());
    Style newStyle = mock(Style.class);
    when(newStyle.isFullyLoaded()).thenReturn(true);
    GeoJsonSource newSource = mock(GeoJsonSource.class);
    when(coreElementProvider.getSource(null)).thenReturn(newSource);
    SymbolLayer newLayer = mock(SymbolLayer.class);
    when(coreElementProvider.getLayer()).thenReturn(newLayer);
    styleLoadedArgumentCaptor.getValue().onStyleLoaded(newStyle);
    verify(newStyle).addSource(newSource);
    verify(newStyle).addLayer(newLayer);
    assertTrue(symbolManager.dataDrivenPropertyUsageMap.size() > 0);
    for (Boolean value : symbolManager.dataDrivenPropertyUsageMap.values()) {
        assertFalse(value);
    }
    verify(newLayer).setProperties(symbolManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
    verify(symbolLayer).setFilter(filter);
    verify(draggableAnnotationController, times(2)).onSourceUpdated();
    verify(newSource).setGeoJson(any(FeatureCollection.class));
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) Expression(com.mapbox.mapboxsdk.style.expressions.Expression) MapView(com.mapbox.mapboxsdk.maps.MapView) Style(com.mapbox.mapboxsdk.maps.Style) Test(org.junit.Test)

Aggregations

Expression (com.mapbox.mapboxsdk.style.expressions.Expression)11 Test (org.junit.Test)8 MapView (com.mapbox.mapboxsdk.maps.MapView)4 Style (com.mapbox.mapboxsdk.maps.Style)4 GeoJsonSource (com.mapbox.mapboxsdk.style.sources.GeoJsonSource)4 PointF (android.graphics.PointF)1 Point (com.mapbox.geojson.Point)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 Symbol (com.mapbox.mapboxsdk.plugins.annotation.Symbol)1