Skip to content

Commit e3f4057

Browse files
committed
提交ICL-1041,ICL-1042,ICL-1047对应的测试案例 review by zhushusun
1 parent 16ff9bd commit e3f4057

File tree

3 files changed

+124
-29
lines changed

3 files changed

+124
-29
lines changed

test/leaflet/mapping/TiledMapLayerSpec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {tiledMapLayer} from '../../../src/leaflet/mapping/TiledMapLayer';
2+
import {tiledVectorLayer} from "../../../src/leaflet/overlay";
23

34
var url = GlobeParameter.ChinaURL;
45
describe('leaflet_TiledMapLayer', () => {
@@ -102,4 +103,10 @@ describe('leaflet_TiledMapLayer', () => {
102103
format = urlTemp.substring(urlTemp.length - 3, urlTemp.length);
103104
expect(format).toBe("gif");
104105
});
106+
it('getAllRequestParams_ICL_1041',()=>{
107+
var options={};
108+
var tiledMapLayerObject = tiledMapLayer(options);
109+
expect(tiledMapLayerObject.options.cacheEnabled).toBe(true);
110+
});
111+
105112
});

test/leaflet/overlay/GraphicLayerSpec.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import {graphicLayer} from '../../../src/leaflet/overlay/GraphicLayer';
33
import {tiledMapLayer} from '../../../src/leaflet/mapping/TiledMapLayer';
44
import {circleStyle} from '../../../src/leaflet/overlay/graphic/CircleStyle';
55
import {graphic} from '../../../src/leaflet/overlay/graphic/Graphic';
6+
import {GraphicWebGLRenderer} from "../../../src/leaflet/overlay/graphic";
7+
import {FetchRequest} from "@supermap/iclient-common";
8+
import {Detector} from "../../../src/leaflet/core/Detector";
69

710
var url = "http://supermapiserver:8090/iserver/services/map-world/rest/maps/World";
811
describe('leaflet_GraphicLayer', () => {
@@ -200,7 +203,18 @@ describe('leaflet_GraphicLayer', () => {
200203
done();
201204
}, 4000);
202205
});
203-
});
204206

207+
//特定条件下,期望的函数被调用、
208+
it("_moveEnd_expect_ICL_1042",()=>{
209+
spyOn(Detector, 'supportWebGL2').and.callFake(() => {
210+
return true;
211+
});
212+
layer = graphicLayer(graphics,{render:"webgl"}).addTo(map);
213+
spyOn(layer, '_update');
214+
layer._moveEnd();
215+
expect(layer._update).toHaveBeenCalled();
216+
});
217+
218+
});
205219
});
206220

test/openlayers/overlay/GraphicSpec.js

Lines changed: 102 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import {
66
import {
77
HitCloverShape
88
} from '../../../src/openlayers/overlay/graphic/HitCloverShape';
9+
10+
import { Graphic as GraphicObj } from '../../../src/openlayers/overlay/graphic/Graphic'
11+
912
import {
10-
Graphic
11-
} from '../../../src/openlayers/overlay/Graphic';
13+
Graphic as GraphicSource
14+
} from '../../../src/openlayers/overlay/Graphic.js';
1215
import {
1316
MapService
1417
} from '../../../src/openlayers/services/MapService';
@@ -29,7 +32,7 @@ describe('openlayers_GraphicLayer', () => {
2932
[-36.16, 40.05],
3033
[-37.16, 40.05],
3134
[-38.16, 39.05]
32-
]
35+
];
3336
var escapedJson = "{\"viewBounds\":{\"top\":66.5212729371629,\"left\":-66.52127293716292,\"bottom\":-66.52127293716293,\"leftBottom\":{\"x\":-66.52127293716292,\"y\":-66.52127293716293},\"right\":66.52127293716292,\"rightTop\":{\"x\":66.52127293716292,\"y\":66.5212729371629}},\"viewer\":{\"leftTop\":{\"x\":0,\"y\":0},\"top\":0,\"left\":0,\"bottom\":256,\"rightBottom\":{\"x\":256,\"y\":256},\"width\":256,\"right\":256,\"height\":256},\"distanceUnit\":\"METER\",\"minVisibleTextSize\":0.1,\"coordUnit\":\"DEGREE\",\"scale\":4.573415833095347E-9,\"description\":\"\",\"paintBackground\":true,\"maxVisibleTextSize\":1000,\"maxVisibleVertex\":3600000,\"clipRegionEnabled\":false,\"antialias\":true,\"textOrientationFixed\":false,\"angle\":0,\"prjCoordSys\":{\"distanceUnit\":\"METER\",\"projectionParam\":null,\"epsgCode\":4326,\"coordUnit\":\"DEGREE\",\"name\":\"Longitude / Latitude Coordinate System---GCS_WGS_1984\",\"projection\":null,\"type\":\"PCS_EARTH_LONGITUDE_LATITUDE\",\"coordSystem\":{\"datum\":{\"name\":\"D_WGS_1984\",\"type\":\"DATUM_WGS_1984\",\"spheroid\":{\"flatten\":0.00335281066474748,\"name\":\"WGS_1984\",\"axis\":6378137,\"type\":\"SPHEROID_WGS_1984\"}},\"unit\":\"DEGREE\",\"spatialRefType\":\"SPATIALREF_EARTH_LONGITUDE_LATITUDE\",\"name\":\"GCS_WGS_1984\",\"type\":\"GCS_WGS_1984\",\"primeMeridian\":{\"longitudeValue\":0,\"name\":\"Greenwich\",\"type\":\"PRIMEMERIDIAN_GREENWICH\"}}},\"minScale\":0,\"markerAngleFixed\":false,\"overlapDisplayedOptions\":{\"allowPointWithTextDisplay\":true,\"horizontalOverlappedSpaceSize\":0,\"allowPointOverlap\":false,\"allowThemeGraduatedSymbolOverlap\":false,\"verticalOverlappedSpaceSize\":0,\"allowTextOverlap\":false,\"allowThemeGraphOverlap\":false,\"allowTextAndPointOverlap\":false},\"visibleScales\":[1.6901635716026555E-9,3.3803271432053056E-9,6.760654286410611E-9,1.3521308572821242E-8,2.7042617145642484E-8,5.408523429128511E-8,1.0817046858256998E-7,2.1634093716513974E-7,4.3268187433028044E-7,8.653637486605571E-7,1.7307274973211203E-6,3.4614549946422405E-6,6.9229099892844565E-6],\"visibleScalesEnabled\":false,\"customEntireBoundsEnabled\":false,\"clipRegion\":{\"center\":null,\"parts\":null,\"style\":null,\"prjCoordSys\":null,\"id\":0,\"type\":\"REGION\",\"partTopo\":null,\"points\":null},\"maxScale\":1.0E12,\"customParams\":\"\",\"center\":{\"x\":0,\"y\":-1.4210854715202004E-14},\"dynamicPrjCoordSyses\":[{\"distanceUnit\":null,\"projectionParam\":null,\"epsgCode\":0,\"coordUnit\":null,\"name\":null,\"projection\":null,\"type\":\"PCS_ALL\",\"coordSystem\":null}],\"colorMode\":\"DEFAULT\",\"textAngleFixed\":false,\"overlapDisplayed\":false,\"userToken\":{\"userID\":\"\"},\"cacheEnabled\":true,\"dynamicProjection\":true,\"autoAvoidEffectEnabled\":true,\"customEntireBounds\":null,\"name\":\"China_4326\",\"bounds\":{\"top\":85.05112877980648,\"left\":-180,\"bottom\":-85.0511287798065,\"leftBottom\":{\"x\":-180,\"y\":-85.0511287798065},\"right\":180,\"rightTop\":{\"x\":180,\"y\":85.05112877980648}},\"backgroundStyle\":{\"fillGradientOffsetRatioX\":0,\"markerSize\":2.4,\"fillForeColor\":{\"red\":255,\"green\":255,\"blue\":255,\"alpha\":255},\"fillGradientOffsetRatioY\":0,\"markerWidth\":0,\"markerAngle\":0,\"fillSymbolID\":0,\"lineColor\":{\"red\":0,\"green\":0,\"blue\":0,\"alpha\":255},\"markerSymbolID\":0,\"lineWidth\":0.1,\"markerHeight\":0,\"fillOpaqueRate\":100,\"fillBackOpaque\":true,\"fillBackColor\":{\"red\":255,\"green\":255,\"blue\":255,\"alpha\":255},\"fillGradientMode\":\"NONE\",\"lineSymbolID\":0,\"fillGradientAngle\":0}}";
3437
beforeAll(() => {
3538
testDiv = window.document.createElement("div");
@@ -86,7 +89,7 @@ describe('openlayers_GraphicLayer', () => {
8689
})
8790
});
8891
for (var j = 0; j < count; ++j) {
89-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
92+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
9093
graphics[j].setStyle(randomCircleStyles);
9194
}
9295
var clone = graphics[0].clone();
@@ -95,7 +98,7 @@ describe('openlayers_GraphicLayer', () => {
9598
expect(clone.getStyle()).toEqual(graphics[0].getStyle());
9699
clone.destroy();
97100
graphicLayer = new ol.layer.Image({
98-
source: new Graphic({
101+
source: new GraphicSource({
99102
graphics: graphics,
100103
map: map,
101104
highLightStyle: new ol.style.Circle({
@@ -110,7 +113,7 @@ describe('openlayers_GraphicLayer', () => {
110113
})
111114
});
112115
map.addLayer(graphicLayer);
113-
var a = new Graphic({
116+
var a = new GraphicSource({
114117
graphics: graphics,
115118
map: map
116119
})._forEachFeatureAtCoordinate(coors[1], 1, (result) => {
@@ -155,11 +158,11 @@ describe('openlayers_GraphicLayer', () => {
155158
points: 3
156159
});
157160
for (var j = 0; j < count; ++j) {
158-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
161+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
159162
graphics[j].setStyle(randomCircleStyles);
160163
}
161164
graphicLayer = new ol.layer.Image({
162-
source: new Graphic({
165+
source: new GraphicSource({
163166
graphics: graphics,
164167
map: map,
165168
highLightStyle: new ol.style.RegularShape({
@@ -214,7 +217,7 @@ describe('openlayers_GraphicLayer', () => {
214217
})
215218
expect(cloverShapeStyle.getCount()).toEqual(3);
216219
for (var j = 0; j < count; ++j) {
217-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
220+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
218221
graphics[j].setStyle(cloverShapeStyle);
219222
}
220223
var hitCloverShape = new HitCloverShape({
@@ -232,7 +235,7 @@ describe('openlayers_GraphicLayer', () => {
232235
expect(hitCloverShape.getSAngle()).toEqual(30);
233236
expect(hitCloverShape.getEAngle()).toEqual(60);
234237
graphicLayer = new ol.layer.Image({
235-
source: new Graphic({
238+
source: new GraphicSource({
236239
graphics: graphics,
237240
map: map,
238241
onclick: (result) => {
@@ -278,14 +281,14 @@ describe('openlayers_GraphicLayer', () => {
278281
renderer: ['canvas']
279282
});
280283
for (let j = 0; j < coors.length; ++j) {
281-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
284+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
282285
graphics[j].setId(j);
283286
graphics[j].setAttributes({
284287
name: "graphic_" + j
285288
});
286289
}
287290
const graphicLayer = new ol.layer.Image({
288-
source: new Graphic({
291+
source: new GraphicSource({
289292
graphics: graphics,
290293
map: map
291294
})
@@ -312,14 +315,14 @@ describe('openlayers_GraphicLayer', () => {
312315
renderer: ['canvas']
313316
});
314317
for (let j = 0; j < coors.length; ++j) {
315-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
318+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
316319
graphics[j].setId(j);
317320
graphics[j].setAttributes({
318321
name: "graphic_" + j
319322
});
320323
}
321324
const graphicLayer = new ol.layer.Image({
322-
source: new Graphic({
325+
source: new GraphicSource({
323326
graphics: graphics,
324327
map: map
325328
})
@@ -352,14 +355,14 @@ describe('openlayers_GraphicLayer', () => {
352355
renderer: ['canvas']
353356
});
354357
for (let j = 0; j < coors.length; ++j) {
355-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
358+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
356359
graphics[j].setId(j);
357360
graphics[j].setAttributes({
358361
name: "graphic_" + j
359362
});
360363
}
361364
const graphicLayer = new ol.layer.Image({
362-
source: new Graphic({
365+
source: new GraphicSource({
363366
graphics: graphics,
364367
map: map
365368
})
@@ -387,14 +390,14 @@ describe('openlayers_GraphicLayer', () => {
387390
renderer: ['canvas']
388391
});
389392
for (let j = 0; j < coors.length; ++j) {
390-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
393+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
391394
graphics[j].setId(j);
392395
graphics[j].setAttributes({
393396
name: "graphic_" + j
394397
});
395398
}
396399
const graphicLayer = new ol.layer.Image({
397-
source: new Graphic({
400+
source: new GraphicSource({
398401
graphics: graphics,
399402
map: map
400403
})
@@ -432,14 +435,14 @@ describe('openlayers_GraphicLayer', () => {
432435
renderer: ['canvas']
433436
});
434437
for (let j = 0; j < coors.length; ++j) {
435-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
438+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
436439
graphics[j].setId(j);
437440
graphics[j].setAttributes({
438441
name: "graphic_" + j
439442
});
440443
}
441444
const graphicLayer = new ol.layer.Image({
442-
source: new Graphic({
445+
source: new GraphicSource({
443446
graphics: graphics,
444447
map: map,
445448
color: "red"
@@ -467,14 +470,14 @@ describe('openlayers_GraphicLayer', () => {
467470
renderer: ['canvas']
468471
});
469472
for (let j = 0; j < coors.length; ++j) {
470-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
473+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
471474
graphics[j].setId(j);
472475
graphics[j].setAttributes({
473476
name: "graphic_" + j
474477
});
475478
}
476479
const graphicLayer = new ol.layer.Image({
477-
source: new Graphic({
480+
source: new GraphicSource({
478481
graphics: graphics,
479482
map: map
480483
})
@@ -486,7 +489,7 @@ describe('openlayers_GraphicLayer', () => {
486489
expect(graphicLayer.getSource().graphics.length).toEqual(0);
487490
let graphics = [];
488491
for (let j = 0; j < coors.length; ++j) {
489-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
492+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
490493
graphics[j].setId(j);
491494
graphics[j].setAttributes({
492495
name: "graphic_" + j
@@ -511,14 +514,14 @@ describe('openlayers_GraphicLayer', () => {
511514
renderer: ['canvas']
512515
});
513516
for (let j = 0; j < coors.length; ++j) {
514-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
517+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
515518
graphics[j].setId(j);
516519
graphics[j].setAttributes({
517520
name: "graphic_" + j
518521
});
519522
}
520523
const graphicLayer = new ol.layer.Image({
521-
source: new Graphic({
524+
source: new GraphicSource({
522525
graphics: graphics,
523526
map: map,
524527
color: "red"
@@ -548,14 +551,14 @@ describe('openlayers_GraphicLayer', () => {
548551
renderer: ['canvas']
549552
});
550553
for (let j = 0; j < coors.length; ++j) {
551-
graphics[j] = new ol.Graphic(new ol.geom.Point(coors[j]));
554+
graphics[j] = new GraphicObj(new ol.geom.Point(coors[j]));
552555
graphics[j].setId(j);
553556
graphics[j].setAttributes({
554557
name: "graphic_" + j
555558
});
556559
}
557560
const graphicLayer = new ol.layer.Image({
558-
source: new Graphic({
561+
source: new GraphicSource({
559562
graphics: graphics,
560563
map: map
561564
})
@@ -570,4 +573,75 @@ describe('openlayers_GraphicLayer', () => {
570573
}, 4000);
571574
});
572575

573-
});
576+
it('forEachFeatureAtCoordinate_ICL_1047',(done)=>{
577+
//三叶草的生成坐标
578+
var coordinate=[
579+
[ 50.154958667070076,-0.89592969754775]
580+
];
581+
let graphics = [];
582+
map = new ol.Map({
583+
target: 'map',
584+
view: new ol.View({
585+
center: [0, 0],
586+
zoom: 2,
587+
projection: 'EPSG:4326'
588+
}),
589+
renderer: ['canvas']
590+
});
591+
for (let j = 0; j < coordinate.length; ++j) {
592+
graphics[j] = new GraphicObj(new ol.geom.Point(coordinate[j]));
593+
}
594+
graphicLayer = new ol.layer.Image({
595+
source: new GraphicSource({
596+
graphics: graphics,
597+
map: map,
598+
highLightStyle: new ol.style.Circle({
599+
radius: 5,
600+
fill: new ol.style.Fill({
601+
color: '#000000'
602+
}),
603+
stroke: new ol.style.Stroke({
604+
color: '#000000'
605+
})
606+
})
607+
})
608+
});
609+
map.addLayer(graphicLayer);
610+
var cloverShapeStyle = new CloverShape({
611+
radius: 20,
612+
angle: 30,
613+
count: 1,
614+
stroke: new ol.style.Stroke({
615+
color: "rgba(0,166,0,1)",
616+
width:1
617+
}),
618+
fill: new ol.style.Fill({
619+
color: "rgba(0,166,0,1)",
620+
}),
621+
});
622+
setTimeout(() => {
623+
var resgraphics = graphicLayer.getSource();
624+
for (let j = 0; j < resgraphics.length; ++j) {
625+
resgraphics[j].setStyle(cloverShapeStyle);
626+
var resolution = 1;
627+
var evtPixel = [-35.16, 38.05];
628+
//1、当鼠标点击在三叶草叶子内时,得到要素,调用高亮函数
629+
var innerCoors = [25.576171875,-27.158203125];
630+
var callback = function (a,b) {
631+
expect(b).toNotBe(null);
632+
expect(a.coordinate).toBe([25.576171875,-27.158203125]);
633+
};
634+
graphicLayer.getSource()._forEachFeatureAtCoordinate(innerCoors,resolution,callback,evtPixel);
635+
spyOn(graphicLayer, '_highLight');
636+
expect( graphicLayer.getSource()._highLight).toHaveBeenCalled();
637+
//2、当鼠标点击在三叶草外时, 关闭高亮,返回undefined
638+
var outerCoors=[ 27.685546875,-26.015625];
639+
var re=graphicLayer.getSource()._forEachFeatureAtCoordinate(outerCoors,resolution,callback,evtPixel);
640+
spyOn(graphicLayer, '_highLightClose');
641+
expect( graphicLayer.getSource()._highLightClose).toHaveBeenCalled();
642+
expect(re).toBe(undefined);
643+
}
644+
done();
645+
}, 4000);
646+
});
647+
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy