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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
public class BackgroundLayerTest extends BaseLayerTest {
private BackgroundLayer layer;
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new BackgroundLayer("my-layer");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSetVisibility() {
Timber.i("Visibility");
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testBackgroundColorTransition() {
Timber.i("background-colorTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundColorTransition(options);
assertEquals(layer.getBackgroundColorTransition(), options);
}
@Test
@UiThreadTest
public void testBackgroundColorAsConstant() {
Timber.i("background-color");
assertNotNull(layer);
assertNull(layer.getBackgroundColor().getValue());
// Set and Get
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(backgroundColor(propertyValue));
assertEquals(layer.getBackgroundColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBackgroundColorAsIntConstant() {
Timber.i("background-color");
assertNotNull(layer);
// Set and Get
layer.setProperties(backgroundColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getBackgroundColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@UiThreadTest
public void testBackgroundPatternTransition() {
Timber.i("background-patternTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundPatternTransition(options);
assertEquals(layer.getBackgroundPatternTransition(), options);
}
@Test
@UiThreadTest
public void testBackgroundPatternAsConstant() {
Timber.i("background-pattern");
assertNotNull(layer);
assertNull(layer.getBackgroundPattern().getValue());
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(backgroundPattern(propertyValue));
assertEquals(layer.getBackgroundPattern().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBackgroundOpacityTransition() {
Timber.i("background-opacityTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundOpacityTransition(options);
assertEquals(layer.getBackgroundOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testBackgroundOpacityAsConstant() {
Timber.i("background-opacity");
assertNotNull(layer);
assertNull(layer.getBackgroundOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(backgroundOpacity(propertyValue));
assertEquals(layer.getBackgroundOpacity().getValue(), propertyValue);
}
}
|