Debian Codegraph @

dojox/mdnd/tests/unitTests/dropMode/OverDropModeTest.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5
6 <title>OverDropMode</title>
7
8 <script type="text/javascript"
9 src="../../../../../dojo/dojo.js"
10 data-dojo-config="isDebug: true, parseOnLoad: true">
11 </script>
12
13 <script type="text/javascript">
14 dojo.require("dijit.robotx");
15 dojo.require("dojo.parser");
16 dojo.require("dojox.mdnd.tests.unitTests.dropMode.FixtureLib");
17 dojo.require("dojox.mdnd.dropMode.OverDropMode");
18
19 dojo.addOnLoad(function(){
20
21 doh.robot.initRobot('resources/domElement.html');
22
23 doh.register("getDragPoint",
24 [
25 // summary:
26 // getDragPoint get the reference point used to
27 // represent the drag item.
28 //
29 // For the overDropMode, this point is equal to
30 // the mouse position.
31
32 new getDragPointFixture("firstCall",function(){
33
34 var point = this.dropMode.getDragPoint(this.coords, this.size, this.mousePosition);
35 doh.assertTrue(point.x === this.mousePosition.x);
36 doh.assertTrue(point.y === this.mousePosition.y);
37 })
38 ]
39 );
40
41 doh.register("addArea",
42 [
43 // summary:
44 // addArea allows to add a DnD area. They are sorted
45 // by their x position.
46
47 new AreaFixture("addAnArea", function(){
48 this.dropMode.addArea(this.array, this.objectA);
49 doh.assertTrue(this.array.length === 1);
50 doh.assertTrue(this.objectA.coords.x === 50 && this.objectA.coords.y === 50);
51 }),
52
53 new AreaFixture("addAtStart", function(){
54 this.dropMode.addArea(this.array, this.objectB);
55 this.dropMode.addArea(this.array, this.objectA);
56 doh.assertTrue(this.array.length === 2);
57 doh.assertTrue(this.array[0]=== this.objectA);
58 }),
59
60 new AreaFixture("addAtEnd", function(){
61 this.dropMode.addArea(this.array, this.objectB);
62 this.dropMode.addArea(this.array, this.objectC);
63 doh.assertTrue(this.array.length === 2);
64 doh.assertTrue(this.array[1] === this.objectC);
65 }),
66
67 new AreaFixture("addAtMiddle", function(){
68 this.dropMode.addArea(this.array, this.objectB);
69 this.dropMode.addArea(this.array, this.objectD);
70 console.dir(this.array);
71 this.dropMode.addArea(this.array, this.objectC);
72 doh.assertTrue(this.array.length === 3);
73 doh.assertTrue(this.array[1] === this.objectC);
74 })
75 ]
76 );
77
78 doh.register("updateAreas",
79 [
80 // summary:
81 // Refresh intervals between areas to determinate the
82 // nearest area to drop an item.
83
84 new AreaFixture("update", function(){
85
86 this.dropMode.addArea(this.array, this.objectA);
87 this.dropMode.updateAreas(this.array);
88
89
90 doh.assertEqual(this.objectA.coords.x, 50);
91 doh.assertEqual(this.objectA.coords.x2, 152);
92 doh.assertEqual(this.objectA.coords.y, 50);
93 }),
94
95 new AreaFixture("updateDOMCoord", function(){
96
97 this.dropMode.addArea(this.array, this.objectC);
98 this.dropMode.updateAreas(this.array);
99
100 doh.assertEqual(this.objectC.coords.x, 350);
101 doh.assertEqual(this.objectC.coords.x2, 452);
102 doh.assertEqual(this.objectC.coords.y, 50);
103
104 dojo.style(this.objectC.node,{'left': '400px','top':'25px'});
105
106 this.dropMode.updateAreas(this.array);
107
108 doh.assertEqual(this.objectC.coords.x, 400);
109 doh.assertEqual(this.objectC.coords.x2, 502);
110 doh.assertEqual(this.objectC.coords.y, 25);
111 })
112 ]
113 );
114
115 doh.register("initItems",
116 [
117 // summary:
118 // iniItems allows to initialize the horizontal line
119 // in order to determinate the drop zone.
120
121 new ItemFixture("initItems", function(){
122
123 this.object = {
124 'items':[this.itemA]
125 }
126 this.dropMode.initItems(this.object);
127
128 doh.assertTrue(this.itemA.y === 551);
129 }),
130
131 new ItemFixture("initItems2", function(){
132
133 this.object = {
134 'items':[this.itemA, this.itemB, this.itemC, this.itemD]
135 }
136 this.dropMode.initItems(this.object);
137
138 doh.assertTrue(this.itemA.y === 551);
139 doh.assertTrue(this.itemB.y === 701);
140 doh.assertTrue(this.itemC.y === 851);
141 doh.assertTrue(this.itemD.y === 1051);
142 })
143 ]
144 );
145
146 doh.register("refreshItems",
147 [
148 new ItemFixture("addAtStart", function(){
149
150 this.object = {
151 'items':[this.itemA, this.itemB, this.itemC, this.itemD]
152 }
153 this.dropMode.initItems(this.object);
154 this.dropMode.refreshItems(this.object, 0, {h:50,w:50}, true);
155
156 doh.assertTrue(this.itemA.y === 601);
157 }),
158
159 new ItemFixture("addDropIndicator", function(){
160
161 this.object = {
162 'items':[this.itemA, this.itemB, this.itemC, this.itemD]
163 }
164 this.dropMode.initItems(this.object);
165 this.dropMode.refreshItems(this.object, 2, {h:50,w:50}, true);
166 doh.assertTrue(this.itemB.y === 701);
167 doh.assertTrue(this.itemD.y === 1101);
168 }),
169
170 new ItemFixture("removeDropIndicator", function(){
171
172 this.object = {
173 'items':[this.itemA, this.itemB, this.itemC, this.itemD]
174 }
175 this.dropMode.initItems(this.object);
176 this.dropMode.refreshItems(this.object, 2, {h:50,w:50}, true);
177
178 doh.assertTrue(this.itemB.y === 701);
179 doh.assertTrue(this.itemD.y === 1101);
180
181 this.dropMode.refreshItems(this.object, 2, {h:50,w:50}, false);
182
183 doh.assertTrue(this.itemB.y === 701);
184 doh.assertTrue(this.itemD.y === 1051);
185 })
186 ]
187 );
188
189 doh.run();
190 });
191 </script>
192 <style type="text/css"></style>
193 </head>
194 <body></body>
195 </html>