Best JavaScript code snippet using qawolf
PolylineGeometryUpdaterSpec.js
Source:PolylineGeometryUpdaterSpec.js
1defineSuite([2 'DataSources/PolylineGeometryUpdater',3 'Core/BoundingSphere',4 'Core/Cartesian3',5 'Core/Color',6 'Core/ColorGeometryInstanceAttribute',7 'Core/DistanceDisplayCondition',8 'Core/DistanceDisplayConditionGeometryInstanceAttribute',9 'Core/JulianDate',10 'Core/PolylinePipeline',11 'Core/ShowGeometryInstanceAttribute',12 'Core/TimeInterval',13 'Core/TimeIntervalCollection',14 'DataSources/BoundingSphereState',15 'DataSources/ColorMaterialProperty',16 'DataSources/ConstantProperty',17 'DataSources/Entity',18 'DataSources/GridMaterialProperty',19 'DataSources/PolylineGraphics',20 'DataSources/PropertyArray',21 'DataSources/SampledPositionProperty',22 'DataSources/SampledProperty',23 'DataSources/TimeIntervalCollectionProperty',24 'Scene/Globe',25 'Scene/ShadowMode',26 'Specs/createDynamicProperty',27 'Specs/createScene'28 ], function(29 PolylineGeometryUpdater,30 BoundingSphere,31 Cartesian3,32 Color,33 ColorGeometryInstanceAttribute,34 DistanceDisplayCondition,35 DistanceDisplayConditionGeometryInstanceAttribute,36 JulianDate,37 PolylinePipeline,38 ShowGeometryInstanceAttribute,39 TimeInterval,40 TimeIntervalCollection,41 BoundingSphereState,42 ColorMaterialProperty,43 ConstantProperty,44 Entity,45 GridMaterialProperty,46 PolylineGraphics,47 PropertyArray,48 SampledPositionProperty,49 SampledProperty,50 TimeIntervalCollectionProperty,51 Globe,52 ShadowMode,53 createDynamicProperty,54 createScene) {55 'use strict';56 var scene;57 beforeAll(function(){58 scene = createScene();59 scene.globe = new Globe();60 });61 afterAll(function(){62 scene.destroyForSpecs();63 });64 beforeEach(function() {65 scene.primitives.removeAll();66 });67 var time = JulianDate.now();68 function createBasicPolyline() {69 var polyline = new PolylineGraphics();70 polyline.positions = new ConstantProperty(Cartesian3.fromRadiansArray([71 0, 0,72 1, 0,73 1, 1,74 0, 175 ]));76 var entity = new Entity();77 entity.polyline = polyline;78 return entity;79 }80 it('Constructor sets expected defaults', function() {81 var entity = new Entity();82 var updater = new PolylineGeometryUpdater(entity, scene);83 expect(updater.isDestroyed()).toBe(false);84 expect(updater.entity).toBe(entity);85 expect(updater.isClosed).toBe(false);86 expect(updater.fillEnabled).toBe(false);87 expect(updater.fillMaterialProperty).toBe(undefined);88 expect(updater.depthFailMaterialProperty).toBe(undefined);89 expect(updater.outlineEnabled).toBe(false);90 expect(updater.hasConstantFill).toBe(true);91 expect(updater.hasConstantOutline).toBe(true);92 expect(updater.outlineColorProperty).toBe(undefined);93 expect(updater.shadowsProperty).toBe(undefined);94 expect(updater.distanceDisplayConditionProperty).toBe(undefined);95 expect(updater.isDynamic).toBe(false);96 expect(updater.isOutlineVisible(time)).toBe(false);97 expect(updater.isFilled(time)).toBe(false);98 updater.destroy();99 expect(updater.isDestroyed()).toBe(true);100 });101 it('No geometry available when polyline is undefined ', function() {102 var entity = createBasicPolyline();103 var updater = new PolylineGeometryUpdater(entity, scene);104 entity.polyline = undefined;105 expect(updater.fillEnabled).toBe(false);106 expect(updater.outlineEnabled).toBe(false);107 expect(updater.isDynamic).toBe(false);108 });109 it('No geometry available when not shown.', function() {110 var entity = createBasicPolyline();111 var updater = new PolylineGeometryUpdater(entity, scene);112 entity.polyline.show = new ConstantProperty(false);113 expect(updater.fillEnabled).toBe(false);114 expect(updater.outlineEnabled).toBe(false);115 expect(updater.isDynamic).toBe(false);116 });117 it('Values correct when using default graphics', function() {118 var entity = createBasicPolyline();119 var updater = new PolylineGeometryUpdater(entity, scene);120 expect(updater.isClosed).toBe(false);121 expect(updater.fillEnabled).toBe(true);122 expect(updater.fillMaterialProperty).toEqual(new ColorMaterialProperty(Color.WHITE));123 expect(updater.depthFailMaterialProperty).toBe(undefined);124 expect(updater.outlineEnabled).toBe(false);125 expect(updater.hasConstantFill).toBe(true);126 expect(updater.hasConstantOutline).toBe(true);127 expect(updater.outlineColorProperty).toBe(undefined);128 expect(updater.shadowsProperty).toEqual(new ConstantProperty(ShadowMode.DISABLED));129 expect(updater.distanceDisplayConditionProperty).toEqual(new ConstantProperty(new DistanceDisplayCondition()));130 expect(updater.isDynamic).toBe(false);131 });132 it('Polyline material is correctly exposed.', function() {133 var entity = createBasicPolyline();134 var updater = new PolylineGeometryUpdater(entity, scene);135 entity.polyline.material = new ColorMaterialProperty();136 expect(updater.fillMaterialProperty).toBe(entity.polyline.material);137 });138 it('Polyline depth fail material is correctly exposed.', function() {139 var entity = createBasicPolyline();140 var updater = new PolylineGeometryUpdater(entity, scene);141 entity.polyline.depthFailMaterial = new ColorMaterialProperty();142 expect(updater.depthFailMaterialProperty).toBe(entity.polyline.depthFailMaterial);143 });144 it('A time-varying positions causes geometry to be dynamic', function() {145 var entity = createBasicPolyline();146 var updater = new PolylineGeometryUpdater(entity, scene);147 var point1 = new SampledPositionProperty();148 point1.addSample(time, new Cartesian3());149 var point2 = new SampledPositionProperty();150 point2.addSample(time, new Cartesian3());151 var point3 = new SampledPositionProperty();152 point3.addSample(time, new Cartesian3());153 entity.polyline.positions = new PropertyArray();154 entity.polyline.positions.setValue([point1, point2, point3]);155 expect(updater.isDynamic).toBe(true);156 });157 it('A time-varying width causes geometry to be dynamic', function() {158 var entity = createBasicPolyline();159 var updater = new PolylineGeometryUpdater(entity, scene);160 entity.polyline.width = new SampledProperty(Number);161 entity.polyline.width.addSample(time, 1);162 expect(updater.isDynamic).toBe(true);163 });164 it('A time-varying followSurface causes geometry to be dynamic', function() {165 var followSurface = new TimeIntervalCollectionProperty();166 followSurface.intervals.addInterval(new TimeInterval({167 start : new JulianDate(0, 0),168 stop : new JulianDate(10, 0),169 data : false170 }));171 var entity = createBasicPolyline();172 var updater = new PolylineGeometryUpdater(entity, scene);173 entity.polyline.followSurface = followSurface;174 expect(updater.isDynamic).toBe(true);175 });176 it('A time-varying granularity causes geometry to be dynamic', function() {177 var entity = createBasicPolyline();178 var updater = new PolylineGeometryUpdater(entity, scene);179 entity.polyline.granularity = new SampledProperty(Number);180 entity.polyline.granularity.addSample(time, 1);181 expect(updater.isDynamic).toBe(true);182 });183 function validateGeometryInstance(options) {184 var entity = createBasicPolyline();185 var polyline = entity.polyline;186 polyline.show = new ConstantProperty(options.show);187 polyline.material = options.material;188 polyline.depthFailMaterial = options.depthFailMaterial;189 polyline.width = new ConstantProperty(options.width);190 polyline.followSurface = new ConstantProperty(options.followSurface);191 polyline.granularity = new ConstantProperty(options.granularity);192 polyline.distanceDisplayCondition = options.distanceDisplayCondition;193 var updater = new PolylineGeometryUpdater(entity, scene);194 var instance;195 var geometry;196 var attributes;197 instance = updater.createFillGeometryInstance(time);198 geometry = instance.geometry;199 expect(geometry._width).toEqual(options.width);200 expect(geometry._followSurface).toEqual(options.followSurface);201 expect(geometry._granularity).toEqual(options.granularity);202 attributes = instance.attributes;203 if (options.material instanceof ColorMaterialProperty) {204 expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.material.color.getValue(time)));205 } else {206 expect(attributes.color).toBeUndefined();207 }208 if (options.depthFailMaterial && options.depthFailMaterial instanceof ColorMaterialProperty) {209 expect(attributes.depthFailColor.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.depthFailMaterial.color.getValue(time)));210 } else {211 expect(attributes.depthFailColor).toBeUndefined();212 }213 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.show));214 if (options.distanceDisplayCondition) {215 expect(attributes.distanceDisplayCondition.value).toEqual(DistanceDisplayConditionGeometryInstanceAttribute.toValue(options.distanceDisplayCondition));216 }217 }218 it('Creates expected per-color geometry', function() {219 validateGeometryInstance({220 show : true,221 material : new ColorMaterialProperty(Color.RED),222 width : 3,223 followSurface : false,224 granularity : 1.0225 });226 });227 it('Creates expected per-color geometry with color depth fail appearance', function() {228 validateGeometryInstance({229 show : true,230 material : new ColorMaterialProperty(Color.RED),231 depthFailMaterial : new ColorMaterialProperty(Color.BLUE),232 width : 3,233 followSurface : false,234 granularity : 1.0235 });236 });237 it('Creates expected per-color geometry with material depth fail appearance', function() {238 validateGeometryInstance({239 show : true,240 material : new ColorMaterialProperty(Color.RED),241 depthFailMaterial : new GridMaterialProperty(),242 width : 3,243 followSurface : false,244 granularity : 1.0245 });246 });247 it('Creates expected per-material geometry', function() {248 validateGeometryInstance({249 show : true,250 material : new GridMaterialProperty(),251 width : 4,252 followSurface : true,253 granularity : 0.5254 });255 });256 it('Creates expected per-material geometry with color depth fail appearance', function() {257 validateGeometryInstance({258 show : true,259 material : new GridMaterialProperty(),260 depthFailMaterial : new ColorMaterialProperty(Color.BLUE),261 width : 4,262 followSurface : true,263 granularity : 0.5264 });265 });266 it('Creates expected per-material geometry with color depth fail appearance', function() {267 validateGeometryInstance({268 show : true,269 material : new GridMaterialProperty(),270 depthFailMaterial : new GridMaterialProperty(),271 width : 4,272 followSurface : true,273 granularity : 0.5274 });275 });276 it('Creates expected distance display condition geometry', function() {277 validateGeometryInstance({278 show : true,279 material : new ColorMaterialProperty(Color.RED),280 width : 3,281 followSurface : false,282 granularity : 1.0,283 distanceDisplayCondition : new DistanceDisplayCondition(10.0, 100.0)284 });285 });286 it('Attributes have expected values at creation time', function() {287 var time1 = new JulianDate(0, 0);288 var time2 = new JulianDate(10, 0);289 var time3 = new JulianDate(20, 0);290 var show = new TimeIntervalCollectionProperty();291 show.intervals.addInterval(new TimeInterval({292 start : time1,293 stop : time2,294 data : false295 }));296 show.intervals.addInterval(new TimeInterval({297 start : time2,298 stop : time3,299 isStartIncluded : false,300 data : true301 }));302 var colorMaterial = new ColorMaterialProperty();303 colorMaterial.color = new SampledProperty(Color);304 colorMaterial.color.addSample(time, Color.YELLOW);305 colorMaterial.color.addSample(time2, Color.BLUE);306 colorMaterial.color.addSample(time3, Color.RED);307 var entity = createBasicPolyline();308 entity.polyline.show = show;309 entity.polyline.material = colorMaterial;310 var updater = new PolylineGeometryUpdater(entity, scene);311 var instance = updater.createFillGeometryInstance(time2);312 var attributes = instance.attributes;313 expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(colorMaterial.color.getValue(time2)));314 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(show.getValue(time2)));315 });316 it('createFillGeometryInstance obeys Entity.show is false.', function() {317 var entity = createBasicPolyline();318 entity.show = false;319 entity.polyline.fill = true;320 var updater = new PolylineGeometryUpdater(entity, scene);321 var instance = updater.createFillGeometryInstance(new JulianDate());322 var attributes = instance.attributes;323 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(false));324 });325 it('dynamic updater sets properties', function() {326 var entity = new Entity();327 var polyline = new PolylineGraphics();328 entity.polyline = polyline;329 var time = new JulianDate(0, 0);330 var time2 = new JulianDate(10, 0);331 var time3 = new JulianDate(20, 0);332 var width = new SampledProperty(Number);333 width.addSample(time, 1);334 width.addSample(time2, 2);335 width.addSample(time3, 3);336 polyline.show = new ConstantProperty(true);337 polyline.width = width;338 polyline.positions = new ConstantProperty([Cartesian3.fromDegrees(0, 0, 0), Cartesian3.fromDegrees(0, 1, 0)]);339 polyline.material = new ColorMaterialProperty(Color.RED);340 polyline.followSurface = new ConstantProperty(false);341 polyline.granularity = new ConstantProperty(0.001);342 var updater = new PolylineGeometryUpdater(entity, scene);343 var primitives = scene.primitives;344 expect(primitives.length).toBe(0);345 var dynamicUpdater = updater.createDynamicUpdater(primitives);346 expect(dynamicUpdater.isDestroyed()).toBe(false);347 expect(primitives.length).toBe(1);348 dynamicUpdater.update(time2);349 var polylineCollection = primitives.get(0);350 var primitive = polylineCollection.get(0);351 expect(primitive.show).toEqual(true);352 expect(primitive.width).toEqual(2);353 expect(primitive.material.type).toEqual('Color');354 expect(primitive.material.uniforms.color).toEqual(Color.RED);355 expect(primitive.positions.length).toEqual(2);356 polyline.followSurface = new ConstantProperty(true);357 dynamicUpdater.update(time3);358 expect(primitive.width).toEqual(3);359 expect(primitive.positions.length).toBeGreaterThan(2);360 dynamicUpdater.destroy();361 expect(primitives.length).toBe(0);362 updater.destroy();363 });364 it('geometryChanged event is raised when expected', function() {365 var entity = createBasicPolyline();366 var updater = new PolylineGeometryUpdater(entity, scene);367 var listener = jasmine.createSpy('listener');368 updater.geometryChanged.addEventListener(listener);369 entity.polyline.positions = new ConstantProperty(Cartesian3.fromRadiansArray([370 0, 0,371 1, 0372 ]));373 expect(listener.calls.count()).toEqual(1);374 entity.polyline.width = new ConstantProperty(82);375 expect(listener.calls.count()).toEqual(2);376 entity.availability = new TimeIntervalCollection();377 expect(listener.calls.count()).toEqual(3);378 entity.polyline.positions = undefined;379 expect(listener.calls.count()).toEqual(4);380 //Since there's no valid geometry, changing another property should not raise the event.381 entity.polyline.width = undefined;382 //Modifying an unrelated property should not have any effect.383 entity.viewFrom = new ConstantProperty(Cartesian3.UNIT_X);384 expect(listener.calls.count()).toEqual(4);385 });386 it('createFillGeometryInstance throws if object is not shown', function() {387 var entity = new Entity();388 var updater = new PolylineGeometryUpdater(entity, scene);389 expect(function() {390 return updater.createFillGeometryInstance(time);391 }).toThrowDeveloperError();392 });393 it('createFillGeometryInstance throws if no time provided', function() {394 var entity = createBasicPolyline();395 var updater = new PolylineGeometryUpdater(entity, scene);396 expect(function() {397 return updater.createFillGeometryInstance(undefined);398 }).toThrowDeveloperError();399 });400 it('createOutlineGeometryInstance throws', function() {401 var entity = new Entity();402 var updater = new PolylineGeometryUpdater(entity, scene);403 expect(function() {404 return updater.createOutlineGeometryInstance();405 }).toThrowDeveloperError();406 });407 it('createDynamicUpdater throws if not dynamic', function() {408 var entity = createBasicPolyline();409 var updater = new PolylineGeometryUpdater(entity, scene);410 expect(function() {411 return updater.createDynamicUpdater(scene.primitives);412 }).toThrowDeveloperError();413 updater.destroy();414 });415 it('createDynamicUpdater throws if primitives undefined', function() {416 var entity = createBasicPolyline();417 entity.polyline.width = new SampledProperty(Number);418 entity.polyline.width.addSample(time, 4);419 var updater = new PolylineGeometryUpdater(entity, scene);420 expect(updater.isDynamic).toBe(true);421 expect(function() {422 return updater.createDynamicUpdater(undefined);423 }).toThrowDeveloperError();424 updater.destroy();425 });426 it('dynamicUpdater.update throws if no time specified', function() {427 var entity = createBasicPolyline();428 entity.polyline.width = new SampledProperty(Number);429 entity.polyline.width.addSample(time, 4);430 var updater = new PolylineGeometryUpdater(entity, scene);431 var dynamicUpdater = updater.createDynamicUpdater(scene.primitives);432 expect(function() {433 dynamicUpdater.update(undefined);434 }).toThrowDeveloperError();435 updater.destroy();436 });437 it('Constructor throws if no entity supplied', function() {438 expect(function() {439 return new PolylineGeometryUpdater(undefined, scene);440 }).toThrowDeveloperError();441 });442 it('Constructor throws if no scene supplied', function() {443 var entity = new Entity();444 expect(function() {445 return new PolylineGeometryUpdater(entity, undefined);446 }).toThrowDeveloperError();447 });448 it('Computes dynamic geometry bounding sphere for fill.', function() {449 var entity = createBasicPolyline();450 entity.polyline.width = createDynamicProperty(1);451 var updater = new PolylineGeometryUpdater(entity, scene);452 var dynamicUpdater = updater.createDynamicUpdater(scene.primitives);453 dynamicUpdater.update(time);454 var result = new BoundingSphere(0);455 var state = dynamicUpdater.getBoundingSphere(entity, result);456 expect(state).toBe(BoundingSphereState.DONE);457 var primitive = scene.primitives.get(0);458 var line = primitive.get(0);459 expect(result).toEqual(BoundingSphere.fromPoints(line.positions));460 updater.destroy();461 scene.primitives.removeAll();462 });463 it('Fails dynamic geometry bounding sphere for entity without billboard.', function() {464 var entity = createBasicPolyline();465 entity.polyline.width = createDynamicProperty(1);466 var updater = new PolylineGeometryUpdater(entity, scene);467 var dynamicUpdater = updater.createDynamicUpdater(scene.primitives);468 var result = new BoundingSphere();469 var state = dynamicUpdater.getBoundingSphere(entity, result);470 expect(state).toBe(BoundingSphereState.FAILED);471 updater.destroy();472 scene.primitives.removeAll();473 });474 it('Compute dynamic geometry bounding sphere throws without entity.', function() {475 var entity = createBasicPolyline();476 entity.polyline.width = createDynamicProperty(1);477 var updater = new PolylineGeometryUpdater(entity, scene);478 var dynamicUpdater = updater.createDynamicUpdater(scene.primitives);479 var result = new BoundingSphere();480 expect(function() {481 dynamicUpdater.getBoundingSphere(undefined, result);482 }).toThrowDeveloperError();483 updater.destroy();484 scene.primitives.removeAll();485 });486 it('Compute dynamic geometry bounding sphere throws without result.', function() {487 var entity = createBasicPolyline();488 entity.polyline.width = createDynamicProperty(1);489 var updater = new PolylineGeometryUpdater(entity, scene);490 var dynamicUpdater = updater.createDynamicUpdater(scene.primitives);491 expect(function() {492 dynamicUpdater.getBoundingSphere(entity, undefined);493 }).toThrowDeveloperError();494 updater.destroy();495 scene.primitives.removeAll();496 });497 it('followSurface true with undefined globe does not call generateCartesianArc', function() {498 var entity = createBasicPolyline();499 entity.polyline.width = createDynamicProperty(1);500 scene.globe = undefined;501 var updater = new PolylineGeometryUpdater(entity, scene);502 var dynamicUpdater = updater.createDynamicUpdater(scene.primitives);503 spyOn(PolylinePipeline, 'generateCartesianArc').and.callThrough();504 dynamicUpdater.update(time);505 expect(PolylinePipeline.generateCartesianArc).not.toHaveBeenCalled();506 updater.destroy();507 scene.primitives.removeAll();508 scene.globe = new Globe();509 });...
BoxGeometryUpdaterSpec.js
Source:BoxGeometryUpdaterSpec.js
1defineSuite([2 'DataSources/BoxGeometryUpdater',3 'Core/Cartesian3',4 'Core/Color',5 'Core/ColorGeometryInstanceAttribute',6 'Core/DistanceDisplayCondition',7 'Core/DistanceDisplayConditionGeometryInstanceAttribute',8 'Core/JulianDate',9 'Core/ShowGeometryInstanceAttribute',10 'Core/TimeInterval',11 'Core/TimeIntervalCollection',12 'DataSources/BoxGraphics',13 'DataSources/ColorMaterialProperty',14 'DataSources/ConstantPositionProperty',15 'DataSources/ConstantProperty',16 'DataSources/Entity',17 'DataSources/GridMaterialProperty',18 'DataSources/SampledProperty',19 'DataSources/TimeIntervalCollectionProperty',20 'Scene/PrimitiveCollection',21 'Scene/ShadowMode',22 'Specs/createDynamicGeometryBoundingSphereSpecs',23 'Specs/createDynamicProperty',24 'Specs/createScene'25 ], function(26 BoxGeometryUpdater,27 Cartesian3,28 Color,29 ColorGeometryInstanceAttribute,30 DistanceDisplayCondition,31 DistanceDisplayConditionGeometryInstanceAttribute,32 JulianDate,33 ShowGeometryInstanceAttribute,34 TimeInterval,35 TimeIntervalCollection,36 BoxGraphics,37 ColorMaterialProperty,38 ConstantPositionProperty,39 ConstantProperty,40 Entity,41 GridMaterialProperty,42 SampledProperty,43 TimeIntervalCollectionProperty,44 PrimitiveCollection,45 ShadowMode,46 createDynamicGeometryBoundingSphereSpecs,47 createDynamicProperty,48 createScene) {49 'use strict';50 var scene;51 var time;52 beforeAll(function() {53 scene = createScene();54 time = JulianDate.now();55 });56 afterAll(function() {57 scene.destroyForSpecs();58 });59 function createBasicBox() {60 var box = new BoxGraphics();61 box.dimensions = new ConstantProperty(new Cartesian3(1, 2, 3));62 var entity = new Entity();63 entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0, 0, 0));64 entity.box = box;65 return entity;66 }67 it('Constructor sets expected defaults', function() {68 var entity = new Entity();69 var updater = new BoxGeometryUpdater(entity, scene);70 expect(updater.isDestroyed()).toBe(false);71 expect(updater.entity).toBe(entity);72 expect(updater.isClosed).toBe(true);73 expect(updater.fillEnabled).toBe(false);74 expect(updater.fillMaterialProperty).toBe(undefined);75 expect(updater.outlineEnabled).toBe(false);76 expect(updater.hasConstantFill).toBe(true);77 expect(updater.hasConstantOutline).toBe(true);78 expect(updater.outlineColorProperty).toBe(undefined);79 expect(updater.outlineWidth).toBe(1.0);80 expect(updater.shadowsProperty).toBe(undefined);81 expect(updater.distanceDisplayConditionProperty).toBe(undefined);82 expect(updater.isDynamic).toBe(false);83 expect(updater.isOutlineVisible(time)).toBe(false);84 expect(updater.isFilled(time)).toBe(false);85 updater.destroy();86 expect(updater.isDestroyed()).toBe(true);87 });88 it('No geometry available when box is undefined ', function() {89 var entity = createBasicBox();90 var updater = new BoxGeometryUpdater(entity, scene);91 entity.box = undefined;92 expect(updater.fillEnabled).toBe(false);93 expect(updater.outlineEnabled).toBe(false);94 expect(updater.isDynamic).toBe(false);95 });96 it('No geometry available when not filled or outline.', function() {97 var entity = createBasicBox();98 var updater = new BoxGeometryUpdater(entity, scene);99 entity.box.fill = new ConstantProperty(false);100 entity.box.outline = new ConstantProperty(false);101 expect(updater.fillEnabled).toBe(false);102 expect(updater.outlineEnabled).toBe(false);103 expect(updater.isDynamic).toBe(false);104 });105 it('Values correct when using default graphics', function() {106 var entity = createBasicBox();107 var updater = new BoxGeometryUpdater(entity, scene);108 expect(updater.isClosed).toBe(true);109 expect(updater.fillEnabled).toBe(true);110 expect(updater.fillMaterialProperty).toEqual(new ColorMaterialProperty(Color.WHITE));111 expect(updater.outlineEnabled).toBe(false);112 expect(updater.hasConstantFill).toBe(true);113 expect(updater.hasConstantOutline).toBe(true);114 expect(updater.outlineColorProperty).toBe(undefined);115 expect(updater.outlineWidth).toBe(1.0);116 expect(updater.shadowsProperty).toEqual(new ConstantProperty(ShadowMode.DISABLED));117 expect(updater.distanceDisplayConditionProperty).toEqual(new ConstantProperty(new DistanceDisplayCondition()));118 expect(updater.isDynamic).toBe(false);119 });120 it('Box material is correctly exposed.', function() {121 var entity = createBasicBox();122 var updater = new BoxGeometryUpdater(entity, scene);123 entity.box.material = new GridMaterialProperty(Color.BLUE);124 expect(updater.fillMaterialProperty).toBe(entity.box.material);125 });126 it('A time-varying outlineWidth causes geometry to be dynamic', function() {127 var entity = createBasicBox();128 var updater = new BoxGeometryUpdater(entity, scene);129 entity.box.outlineWidth = createDynamicProperty();130 expect(updater.isDynamic).toBe(true);131 });132 it('A time-varying dimensions causes geometry to be dynamic', function() {133 var entity = createBasicBox();134 var updater = new BoxGeometryUpdater(entity, scene);135 entity.box.dimensions = createDynamicProperty();136 expect(updater.isDynamic).toBe(true);137 });138 function validateGeometryInstance(options) {139 var entity = createBasicBox();140 var box = entity.box;141 box.show = new ConstantProperty(options.show);142 box.fill = new ConstantProperty(options.fill);143 box.material = options.material;144 box.outline = new ConstantProperty(options.outline);145 box.outlineColor = new ConstantProperty(options.outlineColor);146 box.dimensions = new ConstantProperty(options.dimensions);147 box.distanceDisplayCondition = options.distanceDisplayCondition;148 var updater = new BoxGeometryUpdater(entity, scene);149 var instance;150 var geometry;151 var attributes;152 if (options.fill) {153 instance = updater.createFillGeometryInstance(time);154 geometry = instance.geometry;155 expect(geometry._maximum).toEqual(Cartesian3.multiplyByScalar(options.dimensions, 0.5, new Cartesian3()));156 attributes = instance.attributes;157 if (options.material instanceof ColorMaterialProperty) {158 expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.material.color.getValue(time)));159 } else {160 expect(attributes.color).toBeUndefined();161 }162 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));163 if (options.distanceDisplayCondition) {164 expect(attributes.distanceDisplayCondition.value).toEqual(DistanceDisplayConditionGeometryInstanceAttribute.toValue(options.distanceDisplayCondition));165 }166 }167 if (options.outline) {168 instance = updater.createOutlineGeometryInstance(time);169 geometry = instance.geometry;170 expect(geometry._max).toEqual(Cartesian3.multiplyByScalar(options.dimensions, 0.5, new Cartesian3()));171 attributes = instance.attributes;172 expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.outlineColor));173 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));174 if (options.distanceDisplayCondition) {175 expect(attributes.distanceDisplayCondition.value).toEqual(DistanceDisplayConditionGeometryInstanceAttribute.toValue(options.distanceDisplayCondition));176 }177 }178 }179 it('Creates expected per-color geometry', function() {180 validateGeometryInstance({181 show : true,182 material : new ColorMaterialProperty(Color.RED),183 fill : true,184 outline : true,185 outlineColor : Color.BLUE,186 dimensions : new Cartesian3(1, 2, 3)187 });188 });189 it('Creates expected per-material geometry', function() {190 validateGeometryInstance({191 show : true,192 material : new GridMaterialProperty(),193 fill : true,194 outline : true,195 outlineColor : Color.BLUE,196 dimensions : new Cartesian3(1, 2, 3)197 });198 });199 it('Creates expected distance display condition geometry', function() {200 validateGeometryInstance({201 show : true,202 material : new ColorMaterialProperty(Color.RED),203 fill : true,204 outline : true,205 outlineColor : Color.BLUE,206 dimensions : new Cartesian3(1, 2, 3),207 distanceDisplayCondition : new DistanceDisplayCondition(10.0, 100.0)208 });209 });210 it('Correctly exposes outlineWidth', function() {211 var entity = createBasicBox();212 entity.box.outlineWidth = new ConstantProperty(8);213 var updater = new BoxGeometryUpdater(entity, scene);214 expect(updater.outlineWidth).toBe(8);215 });216 it('Attributes have expected values at creation time', function() {217 var time1 = new JulianDate(0, 0);218 var time2 = new JulianDate(10, 0);219 var time3 = new JulianDate(20, 0);220 var fill = new TimeIntervalCollectionProperty();221 fill.intervals.addInterval(new TimeInterval({222 start : time1,223 stop : time2,224 data : false225 }));226 fill.intervals.addInterval(new TimeInterval({227 start : time2,228 stop : time3,229 isStartIncluded : false,230 data : true231 }));232 var colorMaterial = new ColorMaterialProperty();233 colorMaterial.color = new SampledProperty(Color);234 colorMaterial.color.addSample(time, Color.YELLOW);235 colorMaterial.color.addSample(time2, Color.BLUE);236 colorMaterial.color.addSample(time3, Color.RED);237 var outline = new TimeIntervalCollectionProperty();238 outline.intervals.addInterval(new TimeInterval({239 start : time1,240 stop : time2,241 data : false242 }));243 outline.intervals.addInterval(new TimeInterval({244 start : time2,245 stop : time3,246 isStartIncluded : false,247 data : true248 }));249 var outlineColor = new SampledProperty(Color);250 outlineColor.addSample(time, Color.BLUE);251 outlineColor.addSample(time2, Color.RED);252 outlineColor.addSample(time3, Color.YELLOW);253 var entity = createBasicBox();254 entity.box.fill = fill;255 entity.box.material = colorMaterial;256 entity.box.outline = outline;257 entity.box.outlineColor = outlineColor;258 var updater = new BoxGeometryUpdater(entity, scene);259 var instance = updater.createFillGeometryInstance(time2);260 var attributes = instance.attributes;261 expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(colorMaterial.color.getValue(time2)));262 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(fill.getValue(time2)));263 instance = updater.createOutlineGeometryInstance(time2);264 attributes = instance.attributes;265 expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(outlineColor.getValue(time2)));266 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(outline.getValue(time2)));267 });268 it('createFillGeometryInstance obeys Entity.show is false.', function() {269 var entity = createBasicBox();270 entity.show = false;271 entity.box.fill = true;272 var updater = new BoxGeometryUpdater(entity, scene);273 var instance = updater.createFillGeometryInstance(new JulianDate());274 var attributes = instance.attributes;275 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(false));276 });277 it('createOutlineGeometryInstance obeys Entity.show is false.', function() {278 var entity = createBasicBox();279 entity.show = false;280 entity.box.outline = true;281 var updater = new BoxGeometryUpdater(entity, scene);282 var instance = updater.createFillGeometryInstance(new JulianDate());283 var attributes = instance.attributes;284 expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(false));285 });286 it('dynamic updater sets properties', function() {287 var entity = new Entity();288 entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0, 0, 0));289 var box = new BoxGraphics();290 entity.box = box;291 box.show = createDynamicProperty(true);292 box.dimensions = createDynamicProperty(new Cartesian3(1, 2, 3));293 box.outline = createDynamicProperty(true);294 box.fill = createDynamicProperty(true);295 var updater = new BoxGeometryUpdater(entity, scene);296 var primitives = new PrimitiveCollection();297 var dynamicUpdater = updater.createDynamicUpdater(primitives);298 expect(primitives.length).toBe(0);299 dynamicUpdater.update(JulianDate.now());300 expect(primitives.length).toBe(2);301 expect(dynamicUpdater.isDestroyed()).toBe(false);302 expect(dynamicUpdater._options.id).toBe(entity);303 expect(dynamicUpdater._options.dimensions).toEqual(box.dimensions.getValue());304 entity.show = false;305 dynamicUpdater.update(JulianDate.now());306 expect(primitives.length).toBe(0);307 entity.show = true;308 box.show.setValue(false);309 dynamicUpdater.update(JulianDate.now());310 expect(primitives.length).toBe(0);311 box.show.setValue(true);312 box.fill.setValue(false);313 dynamicUpdater.update(JulianDate.now());314 expect(primitives.length).toBe(1);315 box.fill.setValue(true);316 box.outline.setValue(false);317 dynamicUpdater.update(JulianDate.now());318 expect(primitives.length).toBe(1);319 dynamicUpdater.destroy();320 expect(primitives.length).toBe(0);321 updater.destroy();322 });323 it('dynamic updater does not create primitives when dimensions.getValue() is undefined', function() {324 var entity = new Entity();325 entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0, 0, 0));326 var box = new BoxGraphics();327 entity.box = box;328 box.show = createDynamicProperty(true);329 box.dimensions = createDynamicProperty(undefined);330 box.outline = createDynamicProperty(true);331 box.fill = createDynamicProperty(true);332 var updater = new BoxGeometryUpdater(entity, scene);333 var primitives = new PrimitiveCollection();334 var dynamicUpdater = updater.createDynamicUpdater(primitives);335 dynamicUpdater.update(JulianDate.now());336 expect(primitives.length).toBe(0);337 box.dimensions.setValue(new Cartesian3(1, 2, 3));338 dynamicUpdater.update(JulianDate.now());339 expect(primitives.length).toBe(2);340 updater.destroy();341 });342 it('geometryChanged event is raised when expected', function() {343 var entity = createBasicBox();344 var updater = new BoxGeometryUpdater(entity, scene);345 var listener = jasmine.createSpy('listener');346 updater.geometryChanged.addEventListener(listener);347 entity.box.dimensions = new ConstantProperty();348 expect(listener.calls.count()).toEqual(1);349 entity.availability = new TimeIntervalCollection();350 expect(listener.calls.count()).toEqual(2);351 entity.box.dimensions = undefined;352 expect(listener.calls.count()).toEqual(3);353 //Since there's no valid geometry, changing another property should not raise the event.354 entity.box.height = undefined;355 //Modifying an unrelated property should not have any effect.356 entity.viewFrom = new ConstantProperty(Cartesian3.UNIT_X);357 expect(listener.calls.count()).toEqual(3);358 });359 it('createFillGeometryInstance throws if object is not filled', function() {360 var entity = new Entity();361 var updater = new BoxGeometryUpdater(entity, scene);362 expect(function() {363 return updater.createFillGeometryInstance(time);364 }).toThrowDeveloperError();365 });366 it('createFillGeometryInstance throws if no time provided', function() {367 var entity = createBasicBox();368 var updater = new BoxGeometryUpdater(entity, scene);369 expect(function() {370 return updater.createFillGeometryInstance(undefined);371 }).toThrowDeveloperError();372 });373 it('createOutlineGeometryInstance throws if object is not outlined', function() {374 var entity = new Entity();375 var updater = new BoxGeometryUpdater(entity, scene);376 expect(function() {377 return updater.createOutlineGeometryInstance(time);378 }).toThrowDeveloperError();379 });380 it('createOutlineGeometryInstance throws if no time provided', function() {381 var entity = createBasicBox();382 entity.box.outline = new ConstantProperty(true);383 var updater = new BoxGeometryUpdater(entity, scene);384 expect(function() {385 return updater.createOutlineGeometryInstance(undefined);386 }).toThrowDeveloperError();387 });388 it('createDynamicUpdater throws if not dynamic', function() {389 var entity = createBasicBox();390 var updater = new BoxGeometryUpdater(entity, scene);391 expect(function() {392 return updater.createDynamicUpdater(new PrimitiveCollection());393 }).toThrowDeveloperError();394 });395 it('createDynamicUpdater throws if primitives undefined', function() {396 var entity = createBasicBox();397 entity.box.dimensions = createDynamicProperty(new Cartesian3(1, 2, 3));398 var updater = new BoxGeometryUpdater(entity, scene);399 expect(updater.isDynamic).toBe(true);400 expect(function() {401 return updater.createDynamicUpdater(undefined);402 }).toThrowDeveloperError();403 });404 it('dynamicUpdater.update throws if no time specified', function() {405 var entity = createBasicBox();406 entity.box.dimensions = createDynamicProperty(new Cartesian3(1, 2, 3));407 var updater = new BoxGeometryUpdater(entity, scene);408 var dynamicUpdater = updater.createDynamicUpdater(new PrimitiveCollection());409 expect(function() {410 dynamicUpdater.update(undefined);411 }).toThrowDeveloperError();412 });413 it('Constructor throws if no Entity supplied', function() {414 expect(function() {415 return new BoxGeometryUpdater(undefined, scene);416 }).toThrowDeveloperError();417 });418 it('Constructor throws if no scene supplied', function() {419 var entity = createBasicBox();420 expect(function() {421 return new BoxGeometryUpdater(entity, undefined);422 }).toThrowDeveloperError();423 });424 var entity = createBasicBox();425 entity.box.dimensions = createDynamicProperty(new Cartesian3(1, 2, 3));426 createDynamicGeometryBoundingSphereSpecs(BoxGeometryUpdater, entity, entity.box, function() {427 return scene;428 });...
createGeometryUpdaterGroundGeometrySpecs.js
Source:createGeometryUpdaterGroundGeometrySpecs.js
1import { Color } from "../Source/Cesium.js";2import { GeometryOffsetAttribute } from "../Source/Cesium.js";3import { JulianDate } from "../Source/Cesium.js";4import { ColorMaterialProperty } from "../Source/Cesium.js";5import { ConstantProperty } from "../Source/Cesium.js";6import { SampledProperty } from "../Source/Cesium.js";7import { ClassificationType } from "../Source/Cesium.js";8import { GroundPrimitive } from "../Source/Cesium.js";9import { HeightReference } from "../Source/Cesium.js";10import { PrimitiveCollection } from "../Source/Cesium.js";11function createGeometryUpdaterGroundGeometrySpecs(12 Updater,13 geometryPropertyName,14 createEntity,15 createDynamicEntity,16 getScene17) {18 var time = JulianDate.now();19 it("has default zIndex of zero", function () {20 var entity = createEntity();21 var updater = new Updater(entity, getScene());22 expect(updater.zIndex.getValue()).toBe(0);23 });24 it("uses zIndex value", function () {25 var entity = createEntity();26 entity[geometryPropertyName].zIndex = 22;27 var updater = new Updater(entity, getScene());28 expect(updater.zIndex.getValue()).toBe(22);29 });30 it("A time-varying color does not cause ground geometry to be dynamic", function () {31 var entity = createEntity();32 var color = new SampledProperty(Color);33 color.addSample(time, Color.WHITE);34 entity[geometryPropertyName].material = new ColorMaterialProperty(color);35 var updater = new Updater(entity, getScene());36 expect(updater.isDynamic).toBe(false);37 });38 it("Checks that an entity without height and extrudedHeight is on terrain", function () {39 var entity = createEntity();40 var geometry = entity[geometryPropertyName];41 geometry.height = undefined;42 geometry.outline = new ConstantProperty(true);43 var updater = new Updater(entity, getScene());44 if (GroundPrimitive.isSupported(getScene())) {45 expect(updater.onTerrain).toBe(true);46 expect(updater.outlineEnabled).toBe(false);47 } else {48 expect(updater.onTerrain).toBe(false);49 expect(updater.outlineEnabled).toBe(true);50 }51 });52 it("Checks that an entity with height isn't on terrain", function () {53 var entity = createEntity();54 entity[geometryPropertyName].height = new ConstantProperty(1);55 var updater = new Updater(entity, getScene());56 expect(updater.onTerrain).toBe(false);57 });58 it("Checks that an entity with extrudedHeight isn't on terrain", function () {59 var entity = createEntity();60 var geometry = entity[geometryPropertyName];61 geometry.height = undefined;62 geometry.extrudedHeight = new ConstantProperty(1);63 var updater = new Updater(entity, getScene());64 expect(updater.onTerrain).toBe(false);65 });66 it("fill is true sets onTerrain to true", function () {67 var entity = createEntity();68 entity[geometryPropertyName].fill = true;69 var updater = new Updater(entity, getScene());70 if (GroundPrimitive.isSupported(getScene())) {71 expect(updater.onTerrain).toBe(true);72 } else {73 expect(updater.onTerrain).toBe(false);74 }75 });76 it("fill is false sets onTerrain to false", function () {77 var entity = createEntity();78 entity[geometryPropertyName].fill = false;79 var updater = new Updater(entity, getScene());80 expect(updater.onTerrain).toBe(false);81 });82 it("a defined height sets onTerrain to false", function () {83 var entity = createEntity();84 var geometry = entity[geometryPropertyName];85 geometry.fill = true;86 geometry.height = 0;87 var updater = new Updater(entity, getScene());88 expect(updater.onTerrain).toBe(false);89 });90 it("a defined extrudedHeight sets onTerrain to false", function () {91 var entity = createEntity();92 var geometry = entity[geometryPropertyName];93 geometry.fill = true;94 geometry.extrudedHeight = 12;95 var updater = new Updater(entity, getScene());96 expect(updater.onTerrain).toBe(false);97 });98 it("Creates geometry with no offsetAttribute when geometry is on terrain", function () {99 var entity = createEntity();100 var updater = new Updater(entity, getScene());101 var instance;102 var geometry;103 instance = updater.createFillGeometryInstance(time);104 geometry = instance.geometry;105 expect(geometry._offsetAttribute).toBeUndefined();106 });107 it("Creates geometry with expected offsetAttribute based on height and extrudedHeight", function () {108 var entity = createEntity();109 var graphics = entity[geometryPropertyName];110 graphics.outline = true;111 graphics.outlineColor = Color.BLACK;112 graphics.height = new ConstantProperty(20.0);113 graphics.extrudedHeight = new ConstantProperty(0.0);114 var updater = new Updater(entity, getScene());115 var instance;116 updater._onEntityPropertyChanged(entity, geometryPropertyName);117 instance = updater.createFillGeometryInstance(time);118 expect(instance.geometry._offsetAttribute).toBeUndefined();119 instance = updater.createOutlineGeometryInstance(time);120 expect(instance.geometry._offsetAttribute).toBeUndefined();121 graphics.heightReference = new ConstantProperty(HeightReference.NONE);122 graphics.extrudedHeightReference = new ConstantProperty(123 HeightReference.NONE124 );125 updater._onEntityPropertyChanged(entity, geometryPropertyName);126 instance = updater.createFillGeometryInstance(time);127 expect(instance.geometry._offsetAttribute).toBeUndefined();128 instance = updater.createOutlineGeometryInstance(time);129 expect(instance.geometry._offsetAttribute).toBeUndefined();130 graphics.heightReference = new ConstantProperty(HeightReference.NONE);131 graphics.extrudedHeightReference = new ConstantProperty(132 HeightReference.CLAMP_TO_GROUND133 );134 updater._onEntityPropertyChanged(entity, geometryPropertyName);135 instance = updater.createFillGeometryInstance(time);136 expect(instance.geometry._offsetAttribute).toBeUndefined();137 instance = updater.createOutlineGeometryInstance(time);138 expect(instance.geometry._offsetAttribute).toBeUndefined();139 graphics.heightReference = new ConstantProperty(HeightReference.NONE);140 graphics.extrudedHeightReference = new ConstantProperty(141 HeightReference.RELATIVE_TO_GROUND142 );143 updater._onEntityPropertyChanged(entity, geometryPropertyName);144 instance = updater.createFillGeometryInstance(time);145 expect(instance.geometry._offsetAttribute).toEqual(146 GeometryOffsetAttribute.TOP147 );148 instance = updater.createOutlineGeometryInstance(time);149 expect(instance.geometry._offsetAttribute).toEqual(150 GeometryOffsetAttribute.TOP151 );152 graphics.heightReference = new ConstantProperty(153 HeightReference.CLAMP_TO_GROUND154 );155 graphics.extrudedHeightReference = new ConstantProperty(156 HeightReference.NONE157 );158 updater._onEntityPropertyChanged(entity, geometryPropertyName);159 instance = updater.createFillGeometryInstance(time);160 expect(instance.geometry._offsetAttribute).toEqual(161 GeometryOffsetAttribute.TOP162 );163 instance = updater.createOutlineGeometryInstance(time);164 expect(instance.geometry._offsetAttribute).toEqual(165 GeometryOffsetAttribute.TOP166 );167 graphics.heightReference = new ConstantProperty(168 HeightReference.CLAMP_TO_GROUND169 );170 graphics.extrudedHeightReference = new ConstantProperty(171 HeightReference.CLAMP_TO_GROUND172 );173 updater._onEntityPropertyChanged(entity, geometryPropertyName);174 instance = updater.createFillGeometryInstance(time);175 expect(instance.geometry._offsetAttribute).toEqual(176 GeometryOffsetAttribute.TOP177 );178 instance = updater.createOutlineGeometryInstance(time);179 expect(instance.geometry._offsetAttribute).toEqual(180 GeometryOffsetAttribute.TOP181 );182 graphics.heightReference = new ConstantProperty(183 HeightReference.CLAMP_TO_GROUND184 );185 graphics.extrudedHeightReference = new ConstantProperty(186 HeightReference.RELATIVE_TO_GROUND187 );188 updater._onEntityPropertyChanged(entity, geometryPropertyName);189 instance = updater.createFillGeometryInstance(time);190 expect(instance.geometry._offsetAttribute).toEqual(191 GeometryOffsetAttribute.ALL192 );193 instance = updater.createOutlineGeometryInstance(time);194 expect(instance.geometry._offsetAttribute).toEqual(195 GeometryOffsetAttribute.ALL196 );197 graphics.heightReference = new ConstantProperty(198 HeightReference.RELATIVE_TO_GROUND199 );200 graphics.extrudedHeightReference = new ConstantProperty(201 HeightReference.NONE202 );203 updater._onEntityPropertyChanged(entity, geometryPropertyName);204 instance = updater.createFillGeometryInstance(time);205 expect(instance.geometry._offsetAttribute).toEqual(206 GeometryOffsetAttribute.TOP207 );208 instance = updater.createOutlineGeometryInstance(time);209 expect(instance.geometry._offsetAttribute).toEqual(210 GeometryOffsetAttribute.TOP211 );212 graphics.heightReference = new ConstantProperty(213 HeightReference.RELATIVE_TO_GROUND214 );215 graphics.extrudedHeightReference = new ConstantProperty(216 HeightReference.CLAMP_TO_GROUND217 );218 updater._onEntityPropertyChanged(entity, geometryPropertyName);219 instance = updater.createFillGeometryInstance(time);220 expect(instance.geometry._offsetAttribute).toEqual(221 GeometryOffsetAttribute.TOP222 );223 instance = updater.createOutlineGeometryInstance(time);224 expect(instance.geometry._offsetAttribute).toEqual(225 GeometryOffsetAttribute.TOP226 );227 graphics.heightReference = new ConstantProperty(228 HeightReference.RELATIVE_TO_GROUND229 );230 graphics.extrudedHeightReference = new ConstantProperty(231 HeightReference.RELATIVE_TO_GROUND232 );233 updater._onEntityPropertyChanged(entity, geometryPropertyName);234 instance = updater.createFillGeometryInstance(time);235 expect(instance.geometry._offsetAttribute).toEqual(236 GeometryOffsetAttribute.ALL237 );238 instance = updater.createOutlineGeometryInstance(time);239 expect(instance.geometry._offsetAttribute).toEqual(240 GeometryOffsetAttribute.ALL241 );242 graphics.height = undefined;243 graphics.extrudedHeight = undefined;244 updater._onEntityPropertyChanged(entity, geometryPropertyName);245 instance = updater.createFillGeometryInstance(time);246 expect(instance.geometry._offsetAttribute).toBeUndefined();247 });248 it("color material sets onTerrain to true", function () {249 var entity = createEntity();250 var geometry = entity[geometryPropertyName];251 geometry.fill = true;252 geometry.material = new ColorMaterialProperty(Color.WHITE);253 var updater = new Updater(entity, getScene());254 if (GroundPrimitive.isSupported(getScene())) {255 expect(updater.onTerrain).toBe(true);256 } else {257 expect(updater.onTerrain).toBe(false);258 }259 });260 it("dynamic updater on terrain", function () {261 var entity = createDynamicEntity();262 var updater = new Updater(entity, getScene());263 var primitives = new PrimitiveCollection();264 var groundPrimitives = new PrimitiveCollection();265 var dynamicUpdater = updater.createDynamicUpdater(266 primitives,267 groundPrimitives268 );269 expect(dynamicUpdater.isDestroyed()).toBe(false);270 expect(primitives.length).toBe(0);271 expect(groundPrimitives.length).toBe(0);272 dynamicUpdater.update(time);273 if (GroundPrimitive.isSupported(getScene())) {274 expect(primitives.length).toBe(0);275 expect(groundPrimitives.length).toBe(1);276 } else {277 expect(primitives.length).toBe(2);278 expect(groundPrimitives.length).toBe(0);279 }280 dynamicUpdater.destroy();281 updater.destroy();282 });283 it("dynamic updater on terrain propagates classification type", function () {284 var entity = createDynamicEntity();285 entity[geometryPropertyName].classificationType = ClassificationType.BOTH;286 var updater = new Updater(entity, getScene());287 var primitives = new PrimitiveCollection();288 var groundPrimitives = new PrimitiveCollection();289 var dynamicUpdater = updater.createDynamicUpdater(290 primitives,291 groundPrimitives292 );293 dynamicUpdater.update(time);294 if (GroundPrimitive.isSupported(getScene())) {295 expect(groundPrimitives.get(0).classificationType).toEqual(296 ClassificationType.BOTH297 );298 }299 dynamicUpdater.destroy();300 updater.destroy();301 });302}...
electron-updater_vx.x.x.js
Source:electron-updater_vx.x.x.js
1// flow-typed signature: 21086a5a2ec472c1d873dee7306805432// flow-typed version: <<STUB>>/electron-updater_v^2.16.1/flow_v0.75.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'electron-updater'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'electron-updater' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'electron-updater/out/AppImageUpdater' {23 declare module.exports: any;24}25declare module 'electron-updater/out/AppUpdater' {26 declare module.exports: any;27}28declare module 'electron-updater/out/BaseUpdater' {29 declare module.exports: any;30}31declare module 'electron-updater/out/BintrayProvider' {32 declare module.exports: any;33}34declare module 'electron-updater/out/differentialDownloader/DataSplitter' {35 declare module.exports: any;36}37declare module 'electron-updater/out/differentialDownloader/DifferentialDownloader' {38 declare module.exports: any;39}40declare module 'electron-updater/out/differentialDownloader/downloadPlanBuilder' {41 declare module.exports: any;42}43declare module 'electron-updater/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader' {44 declare module.exports: any;45}46declare module 'electron-updater/out/differentialDownloader/GenericDifferentialDownloader' {47 declare module.exports: any;48}49declare module 'electron-updater/out/differentialDownloader/multipleRangeDownloader' {50 declare module.exports: any;51}52declare module 'electron-updater/out/DownloadedUpdateHelper' {53 declare module.exports: any;54}55declare module 'electron-updater/out/electronHttpExecutor' {56 declare module.exports: any;57}58declare module 'electron-updater/out/GenericProvider' {59 declare module.exports: any;60}61declare module 'electron-updater/out/GitHubProvider' {62 declare module.exports: any;63}64declare module 'electron-updater/out/MacUpdater' {65 declare module.exports: any;66}67declare module 'electron-updater/out/main' {68 declare module.exports: any;69}70declare module 'electron-updater/out/NsisUpdater' {71 declare module.exports: any;72}73declare module 'electron-updater/out/PrivateGitHubProvider' {74 declare module.exports: any;75}76declare module 'electron-updater/out/Provider' {77 declare module.exports: any;78}79declare module 'electron-updater/out/providerFactory' {80 declare module.exports: any;81}82declare module 'electron-updater/out/windowsExecutableCodeSignatureVerifier' {83 declare module.exports: any;84}85// Filename aliases86declare module 'electron-updater/out/AppImageUpdater.js' {87 declare module.exports: $Exports<'electron-updater/out/AppImageUpdater'>;88}89declare module 'electron-updater/out/AppUpdater.js' {90 declare module.exports: $Exports<'electron-updater/out/AppUpdater'>;91}92declare module 'electron-updater/out/BaseUpdater.js' {93 declare module.exports: $Exports<'electron-updater/out/BaseUpdater'>;94}95declare module 'electron-updater/out/BintrayProvider.js' {96 declare module.exports: $Exports<'electron-updater/out/BintrayProvider'>;97}98declare module 'electron-updater/out/differentialDownloader/DataSplitter.js' {99 declare module.exports: $Exports<'electron-updater/out/differentialDownloader/DataSplitter'>;100}101declare module 'electron-updater/out/differentialDownloader/DifferentialDownloader.js' {102 declare module.exports: $Exports<'electron-updater/out/differentialDownloader/DifferentialDownloader'>;103}104declare module 'electron-updater/out/differentialDownloader/downloadPlanBuilder.js' {105 declare module.exports: $Exports<'electron-updater/out/differentialDownloader/downloadPlanBuilder'>;106}107declare module 'electron-updater/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js' {108 declare module.exports: $Exports<'electron-updater/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader'>;109}110declare module 'electron-updater/out/differentialDownloader/GenericDifferentialDownloader.js' {111 declare module.exports: $Exports<'electron-updater/out/differentialDownloader/GenericDifferentialDownloader'>;112}113declare module 'electron-updater/out/differentialDownloader/multipleRangeDownloader.js' {114 declare module.exports: $Exports<'electron-updater/out/differentialDownloader/multipleRangeDownloader'>;115}116declare module 'electron-updater/out/DownloadedUpdateHelper.js' {117 declare module.exports: $Exports<'electron-updater/out/DownloadedUpdateHelper'>;118}119declare module 'electron-updater/out/electronHttpExecutor.js' {120 declare module.exports: $Exports<'electron-updater/out/electronHttpExecutor'>;121}122declare module 'electron-updater/out/GenericProvider.js' {123 declare module.exports: $Exports<'electron-updater/out/GenericProvider'>;124}125declare module 'electron-updater/out/GitHubProvider.js' {126 declare module.exports: $Exports<'electron-updater/out/GitHubProvider'>;127}128declare module 'electron-updater/out/MacUpdater.js' {129 declare module.exports: $Exports<'electron-updater/out/MacUpdater'>;130}131declare module 'electron-updater/out/main.js' {132 declare module.exports: $Exports<'electron-updater/out/main'>;133}134declare module 'electron-updater/out/NsisUpdater.js' {135 declare module.exports: $Exports<'electron-updater/out/NsisUpdater'>;136}137declare module 'electron-updater/out/PrivateGitHubProvider.js' {138 declare module.exports: $Exports<'electron-updater/out/PrivateGitHubProvider'>;139}140declare module 'electron-updater/out/Provider.js' {141 declare module.exports: $Exports<'electron-updater/out/Provider'>;142}143declare module 'electron-updater/out/providerFactory.js' {144 declare module.exports: $Exports<'electron-updater/out/providerFactory'>;145}146declare module 'electron-updater/out/windowsExecutableCodeSignatureVerifier.js' {147 declare module.exports: $Exports<'electron-updater/out/windowsExecutableCodeSignatureVerifier'>;...
index.ts
Source:index.ts
1import { EmployeeCreator } from './employee-creator.handler';2import { EmployeeUpdater } from './employee-updater.handler';3import {EmployeeNameUpdater} from './employee-name-updater.handler';4import {EmployeeAddressUpdater} from './employee-address-updater.handler';5import { EmployeeDeactivator } from './employee-deactivator.handler';6import { EmployeeActivator } from './employee-activator.handler';7import {EmployeeDisplayNameUpdater} from './employee-display-name-updater.handler';8import {EmployeeTagsUpdater} from './employee-tags-updater.handler';9import { EmployeePhoneNumberUpdater } from "./employee-phone-number-updater.handler";10import { EmployeePersonalEmailUpdater } from "./employee-personal-email-updater.handler";11import { EmployeeCompanyEmailUpdater } from "./employee-company-email-updater.handler";12import { EmployeeSalaryUpdater } from "./employee-salary-updater.handler";13import {EmployeeSalaryTypeUpdater} from './employee-salary-type-updater.handler';14import { EmployeeEffectiveDateUpdater } from "./employee-effective-date-updater.handler";15import { EmployeeBirthDateUpdater } from "./employee-birthdate-updater.handler";16export const CommandHandlers = [17 EmployeeCreator,18 EmployeeUpdater,19 EmployeeDeactivator,20 EmployeeActivator,21 EmployeeNameUpdater,22 EmployeeAddressUpdater,23 EmployeeDisplayNameUpdater,24 EmployeeTagsUpdater,25 EmployeePhoneNumberUpdater,26 EmployeePersonalEmailUpdater,27 EmployeeCompanyEmailUpdater,28 EmployeeSalaryUpdater,29 EmployeeSalaryTypeUpdater,30 EmployeeEffectiveDateUpdater,31 EmployeeBirthDateUpdater...
Using AI Code Generation
1const { launch, devices } = require("qawolf");2const iPhone = devices["iPhone 11"];3const { updater } = require("qawolf");4(async () => {5 const page = await browser.newPage();6 await page.setViewportSize(iPhone.viewport);7 await page.click('input[aria-label="Search"]');8 await page.fill('input[aria-label="Search"]', "hello world");9 await page.click('input[ar
Using AI Code Generation
1const { updater } = require('@qawolf/updater');2updater();3const { qawolf } = require('@qawolf/qawolf');4qawolf();5const { qawolf } = require('@qawolf/qawolf');6qawolf();
Using AI Code Generation
1const {updater} = require("qawolf");2const qawolf = require("qawolf");3const {launch} = require("qawolf");4const {create} = require("qawolf");5const {select} = require("qawolf");6const {click} = require("qawolf");7const {type} = require("qawolf");8const {press} = require("qawolf");9const {check} = require("qawolf");10const {uncheck} = require("qawolf");11const {hover} = require("qawolf");12const {scroll} = require("qawolf");13const {dragAndDrop} = require("qawolf");14const {waitFor} = require("qawolf");15const {waitForText} = require("qawolf");16const {waitForSelector} = require("qawolf");17const {waitForNavigation} = require("qawolf");18const {waitForFunction} = require("qawolf");19const {waitForXPath} = require("qawolf");20const {waitForTimeout} = require("qawolf");21const {waitForEvent} = require("qawolf");22const {waitForFileChooser} = require("qawolf");
Using AI Code Generation
1const { launch, devices } = require('qawolf');2const config = {3 launchOptions: {4 },5};6(async () => {7 const browser = await launch(config);8 const page = await browser.newPage();9 await page.click('input[aria-label="Search"]');10 await page.type('input[aria-label="Search"]', 'Hello world');11 await page.click('input[value="Google Search"]'
Using AI Code Generation
1const { QAWolf } = require("qawolf");2const qawolf = new QAWolf();3qawolf.updater();4const { QAWolf } = require("qawolf");5const qawolf = new QAWolf();6qawolf.updater();7const { QAWolf } = require("qawolf");8const qawolf = new QAWolf();9qawolf.updater();10const { QAWolf } = require("qawolf");11const qawolf = new QAWolf();12qawolf.updater();13const { QAWolf } = require("qawolf");14const qawolf = new QAWolf();15qawolf.updater();16const { QAWolf } = require("qawolf");17const qawolf = new QAWolf();18qawolf.updater();19const { QAWolf } = require("qawolf");20const qawolf = new QAWolf();21qawolf.updater();22const { QAWolf } = require("qawolf");23const qawolf = new QAWolf();24qawolf.updater();25const { QAWolf } = require("qawolf");26const qawolf = new QAWolf();27qawolf.updater();28const { QAWolf } = require("qawolf");29const qawolf = new QAWolf();30qawolf.updater();31const { QAWolf } = require("qawolf");32const qawolf = new QAWolf();33qawolf.updater();34const { QAWolf } = require("qawolf");35const qawolf = new QAWolf();36qawolf.updater();37const { QAWolf }
Using AI Code Generation
1const { update } = require("qawolf");2const { test } = require("./test.spec");3update({ test, code: __filename });4const { launch } = require("qawolf");5const selectors = require("../selectors/test.json");6describe("test", () => {7 let browser;8 let page;9 beforeAll(async () => {10 browser = await launch();11 page = await browser.newPage();12 });13 afterAll(async () => {14 await browser.close();15 });16 it("test", async () => {17 await page.click(selectors["input[name='q']"]);18 await page.fill(selectors["input[name='q']"], "Hello World");19 await page.press(selectors["input[name='q']"], "Enter");20 });21});22const { update } = require("qawolf");23update({ code: __filename });24const { launch } = require("qawolf");25const selectors = require("../selectors/test.json");26describe("test", () => {27 let browser;28 let page;29 beforeAll(async () => {30 browser = await launch();31 page = await browser.newPage();32 });33 afterAll(async () => {34 await browser.close();35 });36 it("test", async ()
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!