big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / DragDropTest.as
blob5ea06895df3029164e31b2817437060a97529a88
1 //
2 // Build with:
3 // makeswf -o DrawingApi.swf ../Dejagnu.swf DrawingApi.as
4 // Run with:
5 // firefox DrawingApi.swf
6 // Or:
7 // gnash DrawingApi.swf
8 //
9 //
12 #define info _root.note
13 #define note _root.note
14 #define fail_check _root.fail
15 #define pass_check _root.pass
16 #define xfail_check _root.xfail
17 #define xpass_check _root.xpass
19 #ifdef LOADED_VERSION
20 #define SUPPRESS_RCSID_DUMP
21 #endif
23 #include "../actionscript.all/check.as"
24 #include "../actionscript.all/utils.as"
26 printBounds = function(b)
28 return ''+Math.round(b.xMin*100)/100+','+Math.round(b.yMin*100)/100+' '+Math.round(b.xMax*100)/100+','+Math.round(b.yMax*100)/100;
31 // Draw a circle with given center and radius
32 // Uses 8 curves to approximate the circle
33 drawCircle = function (where, x, y, rad)
35 var ctl = Math.sin(24*Math.PI/180)*rad;
36 var cos = Math.cos(45*Math.PI/180)*rad;
37 var sin = Math.sin(45*Math.PI/180)*rad;
39 with (where)
41 moveTo(x, y-rad);
42 curveTo(x+ctl, y-rad, x+cos, y-sin);
43 curveTo(x+rad, y-ctl, x+rad, y);
44 curveTo(x+rad, y+ctl, x+cos, y+sin);
45 curveTo(x+ctl, y+rad, x, y+rad);
46 curveTo(x-ctl, y+rad, x-cos, y+sin);
47 curveTo(x-rad, y+ctl, x-rad, y);
48 curveTo(x-rad, y-ctl, x-cos, y-sin);
49 curveTo(x-ctl, y-rad, x, y-rad);
53 dragOverHandler = function()
55 check_equals(this, _root.target10);
56 note(this+'.onDragOver called with args: '+dumpObject(arguments));
58 dragOutHandler = function()
60 check_equals(this, _root.target10);
61 note(this+'.onDragOver called with args: '+dumpObject(arguments));
64 createEmptyMovieClip("target10", 10);
65 with (target10)
67 lineStyle(4, 0);
68 beginFill(0xFF0000, 100);
69 drawCircle(target10, 50, 50, 20);
70 #if 1
71 target10.onDragOver = dragOverHandler;
72 target10.onDragOut = dragOutHandler;
73 #else
74 target10.onDragOver = function()
76 check_equals(this, _root.target10);
77 note("(onDragOver): draggable dragged over "+this._droptarget);
79 target10.onDragOut = function()
81 check_equals(this, _root.target10);
82 note("(onDragOut): draggable dragged out of "+this._droptarget);
84 #endif
85 #ifdef LOADED_VERSION
86 _x = 100;
87 #endif
90 createEmptyMovieClip("target20", 20);
91 with (target20)
93 lineStyle(4, 0);
94 beginFill(0x00FF00, 100);
95 drawCircle(target20, 100, 50, 20);
96 #if 1
97 target20.onDragOver = dragOverHandler;
98 target20.onDragOut = dragOutHandler;
99 #else
100 target20.onDragOver = function()
102 check_equals(this, _root.target20);
103 note("(onDragOver): draggable dragged over "+this._droptarget);
105 target20.onDragOut = function()
107 check_equals(this, _root.target20);
108 note("(onDragOut): draggable dragged out of "+this._droptarget);
110 #endif
112 #ifdef LOADED_VERSION
113 _x = 100;
114 #endif
117 createEmptyMovieClip("target100", 100);
118 with (target100)
120 lineStyle(4, 0);
121 beginFill(0x0000FF, 50);
122 drawCircle(target100, 70, 100, 20);
123 #if 1
124 target100.onDragOver = dragOverHandler;
125 target100.onDragOut = dragOutHandler;
126 #else
127 target100.onDragOver = function()
129 check_equals(this, _root.target100);
130 note("(onDragOver): draggable dragged over "+this._droptarget);
132 target100.onDragOut = function()
134 check_equals(this, _root.target100);
135 note("(onDragOut): draggable dragged out of "+this._droptarget);
137 #endif
139 #ifdef LOADED_VERSION
140 _x = 100;
141 #endif
144 #ifndef LOADED_VERSION
146 loadMovie("DragDropTestLoaded.swf", "_level50");
148 createEmptyMovieClip("loadedTarget", 30);
149 loadedTarget.loadMovie("DragDropTestLoaded.swf");
150 loadedTarget._x = 100;
152 createEmptyMovieClip("draggable50", 50);
153 with (draggable50)
155 lineStyle(1, 0);
156 beginFill(0x00FFFF, 50);
157 drawCircle(draggable50, 0, 0, 10);
158 draggable50.startDrag(true, 0, 0, 500, 120);
159 #if 1
160 draggable50.onDragOver = dragOverHandler;
161 draggable50.onDragOut = dragOutHandler;
162 #else
163 draggable50.onDragOver = function()
165 check_equals(this, _root.draggable50);
166 note("(onDragOver): draggable dragged over "+this._droptarget);
168 draggable50.onDragOut = function()
170 check_equals(this, _root.draggable50);
171 note("(onDragOut): draggable dragged out of "+this._droptarget);
173 #endif
175 draggable50.lastDropTarget = undefined;
176 draggable50.onEnterFrame = function()
178 //check_equals(this, _root.draggable50);
179 if ( this._droptarget != this.lastDropTarget )
181 if ( this._droptarget != "" )
183 // reduces space on the textfield..
184 //note(" -> draggable over "+this._droptarget);
186 this.lastDropTarget = this._droptarget;
191 Dejagnu._y = 100;
193 note("- This test is for drag&drop operations. Follow the instructions - ");
195 test1 = function()
197 note("1. Click OUTSIDE of any drawing.");
198 _root.onMouseDown = function()
200 check_equals(_root.draggable50._droptarget, "");
201 check_equals(eval(_root.draggable50._droptarget), undefined);
202 test2();
206 test2 = function()
208 note("2. Click on the FIRST RED circle.");
209 _root.onMouseDown = function()
211 check_equals(_root.draggable50._droptarget, "/target10");
212 check_equals(eval(_root.draggable50._droptarget), _level0.target10);
213 test3();
217 test3 = function()
219 note("3. Click on the FIRST GREEN circle.");
220 _root.onMouseDown = function()
222 check_equals(_root.draggable50._droptarget, "/target20");
223 check_equals(eval(_root.draggable50._droptarget), _level0.target20);
224 test4();
228 test4 = function()
230 note("4. Click on the FIRST BLUE circle.");
231 _root.onMouseDown = function()
233 check_equals(_root.draggable50._droptarget, "/target100");
234 check_equals(eval(_root.draggable50._droptarget), _level0.target100);
235 test5();
239 test5 = function()
241 note("5. Click on the SECOND RED circle.");
242 _root.onMouseDown = function()
244 check_equals(_root.draggable50._droptarget, "_level50/target10");
245 check_equals(eval(_root.draggable50._droptarget), _level50.target10);
246 test6();
250 test6 = function()
252 note("6. Click on the SECOND GREEN circle.");
253 _root.onMouseDown = function()
255 check_equals(_root.draggable50._droptarget, "_level50/target20");
256 check_equals(eval(_root.draggable50._droptarget), _level50.target20);
257 test7();
261 test7 = function()
263 note("7. Click on the SECOND BLUE circle.");
264 _root.onMouseDown = function()
266 check_equals(_root.draggable50._droptarget, "_level50/target100");
267 check_equals(eval(_root.draggable50._droptarget), _level50.target100);
268 test8();
272 test8 = function()
274 note("8. Click on the THIRD RED circle.");
275 _root.onMouseDown = function()
277 check_equals(_root.draggable50._droptarget, "/loadedTarget/target10");
278 check_equals(eval(_root.draggable50._droptarget), _level0.loadedTarget.target10);
279 test9();
283 test9 = function()
285 note("9. Click on the THIRD GREEN circle.");
286 _root.onMouseDown = function()
288 check_equals(_root.draggable50._droptarget, "/loadedTarget/target20");
289 check_equals(eval(_root.draggable50._droptarget), _level0.loadedTarget.target20);
290 test10();
294 test10 = function()
296 note("10. Click on the THIRD BLUE circle.");
297 _root.onMouseDown = function()
299 check_equals(_root.draggable50._droptarget, "/loadedTarget/target100");
300 check_equals(eval(_root.draggable50._droptarget), _level0.loadedTarget.target100);
302 // move the draggable over the first green square
303 _root.draggable50._x = _root.draggable50._y = 50;
305 // and stop the drag
306 _root.draggable50.stopDrag();
308 test11();
312 test11 = function()
314 note("11. Click ANYWHERE OUT of the THIRD BLUE circle (on another circle makes a better test)");
315 _root.onMouseDown = function()
317 check_equals(_root.draggable50._droptarget, "/loadedTarget/target100");
318 endOfTest(); // TODO: test that moving the draggable out of any drawing changes _droptarget to the empty string
323 endOfTest = function()
325 _root.ENDOFTEST = true;
326 note("END OF TEST");
327 check_totals(21);
328 _root.onMouseDown = undefined;
331 test1(); // start the test
334 #endif // ndef LOADED_VERSION
336 stop();