Merge branch 'master' of github.com:openlayers/ol3 into vector

This commit is contained in:
Tim Schaub
2013-03-07 23:10:06 -07:00
120 changed files with 16315 additions and 1555 deletions

View File

@@ -104,67 +104,94 @@ describe('ol.collection', function() {
});
});
describe('remove', function() {
it('removes the first matching element', function() {
var collection = new ol.Collection([0, 1, 2]);
expect(collection.remove(1)).toEqual(1);
expect(collection.getArray()).toEqual([0, 2]);
expect(collection.getLength()).toEqual(2);
});
it('fires a remove event', function() {
var collection = new ol.Collection([0, 1, 2]);
var cb = jasmine.createSpy();
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
expect(collection.remove(1)).toEqual(1);
expect(cb).toHaveBeenCalled();
expect(cb.mostRecentCall.args[0].elem).toEqual(1);
});
it('does not remove more than one matching element', function() {
var collection = new ol.Collection([0, 1, 1, 2]);
expect(collection.remove(1)).toEqual(1);
expect(collection.getArray()).toEqual([0, 1, 2]);
expect(collection.getLength()).toEqual(3);
});
it('returns undefined if the element is not found', function() {
var collection = new ol.Collection([0, 1, 2]);
expect(collection.remove(3)).toBeUndefined();
expect(collection.getArray()).toEqual([0, 1, 2]);
expect(collection.getLength()).toEqual(3);
});
});
describe('setAt and event', function() {
it('does dispatch events', function() {
var collection = new ol.Collection(['a', 'b']);
var index, prev;
var added, removed;
goog.events.listen(collection, ol.CollectionEventType.ADD, function(e) {
added = e.elem;
});
goog.events.listen(
collection,
ol.CollectionEventType.SET_AT,
function(e) {
index = e.index;
prev = e.prev;
collection, ol.CollectionEventType.REMOVE, function(e) {
removed = e.elem;
});
collection.setAt(1, 1);
expect(index).toEqual(1);
expect(prev).toEqual('b');
expect(added).toEqual(1);
expect(removed).toEqual('b');
});
});
describe('removeAt and event', function() {
it('does dispatch events', function() {
var collection = new ol.Collection(['a']);
var index, prev;
var removed;
goog.events.listen(
collection, ol.CollectionEventType.REMOVE_AT, function(e) {
index = e.index;
prev = e.prev;
collection, ol.CollectionEventType.REMOVE, function(e) {
removed = e.elem;
});
collection.pop();
expect(index).toEqual(0);
expect(prev).toEqual('a');
expect(removed).toEqual('a');
});
});
describe('insertAt and event', function() {
it('does dispatch events', function() {
var collection = new ol.Collection([0, 2]);
var index;
var added;
goog.events.listen(
collection, ol.CollectionEventType.INSERT_AT, function(e) {
index = e.index;
collection, ol.CollectionEventType.ADD, function(e) {
added = e.elem;
});
collection.insertAt(1, 1);
expect(index).toEqual(1);
expect(added).toEqual(1);
});
});
describe('setAt beyond end', function() {
it('triggers events properly', function() {
var inserts = [];
var added = [];
goog.events.listen(
collection, ol.CollectionEventType.INSERT_AT, function(e) {
inserts.push(e.index);
collection, ol.CollectionEventType.ADD, function(e) {
added.push(e.elem);
});
collection.setAt(2, 0);
expect(collection.getLength()).toEqual(3);
expect(collection.getAt(0)).toBeUndefined();
expect(collection.getAt(1)).toBeUndefined();
expect(collection.getAt(2)).toEqual(0);
expect(inserts.length).toEqual(3);
expect(inserts[0]).toEqual(0);
expect(inserts[1]).toEqual(1);
expect(inserts[2]).toEqual(2);
expect(added.length).toEqual(3);
expect(added[0]).toEqual(undefined);
expect(added[1]).toEqual(undefined);
expect(added[2]).toEqual(0);
});
});
@@ -235,6 +262,17 @@ describe('ol.collection', function() {
});
});
});
describe('extending a collection', function() {
it('adds elements to end of the collection', function() {
collection.extend([1, 2]);
expect(collection.getLength()).toEqual(2);
expect(goog.array.equals(collection.getArray(), [1, 2])).toBeTruthy();
expect(collection.getAt(0)).toEqual(1);
expect(collection.getAt(1)).toEqual(2);
});
});
});
goog.require('goog.array');

View File

