gecko/dom/tests/mochitest/ajax/scriptaculous/test/unit/dragdrop_test.html

132 lines
5.0 KiB
HTML
Raw Normal View History

<!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>script.aculo.us Unit test file</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="../../lib/prototype.js" type="text/javascript"></script>
<script src="../../src/scriptaculous.js" type="text/javascript"></script>
<script src="../../src/unittest.js" type="text/javascript"></script>
<link rel="stylesheet" href="../test.css" type="text/css" />
<style type="text/css" media="screen">
/* <![CDATA[ */
#div_absolute_test { position: absolute }
/* ]]> */
</style>
</head>
<body>
<h1>script.aculo.us Unit test file</h1>
<p>
Test of drag &amp; drop functions in dragdrop.js
</p>
<!-- Log output -->
<div id="testlog"> </div>
<p id="p_test">p_test</p>
<p id="p_test2">p_test2</p>
<p id="p_test3">p_test3</p>
<img id="img_test" src="icon.png" alt="img_text"/>
<div id="droppable_test">droppable_test</div>
<div id="div_test">div_test</div>
<div id="div_absolute_test">div_absolute_test</div>
<div id="div_absolute_inline_test" style="position:absolute">div_absolute_inline_test</div>
<div id="droppable_container">
<div id="d1">droppable_test</div>
<div id="d2">droppable_test</div>
</div>
<div id="droppable_container_2">
<div id="d3">droppable_test</div>
</div>
<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
new Test.Unit.Runner({
testDraggableBasics: function() { with(this) {
var d = new Draggable('p_test');
assertInstanceOf(Draggable, d);
}},
testDraggableStartEffect: function() { with(this) {
var d = new Draggable('p_test2');
assert(d.options.starteffect, 'There should be a default start effect.');
d = new Draggable('p_test3', { endeffect: Prototype.EmptyFunction });
assert(undefined === d.options.startEffect, 'There should be no default start effect.');
}},
testAutoPositioning: function() { with(this) {
assertEqual('static', Element.getStyle('div_test','position'));
new Draggable('div_test');
new Draggable('div_absolute_test');
new Draggable('div_absolute_inline_test');
assertEqual('relative', Element.getStyle('div_test','position'));
assertEqual('absolute', Element.getStyle('div_absolute_test','position'));
assertEqual('absolute', Element.getStyle('div_absolute_inline_test','position'));
}},
testDroppbalesBasics: function() { with(this) {
assertEqual(0, Droppables.drops.length);
assertEqual('static', Element.getStyle('droppable_test','position'));
Droppables.add('droppable_test');
assertEqual(1, Droppables.drops.length);
assertEqual('relative', Element.getStyle('droppable_test','position'));
Droppables.remove('droppable_test');
assertEqual(0, Droppables.drops.length);
// accept option should take strings or array of strings
Droppables.add('droppable_test',{accept:'document'});
assertEqual(['document'].inspect(), Droppables.drops[0].accept.inspect());
Droppables.remove('droppable_test');
Droppables.add('droppable_test',{accept:['document','image']});
assertEqual(['document','image'].inspect(), Droppables.drops[0].accept.inspect());
Droppables.remove('droppable_test');
}},
testDroppableContainment: function() { with(this) {
// Droppable containers should be cached
Droppables.add('droppable_test', {
containment:'droppable_container' });
assertEqual(1, Droppables.drops[0]._containers.length);
assertEqual($('droppable_container'), Droppables.drops[0]._containers[0]);
assert(Droppables.isContained($('d1'), Droppables.drops[0]));
assert(Droppables.isContained($('d2'), Droppables.drops[0]));
assert(!Droppables.isContained($('d3'), Droppables.drops[0]));
Droppables.remove('droppable_test');
Droppables.add('droppable_test', {
containment:['droppable_container','droppable_container_2'] });
assertEqual(2, Droppables.drops[0]._containers.length);
assertEqual($('droppable_container'), Droppables.drops[0]._containers[0]);
assertEqual($('droppable_container_2'), Droppables.drops[0]._containers[1]);
assert(Droppables.isContained($('d1'), Droppables.drops[0]));
assert(Droppables.isContained($('d2'), Droppables.drops[0]));
assert(Droppables.isContained($('d3'), Droppables.drops[0]));
Droppables.remove('droppable_test');
}},
testDroppablesIsAffected: function() { with(this) {
Droppables.add('droppable_test');
Position.prepare();
assert(!Droppables.isAffected([-10, -10], null, Droppables.drops[0]));
var p = Position.page($('droppable_test'));
assert(Droppables.isAffected(p, null, Droppables.drops[0]));
}}
}, "testlog");
// ]]>
</script>
</body>
</html>