summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Util_common.js
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
committerChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
commitea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch)
treeaf67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/tests/Util_common.js
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/Util_common.js')
-rw-r--r--misc/openlayers/tests/Util_common.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Util_common.js b/misc/openlayers/tests/Util_common.js
new file mode 100644
index 0000000..471b0d6
--- /dev/null
+++ b/misc/openlayers/tests/Util_common.js
@@ -0,0 +1,64 @@
+function com_test_getRenderedDimensions(t) {
+ t.plan(17);
+ var content = (new Array(100)).join("foo ");
+
+ // test with fixed width
+ var fw = OpenLayers.Util.getRenderedDimensions(content, {w: 20});
+ t.eq(fw.w, 20, "got the fixed width");
+
+ // test with fixed height
+ var fh = OpenLayers.Util.getRenderedDimensions(content, {h: 15});
+ t.eq(fh.h, 15, "got the fixed height");
+
+ var size = OpenLayers.Util.getRenderedDimensions("<p>Content</p>");
+ var bigger = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", null, {displayClass: 'test_getRenderedDimensions'});
+ var overflow = OpenLayers.Util.getRenderedDimensions("<p style='overflow:auto'>Content</p>");
+ var width = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", new OpenLayers.Size(250, null));
+ var height = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", new OpenLayers.Size(null, 40));
+ t.ok((size.w + 40) == bigger.w && (size.h + 40) == bigger.h, "bigger Pass: " + size + ", " + bigger);
+ t.ok(size.w == overflow.w && size.h == overflow.h, "overflow Pass: " + size + ", " + overflow);
+ t.ok(width.w == 250 && width.h == size.h, "width Pass: " + size + ", " + width);
+ t.ok(height.h == 40 && height.w == size.w, "height Pass: " + size + ", " + height);
+
+ content = (new Array(10)).join("foo foo foo <br>");
+ var testName,
+ finalSize,
+ initialSize = OpenLayers.Util.getRenderedDimensions(content, null);
+ // containerElement option on absolute position with width and height
+ testName = "Absolute with w&h: ";
+ var optionAbsDiv ={
+ containerElement: document.getElementById("absoluteDiv")
+ };
+ finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv);
+ t.ok(initialSize.w > 0 && initialSize.h > 0, "Has initial size (requires visible test_iframe)");
+ t.eq(finalSize.w, initialSize.w,
+ testName + "initial width " + initialSize.w + "px is maintained");
+ t.eq(finalSize.h, initialSize.h,
+ testName + "initial height " + initialSize.h + "px is maintained");
+ testName = "Absolute with w&h (set height): ";
+ finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv);
+ t.eq(finalSize.h, 15, testName + "got the fixed height to 15px");
+ t.eq(finalSize.w, initialSize.w,
+ testName + "initial width " + initialSize.w + "px is maintained");
+ testName = "Absolute with w&h (set width): ";
+ finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv);
+ t.eq(finalSize.w, 20, testName + "got the fixed width to 20px");
+ // containerElement option on absolute position without width and height
+ testName = "Absolute without w&h: ";
+ var optionAbsDiv00 ={
+ containerElement: document.getElementById("absoluteDiv00")
+ };
+ finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv00);
+ t.eq(finalSize.w, initialSize.w,
+ testName + "initial width " + initialSize.w + "px is maintained");
+ t.eq(finalSize.h, initialSize.h,
+ testName + "initial height " + initialSize.h + "px is maintained");
+ testName = "Absolute without w&h (set height): ";
+ finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv00);
+ t.eq(finalSize.h, 15, testName + "got the fixed height to 15px");
+ t.eq(finalSize.w, initialSize.w,
+ testName + "initial width " + initialSize.w + "px is maintained");
+ testName = "Absolute without w&h (set width): ";
+ finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv00);
+ t.eq(finalSize.w, 20, testName + "got the fixed width to 20px");
+}