Skip to content

Instantly share code, notes, and snippets.

@julesfern
Created January 27, 2011 16:12
Show Gist options
  • Save julesfern/798705 to your computer and use it in GitHub Desktop.
Save julesfern/798705 to your computer and use it in GitHub Desktop.
[Test(description="Elements with height: auto correctly recalculate their dimensions when children modify their sizes")]
public function heightAutoElementsCalculateContentSizes():void
{
var wrapper:UIElement = new UIElement(this._baseUI);
wrapper.localStyleString = "width: 100px; height: auto;";
Assert.assertEquals(0, wrapper.contentHeight);
var children:Vector.<UIElement> = new Vector.<UIElement>();
for(var i:uint=0; i<5; i++)
{
var h:uint = wrapper.contentHeight;
var c:UIElement = new UIElement(this._baseUI);
c.localStyleString = "display: block; width: 50px; height: 10px;";
children.push(c);
wrapper.addElement(c);
Assert.assertEquals(h+10, wrapper.contentHeight);
}
// Now take a child and increase its size
children[0].localStyleString = "display: block; width: 50px; height: 100px;";
Assert.assertEquals(140, wrapper.contentHeight);
// Now do something evil - set them all to float
for(var j:uint=0; j<children.length; j++)
{
children[j].localStyleString = "display: block; width: 50px; height: 10px; float: left;";
}
// It should now be wrapped onto three lines
Assert.assertEquals(30, wrapper.contentHeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment