Skip to content

Commit

Permalink
Added tests for DiscardEmptyTileImagePolicy, updated CHANGES.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyboardSounds committed May 3, 2019
1 parent 5e41791 commit 7a4b700
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change Log
==========
### 1.58 - 2019-06-01

##### Additions :tada:
* Added support for new Bing Maps imagery styles RoadOnDemand and AerialWithLabelsOnDemand. The other versions of these, Road and AerialWithLabels, have been deprecated. [#7808] (https://github.com/AnalyticalGraphicsInc/cesium/pull/7808)

### 1.57 - 2019-05-01

Expand Down
1 change: 1 addition & 0 deletions Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ define([
window.URL.revokeObjectURL(generatedBlobResource.url);
}

// We attach additional information to the error here so that it can be handled by an ImageProvider.
error.blob = generatedBlob;

return when.reject(error);
Expand Down
54 changes: 54 additions & 0 deletions Specs/Scene/DiscardEmptyTileImagePolicySpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
defineSuite([
'Scene/DiscardEmptyTileImagePolicy',
'Core/Resource',
'Specs/pollToPromise',
'ThirdParty/when'
], function(
DiscardEmptyTileImagePolicy,
Resource,
pollToPromise,
when) {
'use strict';

afterEach(function() {
Resource._Implementations.createImage = Resource._DefaultImplementations.createImage;
Resource._Implementations.loadWithXhr = Resource._DefaultImplementations.loadWithXhr;
});

describe('shouldDiscardImage', function() {
fit('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);
});
});

fit('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);
});
});

});
});

0 comments on commit 7a4b700

Please sign in to comment.