diff --git a/tests/Test.AnotherWay.baseadditions.js b/tests/Test.AnotherWay.baseadditions.js index 2354b34361..338bf825c7 100644 --- a/tests/Test.AnotherWay.baseadditions.js +++ b/tests/Test.AnotherWay.baseadditions.js @@ -30,6 +30,7 @@ Test.AnotherWay._run_one_onclick = function(){ // test page loading Test.AnotherWay.old_load_next_page = Test.AnotherWay._load_next_page; Test.AnotherWay._load_next_page = function(){ + document.getElementById("test_iframe_el").style.display = "none"; Test.AnotherWay.update_running_time(); Test.AnotherWay.old_load_next_page.apply(this, arguments); }; @@ -94,6 +95,19 @@ Test.AnotherWay._add_test_page_url = function(test_url, convention){ record_select.appendChild(option); }; +Test.AnotherWay.old_set_iframe_location = Test.AnotherWay._set_iframe_location; +Test.AnotherWay._set_iframe_location = function(iframe, loc, outside_path_correction){ + var optionPos = loc.indexOf( "?" ), + option; + if (optionPos != -1) { + option = loc.substring(optionPos+1); + loc = loc.substring(0, optionPos); + } + if (option === "visible") { + document.getElementById("test_iframe_el").style.display = ""; + } + return Test.AnotherWay.old_set_iframe_location.call(this, iframe, loc, outside_path_correction); +}; // new methods Test.AnotherWay.update_running_time = function() { diff --git a/tests/Util.html b/tests/Util.html index a6cab66612..48d5de7315 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -11,6 +11,9 @@ top: 1234px; left: 123px; } + .test_getRenderedDimensions p{ + padding: 20px; + } + - - - -
-
-
- - +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("

Content

"); + var bigger = OpenLayers.Util.getRenderedDimensions("

Content

", null, {displayClass: 'test_getRenderedDimensions'}); + var overflow = OpenLayers.Util.getRenderedDimensions("

Content

"); + var width = OpenLayers.Util.getRenderedDimensions("

Content

", new OpenLayers.Size(250, null)); + var height = OpenLayers.Util.getRenderedDimensions("

Content

", 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
"); + 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"); +} diff --git a/tests/Util_w3c.html b/tests/Util_w3c.html new file mode 100644 index 0000000000..457341f82e --- /dev/null +++ b/tests/Util_w3c.html @@ -0,0 +1,35 @@ + + + + + + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index b8910c3626..f79076c165 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -191,7 +191,7 @@
  • SingleFile1.html
  • SingleFile2.html
  • SingleFile3.html -
  • Popup.html
  • +
  • Popup.html?visible
  • Popup/Anchored.html
  • Popup/FramedCloud.html
  • Projection.html
  • @@ -233,7 +233,8 @@
  • TileManager.html
  • Tween.html
  • Kinetic.html
  • -
  • Util.html
  • +
  • Util.html?visible
  • +
  • Util_w3c.html?visible
  • Util/vendorPrefix.html
  • WPSClient.html
  • WPSProcess.html
  • diff --git a/tests/run-tests.html b/tests/run-tests.html index b2e0556ac3..d1517e4c37 100644 --- a/tests/run-tests.html +++ b/tests/run-tests.html @@ -92,11 +92,13 @@
    + + + - -