Merge pull request #543 from jorix/no-manual-tests2
Can test some manual tests as normal tests.
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
top: 1234px;
|
||||
left: 123px;
|
||||
}
|
||||
.test_getRenderedDimensions p{
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var OpenLayers = [
|
||||
@@ -26,6 +29,7 @@
|
||||
];
|
||||
</script>
|
||||
<script src="OLLoader.js"></script>
|
||||
<script src="Util_common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var map;
|
||||
@@ -1116,17 +1120,8 @@
|
||||
}
|
||||
|
||||
function test_getRenderedDimensions(t) {
|
||||
t.plan(2);
|
||||
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");
|
||||
|
||||
// from <script src="Util_common.js"> and shared by Util_w3c.html
|
||||
com_test_getRenderedDimensions(t);
|
||||
}
|
||||
|
||||
function test_toFloat(t) {
|
||||
|
||||
@@ -1,102 +1,64 @@
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.testDims p{
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script>
|
||||
function run() {
|
||||
var out = document.getElementById("out");
|
||||
var size = OpenLayers.Util.getRenderedDimensions("<p>Content</p>");
|
||||
var bigger = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", null, {displayClass: 'testDims'});
|
||||
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));
|
||||
if ((size.w + 40) == bigger.w && (size.h + 40) == bigger.h) {
|
||||
out.innerHTML = "bigger Pass: " + size + ", " + bigger;
|
||||
} else {
|
||||
out.innerHTML = "bigger Fail: " + size + ", " + bigger;
|
||||
}
|
||||
|
||||
if (size.w == overflow.w && size.h == overflow.h) {
|
||||
out.innerHTML += "<br/>overflow Pass: " + size + ", " + overflow;
|
||||
} else {
|
||||
out.innerHTML += "<br/>overflow Fail: " + size + ", " + overflow;
|
||||
}
|
||||
|
||||
if (width.w == 250 && width.h == size.h) {
|
||||
out.innerHTML += "<br/>width Pass: " + size + ", " + width;
|
||||
}
|
||||
else {
|
||||
out.innerHTML += "<br/>width Fail: " + size + ", " + width;
|
||||
}
|
||||
|
||||
if (height.h == 40 && height.w == size.w) {
|
||||
out.innerHTML += "<br/>height Pass: " + size + ", " + height;
|
||||
}
|
||||
else {
|
||||
out.innerHTML += "<br/>height Fail: " + size + ", " + height;
|
||||
}
|
||||
|
||||
// To use the same syntax as in "\tests"
|
||||
var t = {eq: function(a, b, msg) {
|
||||
if (a == b) {
|
||||
out.innerHTML += "<br/>ok " + msg;
|
||||
}
|
||||
else {
|
||||
out.innerHTML += "<br/><span style=\"color:red\">Fail (" + a + " not eq " + b + "): " + msg + "<span>";
|
||||
}
|
||||
}
|
||||
};
|
||||
var text = (new Array(10)).join("foo foo foo <br>"),
|
||||
content = "<div>" + text + "</div>";
|
||||
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.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");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<div id="out"></div>
|
||||
<div id="absoluteDiv" style="position:absolute; left:10px; width:500px; height: 500px"></div>
|
||||
<div id="absoluteDiv00" style="position:absolute; left:10px;"></div>
|
||||
</body>
|
||||
</html>
|
||||
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");
|
||||
}
|
||||
35
tests/Util_w3c.html
Normal file
35
tests/Util_w3c.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<style type="text/css">
|
||||
.test_getRenderedDimensions p{
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var OpenLayers = [
|
||||
"OpenLayers/BaseTypes/Class.js",
|
||||
"OpenLayers/Util.js",
|
||||
"OpenLayers/BaseTypes.js",
|
||||
"OpenLayers/BaseTypes/Element.js",
|
||||
"OpenLayers/BaseTypes/LonLat.js",
|
||||
"OpenLayers/BaseTypes/Pixel.js",
|
||||
"OpenLayers/BaseTypes/Size.js",
|
||||
"OpenLayers/Lang.js",
|
||||
"OpenLayers/Console.js"
|
||||
];
|
||||
</script>
|
||||
<script src="OLLoader.js"></script>
|
||||
<script src="Util_common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function test_getRenderedDimensions(t) {
|
||||
// from <script src="Util_common.js"> and shared by Util.html
|
||||
com_test_getRenderedDimensions(t);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -191,7 +191,7 @@
|
||||
<li>SingleFile1.html</html>
|
||||
<li>SingleFile2.html</html>
|
||||
<li>SingleFile3.html</html>
|
||||
<li>Popup.html</li>
|
||||
<li>Popup.html?visible</li>
|
||||
<li>Popup/Anchored.html</li>
|
||||
<li>Popup/FramedCloud.html</li>
|
||||
<li>Projection.html</li>
|
||||
@@ -233,7 +233,8 @@
|
||||
<li>TileManager.html</li>
|
||||
<li>Tween.html</li>
|
||||
<li>Kinetic.html</li>
|
||||
<li>Util.html</li>
|
||||
<li>Util.html?visible</li>
|
||||
<li>Util_w3c.html?visible</li>
|
||||
<li>Util/vendorPrefix.html</li>
|
||||
<li>WPSClient.html</li>
|
||||
<li>WPSProcess.html</li>
|
||||
|
||||
@@ -92,11 +92,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span>
|
||||
<iframe id="test_iframe_el" style="display:none" name="test_iframe" onload="Test.AnotherWay._test_page_onload();">
|
||||
</iframe>
|
||||
</span>
|
||||
<span style="display:none">
|
||||
<iframe name="list_iframe" onload="Test.AnotherWay._list_iframe_onload();">
|
||||
</iframe>
|
||||
<iframe name="test_iframe" onload="Test.AnotherWay._test_page_onload();">
|
||||
</iframe>
|
||||
<!-- record_control div is to be imported into other documents, so all its styles are inline -->-
|
||||
<div id="record_control" style="position:absolute;bottom:0;left:0;margin:0;padding:0.5em;width:22em;height:22em;border:1px solid;background:#ffd;font: normal normal 8pt sans-serif; color:#000; text-align: left">
|
||||
<p style="margin:0 0 0 0; padding:0">
|
||||
|
||||
Reference in New Issue
Block a user