2 * Copyright (C) 2005, 2006, 2007, 2009, 2010,
3 * 2011 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * test ActionGetTimer, getTimer returns the time in milliseconds.
22 * TODO: use AS method "ifFrameLoaded" to ensure that all frames are loaded before
25 * Ming seems do not support "ifFrameLoaded" yet:(
26 * Take care that gprocessor does not support frame-rate-control!
27 * Take care that this test might fail if it is loaded from a network
28 * and the loading speed is too slow!
35 #include "ming_utils.h"
37 #define OUTPUT_VERSION 6
38 #define OUTPUT_FILENAME "getTimer_test.swf"
42 main(int argc
, char** argv
)
45 SWFMovieClip dejagnuclip
;
47 const char *srcdir
=".";
52 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
57 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
58 SWFMovie_setDimension(mo
, 800, 600);
59 SWFMovie_setRate (mo
, 1.0);
61 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
62 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
63 SWFMovie_nextFrame(mo
); // frame1
65 // get current time in frame2
66 add_actions(mo
, "x1 = getTimer();");
67 SWFMovie_nextFrame(mo
); // frame2
69 // just delay some time here
70 add_actions(mo
, " for(i=0; i<1000; i++) {} ");
71 // get current time in frame3
72 add_actions(mo
, "x2 = getTimer();");
73 SWFMovie_nextFrame(mo
); // frame3
75 // check that the timer is working
77 check(mo
, "x2 > x1" );
78 // this is dependent on frame rate(current setting is 1 second per frame)
79 // check(mo, "x2 > 1000");
80 check(mo
, "x2 < 6000");
81 // check that "getTimer" return a intergral number
82 check(mo
, "x2 == Math.ceil(x2)");
83 check(mo
, "x2 == Math.floor(x2)");
84 SWFMovie_nextFrame(mo
); // frame4
86 add_actions(mo
, "_root.totals(); stop();");
87 SWFMovie_nextFrame(mo
); // frame5
90 puts("Saving " OUTPUT_FILENAME
);
91 SWFMovie_save(mo
, OUTPUT_FILENAME
);