blob: 3cff4cad540c66673c3e5e776b63185d36d65e39 (
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
80
81
82
83
84
85
86
87
88
89
90
91
|
package com.mapbox.mapboxsdk.testapp.activity.render;
import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter;
public class RenderTestDefinition {
private static final int DEFAULT_WIDTH = 512;
private static final int DEFAULT_HEIGHT = 512;
private String category; // eg. background-color
private String name; // eg. colorSpace-hcl
private String styleJson;
private RenderTestStyleDefinition definition;
RenderTestDefinition(String category, String name, String styleJson, RenderTestStyleDefinition definition) {
this.category = category;
this.name = name;
this.styleJson = styleJson;
this.definition = definition;
}
public String getName() {
return name;
}
public String getCategory() {
return category;
}
public int getWidth() {
RenderTestStyleDefinition.Test test = getTest();
if (test != null) {
Integer testWidth = test.getWidth();
if (testWidth != null && testWidth > 0) {
return testWidth;
}
}
return DEFAULT_WIDTH;
}
public int getHeight() {
RenderTestStyleDefinition.Test test = getTest();
if (test != null) {
Integer testHeight = test.getHeight();
if (testHeight != null && testHeight > 0) {
return testHeight;
}
}
return DEFAULT_HEIGHT;
}
public float getPixelRatio() {
RenderTestStyleDefinition.Test test = getTest();
if (test != null) {
Float pixelRatio = test.getPixelRatio();
if (pixelRatio != null && pixelRatio > 0) {
return pixelRatio;
}
}
return 1;
}
public String getStyleJson() {
return styleJson;
}
public boolean hasOperations() {
return getTest().getOperations() != null;
}
public RenderTestStyleDefinition.Test getTest() {
return definition.getMetadata().getTest();
}
public MapSnapshotter.Options toOptions() {
return new MapSnapshotter
.Options(getWidth(), getHeight())
.withStyleJson(styleJson)
.withPixelRatio(getPixelRatio())
.withLogo(false);
}
@Override
public String toString() {
return "RenderTestDefinition{"
+ "category='" + category + '\''
+ ", name='" + name + '\''
+ ", styleJson='" + styleJson + '\''
+ '}';
}
}
|