15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import { Color } from "../../Source/Cesium.js";
import { DistanceDisplayCondition } from "../../Source/Cesium.js";
import { ColorMaterialProperty } from "../../Source/Cesium.js";
import { ConstantProperty } from "../../Source/Cesium.js";
import { CylinderGraphics } from "../../Source/Cesium.js";
import { ShadowMode } from "../../Source/Cesium.js";
import testDefinitionChanged from "../testDefinitionChanged.js";
import testMaterialDefinitionChanged from "../testMaterialDefinitionChanged.js";
 
describe("DataSources/CylinderGraphics", function () {
  it("creates expected instance from raw assignment and construction", function () {
    var options = {
      material: Color.BLUE,
      show: true,
      length: 1,
      topRadius: 2,
      bottomRadius: 3,
      numberOfVerticalLines: 4,
      slices: 5,
      fill: false,
      outline: false,
      outlineColor: Color.RED,
      outlineWidth: 6,
      shadows: ShadowMode.DISABLED,
      distanceDisplayCondition: new DistanceDisplayCondition(10.0, 100.0),
    };
 
    var cylinder = new CylinderGraphics(options);
    expect(cylinder.material).toBeInstanceOf(ColorMaterialProperty);
    expect(cylinder.show).toBeInstanceOf(ConstantProperty);
    expect(cylinder.length).toBeInstanceOf(ConstantProperty);
    expect(cylinder.topRadius).toBeInstanceOf(ConstantProperty);
    expect(cylinder.bottomRadius).toBeInstanceOf(ConstantProperty);
    expect(cylinder.numberOfVerticalLines).toBeInstanceOf(ConstantProperty);
    expect(cylinder.slices).toBeInstanceOf(ConstantProperty);
    expect(cylinder.fill).toBeInstanceOf(ConstantProperty);
    expect(cylinder.outline).toBeInstanceOf(ConstantProperty);
    expect(cylinder.outlineColor).toBeInstanceOf(ConstantProperty);
    expect(cylinder.outlineWidth).toBeInstanceOf(ConstantProperty);
    expect(cylinder.shadows).toBeInstanceOf(ConstantProperty);
    expect(cylinder.distanceDisplayCondition).toBeInstanceOf(ConstantProperty);
 
    expect(cylinder.material.color.getValue()).toEqual(options.material);
    expect(cylinder.show.getValue()).toEqual(options.show);
    expect(cylinder.length.getValue()).toEqual(options.length);
    expect(cylinder.topRadius.getValue()).toEqual(options.topRadius);
    expect(cylinder.bottomRadius.getValue()).toEqual(options.bottomRadius);
    expect(cylinder.numberOfVerticalLines.getValue()).toEqual(
      options.numberOfVerticalLines
    );
    expect(cylinder.slices.getValue()).toEqual(options.slices);
    expect(cylinder.fill.getValue()).toEqual(options.fill);
    expect(cylinder.outline.getValue()).toEqual(options.outline);
    expect(cylinder.outlineColor.getValue()).toEqual(options.outlineColor);
    expect(cylinder.outlineWidth.getValue()).toEqual(options.outlineWidth);
    expect(cylinder.shadows.getValue()).toEqual(options.shadows);
    expect(cylinder.distanceDisplayCondition.getValue()).toEqual(
      options.distanceDisplayCondition
    );
  });
 
  it("merge assigns unassigned properties", function () {
    var source = new CylinderGraphics();
    source.material = new ColorMaterialProperty();
    source.length = new ConstantProperty();
    source.topRadius = new ConstantProperty();
    source.bottomRadius = new ConstantProperty();
    source.numberOfVerticalLines = new ConstantProperty();
    source.slices = new ConstantProperty();
    source.fill = new ConstantProperty();
    source.outline = new ConstantProperty();
    source.outlineColor = new ConstantProperty();
    source.outlineWidth = new ConstantProperty();
    source.shadows = new ConstantProperty(ShadowMode.ENABLED);
    source.distanceDisplayCondition = new ConstantProperty();
 
    var target = new CylinderGraphics();
    target.merge(source);
 
    expect(target.material).toBe(source.material);
    expect(target.length).toBe(source.length);
    expect(target.topRadius).toBe(source.topRadius);
    expect(target.bottomRadius).toBe(source.bottomRadius);
    expect(target.numberOfVerticalLines).toBe(source.numberOfVerticalLines);
    expect(target.slices).toBe(source.slices);
    expect(target.fill).toBe(source.fill);
    expect(target.outline).toBe(source.outline);
    expect(target.outlineColor).toBe(source.outlineColor);
    expect(target.outlineWidth).toBe(source.outlineWidth);
    expect(target.shadows).toBe(source.shadows);
    expect(target.distanceDisplayCondition).toBe(
      source.distanceDisplayCondition
    );
  });
 
  it("merge does not assign assigned properties", function () {
    var source = new CylinderGraphics();
 
    var material = new ColorMaterialProperty();
    var topRadius = new ConstantProperty();
    var length = new ConstantProperty();
    var bottomRadius = new ConstantProperty();
    var numberOfVerticalLines = new ConstantProperty();
    var slices = new ConstantProperty();
    var fill = new ConstantProperty();
    var outline = new ConstantProperty();
    var outlineColor = new ConstantProperty();
    var outlineWidth = new ConstantProperty();
    var shadows = new ConstantProperty();
    var distanceDisplayCondition = new ConstantProperty();
 
    var target = new CylinderGraphics();
    target.material = material;
    target.length = length;
    target.topRadius = topRadius;
    target.bottomRadius = bottomRadius;
    target.numberOfVerticalLines = numberOfVerticalLines;
    target.slices = slices;
    target.fill = fill;
    target.outline = outline;
    target.outlineColor = outlineColor;
    target.outlineWidth = outlineWidth;
    target.shadows = shadows;
    target.distanceDisplayCondition = distanceDisplayCondition;
 
    target.merge(source);
 
    expect(target.material).toBe(material);
    expect(target.length).toBe(length);
    expect(target.topRadius).toBe(topRadius);
    expect(target.bottomRadius).toBe(bottomRadius);
    expect(target.numberOfVerticalLines).toBe(numberOfVerticalLines);
    expect(target.slices).toBe(slices);
    expect(target.fill).toBe(fill);
    expect(target.outline).toBe(outline);
    expect(target.outlineColor).toBe(outlineColor);
    expect(target.outlineWidth).toBe(outlineWidth);
    expect(target.shadows).toBe(shadows);
    expect(target.distanceDisplayCondition).toBe(distanceDisplayCondition);
  });
 
  it("clone works", function () {
    var source = new CylinderGraphics();
    source.material = new ColorMaterialProperty();
    source.length = new ConstantProperty();
    source.topRadius = new ConstantProperty();
    source.bottomRadius = new ConstantProperty();
    source.numberOfVerticalLines = new ConstantProperty();
    source.slices = new ConstantProperty();
    source.fill = new ConstantProperty();
    source.outline = new ConstantProperty();
    source.outlineColor = new ConstantProperty();
    source.outlineWidth = new ConstantProperty();
    source.shadows = new ConstantProperty();
    source.distanceDisplayCondition = new ConstantProperty();
 
    var result = source.clone();
    expect(result.material).toBe(source.material);
    expect(result.length).toBe(source.length);
    expect(result.topRadius).toBe(source.topRadius);
    expect(result.bottomRadius).toBe(source.bottomRadius);
    expect(result.numberOfVerticalLines).toBe(source.numberOfVerticalLines);
    expect(result.slices).toBe(source.slices);
    expect(result.fill).toBe(source.fill);
    expect(result.outline).toBe(source.outline);
    expect(result.outlineColor).toBe(source.outlineColor);
    expect(result.outlineWidth).toBe(source.outlineWidth);
    expect(result.shadows).toBe(source.shadows);
    expect(result.distanceDisplayCondition).toBe(
      source.distanceDisplayCondition
    );
  });
 
  it("merge throws if source undefined", function () {
    var target = new CylinderGraphics();
    expect(function () {
      target.merge(undefined);
    }).toThrowDeveloperError();
  });
 
  it("raises definitionChanged when a property is assigned or modified", function () {
    var property = new CylinderGraphics();
    testMaterialDefinitionChanged(property, "material", Color.RED, Color.BLUE);
    testDefinitionChanged(property, "length", 2, 3);
    testDefinitionChanged(property, "topRadius", 3, 4);
    testDefinitionChanged(property, "bottomRadius", 5, 6);
    testDefinitionChanged(property, "numberOfVerticalLines", 16, 32);
    testDefinitionChanged(property, "slices", 16, 24);
    testDefinitionChanged(property, "fill", false, true);
    testDefinitionChanged(property, "outline", true, false);
    testDefinitionChanged(property, "outlineColor", Color.RED, Color.BLUE);
    testDefinitionChanged(property, "outlineWidth", 2, 3);
    testDefinitionChanged(
      property,
      "shadows",
      ShadowMode.ENABLED,
      ShadowMode.DISABLED
    );
    testDefinitionChanged(
      property,
      "distanceDisplayCondition",
      new DistanceDisplayCondition(),
      new DistanceDisplayCondition(10.0, 100.0)
    );
  });
});