summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Format/Text.html
diff options
context:
space:
mode:
Diffstat (limited to 'misc/openlayers/tests/Format/Text.html')
-rw-r--r--misc/openlayers/tests/Format/Text.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Format/Text.html b/misc/openlayers/tests/Format/Text.html
new file mode 100644
index 0000000..9b18bb5
--- /dev/null
+++ b/misc/openlayers/tests/Format/Text.html
@@ -0,0 +1,49 @@
+<html>
+<head>
+ <script src="../OLLoader.js"></script>
+ <script type="text/javascript">
+ function test_basic(t) {
+ t.plan(5);
+ var format = new OpenLayers.Format.Text({extractStyles: true});
+ var features = format.read(OpenLayers.Util.getElement("content").value);
+ t.eq(features[0].style.externalGraphic, format.defaultStyle.externalGraphic, "style is set to defaults if no style props set in text file");
+ var features = format.read(OpenLayers.Util.getElement("contentMarker").value);
+ t.eq(features[0].style.externalGraphic, OpenLayers.Util.getImagesLocation() + "marker.png", "marker set correctly by default.");
+
+ var features = format.read(OpenLayers.Util.getElement("content2").value);
+ t.eq(features.length, 2, "two features read");
+ t.eq(features[0].style.externalGraphic, "marker.png", "marker set correctly from data.");
+ // t.eq(format.defaultStyle.externalGraphic, "../../img/marker.png", "defaultStyle externalGraphic not changed by pulling from data");
+
+ var format = new OpenLayers.Format.Text({extractStyles: false});
+ var features = format.read(OpenLayers.Util.getElement("content2").value);
+ t.eq(features[0].style, null, "extractStyles: false results in null style property, even with style properties used");
+ }
+ function test_extra(t) {
+ t.plan(1);
+ var format = new OpenLayers.Format.Text();
+ var features = format.read(OpenLayers.Util.getElement("content3").value);
+ t.eq(features[0].attributes.whee, "chicken", "extra attributes are stored for later use");
+ }
+ </script>
+</head>
+<body>
+<textarea id="content">
+point
+5,5
+</textarea>
+<textarea id="contentMarker">
+point iconSize
+5,5 8,8
+</textarea>
+<textarea id="content2">
+point icon
+5,5 marker.png
+10,10 marker2.png
+</textarea>
+<textarea id="content3">
+point whee
+5,5 chicken
+</textarea>
+</body>
+</html>