summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java
blob: 744bf55c07db131142463a5c6dc8cdf564668519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.mapbox.mapboxsdk.annotations;

import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class PolygonTest {

    @Test
    public void testSanity() {
        PolygonOptions polygonOptions = new PolygonOptions();
        assertNotNull("polygonOptions should not be null", polygonOptions);
    }

    @Test
    public void testPolygon() {
        Polygon polygon = new PolygonOptions().getPolygon();
        assertNotNull("polyline should not be null", polygon);
    }

    @Test
    public void testAlpha() {
        Polygon polygon = new PolygonOptions().alpha(0.5f).getPolygon();
        assertEquals(0.5f, polygon.getAlpha(), 0.0f);
    }

    @Test
    public void testStrokeColor() {
        Polygon polygon = new PolygonOptions().strokeColor(1).getPolygon();
        assertEquals(1, polygon.getStrokeColor());
    }

    @Test
    public void testFillColor() {
        Polygon polygon = new PolygonOptions().fillColor(1).getPolygon();
        assertEquals(1, polygon.getFillColor());
    }

    @Test
    public void testLatLng() {
        Polygon polygon = new PolygonOptions().add(new LatLng(0, 0)).getPolygon();
        assertNotNull("points should not be null", polygon.getPoints());
        assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
    }

    @Test
    public void testAddAllLatLng() {
        List<LatLng> coordinates = new ArrayList<>();
        coordinates.add(new LatLng(0, 0));
        Polygon polygon = new PolygonOptions().addAll(coordinates).getPolygon();
        assertNotNull(polygon.getPoints());
        assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
    }

    @Test
    public void testBuilder() {
        PolylineOptions polylineOptions = new PolylineOptions();
        polylineOptions.width(1.0f);
        polylineOptions.color(2);
        polylineOptions.add(new LatLng(0, 0));

        Polyline polyline = polylineOptions.getPolyline();
        assertEquals(1.0f, polyline.getWidth(), 0);
        assertEquals(2, polyline.getColor());
        assertNotNull("Points should not be null", polyline.getPoints());
        assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
    }

}