-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for DiscardEmptyTileImagePolicy, updated CHANGES.md
- Loading branch information
1 parent
5e41791
commit 7a4b700
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |