Skip to content

Commit 7decb4c

Browse files
committed
fix 挂掉的 UT,review by caoxinke.
1 parent c489b1f commit 7decb4c

File tree

10 files changed

+174
-153
lines changed

10 files changed

+174
-153
lines changed

dist/iclient9-leaflet.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27529,7 +27529,7 @@ var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
2752927529
initialize: function initialize(name, options) {
2753027530
_leaflet2["default"].Util.setOptions(this, options);
2753127531
this.options.name = name;
27532-
this.features = options && options.features ? options.features : [];
27532+
this.features = [];
2753327533
this.TFEvents = options && options.TFEvents ? options.TFEvents : [];
2753427534
this.levelRenderer = new _LevelRenderer2["default"]();
2753527535
this.movingOffset = [0, 0];
@@ -93984,10 +93984,10 @@ module.exports = {
9398493984
"_requiredBy": [
9398593985
"/"
9398693986
],
93987-
"_resolved": "http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz",
93987+
"_resolved": "https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz",
9398893988
"_shasum": "5ad06e8bca30be0ffa389a49e4565f51f06d089e",
9398993989
"_spec": "proj4@2.3.15",
93990-
"_where": "F:\\dev\\iClient",
93990+
"_where": "G:\\github-iClient\\iClient9",
9399193991
"author": "",
9399293992
"bugs": {
9399393993
"url": "https://github.com/proj4js/proj4js/issues"

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-openlayers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27917,7 +27917,7 @@ var Theme = function (_ol$source$ImageCanva) {
2791727917

2791827918
_this.canvasFunctionInternal_ = canvasFunctionInternal_;
2791927919
_this.EVENT_TYPES = ["loadstart", "loadend", "loadcancel", "visibilitychanged", "move", "moveend", "added", "removed", "tileloaded", "beforefeaturesadded", "featuresadded", "featuresremoved"];
27920-
_this.features = options.features || [];
27920+
_this.features = [];
2792127921
_this.TFEvents = options.TFEvents || [];
2792227922
_this.map = options.map;
2792327923
var size = _this.map.getSize();
@@ -92074,10 +92074,10 @@ module.exports = {
9207492074
"_requiredBy": [
9207592075
"/"
9207692076
],
92077-
"_resolved": "http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz",
92077+
"_resolved": "https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz",
9207892078
"_shasum": "5ad06e8bca30be0ffa389a49e4565f51f06d089e",
9207992079
"_spec": "proj4@2.3.15",
92080-
"_where": "F:\\dev\\iClient",
92080+
"_where": "G:\\github-iClient\\iClient9",
9208192081
"author": "",
9208292082
"bugs": {
9208392083
"url": "https://github.com/proj4js/proj4js/issues"

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/leaflet/overlay/theme/ThemeLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export var ThemeLayer = L.Layer.extend({
2828
initialize: function (name, options) {
2929
L.Util.setOptions(this, options);
3030
this.options.name = name;
31-
this.features = options && options.features ? options.features : [];
31+
this.features = [];
3232
this.TFEvents = options && options.TFEvents ? options.TFEvents : [];
3333
this.levelRenderer = new LevelRenderer();
3434
this.movingOffset = [0, 0];

src/openlayers/overlay/theme/Theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class Theme extends ol.source.ImageCanvas {
8686
this.EVENT_TYPES = ["loadstart", "loadend", "loadcancel",
8787
"visibilitychanged", "move", "moveend", "added", "removed",
8888
"tileloaded", "beforefeaturesadded", "featuresadded", "featuresremoved"];
89-
this.features = options.features || [];
89+
this.features = [];
9090
this.TFEvents = options.TFEvents || [];
9191
this.map = options.map;
9292
var size = this.map.getSize();

test/leaflet/overlay/RankSymbolThemeLayerSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('leaflet_RankSymbolThemeLayer', function () {
3737

3838
it('addFeatures', function () {
3939
//initialize
40-
var rankSymbolThemeLayer = L.supermap.rankSymbolThemeLayer("ThemeLayer", SuperMap.ChartType.CIRCLE).addTo(map);
40+
var rankSymbolThemeLayer = L.supermap.rankSymbolThemeLayer("ThemeLayer", SuperMap.ChartType.CIRCLE);
4141
rankSymbolThemeLayer.themeField = "CON2009";
4242
rankSymbolThemeLayer.symbolSetting = {
4343
codomain: [0, 40000],

test/openlayers/overlay/GraphSpec.js

Lines changed: 85 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -109,83 +109,91 @@ describe('openlayers_Graph', function () {
109109
});
110110

111111
it('addFeatures, removeFeatures', function (done) {
112-
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
113-
map: map
114-
});
115-
graphThemeSource.themeFields = ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"];
116-
graphThemeSource.chartsSetting = {
117-
width: 240,
118-
height: 100,
119-
codomain: [0, 40000],
120-
barStyle: {fillOpacity: 0.7},
121-
barHoverStyle: {fillOpacity: 1},
122-
xShapeBlank: [10, 10, 10],
123-
axisYTick: 4,
124-
axisYLabels: ["4万", "3万", "2万", "1万", "0"],
125-
axisXLabels: ["09年", "10年", "11年", "12年", "13年"],
126-
backgroundStyle: {fillColor: "#CCE8CF"},
127-
backgroundRadius: [5, 5, 5, 5],
128-
showShadow: true,
129-
barShadowStyle: {shadowBlur: 8, shadowOffsetX: 2, shadowOffsetY: 2, shadowColor: "rgba(100,100,100,0.8)"},
130-
barLinearGradient: [["#00FF00", "#00CD00"], ["#00CCFF", "#5E87A2"], ["#00FF66", "#669985"], ["#CCFF00", "#94A25E"], ["#FF9900", "#A2945E"]]
131-
};
132-
var layer = new ol.layer.Image({
133-
source: graphThemeSource
134-
});
135-
map.addLayer(layer);
136-
expect(graphThemeSource.features.length).toEqual(0);
137-
var features = [];
138-
for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
139-
var provinceInfo = chinaConsumptionLevel[i];
140-
var geometry = new ol.geom.Point([provinceInfo[1], provinceInfo[2]]);
141-
var atrributes = {};
142-
atrributes.NAME = provinceInfo[0];
143-
atrributes.CON2009 = provinceInfo[3];
144-
atrributes.CON2010 = provinceInfo[4];
145-
atrributes.CON2011 = provinceInfo[5];
146-
atrributes.CON2012 = provinceInfo[6];
147-
atrributes.CON2013 = provinceInfo[7];
148-
var fea = new ol.supermap.ThemeFeature(geometry, atrributes);
149-
features.push(fea);
150-
}
151-
graphThemeSource.addFeatures(features);
152-
var LayerFeatures = graphThemeSource.features;
153-
expect(LayerFeatures.length).toBeGreaterThan(0);
154-
for (var j = 0; j < LayerFeatures.length; j++) {
155-
expect(LayerFeatures[j].CLASS_NAME).toBe("SuperMap.Feature.Vector");
156-
expect(LayerFeatures[j].id).toContain("SuperMap.Feature");
157-
expect(LayerFeatures[j].attributes).not.toBeNull();
158-
expect(LayerFeatures[j].geometry).not.toBeNull();
159-
expect(LayerFeatures[j].geometry.CLASS_NAME).toBe("SuperMap.Geometry.Point");
160-
expect(LayerFeatures[j].geometry.id).toContain("SuperMap.Geometry");
161-
expect(LayerFeatures[j].geometry.x).not.toBeNull();
162-
expect(LayerFeatures[j].geometry.y).not.toBeNull();
163-
}
164-
expect(LayerFeatures[0].geometry.x).toEqual(116.407283);
165-
expect(LayerFeatures[0].geometry.y).toEqual(39.904557);
166-
expect(LayerFeatures[0].data).toEqual(LayerFeatures[0].attributes);
167-
expect(LayerFeatures[0].attributes).toEqual(Object({
168-
CON2009: 22023,
169-
CON2010: 24982,
170-
CON2011: 27760,
171-
CON2012: 30350,
172-
CON2013: 33337,
173-
NAME: "北京市"
174-
}));
175-
var shape1 = graphThemeSource.getShapesByFeatureID();
176-
var shape2 = graphThemeSource.getShapesByFeatureID(LayerFeatures[0].id);
177-
expect(shape1.length).toEqual(17);
178-
expect(shape2.length).toEqual(5);
179-
graphThemeSource.features[0].geometry.x = 39;
180-
var redraw = graphThemeSource.redraw();
181-
expect(redraw).toBeTruthy();
182-
expect(graphThemeSource.features[0].geometry.x).toEqual(39);
183-
graphThemeSource.removeFeatures();
184-
expect(graphThemeSource.features.length).toBeGreaterThan(0);
185-
graphThemeSource.removeAllFeatures();
186-
expect(graphThemeSource.features.length).toEqual(0);
187-
graphThemeSource.clear();
188-
done();
112+
setTimeout(function () {
113+
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
114+
map: map
115+
});
116+
graphThemeSource.themeFields = ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"];
117+
graphThemeSource.chartsSetting = {
118+
width: 240,
119+
height: 100,
120+
codomain: [0, 40000],
121+
barStyle: {fillOpacity: 0.7},
122+
barHoverStyle: {fillOpacity: 1},
123+
xShapeBlank: [10, 10, 10],
124+
axisYTick: 4,
125+
axisYLabels: ["4万", "3万", "2万", "1万", "0"],
126+
axisXLabels: ["09年", "10年", "11年", "12年", "13年"],
127+
backgroundStyle: {fillColor: "#CCE8CF"},
128+
backgroundRadius: [5, 5, 5, 5],
129+
showShadow: true,
130+
barShadowStyle: {
131+
shadowBlur: 8,
132+
shadowOffsetX: 2,
133+
shadowOffsetY: 2,
134+
shadowColor: "rgba(100,100,100,0.8)"
135+
},
136+
barLinearGradient: [["#00FF00", "#00CD00"], ["#00CCFF", "#5E87A2"], ["#00FF66", "#669985"], ["#CCFF00", "#94A25E"], ["#FF9900", "#A2945E"]]
137+
};
138+
var layer = new ol.layer.Image({
139+
source: graphThemeSource
140+
});
141+
map.addLayer(layer);
142+
expect(graphThemeSource.features.length).toEqual(0);
143+
var features = [];
144+
for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
145+
var provinceInfo = chinaConsumptionLevel[i];
146+
var geometry = new ol.geom.Point([provinceInfo[1], provinceInfo[2]]);
147+
var atrributes = {};
148+
atrributes.NAME = provinceInfo[0];
149+
atrributes.CON2009 = provinceInfo[3];
150+
atrributes.CON2010 = provinceInfo[4];
151+
atrributes.CON2011 = provinceInfo[5];
152+
atrributes.CON2012 = provinceInfo[6];
153+
atrributes.CON2013 = provinceInfo[7];
154+
var fea = new ol.supermap.ThemeFeature(geometry, atrributes);
155+
features.push(fea);
156+
}
157+
graphThemeSource.addFeatures(features);
158+
var LayerFeatures = graphThemeSource.features;
159+
expect(LayerFeatures.length).toBeGreaterThan(0);
160+
for (var j = 0; j < LayerFeatures.length; j++) {
161+
expect(LayerFeatures[j].CLASS_NAME).toBe("SuperMap.Feature.Vector");
162+
expect(LayerFeatures[j].id).toContain("SuperMap.Feature");
163+
expect(LayerFeatures[j].attributes).not.toBeNull();
164+
expect(LayerFeatures[j].geometry).not.toBeNull();
165+
expect(LayerFeatures[j].geometry.CLASS_NAME).toBe("SuperMap.Geometry.Point");
166+
expect(LayerFeatures[j].geometry.id).toContain("SuperMap.Geometry");
167+
expect(LayerFeatures[j].geometry.x).not.toBeNull();
168+
expect(LayerFeatures[j].geometry.y).not.toBeNull();
169+
}
170+
expect(LayerFeatures[0].geometry.x).toEqual(116.407283);
171+
expect(LayerFeatures[0].geometry.y).toEqual(39.904557);
172+
expect(LayerFeatures[0].data).toEqual(LayerFeatures[0].attributes);
173+
expect(LayerFeatures[0].attributes).toEqual(Object({
174+
CON2009: 22023,
175+
CON2010: 24982,
176+
CON2011: 27760,
177+
CON2012: 30350,
178+
CON2013: 33337,
179+
NAME: "北京市"
180+
}));
181+
var shape1 = graphThemeSource.getShapesByFeatureID();
182+
var shape2 = graphThemeSource.getShapesByFeatureID(LayerFeatures[0].id);
183+
expect(shape1.length).toEqual(17);
184+
expect(shape2.length).toEqual(5);
185+
graphThemeSource.features[0].geometry.x = 39;
186+
var redraw = graphThemeSource.redraw();
187+
expect(redraw).toBeTruthy();
188+
expect(graphThemeSource.features[0].geometry.x).toEqual(39);
189+
graphThemeSource.removeFeatures();
190+
expect(graphThemeSource.features.length).toBeGreaterThan(0);
191+
graphThemeSource.removeAllFeatures();
192+
expect(graphThemeSource.features.length).toEqual(0);
193+
graphThemeSource.clear();
194+
done();
195+
}, 3000);
196+
189197
});
190198

191199
it('isQuadrilateralOverLap', function (done) {

0 commit comments

Comments
 (0)