280 lines
11 KiB
HTML
280 lines
11 KiB
HTML
<html>
|
|
<head>
|
|
<title>LayoutConstructorsTest</title>
|
|
<script type="text/javascript" src="testcase.js"></script>
|
|
<script type="text/javascript" src="prototype.js"></script>
|
|
<script type="text/javascript" src="FloatedDivConstructor.js"></script>
|
|
<script type="text/javascript" src="TableConstructor.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
var FloatedDivConstructorTest = TestCase.create({
|
|
name: "Floated Div Constructor Test",
|
|
|
|
testGenerateHTML: function() {
|
|
var myThis = this;
|
|
[
|
|
{
|
|
'input': {
|
|
'left': {
|
|
'active': false,
|
|
'start': 0,
|
|
'end': 3
|
|
},
|
|
'right': {
|
|
'active': false,
|
|
'start': 1,
|
|
'end': 3
|
|
}
|
|
},
|
|
'expected_result': '<div id="container">\n' +
|
|
' <div id="header"><?php echo $header ?></div>\n' +
|
|
' <div id="comic"><?php echo $comic ?></div>\n' +
|
|
' <div id="body"><?php echo $body ?></div>\n' +
|
|
' <div id="footer"><?php echo $footer ?></div>\n' +
|
|
'</div>'
|
|
},
|
|
{
|
|
'input': {
|
|
'left': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 0
|
|
},
|
|
'right': {
|
|
'active': false,
|
|
'start': 0,
|
|
'end': 3
|
|
}
|
|
},
|
|
'expected_result': '<div id="container">\n' +
|
|
' <div id="sidebar-container">\n' +
|
|
' <div id="left-sidebar"><?php echo $left_sidebar ?></div>\n' +
|
|
' <div id="header"><?php echo $header ?></div>\n' +
|
|
' <br class="clear" />\n' +
|
|
' </div>\n' +
|
|
' <div id="comic"><?php echo $comic ?></div>\n' +
|
|
' <div id="body"><?php echo $body ?></div>\n' +
|
|
' <div id="footer"><?php echo $footer ?></div>\n' +
|
|
'</div>'
|
|
},
|
|
{
|
|
'input': {
|
|
'left': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 1
|
|
}, 'right': {
|
|
'active': false,
|
|
'start': 1,
|
|
'end': 3
|
|
}
|
|
},
|
|
'expected_result': '<div id="container">\n' +
|
|
' <div id="sidebar-container">\n' +
|
|
' <div id="left-sidebar"><?php echo $left_sidebar ?></div>\n' +
|
|
' <div id="header"><?php echo $header ?></div>\n' +
|
|
' <div id="comic"><?php echo $comic ?></div>\n' +
|
|
' <br class="clear" />\n' +
|
|
' </div>\n' +
|
|
' <div id="body"><?php echo $body ?></div>\n' +
|
|
' <div id="footer"><?php echo $footer ?></div>\n' +
|
|
'</div>'
|
|
},
|
|
{
|
|
'input': {
|
|
'right': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 1
|
|
},
|
|
'left': {
|
|
'active': false,
|
|
'start': 1,
|
|
'end': 3
|
|
}
|
|
},
|
|
'expected_result': '<div id="container">\n' +
|
|
' <div id="sidebar-container">\n' +
|
|
' <div id="right-sidebar"><?php echo $right_sidebar ?></div>\n' +
|
|
' <div id="header"><?php echo $header ?></div>\n' +
|
|
' <div id="comic"><?php echo $comic ?></div>\n' +
|
|
' <br class="clear" />\n' +
|
|
' </div>\n' +
|
|
' <div id="body"><?php echo $body ?></div>\n' +
|
|
' <div id="footer"><?php echo $footer ?></div>\n' +
|
|
'</div>'
|
|
},
|
|
{
|
|
'input': {
|
|
'left': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 3
|
|
},
|
|
'right': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 1
|
|
}
|
|
},
|
|
'expected_result': '<div id="container">\n' +
|
|
' <div id="whole-sidebar-container">\n' +
|
|
' <div id="left-sidebar"><?php echo $left_sidebar ?></div>\n' +
|
|
' <div id="sidebar-container">\n' +
|
|
' <div id="right-sidebar"><?php echo $right_sidebar ?></div>\n' +
|
|
' <div id="header"><?php echo $header ?></div>\n' +
|
|
' <div id="comic"><?php echo $comic ?></div>\n' +
|
|
' <br class="clear" />\n' +
|
|
' </div>\n' +
|
|
' <div id="body"><?php echo $body ?></div>\n' +
|
|
' <div id="footer"><?php echo $footer ?></div>\n' +
|
|
' <br class="clear" />\n' +
|
|
' </div>\n' +
|
|
'</div>'
|
|
},
|
|
].each(function(info) {
|
|
var f = new FloatedDivConstructor();
|
|
myThis.assertEqual(info.expected_result, f.generate_html(info.input));
|
|
});
|
|
},
|
|
|
|
testGenerateCSS: function() {
|
|
var myThis = this;
|
|
[
|
|
{
|
|
'input': {
|
|
'left': {
|
|
'active': false,
|
|
'start': 0,
|
|
'end': 0,
|
|
'width': 0
|
|
},
|
|
'right': {
|
|
'active': false,
|
|
'start': 0,
|
|
'end': 0,
|
|
'width': 0
|
|
}
|
|
},
|
|
'expected_result': ''
|
|
},
|
|
{
|
|
'input': {
|
|
'body': '800',
|
|
'left': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 3,
|
|
'width': 200
|
|
},
|
|
'right': {
|
|
'active': false,
|
|
'start': 1,
|
|
'end': 3,
|
|
'width': 175
|
|
}
|
|
},
|
|
'expected_result': '#container { width: 800px }\n'
|
|
+ '#sidebar-container, #whole-sidebar-container { overflow: hidden }\n'
|
|
+ '#left-sidebar { float: left; display: inline; width: 200px }\n'
|
|
+ '#header { margin-left: 200px }\n'
|
|
+ '#comic { margin-left: 200px }\n'
|
|
+ '#body { margin-left: 200px }\n'
|
|
+ '#footer { margin-left: 200px }\n'
|
|
+ '.clear { clear: both }'
|
|
},
|
|
{
|
|
'input': {
|
|
'body': '800',
|
|
'left': {
|
|
'active': true,
|
|
'start': 1,
|
|
'end': 2,
|
|
'width': 200
|
|
},
|
|
'right': {
|
|
'active': false,
|
|
'start': 1,
|
|
'end': 3,
|
|
'width': 175
|
|
}
|
|
},
|
|
'expected_result': '#container { width: 800px }\n'
|
|
+ '#sidebar-container, #whole-sidebar-container { overflow: hidden }\n'
|
|
+ '#left-sidebar { float: left; display: inline; width: 200px }\n'
|
|
+ '#comic { margin-left: 200px }\n'
|
|
+ '#body { margin-left: 200px }\n'
|
|
+ '.clear { clear: both }'
|
|
},
|
|
{
|
|
'input': {
|
|
'body': '800',
|
|
'left': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 1,
|
|
'width': 200
|
|
},
|
|
'right': {
|
|
'active': true,
|
|
'start': 0,
|
|
'end': 3,
|
|
'width': 100
|
|
}
|
|
},
|
|
'expected_result': '#container { width: 800px }\n'
|
|
+ '#sidebar-container, #whole-sidebar-container { overflow: hidden }\n'
|
|
+ '#left-sidebar { float: left; display: inline; width: 200px }\n'
|
|
+ '#right-sidebar { float: right; display: inline; width: 100px }\n'
|
|
+ '#header { margin-left: 200px; margin-right: 100px }\n'
|
|
+ '#comic { margin-left: 200px; margin-right: 100px }\n'
|
|
+ '#body { margin-right: 100px }\n'
|
|
+ '#footer { margin-right: 100px }\n'
|
|
+ '.clear { clear: both }'
|
|
}
|
|
].each(function(info) {
|
|
var f = new FloatedDivConstructor();
|
|
myThis.assertEqual(info.expected_result, f.generate_css(info.input));
|
|
});
|
|
}
|
|
});
|
|
|
|
var TableConstructorTest = TestCase.create({
|
|
name: "Table Constructor Test",
|
|
|
|
testGenerateHTML: function() {
|
|
var myThis = this;
|
|
[
|
|
{
|
|
'input': {
|
|
'left': {
|
|
'active': false,
|
|
'start': 0,
|
|
'end': 3
|
|
},
|
|
'right': {
|
|
'active': false,
|
|
'start': 0,
|
|
'end': 3
|
|
}
|
|
},
|
|
'expected_result': '<table id="container" cellspacing="0">\n' +
|
|
' <tr><td id="header"><?php echo $header ?></td></tr>\n' +
|
|
' <tr><td id="comic"><?php echo $comic ?></td></tr>\n' +
|
|
' <tr><td id="body"><?php echo $body ?></td></tr>\n' +
|
|
' <tr><td id="footer"><?php echo $footer ?></td></tr>\n' +
|
|
'</table>'
|
|
}
|
|
].each(function(info) {
|
|
var f = new FloatedDivConstructor();
|
|
myThis.assertEqual(info.expected_result, f.generate_html(info.input));
|
|
});
|
|
}
|
|
});
|
|
|
|
FloatedDivConstructorTest.run();
|
|
TableConstructorTest.run();
|
|
</script>
|
|
</body>
|
|
</html> |