This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
forked from openlayers/openlayers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openlayers#3493 from tsauerwein/image-static-load
Add image loading events to ol.source.ImageStatic
- Loading branch information
Showing
3 changed files
with
48 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
goog.provide('ol.test.source.ImageStatic'); | ||
|
||
describe('ol.source.ImageStatic', function() { | ||
|
||
var extent, pixelRatio, projection, resolution; | ||
beforeEach(function() { | ||
extent = [ | ||
-13637278.73946974, 4543799.13271362, | ||
-13617443.330629736, 4553927.038961405]; | ||
pixelRatio = 1; | ||
projection = ol.proj.get('EPSG:3857'); | ||
resolution = 38; | ||
}); | ||
|
||
describe('#getImage', function() { | ||
|
||
it('triggers image load events', function(done) { | ||
var source = new ol.source.ImageStatic({ | ||
url: 'spec/ol/source/images/12-655-1583.png', | ||
imageExtent: [ | ||
-13629027.891360067, 4539747.983913189, | ||
-13619243.951739565, 4549531.923533691], | ||
projection: projection, | ||
imageSize: [256, 256] | ||
}); | ||
|
||
var imageloadstart = sinon.spy(); | ||
var imageloaderror = sinon.spy(); | ||
|
||
source.on('imageloadstart', imageloadstart); | ||
source.on('imageloaderror', imageloaderror); | ||
source.on('imageloadend', function(event) { | ||
expect(imageloadstart.callCount).to.be(1); | ||
expect(imageloaderror.callCount).to.be(0); | ||
done(); | ||
}); | ||
|
||
var image = source.getImage(extent, resolution, pixelRatio, projection); | ||
image.load(); | ||
}); | ||
}); | ||
}); | ||
|
||
goog.require('ol.source.ImageStatic'); | ||
goog.require('ol.proj'); |