Skip to content

Commit

Permalink
Merge pull request CesiumGS#2859 from AnalyticalGraphicsInc/fix-ie11-…
Browse files Browse the repository at this point in the history
…tests

Make most tests pass on IE11
  • Loading branch information
pjcozzi committed Jul 1, 2015
2 parents 0522254 + 056b0ae commit 15c7a99
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 166 deletions.
5 changes: 4 additions & 1 deletion Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,10 @@ define([

this._transitioner.destroy();

this._globeDepth.destroy();
if (defined(this._globeDepth)) {
this._globeDepth.destroy();
}

if (defined(this._oit)) {
this._oit.destroy();
}
Expand Down
4 changes: 3 additions & 1 deletion Specs/Scene/BillboardCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defineSuite([
'Core/Cartesian2',
'Core/Cartesian3',
'Core/Color',
'Core/defined',
'Core/Ellipsoid',
'Core/loadImage',
'Core/Math',
Expand All @@ -25,6 +26,7 @@ defineSuite([
Cartesian2,
Cartesian3,
Color,
defined,
Ellipsoid,
loadImage,
CesiumMath,
Expand Down Expand Up @@ -55,7 +57,7 @@ defineSuite([
scene = createScene();
camera = scene.camera;

heightReferenceSupported = scene._globeDepth.supported && scene.context.maximumVertexTextureImageUnits > 0;
heightReferenceSupported = defined(scene._globeDepth) && scene._globeDepth.supported && scene.context.maximumVertexTextureImageUnits > 0;

return when.join(
loadImage('./Data/Images/Green.png').then(function(result) {
Expand Down
4 changes: 3 additions & 1 deletion Specs/Scene/LabelCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defineSuite([
'Core/Cartesian2',
'Core/Cartesian3',
'Core/Color',
'Core/defined',
'Core/Ellipsoid',
'Core/Math',
'Core/NearFarScalar',
Expand All @@ -20,6 +21,7 @@ defineSuite([
Cartesian2,
Cartesian3,
Color,
defined,
Ellipsoid,
CesiumMath,
NearFarScalar,
Expand All @@ -44,7 +46,7 @@ defineSuite([
scene = createScene();
camera = scene.camera;

heightReferenceSupported = scene._globeDepth.supported && scene.context.maximumVertexTextureImageUnits > 0;
heightReferenceSupported = defined(scene._globeDepth) && scene._globeDepth.supported && scene.context.maximumVertexTextureImageUnits > 0;
});

afterAll(function() {
Expand Down
96 changes: 58 additions & 38 deletions Specs/Scene/SceneSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defineSuite([
'Core/Cartesian2',
'Core/Cartesian3',
'Core/Color',
'Core/defined',
'Core/Ellipsoid',
'Core/GeographicProjection',
'Core/PixelFormat',
Expand All @@ -30,6 +31,7 @@ defineSuite([
Cartesian2,
Cartesian3,
Color,
defined,
Ellipsoid,
GeographicProjection,
PixelFormat,
Expand Down Expand Up @@ -232,6 +234,10 @@ defineSuite([
});

it('debugShowGlobeDepth', function() {
if(!defined(scene._globeDepth)){
return;
}

var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
scene.camera.viewRectangle(rectangle);

Expand Down Expand Up @@ -393,8 +399,11 @@ defineSuite([
}

var s = createScene();
s._oit._translucentMRTSupport = false;
s._oit._translucentMultipassSupport = false;

if (defined(s._oit)) {
s._oit._translucentMRTSupport = false;
s._oit._translucentMultipassSupport = false;
}

s.fxaa = true;

Expand Down Expand Up @@ -463,35 +472,40 @@ defineSuite([
it('renders with multipass OIT if MRT is available', function() {
if (scene.context.drawBuffers) {
var s = createScene();
s._oit._translucentMRTSupport = false;
s._oit._translucentMultipassSupport = true;
if (defined(s._oit)) {
s._oit._translucentMRTSupport = false;
s._oit._translucentMultipassSupport = true;

var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);

var rectanglePrimitive = new RectanglePrimitive({
rectangle : rectangle,
height : 1000.0,
asynchronous : false
});
rectanglePrimitive.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);
var rectanglePrimitive = new RectanglePrimitive({
rectangle : rectangle,
height : 1000.0,
asynchronous : false
});
rectanglePrimitive.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);

var primitives = s.primitives;
primitives.add(rectanglePrimitive);
var primitives = s.primitives;
primitives.add(rectanglePrimitive);

s.camera.viewRectangle(rectangle);
s.camera.viewRectangle(rectangle);

var pixels = s.renderForSpecs();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
var pixels = s.renderForSpecs();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
}

s.destroyForSpecs();
}
});

it('renders with alpha blending if floating point textures are available', function() {
if (scene.context.floatingPointTexture) {
var s = createScene();
if (!scene.context.floatingPointTexture) {
return;
}
var s = createScene();
if (defined(s._oit)) {
s._oit._translucentMRTSupport = false;
s._oit._translucentMultipassSupport = false;

Expand All @@ -513,39 +527,45 @@ defineSuite([
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);

s.destroyForSpecs();
}
s.destroyForSpecs();
});

it('copies the globe depth', function() {
var scene = createScene();
if (defined(scene._globeDepth)) {
var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);

var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
var rectanglePrimitive = new RectanglePrimitive({
rectangle : rectangle,
height : 1000.0,
asynchronous : false
});
rectanglePrimitive.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);

var rectanglePrimitive = new RectanglePrimitive({
rectangle : rectangle,
height : 1000.0,
asynchronous : false
});
rectanglePrimitive.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);
var primitives = scene.primitives;
primitives.add(rectanglePrimitive);

var primitives = scene.primitives;
primitives.add(rectanglePrimitive);
scene.camera.viewRectangle(rectangle);

scene.camera.viewRectangle(rectangle);
var uniformState = scene.context.uniformState;

var uniformState = scene.context.uniformState;
scene.renderForSpecs();
expect(uniformState.globeDepthTexture).not.toBeDefined();

scene.renderForSpecs();
expect(uniformState.globeDepthTexture).not.toBeDefined();
scene.copyGlobeDepth = true;
scene.renderForSpecs();
expect(uniformState.globeDepthTexture).toBeDefined();
}

scene.copyGlobeDepth = true;
scene.renderForSpecs();
expect(uniformState.globeDepthTexture).toBeDefined();
scene.destroyForSpecs();
});

it('pickPosition', function() {
if (!scene.pickPositionSupported) {
return;
}

var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
scene.camera.viewRectangle(rectangle);

Expand Down
64 changes: 26 additions & 38 deletions Specs/Widgets/BaseLayerPicker/BaseLayerPickerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
defineSuite([
'Widgets/BaseLayerPicker/BaseLayerPicker',
'Core/EllipsoidTerrainProvider',
'Core/FeatureDetection',
'Scene/ImageryLayerCollection',
'Specs/DomEventSimulator'
], function(
BaseLayerPicker,
EllipsoidTerrainProvider,
FeatureDetection,
ImageryLayerCollection,
DomEventSimulator) {
"use strict";
Expand Down Expand Up @@ -35,49 +37,35 @@ defineSuite([
document.body.removeChild(container);
});

it('mousedown event closes dropdown if target is not inside container', function() {
var container = document.createElement('div');
container.id = 'testContainer';
document.body.appendChild(container);

var widget = new BaseLayerPicker('testContainer', {
globe : new MockGlobe()
});
function addCloseOnInputSpec(name, func){
it(name + ' event closes dropdown if target is not inside container', function() {
var container = document.createElement('div');
container.id = 'testContainer';
document.body.appendChild(container);

widget.viewModel.dropDownVisible = true;
DomEventSimulator.fireMouseDown(document.body);
expect(widget.viewModel.dropDownVisible).toEqual(false);
var widget = new BaseLayerPicker('testContainer', {
globe : new MockGlobe()
});

widget.viewModel.dropDownVisible = true;
DomEventSimulator.fireMouseDown(container.firstChild);
expect(widget.viewModel.dropDownVisible).toEqual(true);
widget.viewModel.dropDownVisible = true;
func(document.body);
expect(widget.viewModel.dropDownVisible).toEqual(false);

widget.destroy();
document.body.removeChild(container);
});
widget.viewModel.dropDownVisible = true;
func(container.firstChild);
expect(widget.viewModel.dropDownVisible).toEqual(true);

it('touchstart event closes dropdown if target is not inside container', function() {
var container = document.createElement('div');
container.id = 'testContainer';
document.body.appendChild(container);

var widget = new BaseLayerPicker('testContainer', {
globe : new MockGlobe()
widget.destroy();
document.body.removeChild(container);
});

widget.viewModel.dropDownVisible = true;

widget.viewModel.dropDownVisible = true;
DomEventSimulator.fireTouchStart(document.body);
expect(widget.viewModel.dropDownVisible).toEqual(false);

widget.viewModel.dropDownVisible = true;
DomEventSimulator.fireTouchStart(container.firstChild);
expect(widget.viewModel.dropDownVisible).toEqual(true);

widget.destroy();
document.body.removeChild(container);
});
}

if (FeatureDetection.supportsPointerEvents()) {
addCloseOnInputSpec('pointerDown', DomEventSimulator.firePointerDown);
} else {
addCloseOnInputSpec('mousedown', DomEventSimulator.fireMouseDown);
addCloseOnInputSpec('touchstart', DomEventSimulator.fireTouchStart);
}

it('constructor throws with no layer collection', function() {
expect(function() {
Expand Down
7 changes: 0 additions & 7 deletions Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,6 @@ defineSuite([
expect(contextAttributes.preserveDrawingBuffer).toEqual(webglOptions.preserveDrawingBuffer);
});

it('can enable Order Independent Translucency', function() {
widget = new CesiumWidget(container, {
orderIndependentTranslucency : true
});
expect(widget.scene.orderIndependentTranslucency).toBe(true);
});

it('can disable Order Independent Translucency', function() {
widget = new CesiumWidget(container, {
orderIndependentTranslucency : false
Expand Down
Loading

0 comments on commit 15c7a99

Please sign in to comment.