prototype/test/unit/position.html
2007-08-10 14:24:28 +00:00

90 lines
3.0 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Prototype Unit test file</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="../../dist/prototype.js" type="text/javascript"></script>
<script src="../lib/unittest.js" type="text/javascript"></script>
<link rel="stylesheet" href="../test.css" type="text/css" />
<style type="text/css" media="screen">
/* <![CDATA[ */
#testcss1 { font-size:11px; color: #f00; }
#testcss2 { font-size:12px; color: #0f0; display: none; }
/* ]]> */
</style>
</head>
<body>
<div id="ensure_scrollbars" style="width:10000px; height:10000px; position:absolute" > </div>
<h1>Prototype Unit test file</h1>
<p>
Test of functions in position.js
</p>
<!-- Log output -->
<div id="testlog"> </div>
<div id="body_absolute" style="position: absolute; top: 10px; left: 10px">
<div id="absolute_absolute" style="position: absolute; top: 10px; left:10px"> </div>
<div id="absolute_relative" style="position: relative; top: 10px; left:10px">
<div style="height:10px;font-size:2px">test<span id="inline">test</span></div>
<div id="absolute_relative_undefined"> </div>
</div>
</div>
<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
var testVar = 'to be updated';
new Test.Unit.Runner({
setup: function() {
scrollTo(0,0);
Position.prepare();
Position.includeScrollOffsets = false;
},
teardown: function() {
scrollTo(0,0);
Position.prepare();
Position.includeScrollOffsets = false;
},
testPrepare: function() {with(this) {
Position.prepare();
assertEqual(0, Position.deltaX);
assertEqual(0, Position.deltaY);
scrollTo(20,30);
Position.prepare();
assertEqual(20, Position.deltaX);
assertEqual(30, Position.deltaY);
}},
testWithin: function() {with(this) {
[true, false].each(function(withScrollOffsets) {
Position.includeScrollOffsets = withScrollOffsets;
assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top');
assert(Position.within($('body_absolute'), 10, 10), 'left/top corner');
assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner');
assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom');
});
scrollTo(20,30);
Position.prepare();
Position.includeScrollOffsets = true;
assert(!Position.within($('body_absolute'), 9, 9), 'outside left/top');
assert(Position.within($('body_absolute'), 10, 10), 'left/top corner');
assert(Position.within($('body_absolute'), 10, 19), 'left/bottom corner');
assert(!Position.within($('body_absolute'), 10, 20), 'outside bottom');
}}
}, 'testlog');
// ]]>
</script>
</body>
</html>