3 // makeswf -o DrawingApi.swf ../Dejagnu.swf DrawingApi.as
5 // firefox DrawingApi.swf
7 // gnash DrawingApi.swf
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
20 #define SUPPRESS_RCSID_DUMP
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
;
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 createTextField
("tf", 0, 0, 100, 20, 5004);
67 createEmptyMovieClip
("target10", 10);
71 beginFill
(0xFF0000, 100);
72 drawCircle
(target10
, 50, 50, 20);
74 target10
.onDragOver
= dragOverHandler
;
75 target10
.onDragOut
= dragOutHandler
;
77 target10
.onDragOver
= function()
79 check_equals
(this, _root
.target10
);
80 note
("(onDragOver): draggable dragged over "+this._droptarget
);
82 target10
.onDragOut
= function()
84 check_equals
(this, _root
.target10
);
85 note
("(onDragOut): draggable dragged out of "+this._droptarget
);
93 createEmptyMovieClip
("target20", 20);
97 beginFill
(0x00FF00, 100);
98 drawCircle
(target20
, 100, 50, 20);
100 target20
.onDragOver
= dragOverHandler
;
101 target20
.onDragOut
= dragOutHandler
;
103 target20
.onDragOver
= function()
105 check_equals
(this, _root
.target20
);
106 note
("(onDragOver): draggable dragged over "+this._droptarget
);
108 target20
.onDragOut
= function()
110 check_equals
(this, _root
.target20
);
111 note
("(onDragOut): draggable dragged out of "+this._droptarget
);
115 #ifdef LOADED_VERSION
120 createEmptyMovieClip
("target100", 100);
124 beginFill
(0x0000FF, 50);
125 drawCircle
(target100
, 70, 100, 20);
127 target100
.onDragOver
= dragOverHandler
;
128 target100
.onDragOut
= dragOutHandler
;
130 target100
.onDragOver
= function()
132 check_equals
(this, _root
.target100
);
133 note
("(onDragOver): draggable dragged over "+this._droptarget
);
135 target100
.onDragOut
= function()
137 check_equals
(this, _root
.target100
);
138 note
("(onDragOut): draggable dragged out of "+this._droptarget
);
142 #ifdef LOADED_VERSION
147 #ifndef LOADED_VERSION
149 loadMovie
("DragDropTestLoaded.swf", "_level50");
151 createEmptyMovieClip
("loadedTarget", 30);
152 loadedTarget
.loadMovie
("DragDropTestLoaded.swf");
153 loadedTarget
._x
= 100;
155 createEmptyMovieClip
("draggable50", 50);
159 beginFill
(0x00FFFF, 50);
160 drawCircle
(draggable50
, 0, 0, 10);
161 draggable50
.startDrag
(true, 0, 0, 500, 120);
163 draggable50
.onDragOver
= dragOverHandler
;
164 draggable50
.onDragOut
= dragOutHandler
;
166 draggable50
.onDragOver
= function()
168 check_equals
(this, _root
.draggable50
);
169 note
("(onDragOver): draggable dragged over "+this._droptarget
);
171 draggable50
.onDragOut
= function()
173 check_equals
(this, _root
.draggable50
);
174 note
("(onDragOut): draggable dragged out of "+this._droptarget
);
178 draggable50
.lastDropTarget
= undefined;
179 draggable50
.onEnterFrame
= function()
181 //check_equals(this, _root.draggable50);
182 if ( this._droptarget
!= this.lastDropTarget
)
184 if ( this._droptarget
!= "" )
186 // reduces space on the textfield..
187 //note(" -> draggable over "+this._droptarget);
189 this.lastDropTarget
= this._droptarget
;
196 note
("- This test is for drag&drop operations. Follow the instructions - ");
200 note
("1. Click OUTSIDE of any drawing.");
201 _root
.onMouseDown
= function()
203 check_equals
(_root
.draggable50
._droptarget
, "");
204 check_equals
(eval
(_root
.draggable50
._droptarget
), undefined);
211 note
("2. Click on the FIRST RED circle.");
212 _root
.onMouseDown
= function()
214 check_equals
(_root
.draggable50
._droptarget
, "/target10");
215 check_equals
(eval
(_root
.draggable50
._droptarget
), _level0
.target10
);
222 note
("3. Click on the FIRST GREEN circle.");
223 _root
.onMouseDown
= function()
225 check_equals
(_root
.draggable50
._droptarget
, "/target20");
226 check_equals
(eval
(_root
.draggable50
._droptarget
), _level0
.target20
);
233 note
("4. Click on the FIRST BLUE circle.");
234 _root
.onMouseDown
= function()
236 check_equals
(_root
.draggable50
._droptarget
, "/target100");
237 check_equals
(eval
(_root
.draggable50
._droptarget
), _level0
.target100
);
244 note
("5. Click on the SECOND RED circle.");
245 _root
.onMouseDown
= function()
247 check_equals
(_root
.draggable50
._droptarget
, "_level50/target10");
248 check_equals
(eval
(_root
.draggable50
._droptarget
), _level50
.target10
);
255 note
("6. Click on the SECOND GREEN circle.");
256 _root
.onMouseDown
= function()
258 check_equals
(_root
.draggable50
._droptarget
, "_level50/target20");
259 check_equals
(eval
(_root
.draggable50
._droptarget
), _level50
.target20
);
266 note
("7. Click on the SECOND BLUE circle.");
267 _root
.onMouseDown
= function()
269 check_equals
(_root
.draggable50
._droptarget
, "_level50/target100");
270 check_equals
(eval
(_root
.draggable50
._droptarget
), _level50
.target100
);
277 note
("8. Click on the THIRD RED circle.");
278 _root
.onMouseDown
= function()
280 check_equals
(_root
.draggable50
._droptarget
, "/loadedTarget/target10");
281 check_equals
(eval
(_root
.draggable50
._droptarget
), _level0
.loadedTarget
.target10
);
288 note
("9. Click on the THIRD GREEN circle.");
289 _root
.onMouseDown
= function()
291 check_equals
(_root
.draggable50
._droptarget
, "/loadedTarget/target20");
292 check_equals
(eval
(_root
.draggable50
._droptarget
), _level0
.loadedTarget
.target20
);
299 note
("10. Click on the THIRD BLUE circle.");
300 _root
.onMouseDown
= function()
302 check_equals
(_root
.draggable50
._droptarget
, "/loadedTarget/target100");
303 check_equals
(eval
(_root
.draggable50
._droptarget
), _level0
.loadedTarget
.target100
);
305 // move the draggable over the first green square
306 _root
.draggable50
._x
= _root
.draggable50
._y
= 50;
312 // Check that startDrag works for a textfield.
313 // The textfield should no longer be at 0, 100.
316 note
("11. Click on the SECOND GREEN circle.");
318 // Deliberately set target to null and then
319 // call stopDrag (old version) to make sure it still works.
320 asm
{ push
null settargetexpr
};
323 check_equals
(_root
.tf
._x
, 0);
324 check_equals
(_root
.tf
._y
, 100);
326 tf
.startDrag
= MovieClip.prototype
.startDrag
;
328 _root
.onMouseDown
= function()
330 check_equals
(_root
.draggable50
._droptarget
, "/loadedTarget/target100");
331 check
(_root
.tf
._x
!= 0);
332 check
(_root
.tf
._y
!= 100);
339 note
("12. Click ANYWHERE OUT of the THIRD BLUE circle (on another circle makes a better test)");
340 _root
.onMouseDown
= function()
342 check_equals
(_root
.draggable50
._droptarget
, "/loadedTarget/target100");
343 endOfTest
(); // TODO: test that moving the draggable out of any drawing changes _droptarget to the empty string
348 endOfTest
= function()
350 _root
.ENDOFTEST
= true;
353 _root
.onMouseDown
= undefined;
356 test1
(); // start the test
359 #endif
// ndef LOADED_VERSION