Search in sources :

Example 6 with ScaleBarOptions

use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.

the class ScaleBarTest method testMargin.

@Test
public void testMargin() {
    validateTestSetup();
    setupScaleBar();
    invoke(mapboxMap, (uiController, mapboxMap) -> {
        assertEquals(activity.getResources().getDimension(R.dimen.mapbox_scale_bar_margin_left), scaleBarWidget.getMarginLeft(), 0);
        assertEquals(activity.getResources().getDimension(R.dimen.mapbox_scale_bar_margin_top), scaleBarWidget.getMarginTop(), 0);
        assertEquals(activity.getResources().getDimension(R.dimen.mapbox_scale_bar_text_margin), scaleBarWidget.getTextBarMargin(), 0);
        ScaleBarOptions option = new ScaleBarOptions(activity);
        option.setMarginLeft(R.dimen.fab_margin);
        option.setMarginTop(R.dimen.fab_margin);
        option.setTextBarMargin(R.dimen.fab_margin);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(activity.getResources().getDimension(R.dimen.fab_margin), scaleBarWidget.getMarginLeft(), 0);
        assertEquals(activity.getResources().getDimension(R.dimen.fab_margin), scaleBarWidget.getMarginTop(), 0);
        assertEquals(activity.getResources().getDimension(R.dimen.fab_margin), scaleBarWidget.getTextBarMargin(), 0);
        option = new ScaleBarOptions(activity);
        option.setMarginLeft(100f);
        option.setMarginTop(50f);
        option.setTextBarMargin(30f);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(100f, scaleBarWidget.getMarginLeft(), 0);
        assertEquals(50f, scaleBarWidget.getMarginTop(), 0);
        assertEquals(30f, scaleBarWidget.getTextBarMargin(), 0);
    });
}
Also used : ScaleBarOptions(com.mapbox.pluginscalebar.ScaleBarOptions) Test(org.junit.Test) BaseActivityTest(com.mapbox.mapboxsdk.plugins.BaseActivityTest)

Example 7 with ScaleBarOptions

use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.

the class ScaleBarTest method testBarHeight.

@Test
public void testBarHeight() {
    validateTestSetup();
    setupScaleBar();
    invoke(mapboxMap, (uiController, mapboxMap) -> {
        assertEquals(activity.getResources().getDimension(R.dimen.mapbox_scale_bar_height), scaleBarWidget.getBarHeight(), 0);
        ScaleBarOptions option = new ScaleBarOptions(activity);
        option.setBarHeight(R.dimen.fab_margin);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(activity.getResources().getDimension(R.dimen.fab_margin), scaleBarWidget.getBarHeight(), 0);
        option = new ScaleBarOptions(activity);
        option.setBarHeight(100f);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(100f, scaleBarWidget.getBarHeight(), 0);
    });
}
Also used : ScaleBarOptions(com.mapbox.pluginscalebar.ScaleBarOptions) Test(org.junit.Test) BaseActivityTest(com.mapbox.mapboxsdk.plugins.BaseActivityTest)

Example 8 with ScaleBarOptions

use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.

the class ScaleBarTest method setupScaleBar.

private void setupScaleBar() {
    Timber.i("Retrieving layer");
    invoke(mapboxMap, (uiController, mapboxMap) -> {
        scaleBarPlugin = new ScaleBarPlugin(idlingResource.getMapView(), mapboxMap);
        activity = rule.getActivity();
        scaleBarWidget = scaleBarPlugin.create(new ScaleBarOptions(activity));
        assertNotNull(scaleBarPlugin);
        assertNotNull(scaleBarWidget);
    });
}
Also used : ScaleBarOptions(com.mapbox.pluginscalebar.ScaleBarOptions) ScaleBarPlugin(com.mapbox.pluginscalebar.ScaleBarPlugin)

Example 9 with ScaleBarOptions

use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.

the class ScaleBarTest method testTextSize.

@Test
public void testTextSize() {
    validateTestSetup();
    setupScaleBar();
    invoke(mapboxMap, (uiController, mapboxMap) -> {
        assertEquals(activity.getResources().getDimension(R.dimen.mapbox_scale_bar_text_size), scaleBarWidget.getTextSize(), 0);
        ScaleBarOptions option = new ScaleBarOptions(activity);
        option.setTextSize(R.dimen.fab_margin);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(activity.getResources().getDimension(R.dimen.fab_margin), scaleBarWidget.getTextSize(), 0);
        option = new ScaleBarOptions(activity);
        option.setTextSize(100f);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(100f, scaleBarWidget.getTextSize(), 0);
    });
}
Also used : ScaleBarOptions(com.mapbox.pluginscalebar.ScaleBarOptions) Test(org.junit.Test) BaseActivityTest(com.mapbox.mapboxsdk.plugins.BaseActivityTest)

Example 10 with ScaleBarOptions

use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.

the class ScaleBarTest method testRatio.

@Test
public void testRatio() {
    validateTestSetup();
    setupScaleBar();
    assertEquals(0.5f, scaleBarWidget.getRatio(), 0f);
    invoke(mapboxMap, (uiController, mapboxMap) -> {
        ScaleBarOptions option = new ScaleBarOptions(activity);
        option.setMaxWidthRatio(0.1f);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(0.1f, scaleBarWidget.getRatio(), 0f);
    });
    invoke(mapboxMap, (uiController, mapboxMap) -> {
        ScaleBarOptions option = new ScaleBarOptions(activity);
        option.setMaxWidthRatio(1.0f);
        scaleBarWidget = scaleBarPlugin.create(option);
        assertNotNull(scaleBarWidget);
        assertEquals(1.0f, scaleBarWidget.getRatio(), 0f);
    });
}
Also used : ScaleBarOptions(com.mapbox.pluginscalebar.ScaleBarOptions) Test(org.junit.Test) BaseActivityTest(com.mapbox.mapboxsdk.plugins.BaseActivityTest)

Aggregations

ScaleBarOptions (com.mapbox.pluginscalebar.ScaleBarOptions)11 BaseActivityTest (com.mapbox.mapboxsdk.plugins.BaseActivityTest)9 Test (org.junit.Test)9 ScaleBarPlugin (com.mapbox.pluginscalebar.ScaleBarPlugin)2 SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 UiSettings (com.mapbox.mapboxsdk.maps.UiSettings)1 Callback (fr.free.nrw.commons.nearby.fragments.AdvanceQueryFragment.Callback)1 IOException (java.io.IOException)1 Date (java.util.Date)1