summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/render/RenderTestDefinition.java
blob: fa8c8162030d992ec74599526776ae68ad021741 (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.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 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)
      .withLogo(false);
  }

  @Override
  public String toString() {
    return "RenderTestDefinition{"
      + "category='" + category + '\''
      + ", name='" + name + '\''
      + ", styleJson='" + styleJson + '\''
      + '}';
  }
}