yzt
2023-05-05 4c558c77a6a9d23f057f094c4dc3e315eabef497
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
import createScene from "../../createScene.js";
import { PerformanceWatchdog } from "../../../Source/Cesium.js";
 
describe(
  "Widgets/PerformanceWatchdog/PerformanceWatchdog",
  function () {
    var scene;
    beforeAll(function () {
      scene = createScene();
    });
 
    afterAll(function () {
      scene.destroyForSpecs();
    });
 
    it("can create and destroy", function () {
      var container = document.createElement("span");
      container.id = "testContainer";
      document.body.appendChild(container);
 
      var widget = new PerformanceWatchdog({
        container: "testContainer",
        scene: scene,
      });
      expect(widget.container.id).toEqual(container.id);
      expect(widget.isDestroyed()).toEqual(false);
 
      widget.destroy();
      expect(widget.isDestroyed()).toEqual(true);
 
      document.body.removeChild(container);
    });
 
    it("throws if options is undefined", function () {
      expect(function () {
        return new PerformanceWatchdog(undefined);
      }).toThrowDeveloperError();
    });
 
    it("throws if options.container is undefined", function () {
      expect(function () {
        return new PerformanceWatchdog({
          container: undefined,
          scene: scene,
        });
      }).toThrowDeveloperError();
    });
 
    it("throws if options.scene is undefined", function () {
      var container = document.createElement("span");
      container.id = "testContainer";
      document.body.appendChild(container);
 
      expect(function () {
        return new PerformanceWatchdog({
          container: container,
          scene: undefined,
        });
      }).toThrowDeveloperError();
 
      document.body.removeChild(container);
    });
 
    it("constructor throws with string element that does not exist", function () {
      expect(function () {
        return new PerformanceWatchdog({
          container: "does not exist",
          scene: scene,
        });
      }).toThrowDeveloperError();
    });
  },
  "WebGL"
);