Add a couple more layout tests.

This commit is contained in:
Andrew Dupont 2009-12-04 18:24:45 -06:00
parent 2efeb8e20d
commit 5149c1b0df
2 changed files with 32 additions and 0 deletions

View File

@ -1,3 +1,5 @@
<!-- Absolutely-positioned element with BODY as offset parent. -->
<div id="box1">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div> <!-- #box1 -->
@ -16,6 +18,7 @@
</style>
<!-- Hidden, statically-positioned element. -->
<div id="box2">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div> <!-- #box2 -->
@ -30,6 +33,7 @@
}
</style>
<!-- Hidden, statically positioned element with width constrained by parent. -->
<div id="box3_parent">
<div id="box3">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@ -52,6 +56,7 @@
}
</style>
<!-- Deeply hidden, statically-positioned element with width constrained by ancestor. -->
<div id="box4_ancestor">
<div id="box4_parent">
<div id="box4">
@ -79,6 +84,7 @@
}
</style>
<!-- Absolutely-positioned element with non-BODY offset parent and positioning by percentage. -->
<div id="box5_ancestor">
<div id="box5_parent">
<div id="box5">
@ -102,4 +108,23 @@
top: 30px;
right: 10%;
}
</style>
<!-- Element positioned to the exact top-left corner of its parent. -->
<div id="box6_parent">
<div id="box6">
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div> <!-- #box6 -->
</div> <!-- #box6_parent -->
<style type="text/css" media="screen">
#box6_parent {
position: relative;
}
#box6 {
position: absolute;
left: 0;
top: 0;
}
</style>

View File

@ -78,5 +78,12 @@ new Test.Unit.Runner({
this.assertEqual(60, layout.get('right'), 'right (percentage value)');
this.assertEqual(340, layout.get('left'), 'left');
},
'test positioning on absolutely-positioned element with top=0 and left=0': function() {
var layout = $('box6').getLayout();
this.assertEqual(0, layout.get('top'), 'top');
this.assertIdentical($('box6_parent'), $('box6').getOffsetParent());
}
});