yzt
2023-05-05 634ab285812bcc3eb802cacb9ec54f489bc2728f
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
import { Resource } from "../../Source/Cesium.js";
import { DiscardEmptyTileImagePolicy } from "../../Source/Cesium.js";
import pollToPromise from "../pollToPromise.js";
import { when } from "../../Source/Cesium.js";
 
describe("Scene/DiscardEmptyTileImagePolicy", function () {
  afterEach(function () {
    Resource._Implementations.createImage =
      Resource._DefaultImplementations.createImage;
    Resource._Implementations.loadWithXhr =
      Resource._DefaultImplementations.loadWithXhr;
  });
 
  describe("shouldDiscardImage", function () {
    it("does not discard a non-empty image", function () {
      var promises = [];
      promises.push(Resource.fetchImage("Data/Images/Green4x4.png"));
 
      var policy = new DiscardEmptyTileImagePolicy();
 
      promises.push(
        pollToPromise(function () {
          return policy.isReady();
        })
      );
 
      return when.all(promises, function (results) {
        var greenImage = results[0];
 
        expect(policy.shouldDiscardImage(greenImage)).toEqual(false);
      });
    });
 
    it("discards an empty image", function () {
      var promises = [];
      promises.push(when.resolve(DiscardEmptyTileImagePolicy.EMPTY_IMAGE));
 
      var policy = new DiscardEmptyTileImagePolicy();
 
      promises.push(
        pollToPromise(function () {
          return policy.isReady();
        })
      );
 
      return when.all(promises, function (results) {
        var emptyImage = results[0];
 
        expect(policy.shouldDiscardImage(emptyImage)).toEqual(true);
      });
    });
  });
});