summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java
blob: c95c9596448ce79190a6bfc7ae2358dc93d1fe86 (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
package com.mapbox.mapboxsdk.testapp.style;

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;

import timber.log.Timber;

import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * Basic smoke tests for BackgroundLayer
 */
@RunWith(AndroidJUnit4.class)
public class RuntimeStyleBackgroundLayerTest
  extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {

  public RuntimeStyleBackgroundLayerTest() {
    super(RuntimeStyleTestActivity.class);
  }

  @Before
  public void setUp() throws Exception {
    super.setUp();
    injectInstrumentation(InstrumentationRegistry.getInstrumentation());
  }

  @Test
  public void testSetVisibility() {
    getActivity().mapView.getMapAsync(new OnMapReadyCallback() {
      @Override
      public void onMapReady(MapboxMap mapboxMap) {
        Timber.i("visibility");
        BackgroundLayer layer = mapboxMap.getLayerAs("background");
        assertNotNull(layer);

        // Get initial
        assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);

        // Set
        layer.setProperties(PropertyFactory.visibility(Property.NONE));
        assertEquals(layer.getVisibility().getValue(), Property.NONE);
      }
    });
  }

  @After
  public void tearDown() throws Exception {
    super.tearDown();
  }
}