Update with current status
[gnash.git] / testsuite / misc-ming.all / getTimer_test.c
blobd4fef29c30a6bdd42255e39057c23bf26bf2e08a
1 /*
2 * Copyright (C) 2005, 2006, 2007, 2009, 2010,
3 * 2011 Free Software Foundation, Inc.
4 *
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.
9 *
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
18 */
20 * test ActionGetTimer, getTimer returns the time in milliseconds.
22 * TODO: use AS method "ifFrameLoaded" to ensure that all frames are loaded before
23 * testing getTimer().
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!
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <ming.h>
35 #include "ming_utils.h"
37 #define OUTPUT_VERSION 6
38 #define OUTPUT_FILENAME "getTimer_test.swf"
41 int
42 main(int argc, char** argv)
44 SWFMovie mo;
45 SWFMovieClip dejagnuclip;
47 const char *srcdir=".";
48 if ( argc>1 )
49 srcdir=argv[1];
50 else
52 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
53 return 1;
56 Ming_init();
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
76 check(mo, "x1 > 0");
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
89 //Output movie
90 puts("Saving " OUTPUT_FILENAME );
91 SWFMovie_save(mo, OUTPUT_FILENAME);
93 return 0;