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
import { Color } from "../../Source/Cesium.js";
import { JulianDate } from "../../Source/Cesium.js";
import { TimeInterval } from "../../Source/Cesium.js";
import { ColorMaterialProperty } from "../../Source/Cesium.js";
import { ConstantProperty } from "../../Source/Cesium.js";
import { TimeIntervalCollectionProperty } from "../../Source/Cesium.js";
 
describe("DataSources/ColorMaterialProperty", function () {
  it("constructor provides the expected defaults", function () {
    var property = new ColorMaterialProperty();
    expect(property.color).toBeUndefined();
    expect(property.getType()).toEqual("Color");
    expect(property.isConstant).toBe(true);
 
    var result = property.getValue();
    expect(result.color).toEqual(Color.WHITE);
 
    var colorProperty = new ConstantProperty(Color.BLUE);
    property = new ColorMaterialProperty(colorProperty);
    expect(property.color).toBe(colorProperty);
 
    property = new ColorMaterialProperty(Color.BLUE);
    expect(property.color).toBeInstanceOf(ConstantProperty);
    expect(property.color.getValue()).toEqual(Color.BLUE);
  });
 
  it("works with constant values", function () {
    var property = new ColorMaterialProperty();
    property.color = new ConstantProperty(Color.RED);
 
    var result = property.getValue(JulianDate.now());
    expect(result.color).toEqual(Color.RED);
  });
 
  it("works with dynamic values", function () {
    var property = new ColorMaterialProperty();
    property.color = new TimeIntervalCollectionProperty();
 
    var start = new JulianDate(1, 0);
    var stop = new JulianDate(2, 0);
    property.color.intervals.addInterval(
      new TimeInterval({
        start: start,
        stop: stop,
        data: Color.BLUE,
      })
    );
 
    expect(property.isConstant).toBe(false);
 
    var result = property.getValue(start);
    expect(result.color).toEqual(Color.BLUE);
  });
 
  it("works with a result parameter", function () {
    var property = new ColorMaterialProperty();
    property.color = new ConstantProperty(Color.RED);
 
    var result = {
      color: Color.BLUE.clone(),
    };
    var returnedResult = property.getValue(JulianDate.now(), result);
    expect(returnedResult).toBe(result);
    expect(result.color).toEqual(Color.RED);
  });
 
  it("equals works", function () {
    var left = new ColorMaterialProperty();
    left.color = new ConstantProperty(Color.WHITE);
 
    var right = new ColorMaterialProperty();
    right.color = new ConstantProperty(Color.WHITE);
    expect(left.equals(right)).toEqual(true);
 
    right.color = new ConstantProperty(Color.BLACK);
    expect(left.equals(right)).toEqual(false);
  });
 
  it("raises definitionChanged when a color property is assigned or modified", function () {
    var property = new ColorMaterialProperty();
 
    var listener = jasmine.createSpy("listener");
    property.definitionChanged.addEventListener(listener);
 
    var oldValue = property.color;
    property.color = new ConstantProperty(Color.WHITE);
    expect(listener).toHaveBeenCalledWith(
      property,
      "color",
      property.color,
      oldValue
    );
    listener.calls.reset();
 
    property.color.setValue(Color.BLACK);
    expect(listener).toHaveBeenCalledWith(
      property,
      "color",
      property.color,
      property.color
    );
    listener.calls.reset();
 
    property.color = property.color;
    expect(listener.calls.count()).toEqual(0);
  });
});