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 createEmptyMovieClip
("target10", 10);
68 beginFill
(0xFF0000, 100);
69 drawCircle
(target10
, 50, 50, 20);
71 target10
.onDragOver
= dragOverHandler
;
72 target10
.onDragOut
= dragOutHandler
;
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
);
90 createEmptyMovieClip
("target20", 20);
94 beginFill
(0x00FF00, 100);
95 drawCircle
(target20
, 100, 50, 20);
97 target20
.onDragOver
= dragOverHandler
;
98 target20
.onDragOut
= dragOutHandler
;
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
);
112 #ifdef LOADED_VERSION
117 createEmptyMovieClip
("target100", 100);
121 beginFill
(0x0000FF, 50);
122 drawCircle
(target100
, 70, 100, 20);
124 target100
.onDragOver
= dragOverHandler
;
125 target100
.onDragOut
= dragOutHandler
;
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
);
139 #ifdef LOADED_VERSION
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);
156 beginFill
(0x00FFFF, 50);
157 drawCircle
(draggable50
, 0, 0, 10);
158 draggable50
.startDrag
(true, 0, 0, 500, 120);
160 draggable50
.onDragOver
= dragOverHandler
;
161 draggable50
.onDragOut
= dragOutHandler
;
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
);
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
;
193 note
("- This test is for drag&drop operations. Follow the instructions - ");
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);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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;
306 _root
.draggable50
.stopDrag
();
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;
328 _root
.onMouseDown
= undefined;
331 test1
(); // start the test
334 #endif
// ndef LOADED_VERSION