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);
});
}
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);
});
}
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);
});
}
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);
});
}
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);
});
}
Aggregations