test_dnd.html 3.57 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>robot DnD Test</title>

	<style>
		@import "../../../../util/doh/robot/robot.css";
	</style>

	<!-- required: dojo.js -->
	<script type="text/javascript" src="../../../../dojo/dojo.js"
		data-dojo-config="isDebug: true"></script>
	<script type="text/javascript">
		require(["doh", "dojo/dom", "dojo/query", "dojo/robotx", "dojo/domReady!"], function(doh, dom, query, robot){

			var container1;
			var container2;
			var container3;
			var container4;
			var container5;

			robot.initRobot('../test_dnd.html');

			doh.register('dojox.robot.AutoGeneratedTestGroup',{
				name: 'autotest0',
				timeout: 10000,
				setUp: function(){
					container1=dom.byId('container1', robot.doc);
					container2=query("div[data-dojo-id='c2']", robot.doc)[0];
					container3=query("div[data-dojo-id='c3']", robot.doc)[0];
					container4=query("div[data-dojo-id='c4']", robot.doc)[0];
					container5=query("div[data-dojo-id='c5']", robot.doc)[0];
				},
				runTest: function(){
					var count1=query("div", container1).length;
					var count2=query("div", container2).length;
					var d = new doh.Deferred();
					robot.mouseMoveAt('dojoUnique13', 500, 500, 10, 10);
					robot.mousePress({left:true}, 100);
					robot.mouseMoveAt(container2, 100, 1000);
					robot.mouseRelease({left:true}, 500);
					robot.sequence(d.getTestCallback(function(){
						var actual = query("> div", container1).length;
						count1--;
						doh.is(count1, actual, "Wrong number of items ("+actual+") in container 1 (expected " + count1 + ")");
						var actual = query("> div", container2).length;
						count2++;
						doh.is(count2, actual, "Wrong number of items ("+actual+") in container 2 (expected " + count2 + ")");
					}), 1000);
					return d;
				}
			});
			doh.register('dojox.robot.AutoGeneratedTestGroup',{
				name: 'autotest1',
				timeout: 10000,
				runTest: function(){
					var count1=query("> div", container1).length;
					var count2=query("> div", container2).length;
					var d = new doh.Deferred();
					robot.mouseMoveAt('dojoUnique3', 500, 500, 10, 10);
					robot.mousePress({left:true}, 500);
					robot.mouseMoveAt(container1, 500, 1000);
					robot.mouseRelease({left:true}, 500);
					robot.sequence(d.getTestCallback(function(){
						var actual = query("> div", container1).length;
						count1++;
						doh.is(count1, actual, "Wrong number of items ("+actual+") in container 1 (expected " + count1 + ")");
						var actual = query("> div", container2).length;
						doh.is(count2, actual, "Wrong number of items ("+actual+") in container 2 (expected " + count2 + ")");
					}), 1000);
					return d;
				}
			});
			doh.register('dojox.robot.AutoGeneratedTestGroup',{
				name: 'autotest2',
				timeout: 10000,
				runTest: function(){
					var count2=query("> div", container2).length;
					var count5=query("> div", container5).length;
					var d = new doh.Deferred();
					robot.mouseMoveAt('dojoUnique11', 500, 500, 10, 10);
					robot.mousePress({left:true}, 500);
					robot.mouseMoveAt(container2, 500, 1000);
					robot.mouseRelease({left:true}, 500);
					robot.sequence(d.getTestCallback(function(){
						var actual = query("> div", container2).length;
						doh.is(count2, actual, "Wrong number of items ("+actual+") in container 2 (expected " + count2 + ")");
						var actual = query("> div", container5).length;
						doh.is(count5, actual, "Wrong number of items ("+actual+") in container 5 (expected " + count5 + ")");
					}), 1000);
					return d;
				}
			});
			doh.run();
		});
	</script>
</head>
</html>