int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; SWFMovieClip dejagnuclip; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s\n", argv[0]); return 1; } puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); /* let's talk pixels */ mo = newSWFMovie(); SWFMovie_setRate(mo, 12); //SWFMovie_setDimension(mo, 6400, 4000); SWFMovie_setDimension(mo, 640, 400); /********************************************* * * Body * *********************************************/ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); addRedSquareExport(mo); /* it seems we need a SHOWFRAME for this to be effective */ /* (maybe it's related to loop-back handling ?) */ SWFMovie_nextFrame(mo); /* A load of tests for depth */ add_actions(mo, "attachMovie('redsquare', 'depthtest', -16, initObj);" "d = depthtest.getDepth();"); check_equals(mo, "d", "-16"); add_actions(mo, "attachMovie('redsquare', 'depthtest', -16384, initObj);" "d = depthtest.getDepth();"); check_equals(mo, "d", "-16384"); /* Less than -16384 fails */ add_actions(mo, "attachMovie('redsquare', 'depthtest2', -20000, initObj);" "d = depthtest2.getDepth();"); check_equals(mo, "d", "undefined"); /* It really does */ add_actions(mo, "attachMovie('redsquare', 'depthtest2', -16385, initObj);" "d = depthtest2.getDepth();"); check_equals(mo, "d", "undefined"); /* Up to 2130690044 works */ add_actions(mo, "attachMovie('redsquare', 'depthtest2', 1147483648, initObj);" "d = depthtest2.getDepth();"); check_equals(mo, "d", "1147483648"); /* Up to 2130690044 works */ add_actions(mo, "attachMovie('redsquare', 'depthtest3', 2130690044, initObj);" "d = depthtest3.getDepth();"); check_equals(mo, "d", "2130690044"); /* 2130690045 doesn't work */ add_actions(mo, "attachMovie('redsquare', 'depthtest4', 2130690045, initObj);" "d = depthtest4.getDepth();"); check_equals(mo, "d", "undefined"); /* duplicateMovieClip */ /* Same limits... */ add_actions(mo, "createEmptyMovieClip('original', 10);"); add_actions(mo, "duplicateMovieClip('original', 'dup1', -1);" "d = dup1.getDepth();"); check_equals(mo, "d", "-1"); add_actions(mo, "original.duplicateMovieClip('odup1', -1);" "d = odup1.getDepth();"); check_equals(mo, "d", "-1"); add_actions(mo, "duplicateMovieClip('original', 'dup2', -16384);" "d = dup2.getDepth();"); check_equals(mo, "d", "-16384"); add_actions(mo, "original.duplicateMovieClip('odup2', -16384);" "d = odup2.getDepth();"); check_equals(mo, "d", "-16384"); add_actions(mo, "duplicateMovieClip('original', 'dup3', -16385);" "d = dup3.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "original.duplicateMovieClip('odup3', -16385);" "d = odup3.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "duplicateMovieClip('original', 'dup4', 2130690044);" "d = dup4.getDepth();"); check_equals(mo, "d", "2130690044"); add_actions(mo, "original.duplicateMovieClip('odup4', 2130690044);" "d = odup4.getDepth();"); check_equals(mo, "d", "2130690044"); add_actions(mo, "duplicateMovieClip('original', 'dup5', 2130690045);" "d = dup5.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "original.duplicateMovieClip('odup5', 2130690045);" "d = odup5.getDepth();"); check_equals(mo, "d", "undefined"); add_actions(mo, "totals(); stop();"); SWFMovie_nextFrame(mo); /* showFrame */ /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; SWFMovieClip dejagnuclip, staticSquare; SWFShape shape; SWFDisplayItem it; if ( argc>1 ) mediadir=argv[1]; else { fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); return 1; } Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); mo = newSWFMovie(); SWFMovie_setDimension(mo, 800, 600); if (mo == NULL) return -1; addRedSquareExport(mo); add_actions(mo, "_root.onKeyDown = _root.onMouseUp = function() {" "play(); }; " "Key.addListener(_root);"); SWFMovie_setRate(mo, 12); dejagnuclip = get_dejagnu_clip( (SWFBlock)get_default_font(mediadir), 10, 10, 150, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); SWFMovie_nextFrame(mo); add_actions(mo, "BitmapData = flash.display.BitmapData;" "Rectangle = flash.geom.Rectangle;" "bmp = new BitmapData(150, 150, false);" "rect = new Rectangle(10, 10, 100, 100);" "bmp.fillRect(rect, 0x00ff00);" "mc = _root.createEmptyMovieClip('mc', getNextHighestDepth());" "d = mc.getNextHighestDepth();" "mc.attachBitmap(bmp, d);" "bmp2 = new BitmapData(20, 20, true);" "rect2 = new Rectangle (10, 10, 20, 20);" "bmp2.fillRect(rect2, 0xffffff00);" "d2 = mc.getNextHighestDepth();" "mc.attachBitmap(bmp2, d2);" "note('1. You should see a small yellow square in the top left " "corner of a larger green square. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "rect = new Rectangle (90, 90, 120, 120);" "bmp.fillRect(rect, 0x0000FF);" "note('2. You should see a new blue square covering the " "bottom right corner of the large green square. Click" " to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "mc.createEmptyMovieClip('d', d);" "note('3. You should see just the small yellow square in the top " "left corner. Click to proceed.');"); add_actions(mo, "stop();"); SWFMovie_nextFrame(mo); // Place a dynamic DisplayObject at depth 4 add_actions(mo, "mc.removeMovieClip();" "_root.attachMovie('redsquare', 'rs', 4);"); // Place a static DisplayObject at depth 3 staticSquare = newSWFMovieClip(); shape = make_fill_square (300, 0, 60, 60, 255, 0, 255, 255, 0, 255); SWFMovieClip_add(staticSquare, (SWFBlock)shape); SWFMovieClip_nextFrame(staticSquare); it = SWFMovie_add(mo, (SWFBlock)staticSquare); SWFDisplayItem_setDepth(it, 3); SWFDisplayItem_setName(it, "staticSquare"); add_actions(mo, "note('4. You should see a red square in the top left and a " "purple square in the top right. Click to proceed.');"); add_actions(mo, "stop();"); SWFMovie_nextFrame(mo); add_actions(mo, "staticSquare.swapDepths(20);" "note('5. There should have been no change. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "_root.attachBitmap(bmp, 2);" "note('6. You should see the green and blue squares " "under the red square. The purple square should still be there. " "Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "_root.attachBitmap(bmp, 3);" "note('7. There should have been no change. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); SWFDisplayItem_remove(it); add_actions(mo, "_root.attachBitmap(bmp2, 20);" "note('8. The purple square should have gone. The small yellow " "square should have replaced the top left corner of the red " "square. The green and blue squares should still be there. " "Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "bmp.dispose(); bmp2.dispose();" "note('9. You should see just the red square. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "bmp = new BitmapData(100, 100, false, 0x0000ff);" "note('10. There should have been no change. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "bmp3 = new BitmapData(100, 100, false);" "rect3 = new Rectangle(20, 20, 90, 90);" "bmp3.fillRect(rect3, 0x0000ff);" "ch = _root.createEmptyMovieClip('original', 40);" "original.attachBitmap(bmp3, getNextHighestDepth());" "ch._name = 'duplicate';" "newch = _root.createEmptyMovieClip('original', " "getNextHighestDepth());" "note('11. You should see a large blue square only. " "Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "original.removeMovieClip();" "note('12. There should have been no change. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "duplicate.removeMovieClip();" "note('13. You should see the red square again. Click to " "proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "_root.createEmptyMovieClip('mcLeft', getNextHighestDepth());" "mcLeft.duplicateMovieClip('mcMiddle', getNextHighestDepth()," " { _x: 300, _y: 0 } );" "mcLeft.attachBitmap(bmp3, getNextHighestDepth());" "mcMiddle.attachBitmap(bmp3, getNextHighestDepth());" "mcMiddle.duplicateMovieClip('mcRight', getNextHighestDepth()," " { _x: 600, _y: 0 } );" "note('14. You should see two blue squares. Click to proceed.');" "stop();" ); SWFMovie_nextFrame(mo); add_actions(mo, "bmp3.noise(293);" "note('15. You should see two noise patterns where the two " "squares were. Click to proceed.');" "stop();" ); add_actions(mo, "_root.onKeyDown = _root.onMouseUp = undefined;" "_root.eof = true;" // hook for test runner... "note(' - END OF TEST - thanks for flying with us ! ');" //"totals(6);" // no AS based tests... ); SWFMovie_nextFrame(mo); //Output movie puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; SWFMovieClip dejagnuclip; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s\n", argv[0]); return 1; } puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); /* let's talk pixels */ mo = newSWFMovie(); SWFMovie_setRate(mo, 12); //SWFMovie_setDimension(mo, 6400, 4000); SWFMovie_setDimension(mo, 640, 400); /********************************************* * * Body * *********************************************/ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); addRedSquareExport(mo); /* it seems we need a SHOWFRAME for this to be effective */ /* (maybe it's related to loop-back handling ?) */ SWFMovie_nextFrame(mo); // This should run for four frames. The counter should only be reset // on the first frame, i.e. when start is undefined. This should // work for all swf versions, unlike "if (undefined < 4);" add_actions(mo, "initObj = new Object();"); add_actions(mo, "if (!started) { counter = 0; started = true; }"); add_actions(mo, "redsquare = function() { " " trace('hello redsquare'); " " if (counter > 0) {" " check_equals(this._x, counter * 70);" " check_equals(Math.round(this._xscale), 99);" " check_equals(Math.round(this._yscale), " " Math.round((10 * counter +5) / 60 * 100));" " check_equals(this._height, 10 * counter + 5); " " check_equals(this.aProperty, 6); " " } else {" " check_equals(this._x, 0);" " check_equals(this._xscale, 100);" " check_equals(this._height, 60.1);" " check_equals(this.aProperty, undefined); " " };" " };" "redsquare.prototype = new MovieClip();" "Object.registerClass('redsquare', redsquare);" ); add_actions(mo, "if ( counter < 4 ) {" " if ( counter > 0 ) { " " initObj.aProperty = 6;" " initObj._xscale = 99;" " initObj._x = 70*counter;" " initObj._height = 10*counter + 5; " " attachMovie('redsquare', " " 'square'+counter, 70+counter, initObj);" " } else {" /* We don't use an initObject for the first attachMovie call * to verify that the DisplayObject will be kept in DisplayList * at loopback time anyway */ " attachMovie('redsquare', " " 'square'+counter, 70+counter);" " }" " check_equals(this['square'+counter]._x, 70*counter);" " if (counter > 0) {" " check_equals(this['square'+counter]._height, 10 * counter + 5);" " };" " note('Depth is '+70*counter);" " counter++;" " note('Next counter is '+counter);" "} else {" " totals(26); stop();" "}" ); SWFMovie_nextFrame(mo); /* showFrame */ /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }
int main(int argc, char** argv) { SWFMovie mo; const char *srcdir="."; SWFMovieClip dejagnuclip; /********************************************* * * Initialization * *********************************************/ if ( argc>1 ) srcdir=argv[1]; else { fprintf(stderr, "Usage: %s\n", argv[0]); return 1; } puts("Setting things up"); Ming_init(); Ming_useSWFVersion (OUTPUT_VERSION); Ming_setScale(20.0); /* let's talk pixels */ mo = newSWFMovie(); SWFMovie_setRate(mo, 12); SWFMovie_setDimension(mo, 640, 400); /********************************************* * * Body * *********************************************/ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600); SWFMovie_add(mo, (SWFBlock)dejagnuclip); addRedSquareExport(mo); /* it seems we need a SHOWFRAME for this to be effective */ /* (maybe it's related to loop-back handling ?) */ SWFMovie_nextFrame(mo); /* end of frame1 */ add_actions(mo, "counter = 1; onLoadCalled = new Array();"); add_actions(mo, "var name1 = 'square'+counter;" "attachMovie('redsquare', name1, 70+counter);" "var clip1 = this[name1];" "counter++;" ); SWFMovie_nextFrame(mo); /* end of frame2 */ add_actions(mo, "function CustomClass() { this._x = 80; }" "CustomClass.prototype.onLoad = function() { note(this+'.onLoad called'); _root.onLoadCalled.push(this); };" "registerClassRet = Object.registerClass('redsquare', CustomClass);" ); check_equals(mo, "typeof(registerClassRet)", "'boolean'"); check_equals(mo, "registerClassRet", "true"); add_actions(mo, "var name2 = 'square'+counter;" "attachMovie('redsquare', name2, 70+counter);" "var clip2 = this[name2];" "counter++;" ); SWFMovie_nextFrame(mo); /* end of frame3 */ add_actions(mo, "function CustomClass2() { this._x = 160; check_equals(typeof(super.lineTo), 'function'); }" "CustomClass2.prototype = new MovieClip;" "registerClassRet = Object.registerClass('redsquare', CustomClass2);" ); check_equals(mo, "_root.onLoadCalled.length", "1"); check_equals(mo, "_root.onLoadCalled[0]", "_level0.square2"); check_equals(mo, "typeof(registerClassRet)", "'boolean'"); check_equals(mo, "registerClassRet", "true"); add_actions(mo, "var name3 = 'square'+counter;" "attachMovie('redsquare', name3, 70+counter);" "var clip3 = this[name3];" "counter++;" ); SWFMovie_nextFrame(mo); /* end of frame4 */ add_actions(mo, "registerClassRet = Object.registerClass('redsquare');" ); check_equals(mo, "typeof(registerClassRet)", "'boolean'"); check_equals(mo, "registerClassRet", "false"); add_actions(mo, "var name4 = 'square'+counter;" "attachMovie('redsquare', name4, 70+counter);" "var clip4 = this[name4];" "clip4._x = 240;" "counter++;" ); SWFMovie_nextFrame(mo); /* end of frame5 */ check_equals(mo, "typeof(clip1)", "'movieclip'"); check(mo, "clip1 instanceOf MovieClip"); check_equals(mo, "clip1._x", "0"); check(mo, "! clip1 instanceOf CustomClass"); // Check that non-enumerable properties (unnamed instances, // constructor, __constructor__) are not enumerated. add_actions(mo, "var s = ''; for (i in clip1) { s += i + ','; };"); check_equals(mo, "s", "'onRollOver,'"); check_equals(mo, "typeof(clip2)", "'movieclip'"); check(mo, "clip2 instanceOf CustomClass"); check(mo, "clip2.hasOwnProperty('__constructor__')"); check(mo, "clip2.hasOwnProperty('constructor')"); check(mo, "clip2.hasOwnProperty('__proto__')"); check_equals(mo, "clip2.__proto__", "CustomClass.prototype"); check_equals(mo, "clip2.__constructor__", "CustomClass"); check_equals(mo, "clip2.constructor", "CustomClass"); check_equals(mo, "clip2._x", "80"); check_equals(mo, "typeof(clip2.lineTo)", "'undefined'"); check(mo, "! clip2 instanceOf MovieClip"); // Check that non-enumerable properties (unnamed instances, // constructor, __constructor__) are not enumerated. add_actions(mo, "var s = ''; for (i in clip2) { s += i + ','; };"); check_equals(mo, "s", "'onLoad,onRollOver,'"); check(mo, "clip3.hasOwnProperty('__constructor__')"); check(mo, "clip3.hasOwnProperty('constructor')"); check(mo, "clip3.hasOwnProperty('__proto__')"); check_equals(mo, "clip3.__proto__", "CustomClass2.prototype"); check_equals(mo, "clip3.__constructor__", "CustomClass2"); check_equals(mo, "clip3.constructor", "CustomClass2"); check_equals(mo, "typeof(clip3)", "'movieclip'"); check_equals(mo, "clip3._x", "160"); check(mo, "clip3 instanceOf CustomClass2"); check(mo, "clip3 instanceOf MovieClip"); // Check that non-enumerable properties (unnamed instances, // constructor, __constructor__) are not enumerated. add_actions(mo, "var s = ''; for (i in clip3) { s += i + ','; };"); check_equals(mo, "s", "'onRollOver,'"); check(mo, "clip4.hasOwnProperty('__constructor__')"); check(mo, "clip4.hasOwnProperty('constructor')"); check(mo, "clip4.hasOwnProperty('__proto__')"); check_equals(mo, "clip4.__proto__", "CustomClass2.prototype"); check_equals(mo, "clip4.__constructor__", "CustomClass2"); check_equals(mo, "clip4.constructor", "CustomClass2"); check_equals(mo, "typeof(clip4)", "'movieclip'"); check_equals(mo, "clip4._x", "240"); check(mo, "clip4 instanceOf MovieClip"); add_actions(mo, "totals(47);" "stop();" ); SWFMovie_nextFrame(mo); /* end of frame5 */ /***************************************************** * * Output movie * *****************************************************/ puts("Saving " OUTPUT_FILENAME ); SWFMovie_save(mo, OUTPUT_FILENAME); return 0; }