From 56b63d191ab9099d9f5996856a3ca1e60722339f Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 2 Jan 2019 16:34:33 -0500 Subject: [PATCH] Wrap pollToPromise blocks --- Specs/DataSources/GeometryVisualizerSpec.js | 264 ++++---------------- Specs/DataSources/PolylineVisualizerSpec.js | 257 ++++--------------- 2 files changed, 105 insertions(+), 416 deletions(-) diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index 489d7694c243..f7f0ba49c965 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -82,6 +82,24 @@ defineSuite([ }); + function visualizerUpdated(visualizer) { + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }); + } + + function visualizerEmpty(visualizer) { + return pollToPromise(function() { + scene.initializeFrame(); + expect(visualizer.update(time)).toBe(true); + scene.render(time); + return scene.primitives.length === 0 && scene.groundPrimitives.length === 0; + }); + } + it('Can create and destroy', function() { var objects = new EntityCollection(); var visualizer = new GeometryVisualizer(scene, objects, scene.primitives, scene.groundPrimitives); @@ -107,12 +125,7 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -123,12 +136,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -149,12 +157,7 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -165,12 +168,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -191,12 +189,7 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -207,12 +200,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -233,12 +221,7 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -249,12 +232,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -276,12 +254,7 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -291,12 +264,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -318,23 +286,13 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); expect(primitive.shadows).toBe(shadows); objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -371,23 +329,13 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.groundPrimitives.get(0); expect(primitive.classificationType).toBe(type); objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -420,12 +368,7 @@ defineSuite([ entity.ellipse = ellipse; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -435,12 +378,7 @@ defineSuite([ ellipse.material = new GridMaterialProperty(); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -476,12 +414,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -490,12 +423,7 @@ defineSuite([ color = Color.RED.withAlpha(0.5); entity.ellipse.outlineColor.setValue(color); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); @@ -662,12 +590,7 @@ defineSuite([ }); objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { objects.remove(entity); var entity2 = new Entity({ @@ -682,13 +605,7 @@ defineSuite([ }); objects.add(entity2); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { - + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity2); expect(attributes).toBeDefined(); @@ -698,12 +615,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function() { + return visualizerEmpty(visualizer).then(function() { visualizer.destroy(); }); }); @@ -724,12 +636,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -737,12 +644,7 @@ defineSuite([ entity.show = false; - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); @@ -769,12 +671,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -782,12 +679,7 @@ defineSuite([ entity.show = false; - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); @@ -815,12 +707,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -828,12 +715,7 @@ defineSuite([ entity.show = false; - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); @@ -862,12 +744,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { expect(scene.groundPrimitives.length).toEqual(1); entities.add({ @@ -879,12 +756,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(1); @@ -897,12 +769,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(2); @@ -930,12 +797,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { expect(scene.groundPrimitives.length).toEqual(1); entities.add({ @@ -948,12 +810,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(1); @@ -967,12 +824,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(1); @@ -986,12 +838,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(2); @@ -1005,12 +852,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(3); diff --git a/Specs/DataSources/PolylineVisualizerSpec.js b/Specs/DataSources/PolylineVisualizerSpec.js index 04b06751e870..e288753d9002 100644 --- a/Specs/DataSources/PolylineVisualizerSpec.js +++ b/Specs/DataSources/PolylineVisualizerSpec.js @@ -66,6 +66,24 @@ defineSuite([ ApproximateTerrainHeights._terrainHeights = undefined; }); + function visualizerUpdated(visualizer) { + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }); + } + + function visualizerEmpty(visualizer) { + return pollToPromise(function() { + scene.initializeFrame(); + expect(visualizer.update(time)).toBe(true); + scene.render(time); + return scene.primitives.length === 0 && scene.groundPrimitives.length === 0; + }); + } + it('Can create and destroy', function() { var objects = new EntityCollection(); var visualizer = new PolylineVisualizer(scene, objects); @@ -88,12 +106,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -104,12 +117,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -127,12 +135,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -143,12 +146,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -171,12 +169,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.groundPrimitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -187,12 +180,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.groundPrimitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -211,23 +199,13 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); expect(primitive.shadows).toBe(shadows); objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -263,12 +241,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -280,12 +253,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -305,12 +273,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -322,12 +285,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -347,12 +305,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -364,12 +317,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -389,12 +337,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -406,12 +349,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -435,23 +373,13 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.groundPrimitives.get(0); expect(primitive.classificationType).toBe(classificationType); objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function(){ + return visualizerEmpty(visualizer).then(function(){ visualizer.destroy(); }); }); @@ -481,12 +409,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -496,12 +419,7 @@ defineSuite([ polyline.material = new PolylineArrowMaterialProperty(); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { primitive = scene.primitives.get(0); attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -638,12 +556,7 @@ defineSuite([ }); objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { objects.remove(entity); var entity2 = new Entity({ @@ -656,13 +569,7 @@ defineSuite([ }); objects.add(entity2); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { - + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity2); expect(attributes).toBeDefined(); @@ -672,12 +579,7 @@ defineSuite([ objects.remove(entity); - return pollToPromise(function() { - scene.initializeFrame(); - expect(visualizer.update(time)).toBe(true); - scene.render(time); - return scene.primitives.length === 0; - }).then(function() { + return visualizerEmpty(visualizer).then(function() { visualizer.destroy(); }); }); @@ -695,12 +597,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -708,12 +605,7 @@ defineSuite([ entity.show = false; - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); @@ -737,12 +629,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -750,12 +637,7 @@ defineSuite([ entity.show = false; - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { var primitive = scene.primitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); @@ -784,12 +666,7 @@ defineSuite([ entity.polyline = polyline; objects.add(entity); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { var primitive = scene.groundPrimitives.get(0); var attributes = primitive.getGeometryInstanceAttributes(entity); expect(attributes).toBeDefined(); @@ -800,12 +677,7 @@ defineSuite([ entity.polyline.show = false; - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.primitives.length).toEqual(0); @@ -834,12 +706,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }).then(function() { + return visualizerUpdated(visualizer).then(function() { expect(scene.groundPrimitives.length).toEqual(1); entities.add({ @@ -851,12 +718,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(1); @@ -869,12 +731,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(1); @@ -887,12 +744,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(2); @@ -905,12 +757,7 @@ defineSuite([ } }); - return pollToPromise(function() { - scene.initializeFrame(); - var isUpdated = visualizer.update(time); - scene.render(time); - return isUpdated; - }); + return visualizerUpdated(visualizer); }).then(function() { expect(scene.groundPrimitives.length).toEqual(3);