@@ -70,8 +70,7 @@ describe('ol.Extent', function() {
describe('transform', function() {
it('does transform', function() {
var transformFn =
ol.projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857');
var transformFn = ol.projection.getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = new ol.Extent(-15, -30, 45, 60);
var destinationExtent = sourceExtent.transform(transformFn);
expect(destinationExtent).not.toBeUndefined();

View File

@@ -9,7 +9,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() {
layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});
});
@@ -53,7 +53,7 @@ describe('ol.layer.Layer', function() {
it('accepts options', function() {
var layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
}),
brightness: 0.5,
contrast: 10,
@@ -82,7 +82,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() {
layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});
});
@@ -120,7 +120,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() {
layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});
});
@@ -154,7 +154,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() {
layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});
});
@@ -193,7 +193,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() {
layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});
});
@@ -227,7 +227,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() {
layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});
});
@@ -259,7 +259,7 @@ describe('ol.layer.Layer', function() {
it('sets visible property', function() {
var layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
})
});

View File

@@ -87,7 +87,7 @@ describe('ol.Map', function() {
describe('create mousewheel interaction', function() {
it('creates mousewheel interaction', function() {
options.mouseWheelZoom = true;
var interactions = ol.Map.createInteractions_(options);
var interactions = ol.interaction.defaults(options);
expect(interactions.getLength()).toEqual(1);
expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom);
});
@@ -101,7 +101,7 @@ describe('ol.Map', function() {
describe('default zoomDelta', function() {
it('create double click interaction with default delta', function() {
var interactions = ol.Map.createInteractions_(options);
var interactions = ol.interaction.defaults(options);
expect(interactions.getLength()).toEqual(1);
expect(interactions.getAt(0)).toBeA(ol.interaction.DblClickZoom);
expect(interactions.getAt(0).delta_).toEqual(1);
@@ -111,7 +111,7 @@ describe('ol.Map', function() {
describe('set zoomDelta', function() {
it('create double click interaction with set delta', function() {
options.zoomDelta = 7;
var interactions = ol.Map.createInteractions_(options);
var interactions = ol.interaction.defaults(options);
expect(interactions.getLength()).toEqual(1);
expect(interactions.getAt(0)).toBeA(ol.interaction.DblClickZoom);
expect(interactions.getAt(0).delta_).toEqual(7);
@@ -233,5 +233,6 @@ goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.interaction.DblClickZoom');
goog.require('ol.interaction.MouseWheelZoom');
goog.require('ol.interaction.defaults');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.XYZ');

View File

@@ -0,0 +1,45 @@
goog.provide('ol.test.parser.ogc.WMSCapabilities_v1_0_0');
/**
* @define {boolean} Whether to enable WMS Capabilities version 1.0.0.
*/
ol.ENABLE_WMSCAPS_1_0_0 = true;
describe('ol.parser.ogc.wmscapabilities_v1_0_0', function() {
var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read', function() {
it('Test read', function() {
var obj;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_0_0.xml';
goog.net.XhrIo.send(url, function(e) {
var xhr = e.target;
obj = parser.read(xhr.getResponseXml());
});
});
waitsFor(function() {
return (obj !== undefined);
}, 'XHR timeout', 1000);
runs(function() {
expect(obj.service.keywords.length).toEqual(2);
expect(obj.service.keywords[0]['value']).toEqual('BGDI');
expect(obj.service.href).toEqual('https://wms.geo.admin.ch/?');
var url = 'https://wms.geo.admin.ch/?';
var getmap = obj.capability.request.getmap;
expect(getmap.get.href).toEqual(url);
expect(getmap.post.href).toEqual(url);
expect(getmap.formats.length).toEqual(4);
expect(getmap.formats[0]).toEqual('GIF');
expect(obj.capability.layers[64].keywords.length).toEqual(2);
expect(obj.capability.layers[64].keywords[0].value).toEqual('Geometer');
});
});
});
});
goog.require('goog.net.XhrIo');
goog.require('ol.parser.ogc.WMSCapabilities');

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@ describe('ol.projection.EPSG3857', function() {
it('returns the correct point scale at the equator', function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
var epsg3857 = ol.projection.get('EPSG:3857');
var resolution = 19.11;
var point = new ol.Coordinate(0, 0);
expect(epsg3857.getPointResolution(resolution, point)).
@@ -17,8 +17,8 @@ describe('ol.projection.EPSG3857', function() {
it('returns the correct point scale at the latitude of Toronto',
function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
var epsg3857 = ol.projection.get('EPSG:3857');
var epsg4326 = ol.projection.get('EPSG:4326');
var resolution = 19.11;
var point = ol.projection.transform(
new ol.Coordinate(0, 43.65), epsg4326, epsg3857);
@@ -28,8 +28,8 @@ describe('ol.projection.EPSG3857', function() {
it('returns the correct point scale at various latitudes', function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
var epsg3857 = ol.projection.get('EPSG:3857');
var epsg4326 = ol.projection.get('EPSG:4326');
var resolution = 19.11;
var latitude;
for (latitude = 0; latitude < 90; ++latitude) {

View File

@@ -26,7 +26,7 @@ describe('ol.projection', function() {
describe('projection equivalence', function() {
function _testAllEquivalent(codes) {
var projections = goog.array.map(codes, ol.projection.getFromCode);
var projections = goog.array.map(codes, ol.projection.get);
goog.array.forEach(projections, function(source) {
goog.array.forEach(projections, function(destination) {
expect(ol.projection.equivalent(source, destination)).toBeTruthy();
@@ -56,7 +56,7 @@ describe('ol.projection', function() {
describe('identify transform', function() {
it('returns a new object, with same coord values', function() {
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
var epsg4326 = ol.projection.get('EPSG:4326');
var uniqueObject = {};
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
var destinationPoint = ol.projection.transform(
@@ -70,7 +70,7 @@ describe('ol.projection', function() {
describe('transform 0,0 from 4326 to 3857', function() {
it('returns expected value', function() {
var point = ol.projection.transformWithCodes(
var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
expect(point).not.toBeUndefined();
expect(point).not.toBeNull();
@@ -81,7 +81,7 @@ describe('ol.projection', function() {
describe('transform 0,0 from 3857 to 4326', function() {
it('returns expected value', function() {
var point = ol.projection.transformWithCodes(
var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
expect(point).not.toBeUndefined();
expect(point).not.toBeNull();
@@ -94,7 +94,7 @@ describe('ol.projection', function() {
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
it('returns expected value', function() {
var point = ol.projection.transformWithCodes(
var point = ol.projection.transform(
new ol.Coordinate(-5.625, 52.4827802220782),
'EPSG:4326',
'EPSG:900913');
@@ -109,7 +109,7 @@ describe('ol.projection', function() {
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
it('returns expected value', function() {
var point = ol.projection.transformWithCodes(
var point = ol.projection.transform(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
'EPSG:900913',
'EPSG:4326');
@@ -123,7 +123,7 @@ describe('ol.projection', function() {
describe('Proj4js integration', function() {
it('allows Proj4js projections to be used transparently', function() {
var point = ol.projection.transformWithCodes(
var point = ol.projection.transform(
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
'GOOGLE',
'WGS84');
@@ -136,7 +136,7 @@ describe('ol.projection', function() {
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
var point = ol.projection.transformWithCodes(
var point = ol.projection.transform(
new ol.Coordinate(7.439583333333333, 46.95240555555556),
'EPSG:4326',
'EPSG:21781');
@@ -151,24 +151,24 @@ describe('ol.projection', function() {
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
var code = 'urn:ogc:def:crs:EPSG:21781';
var srsCode = 'EPSG:21781';
var proj = ol.projection.getFromCode(code);
var proj = ol.projection.get(code);
expect(ol.projection.proj4jsProjections_.hasOwnProperty(code))
.toBeTruthy();
expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode))
.toBeTruthy();
var proj2 = ol.projection.getFromCode(srsCode);
var proj2 = ol.projection.get(srsCode);
expect(proj2).toBe(proj);
});
it('numerically estimates point scale at the equator', function() {
var googleProjection = ol.projection.getFromCode('GOOGLE');
var googleProjection = ol.projection.get('GOOGLE');
expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))).
toRoughlyEqual(1, 1e-1);
});
it('numerically estimates point scale at various latitudes', function() {
var epsg3857Projection = ol.projection.getFromCode('EPSG:3857');
var googleProjection = ol.projection.getFromCode('GOOGLE');
var epsg3857Projection = ol.projection.get('EPSG:3857');
var googleProjection = ol.projection.get('GOOGLE');
var point, y;
for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(0, 1000000 * y);
@@ -178,8 +178,8 @@ describe('ol.projection', function() {
});
it('numerically estimates point scale at various points', function() {
var epsg3857Projection = ol.projection.getFromCode('EPSG:3857');
var googleProjection = ol.projection.getFromCode('GOOGLE');
var epsg3857Projection = ol.projection.get('EPSG:3857');
var googleProjection = ol.projection.get('GOOGLE');
var point, x, y;
for (x = -20; x <= 20; ++x) {
for (y = -20; y <= 20; ++y) {
@@ -192,13 +192,13 @@ describe('ol.projection', function() {
});
describe('ol.projection.getTransform()', function() {
describe('ol.projection.getTransformFromProjections()', function() {
var sm = ol.projection.getFromCode('GOOGLE');
var gg = ol.projection.getFromCode('EPSG:4326');
var sm = ol.projection.get('GOOGLE');
var gg = ol.projection.get('EPSG:4326');
it('returns a transform function', function() {
var transform = ol.projection.getTransform(sm, gg);
var transform = ol.projection.getTransformFromProjections(sm, gg);
expect(typeof transform).toBe('function');
var output = transform([-12000000, 5000000]);
@@ -208,7 +208,7 @@ describe('ol.projection', function() {
});
it('works for longer arrays', function() {
var transform = ol.projection.getTransform(sm, gg);
var transform = ol.projection.getTransformFromProjections(sm, gg);
expect(typeof transform).toBe('function');
var output = transform([-12000000, 5000000, -12000000, 5000000]);
@@ -221,18 +221,15 @@ describe('ol.projection', function() {
});
describe('ol.projection.getTransformFromCodes()', function() {
describe('ol.projection.getTransform()', function() {
it('returns a function', function() {
var transform = ol.projection.getTransformFromCodes(
'GOOGLE', 'EPSG:4326');
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function');
});
it('returns a transform function', function() {
var transform = ol.projection.getTransformFromCodes(
'GOOGLE', 'EPSG:4326');
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function');
var output = transform([-626172.13571216376, 6887893.4928337997]);
@@ -243,8 +240,7 @@ describe('ol.projection', function() {
});
it('works for longer arrays of coordinate values', function() {
var transform = ol.projection.getTransformFromCodes(
'GOOGLE', 'EPSG:4326');
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function');
var output = transform([
@@ -262,8 +258,7 @@ describe('ol.projection', function() {
});
it('accepts an optional destination array', function() {
var transform = ol.projection.getTransformFromCodes(
'EPSG:3857', 'EPSG:4326');
var transform = ol.projection.getTransform('EPSG:3857', 'EPSG:4326');
var input = [-12000000, 5000000];
var output = [];
@@ -277,8 +272,7 @@ describe('ol.projection', function() {
});
it('accepts a dimension', function() {
var transform = ol.projection.getTransformFromCodes(
'GOOGLE', 'EPSG:4326');
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function');
var dimension = 3;
@@ -306,8 +300,16 @@ describe('ol.projection', function() {
var units = ol.ProjectionUnits.DEGREES;
it('removes functions cached by addTransform', function() {
var foo = new ol.Projection('foo', units, extent);
var bar = new ol.Projection('bar', units, extent);
var foo = new ol.Projection({
code: 'foo',
units: units,
extent: extent
});
var bar = new ol.Projection({
code: 'bar',
units: units,
extent: extent
});
var transform = function(input, output, dimension) {return input};
ol.projection.addTransform(foo, bar, transform);
expect(ol.projection.transforms_).not.toBeUndefined();
@@ -321,6 +323,36 @@ describe('ol.projection', function() {
});
describe('ol.Projection.prototype.getMetersPerUnit()', function() {
it('returns value in meters', function() {
var epsg4326 = ol.projection.get('EPSG:4326');
expect(epsg4326.getMetersPerUnit()).toEqual(111194.87428468118);
});
});
describe('ol.projection.configureProj4jsProjection()', function() {
beforeEach(function() {
ol.projection.proj4jsProjections_ = {};
});
it('returns a configured projection', function() {
var extent = new ol.Extent(
485869.5728, 76443.1884, 837076.5648, 299941.7864);
var epsg21781 = ol.projection.configureProj4jsProjection({
code: 'EPSG:21781',
extent: extent
});
expect(epsg21781.getCode()).toEqual('EPSG:21781');
expect(epsg21781.getExtent()).toBe(extent);
expect(epsg21781.getUnits()).toBe(ol.ProjectionUnits.METERS);
expect(epsg21781.isGlobal()).toBeFalsy();
});
});
});
goog.require('goog.array');

View File

@@ -5,7 +5,7 @@ describe('ol.source.TileSource', function() {
describe('constructor', function() {
it('returns a tile source', function() {
var source = new ol.source.TileSource({
projection: ol.projection.getFromCode('EPSG:4326')
projection: ol.projection.get('EPSG:4326')
});
expect(source).toBeA(ol.source.Source);
expect(source).toBeA(ol.source.TileSource);
@@ -202,7 +202,7 @@ ol.test.source.MockTileSource = function(loaded) {
goog.base(this, {
extent: extent,
projection: ol.projection.getFromCode('EPSG:4326'),
projection: ol.projection.get('EPSG:4326'),
tileGrid: tileGrid
});

View File

@@ -164,7 +164,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('createForProjection', function() {
it('allows easier creation of a tile grid', function() {
var projection = ol.projection.getFromCode('EPSG:3857');
var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection);
expect(grid).toBeA(ol.tilegrid.TileGrid);
@@ -173,7 +173,7 @@ describe('ol.tilegrid.TileGrid', function() {
});
it('accepts a number of zoom levels', function() {
var projection = ol.projection.getFromCode('EPSG:3857');
var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection, 18);
expect(grid).toBeA(ol.tilegrid.TileGrid);
@@ -182,7 +182,7 @@ describe('ol.tilegrid.TileGrid', function() {
});
it('accepts a big number of zoom levels', function() {
var projection = ol.projection.getFromCode('EPSG:3857');
var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection, 23);
expect(grid).toBeA(ol.tilegrid.TileGrid);
@@ -195,7 +195,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('getForProjection', function() {
it('gets the default tile grid for a projection', function() {
var projection = ol.projection.getFromCode('EPSG:3857');
var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.getForProjection(projection);
expect(grid).toBeA(ol.tilegrid.TileGrid);
@@ -205,7 +205,7 @@ describe('ol.tilegrid.TileGrid', function() {
});
it('stores the default tile grid on a projection', function() {
var projection = ol.projection.getFromCode('EPSG:3857');
var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.getForProjection(projection);
var gridAgain = ol.tilegrid.getForProjection(projection);

View File

@@ -21,20 +21,13 @@ describe('ol.TileQueue', function() {
}
function addRandomPriorityTiles(tq, num) {
var tiles = [];
var i, tile, priority;
for (i = 0; i < num; i++) {
tile = new ol.Tile();
tile.toDrop = (i % 2 === 0) ? true : false;
goog.events.listen(tile, goog.events.EventType.CHANGE,
goog.nullFunction);
priority = Math.floor(Math.random() * 100);
tq.heap_.push([priority, tile, '', new ol.Coordinate(0, 0)]);
tq.queuedTileKeys_[tile.getKey()] = true;
tile.inQueue++;
tiles.push(tile);
}
return tiles;
}
describe('heapify', function() {
@@ -52,15 +45,16 @@ describe('ol.TileQueue', function() {
it('does reprioritize the array', function() {
var tq = new ol.TileQueue(function() {});
var tiles = addRandomPriorityTiles(tq, 100);
addRandomPriorityTiles(tq, 100);
tq.heapify_();
// now reprioritize, changing the priority of 50 tiles and removing the
// rest
tq.tilePriorityFunction_ = function(tile) {
if (tile.toDrop) {
var i = 0;
tq.tilePriorityFunction_ = function() {
if ((i++) % 2 === 0) {
return ol.TileQueue.DROP;
}
return Math.floor(Math.random() * 100);
@@ -70,23 +64,10 @@ describe('ol.TileQueue', function() {
expect(tq.heap_.length).toEqual(50);
expect(isHeap(tq)).toBeTruthy();
var i, tile;
for (i = 0; i < tiles.length; ++i) {
tile = tiles[i];
var hasListener = goog.events.hasListener(tile);
if (tile.toDrop) {
expect(hasListener).toBeFalsy();
} else {
expect(hasListener).toBeTruthy();
}
}
});
});
});
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.Coordinate');
goog.require('ol.Tile');
goog.require('ol.TileQueue');

View File

@@ -69,7 +69,7 @@ describe('ol.TileUrlFunction', function() {
});
});
it('creates expected URL', function() {
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
var epsg3857 = ol.projection.get('EPSG:3857');
var tileUrlFunction = ol.TileUrlFunction.createWMSParams(
'http://wms?foo=bar', {});
var tileCoord = new ol.TileCoord(1, 0, 0);
@@ -81,7 +81,7 @@ describe('ol.TileUrlFunction', function() {
expect(tileUrl).toEqual(expected);
});
it('creates expected URL respecting axis orientation', function() {
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
var epsg4326 = ol.projection.get('EPSG:4326');
var tileUrlFunction = ol.TileUrlFunction.createWMSParams(
'http://wms?foo=bar', {});
var tileCoord = new ol.TileCoord(1, 0, 0);