Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Apr 18, 2017
1 parent 60f303e commit 2c78cc9
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 444 deletions.
1 change: 0 additions & 1 deletion Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ define([
this._model.shadows = this._tileset.shadows;
this._model.debugWireframe = this._tileset.debugWireframe;
this._model.update(frameState);

frameState.addCommand = oldAddCommand;
};

Expand Down
14 changes: 7 additions & 7 deletions Source/Scene/Cesium3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,28 @@ define([
},

/**
* Gets the tile's batch table memory in bytes.
* Gets the tile's texture memory in bytes.
*
* @memberof Cesium3DTileContent.prototype
*
* @type {Number}
* @readonly
*/
batchTableMemorySizeInBytes : {
textureMemorySizeInBytes : {
get : function() {
DeveloperError.throwInstantiationError();
}
},

/**
* Gets the tile's texture memory in bytes.
* Gets the tile's batch table memory in bytes.
*
* @memberof Cesium3DTileContent.prototype
*
* @type {Number}
* @readonly
*/
textureMemorySizeInBytes : {
batchTableMemorySizeInBytes : {
get : function() {
DeveloperError.throwInstantiationError();
}
Expand All @@ -142,7 +142,7 @@ define([
* Gets the array of {@link Cesium3DTileContent} objects that represent the
* content a composite's inner tiles, which can also be composites.
*
* @memberof Composite3DTileContent.prototype
* @memberof Cesium3DTileContent.prototype
*
* @type {Array}
* @readonly
Expand All @@ -156,10 +156,10 @@ define([
/**
* Gets the promise that will be resolved when the tile's content is ready to render.
*
* @memberof Cesium3DTileContent.prototype
*
* @type {Promise.<Cesium3DTileContent>}
* @readonly
*
* @private
*/
readyPromise : {
get : function() {
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ define([
function selectionHeuristic(tileset, ancestor, tile) {
var skipLevels = tileset.skipLODs ? tileset._skipLevels : 0;
var skipSSEFactor = tileset.skipLODs ? tileset.skipSSEFactor : 0.1;
return (ancestor !== tile && tile.hasRenderableContent && !tileset.immediatelyLoadDesiredLOD) &&
return (ancestor !== tile && !tile.hasEmptyContent && !tileset.immediatelyLoadDesiredLOD) &&
(tile._sse < ancestor._sse / skipSSEFactor) &&
(tile._depth > ancestor._depth + skipLevels);
}
Expand Down
12 changes: 5 additions & 7 deletions Source/Scene/Composite3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ define([
'../Core/Request',
'../Core/RequestScheduler',
'../Core/RequestType',
'../ThirdParty/when',
'./Cesium3DTileContentState'
'../ThirdParty/when'
], function(
defaultValue,
defined,
Expand All @@ -23,8 +22,7 @@ define([
Request,
RequestScheduler,
RequestType,
when,
Cesium3DTileContentState) {
when) {
'use strict';

/**
Expand Down Expand Up @@ -206,7 +204,7 @@ define([
if (defined(contentFactory)) {
var innerContent = contentFactory(content._tileset, content._tile, content._url, arrayBuffer, byteOffset);
content._contents.push(innerContent);
contentPromises.push(content.readyPromise);
contentPromises.push(innerContent.readyPromise);
} else {
throw new DeveloperError('Unknown tile content type, ' + tileType + ', inside Composite tile');
}
Expand Down Expand Up @@ -235,11 +233,11 @@ define([
/**
* Part of the {@link Cesium3DTileContent} interface.
*/
Composite3DTileContent.prototype.update = function(tileset, context, frameState, commandList) {
Composite3DTileContent.prototype.update = function(tileset, frameState) {
var contents = this._contents;
var length = contents.length;
for (var i = 0; i < length; ++i) {
contents[i].update(tileset, context, frameState, commandList);
contents[i].update(tileset, frameState);
}
};

Expand Down
23 changes: 1 addition & 22 deletions Source/Scene/Empty3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,12 @@ define([
}
},

/**
* Part of the {@link Cesium3DTileContent} interface.
*/
contentReadyToProcessPromise : {
get : function() {
return this._contentReadyToProcessPromise.promise;
}
},

/**
* Part of the {@link Cesium3DTileContent} interface.
*/
readyPromise : {
get : function() {
return this._readyPromise.promise;
return undefined;
}
}
});
Expand All @@ -124,18 +115,6 @@ define([
return undefined;
};

/**
* Part of the {@link Cesium3DTileContent} interface.
*/
Empty3DTileContent.prototype.request = function() {
};

/**
* Part of the {@link Cesium3DTileContent} interface.
*/
Empty3DTileContent.prototype.initialize = function(arrayBuffer, byteOffset) {
};

/**
* Part of the {@link Cesium3DTileContent} interface.
*/
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4290,7 +4290,7 @@ define([
var extensionsUsed = model.gltf.extensionsUsed;
if (defined(extensionsUsed)) {
var extensionsUsedCount = extensionsUsed.length;
for (var index=0;index<extensionsUsedCount;++index) {
for (var index = 0; index < extensionsUsedCount; ++index) {
var extension = extensionsUsed[index];

if (extension !== 'CESIUM_RTC' && extension !== 'KHR_binary_glTF' &&
Expand Down
3 changes: 2 additions & 1 deletion Source/Scene/Tileset3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ define([
try {
tilesetJson = JSON.parse(jsonString);
} catch (error) {
content._readyPromise.reject(new DeveloperError('Invalid json content'));
content._readyPromise.reject(new DeveloperError('Invalid tile content.'));
return;
}

content._tileset.loadTileset(content._url, tilesetJson, content._tile);
Expand Down
49 changes: 5 additions & 44 deletions Specs/Cesium3DTilesTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,16 @@ define([
Cesium3DTilesTester.loadTileExpectError = function(scene, arrayBuffer, type) {
var tileset = {};
var url = '';
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url);
expect(function() {
content.initialize(arrayBuffer);
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url, arrayBuffer, type);
content.update(tileset, scene.frameState);
}).toThrowDeveloperError();
return content;
};

Cesium3DTilesTester.loadTile = function(scene, arrayBuffer, type) {
var tileset = {};
var url = '';
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url);
content.initialize(arrayBuffer);
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url, arrayBuffer, 0);
content.update(tileset, scene.frameState);
return content;
};
Expand All @@ -148,38 +145,21 @@ define([
baseUrl : counter++
};
var url = '';
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url);
content.initialize(arrayBuffer);
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url, arrayBuffer, 0);
content.update(tileset, scene.frameState);

return content.readyPromise.then(function(content) {
fail('should not resolve');
}).otherwise(function(error) {
expect(content.state).toEqual(Cesium3DTileContentState.FAILED);
});
};

Cesium3DTilesTester.rejectsReadyPromiseOnFailedRequest = function(type) {
var tileset = {
loadTileset : Cesium3DTileset.prototype.loadTileset
};
var url = 'invalid';
var content = Cesium3DTileContentFactory[type](tileset, mockTile, url);
content.request();

return content.readyPromise.then(function(content) {
fail('should not resolve');
}).otherwise(function(error) {
expect(content.state).toEqual(Cesium3DTileContentState.FAILED);
expect(error.statusCode).toEqual(404);
expect(error).toBeDefined();
});
};

Cesium3DTilesTester.resolvesReadyPromise = function(scene, url) {
return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) {
var content = tileset._root.content;
return content.readyPromise.then(function(content) {
expect(content.state).toEqual(Cesium3DTileContentState.READY);
expect(content).toBeDefined();
});
});
};
Expand All @@ -193,25 +173,6 @@ define([
});
};

Cesium3DTilesTester.tileDestroysBeforeLoad = function(scene, url) {
var tileset = scene.primitives.add(new Cesium3DTileset({
url : url
}));
scene.renderForSpecs();
return tileset.readyPromise.then(function(tileset) {
var content = tileset._root.content;
scene.renderForSpecs(); // Request root
scene.primitives.remove(tileset);

return content.readyPromise.then(function(content) {
fail('should not resolve');
}).otherwise(function(error) {
expect(content.state).toEqual(Cesium3DTileContentState.FAILED);
return content;
});
});
};

Cesium3DTilesTester.generateBatchedTileBuffer = function(options) {
// Procedurally generate the tile array buffer for testing purposes
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
Expand Down
Binary file not shown.
104 changes: 0 additions & 104 deletions Specs/Data/Cesium3DTiles/Tilesets/TilesetInvalid/tileset.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 2c78cc9

Please sign in to comment.