"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/testsuite/misc-ming.all/action_order/action_execution_order_test9.c" (19 Jan 2012, 2988 Bytes) of package /linux/www/old/gnash-0.8.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  *   Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
    3  * 
    4  * This program is free software; you can redistribute it and/or modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation; either version 3 of the License, or
    7  * (at your option) any later version.
    8  * 
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU General Public License for more details.
   13  * You should have received a copy of the GNU General Public License
   14  * along with this program; if not, write to the Free Software
   15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16  *
   17  */ 
   18 
   19 /*
   20  * frame2: gotoAndPlay(4);
   21  * frame4: place "mc1" at depth3; gotoAndPlay(6);
   22  * frame5: place "mc2" at depth4;
   23  * frame6: stop;
   24  *
   25  * expected behaviour:
   26  *  first frame actions in "mc1" and "mc2" should not be executed.
   27  */
   28 
   29 #include <stdlib.h>
   30 #include <stdio.h>
   31 #include <ming.h>
   32 
   33 #include "ming_utils.h"
   34 
   35 #define OUTPUT_VERSION 6
   36 #define OUTPUT_FILENAME "action_execution_order_test9.swf"
   37 
   38 SWFDisplayItem add_static_mc(SWFMovie mo, const char* name,
   39         const char* scripts, int depth);
   40 
   41 SWFDisplayItem
   42 add_static_mc(SWFMovie mo, const char* name, const char* scripts, int depth)
   43 {
   44   SWFMovieClip mc;
   45   SWFDisplayItem it;
   46 
   47   mc = newSWFMovieClip();
   48   add_clip_actions(mc, scripts);
   49   SWFMovieClip_nextFrame(mc);
   50 
   51   it = SWFMovie_add(mo, (SWFBlock)mc);
   52   SWFDisplayItem_setDepth(it, depth); 
   53   SWFDisplayItem_setName(it, name);
   54 
   55   return it;
   56 }
   57 
   58 int
   59 main(int argc, char** argv)
   60 {
   61   SWFMovie mo;
   62   SWFMovieClip  dejagnuclip;
   63   SWFDisplayItem it1, it2;
   64   
   65   const char *srcdir=".";
   66   if ( argc>1 ) 
   67     srcdir=argv[1];
   68   else
   69   {
   70       fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
   71       return 1;
   72   }
   73 
   74   Ming_init();
   75   mo = newSWFMovieWithVersion(OUTPUT_VERSION);
   76   SWFMovie_setDimension(mo, 800, 600);
   77   SWFMovie_setRate (mo, 12.0);
   78 
   79   dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
   80   SWFMovie_add(mo, (SWFBlock)dejagnuclip);
   81   SWFMovie_nextFrame(mo); // 1st frame 
   82 
   83   add_actions(mo, " gotoAndPlay(4); ");
   84   SWFMovie_nextFrame(mo); // 2nd frame
   85   
   86   SWFMovie_nextFrame(mo); // 3rd frame 
   87     
   88   it1 = add_static_mc(mo, "mc1", "_root.x = 100;", 3);
   89   add_actions(mo, " gotoAndPlay(6); ");
   90   SWFMovie_nextFrame(mo); // 4th frame 
   91 
   92   SWFDisplayItem_remove(it1);
   93   it2 = add_static_mc(mo, "mc2", "_root.x = 200;", 4); 
   94   SWFMovie_nextFrame(mo); // 5th frame 
   95 
   96   SWFDisplayItem_remove(it2);
   97   // Gnash fails because actions in "mc1" got executed, see expected behaviour
   98   check_equals(mo, "typeof(_root.x)", "'undefined'");
   99   add_actions(mo, " _root.totals(); stop(); ");
  100   SWFMovie_nextFrame(mo); // 6th frame 
  101   
  102   //Output movie
  103   puts("Saving " OUTPUT_FILENAME );
  104   SWFMovie_save(mo, OUTPUT_FILENAME);
  105 
  106   return 0;
  107 }
  108 
  109