Skip to content

Commit

Permalink
Merge pull request #7104 from AnalyticalGraphicsInc/ie-tests
Browse files Browse the repository at this point in the history
Fix some IE tests
  • Loading branch information
lilleyse authored Oct 18, 2018
2 parents 420250e + 2ff95d3 commit 919ce81
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Specs/Scene/ExpressionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ defineSuite([
expect(expression.evaluate(undefined)).toEqual(new Cartesian3(0.0, 1.0, 2.0));

expression = new Expression('log2(vec4(1.0, 2.0, 4.0, 8.0))');
expect(expression.evaluate(undefined)).toEqual(new Cartesian4(0.0, 1.0, 2.0, 3.0));
expect(expression.evaluate(undefined)).toEqualEpsilon(new Cartesian4(0.0, 1.0, 2.0, 3.0), CesiumMath.EPSILON10);
});

it('throws if log2 function takes an invalid number of arguments', function() {
Expand Down
6 changes: 4 additions & 2 deletions Specs/Scene/GroundPrimitiveSpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defineSuite([
'Scene/GroundPrimitive',
'Core/ApproximateTerrainHeights',
'Core/arraySlice',
'Core/Color',
'Core/ColorGeometryInstanceAttribute',
'Core/destroyObject',
Expand All @@ -26,6 +27,7 @@ defineSuite([
], function(
GroundPrimitive,
ApproximateTerrainHeights,
arraySlice,
Color,
ColorGeometryInstanceAttribute,
destroyObject,
Expand Down Expand Up @@ -499,13 +501,13 @@ defineSuite([

largeScene.groundPrimitives.add(largeSceneDepthPrimitive);
expect(largeScene).toRenderAndCall(function(rgba) {
expect(rgba.slice(0, 4)).not.toEqual([0, 0, 0, 255]);
expect(arraySlice(rgba, 0, 4)).not.toEqual([0, 0, 0, 255]);
expect(rgba[0]).toEqual(0);
});

largeScene.groundPrimitives.add(groundPrimitive);
expect(largeScene).toRenderAndCall(function(rgba) {
expect(rgba.slice(0, 4)).toEqual(expectedColor);
expect(arraySlice(rgba, 0, 4)).toEqual(expectedColor);
});
}

Expand Down
4 changes: 3 additions & 1 deletion Specs/Scene/PointCloud3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ defineSuite([

tileset.style.color = new Expression('color("blue", 0.5)');
tileset.makeStyleDirty();
expect(scene).toRender([0, 0, 255, 255]);
expect(scene).toRenderAndCall(function(rgba) {
expect(rgba).toEqualEpsilon([0, 0, 255, 255], 5);
});

var i;
var commands = scene.frameState.commandList;
Expand Down
17 changes: 16 additions & 1 deletion Specs/addDefaultMatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
'Core/defaultValue',
'Core/defined',
'Core/DeveloperError',
'Core/FeatureDetection',
'Core/Math',
'Core/PrimitiveType',
'Core/RuntimeError',
Expand All @@ -19,6 +20,7 @@ define([
defaultValue,
defined,
DeveloperError,
FeatureDetection,
CesiumMath,
PrimitiveType,
RuntimeError,
Expand Down Expand Up @@ -599,6 +601,19 @@ define([
return scene.context.readPixels();
}

function isTypedArray(o) {
return FeatureDetection.typedArrayTypes.some(function(type) {
return o instanceof type;
});
}

function typedArrayToArray(array) {
if (isTypedArray(array)) {
return Array.prototype.slice.call(array, 0);
}
return array;
}

function renderEquals(util, customEqualityTesters, actual, expected, expectEqual) {
var actualRgba = renderAndReadPixels(actual);

Expand All @@ -617,7 +632,7 @@ define([

var message;
if (!pass) {
message = 'Expected ' + (expectEqual ? '' : 'not ') + 'to render [' + expected + '], but actually rendered [' + actualRgba + '].';
message = 'Expected ' + (expectEqual ? '' : 'not ') + 'to render [' + typedArrayToArray(expected) + '], but actually rendered [' + typedArrayToArray(actualRgba) + '].';
}

return {
Expand Down

0 comments on commit 919ce81

Please sign in to comment.