gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog doc/C/internals.xml testsuite/m...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog doc/C/internals.xml testsuite/m...
Date: Tue, 14 Nov 2006 10:58:35 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/14 10:58:35

Modified files:
        .              : ChangeLog 
        doc/C          : internals.xml 
        testsuite/misc-ming.all: DefineEditTextVariableNameTest.c 
                                 ming_utils.c ming_utils.h 

Log message:
                * testsuite/misc-ming.all/: ming_utils.{c,h},
                  DefineEditTextVariableNameTest.c:
                  Moved general testcase generator facilities to ming_utils
                  lib.
                * doc/C/internals.xml: new sections about writing Ming-based
                  self-contained SWF testcases and MovieTester-based testcases.
                  (Ann, help!)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1613&r2=1.1614
http://cvs.savannah.gnu.org/viewcvs/gnash/doc/C/internals.xml?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineEditTextVariableNameTest.c?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ming_utils.c?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ming_utils.h?cvsroot=gnash&r1=1.5&r2=1.6

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1613
retrieving revision 1.1614
diff -u -b -r1.1613 -r1.1614
--- ChangeLog   14 Nov 2006 10:37:40 -0000      1.1613
+++ ChangeLog   14 Nov 2006 10:58:35 -0000      1.1614
@@ -1,3 +1,13 @@
+2006-11-14 Sandro Santilli <address@hidden>
+
+       * testsuite/misc-ming.all/: ming_utils.{c,h},
+         DefineEditTextVariableNameTest.c: 
+         Moved general testcase generator facilities to ming_utils
+         lib.
+       * doc/C/internals.xml: new sections about writing Ming-based
+         self-contained SWF testcases and MovieTester-based testcases.
+         (Ann, help!)
+
 2006-11-14 Bastiaan Jacques <address@hidden>
 
        * server/parser/Makefile.am: parser uses Boost, so add BOOST_CFLAGS

Index: doc/C/internals.xml
===================================================================
RCS file: /sources/gnash/gnash/doc/C/internals.xml,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- doc/C/internals.xml 6 Nov 2006 19:44:29 -0000       1.29
+++ doc/C/internals.xml 14 Nov 2006 10:58:35 -0000      1.30
@@ -1936,14 +1936,15 @@
        these are organized as one file for ActionScript class.
        Other Ming-generated tests are under testsuite/ming-misc.all/;
        these are typically used to test specific tag types.
-       Full movies are located under testsuite/movies.all/. 
+       Full movies are located under testsuite/movies.all/ and
+       sample movies are under testsuite/samples/.
        Other directories under testsuite/ are (or shall be) used for other
        kind of tests.
       </para>
       
     </sect3>
 
-    <sect3 id="writetests">
+    <sect3 id="writeastests">
       <title>Writing ActionScript Tests</title>
 
       <para>
@@ -2030,6 +2031,186 @@
       </para>
     </sect3>
 
+    <sect3 id="writemingtests">
+      <title>Writing Ming-based Tests</title>
+
+      <para>
+       Ming-based testcases are located under testsuite/misc-ming.all
+       and are composed by a test generator, and a test runner.
+       The test generator (usually a C program) is used to produce the SWF
+       file, the test runner (a C++ program) will run it using a MovieTester
+       class.
+       Note that it is only the test generator needing Ming, not the test
+       runner, so in case there's no Ming installed on users hosts,
+       they can still run the testcase as long as the SWF has been
+       distributed.
+      </para>
+      
+      <para>
+       Producing tests using Ming has the advantage that you can easily see
+       and modify full source code for the SWF movie, and you can use
+       some <link linkend="ming_testgenerator_facilities">facilities</link>
+       provided by Gnash testing framework to easy tests run.
+      </para>
+
+      <para>
+       For generic Ming API documentation, see <ulink type="http"
+       url="http://www.libming.org/";>http://www.libming.org</ulink>. 
+      </para>
+
+      <sect4 id="ming_testgenerator_facilities">
+      <title>Using Ming-based test generators facilities.</title>
+
+      <para>
+       Ming-based test generators facilities, which might be moved into
+       a loadable SWF in the future, can be currently used by your test
+       generator by including the ming_utils.h file and calling the
+       appropriate functions.
+      </para>
+
+      <para>
+       The most useful facility provided for Ming-based SWF test generators
+       is a Dejagnu-like TestState ActionScript class.
+       In order to use this facility you must call 'add_dejagnu_functions()'
+       right after Movie creation.
+       The function takes an SWFMovie object and some parameters specifying
+       depth and location of the "visual" trace textfield; it instantiate
+       a global 'TestState' ActionScript object to keep track of tests state.
+      </para>
+
+      <para>
+        You will <emphasis>not</emphasis> need to directly invoke the
+       TestState object created by the 'add_dejagnu_functions()' routine,
+       rather you will be using other C functions hiding the complexity
+       of it:
+       
+       <programlisting>
+
+       check(SWFMovie mo, const char* expr, int expect_failure)
+
+               Evaluate an ActionScript expression.
+               If 'expect_failure' is true a failure is expected
+               (in case that exposes a known bug)
+
+       check_equals(SWFMovie mo, const char* obtained,
+                               const char* expected, int expect_failure) 
+
+               Evaluate an ActionScript expression against an
+               expected output.
+               If 'expect_failure' is true a failure is expected
+               (in case that exposes a known bug)
+
+       print_tests_summary(SWFMovie mo)
+
+               To be called as last step in your SWF generator,
+               just before saving the movie. Will print tests run
+               summary.
+
+       </programlisting>
+       
+      </para>
+      
+    </sect4>
+
+    <sect4 id="ming_generated_tests_run">
+      <title>Running Ming-generated testcases.</title>
+
+       <para>
+       Testcases generated using Ming and the provided
+       <link linkend="ming_testgenerator_facilities">facilities</link>
+       will be self-contained, which means they can be used as tests
+       by simply running them with whatever Player you might have.
+       Any 'check' or 'check_equals' result will be both traced and
+       printed in a textfield. You can use 'gprocessor -v' to have
+       gnash use them as tests.
+       </para>
+
+       <para>
+       In order to make the test automatically run by 'make check'
+       you'll need to provide a 'test runner' for your testcase
+       and list it in the TEST_CASES variable under testsuite/misc-ming.all/
+       Makefile.am.
+       </para>
+
+       <para>
+       A simple and generic test-runner can be found in
+       testsuite/generic-testrunner.sh. That script can be invoked     
+       passing it the $(top_builddir) as first argument and the
+       name of the SWF file as second argument (w/out path) to output
+       a specific runner for you test in the current builddir.
+       A simple Makefile.am rule for doing this follows:
+
+       <programlisting>
+MyTest-Runner: $(srcdir)/../generic-testrunner.sh MyTest.swf
+        sh $(srcdir)/../generic-testrunner.sh $(top_builddir) MyTest.swf > $@
+        chmod +x $@
+       </programlisting>
+
+       </para>
+
+       <para>
+       Note that there are some parts of Gnash that can NOT be tested
+       by only using ActionScript tests. Examples include: frames
+       advancements, actual actions execution, gui events and so on.
+       </para>
+
+       <para>
+       In this case you might want to use the MovieTester class to
+       implement a C++ test runner. Be aware that you can *mix* tests in
+       the MovieTester-based class with *self-contained*
+       tests in the SWF file, as long as you activate verbosity of
+       the debuglogfile. This is done, for example, for the
+       DefineEditTextVariableNameTest.swf file. The corresponding
+       test runner (DefineEditTextVariableNameTest-Runner) is a C++
+       runner based on MovieTester class. If you run the runner you
+       see two kind of test results: the ones coming from the ActionScript
+       engine, and the ones coming from the test runner. You can
+       distinguish the two becouse the former contains an additional
+       timestamp and the latter does not. Also, you'll see two final
+       summaries for the two test sets. The 'make check' rule, which uses
+       the testsuite/simple.exp output parser as it's work-horse, will
+       count test results from both test sets.
+       </para>
+
+       <para>
+       More info about writing SWF test runners may be found in
+       the <link linkend="writing_movie_testers">Writing Movie
+       testers</link> section.
+       </para>
+
+    </sect4>
+
+    </sect3>
+
+    <sect3 id="writing_movie_testers">
+      <title>Writing Movie testers</title>
+
+       <para>
+       <note>
+       This section is a stub, must be improved
+       </note>
+       </para>
+
+       <para>
+       Movie testers are executables that load an SWF, generate events
+       (both user or system) on that and check their state using
+       a standard interface.
+       </para>
+
+       <para>
+       To help this process a MovieTester class is defined in the
+       testsuite/MovieTester.{h,cpp} files, see Doxygen documentation
+       for more info.
+       </para>
+
+       <para>
+       Note that you do NOT need access to the SWF sourcecode in order
+       to implement a Move tester for it, just some knowledge about
+       it's expected behaviour suffices. 
+       </para>
+
+    </sect3>
+
     <sect3 id="runtests">
       <title>Running The Tests</title>
 

Index: testsuite/misc-ming.all/DefineEditTextVariableNameTest.c
===================================================================
RCS file: 
/sources/gnash/gnash/testsuite/misc-ming.all/DefineEditTextVariableNameTest.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/misc-ming.all/DefineEditTextVariableNameTest.c    14 Nov 2006 
09:38:57 -0000      1.12
+++ testsuite/misc-ming.all/DefineEditTextVariableNameTest.c    14 Nov 2006 
10:58:35 -0000      1.13
@@ -85,45 +85,6 @@
 }
 
 
-/* The following three functions to be exported in ming_utils */
-void check(SWFMovie mo, const char* expr, int expected_failure);
-void check_equals(SWFMovie mo, const char* obtained, const char* expected, int 
expected_failure);
-void add_actions(SWFMovie mo, const char* code);
-
-
-void
-check(SWFMovie mo, const char* expr,
-               int expected_failure)
-{
-       static const size_t BUFLEN = 512;
-
-       char buf[BUFLEN];
-       SWFAction ac;
-       snprintf(buf, BUFLEN, "%scheck(%s);",
-               expected_failure ? "x" : "",
-               expr);
-       buf[BUFLEN-1] = '\0';
-       ac = compileSWFActionCode(buf);
-       SWFMovie_add(mo, (SWFBlock)ac);
-}
-
-void
-check_equals(SWFMovie mo, const char* obtained, const char* expected,
-               int expected_failure)
-{
-       static const size_t BUFLEN = 512;
-
-       char buf[BUFLEN];
-       SWFAction ac;
-       snprintf(buf, BUFLEN, "%scheck_equals(%s, %s);",
-               (expected_failure ? "x" : ""),
-               obtained, expected);
-       buf[BUFLEN-1] = '\0';
-       ac = compileSWFActionCode(buf);
-       /*fprintf(stderr, "%s\n", buf);*/
-       SWFMovie_add(mo, (SWFBlock)ac);
-}
-
 void
 set_text(SWFMovie mo, const char* txt, const char* mcname, const char* varname)
 {
@@ -139,19 +100,6 @@
 }
 
 void
-add_actions(SWFMovie mo, const char* code)
-{
-       static const size_t BUFLEN = 1024;
-
-       char buf[BUFLEN];
-       SWFAction ac;
-       snprintf(buf, BUFLEN, "%s", code);
-       buf[BUFLEN-1] = '\0';
-       ac = compileSWFActionCode(buf);
-       SWFMovie_add(mo, (SWFBlock)ac);
-}
-
-void
 add_text_field(SWFMovieClip mo, SWFBlock font, const char* varname,
                const char* text)
 {
@@ -328,7 +276,8 @@
        check_equals(mo, varName2, "''", 0);
        check_equals(mo, "mc2.textfield._x", "150", 0);
 
-       add_actions(mo, "runtest.totals();");
+       print_tests_summary();
+
        add_actions(mo, "stop();");
 
        SWFMovie_nextFrame(mo); /* showFrame */

Index: testsuite/misc-ming.all/ming_utils.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/ming_utils.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/misc-ming.all/ming_utils.c        14 Nov 2006 09:38:57 -0000      
1.7
+++ testsuite/misc-ming.all/ming_utils.c        14 Nov 2006 10:58:35 -0000      
1.8
@@ -142,3 +142,57 @@
 
        SWFMovie_add(mo, (SWFBlock)ac);
 }
+
+void
+check(SWFMovie mo, const char* expr,
+               int expected_failure)
+{
+       static const size_t BUFLEN = 512;
+
+       char buf[BUFLEN];
+       SWFAction ac;
+       snprintf(buf, BUFLEN, "%scheck(%s);",
+               expected_failure ? "x" : "",
+               expr);
+       buf[BUFLEN-1] = '\0';
+       ac = compileSWFActionCode(buf);
+       SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+void
+check_equals(SWFMovie mo, const char* obtained, const char* expected,
+               int expected_failure)
+{
+       static const size_t BUFLEN = 512;
+
+       char buf[BUFLEN];
+       SWFAction ac;
+       snprintf(buf, BUFLEN, "%scheck_equals(%s, %s);",
+               (expected_failure ? "x" : ""),
+               obtained, expected);
+       buf[BUFLEN-1] = '\0';
+       ac = compileSWFActionCode(buf);
+       /*fprintf(stderr, "%s\n", buf);*/
+       SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+void
+add_actions(SWFMovie mo, const char* code)
+{
+       static const size_t BUFLEN = 1024;
+
+       char buf[BUFLEN];
+       SWFAction ac;
+       snprintf(buf, BUFLEN, "%s", code);
+       buf[BUFLEN-1] = '\0';
+       ac = compileSWFActionCode(buf);
+       SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+void
+print_tests_summary(SWFMovie mo)
+{
+       add_actions(mo, "runtest.totals();");
+}
+
+

Index: testsuite/misc-ming.all/ming_utils.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/ming_utils.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/misc-ming.all/ming_utils.h        13 Nov 2006 12:00:05 -0000      
1.5
+++ testsuite/misc-ming.all/ming_utils.h        14 Nov 2006 10:58:35 -0000      
1.6
@@ -22,20 +22,82 @@
 
 #include <ming.h>
 
-/// Add an 'xtrace' function that both traces usin 'trace' and
-/// printing to a textfield created using the given depth, position and size
+/** \brief
+ * Add an 'xtrace' function that both traces usin 'trace' and
+ * printing to a textfield created using the given depth, position and size
+ */
 void add_xtrace_function(SWFMovie mo, int depth, int x, int y, int width, int 
height);
 
-/// Add 'check', 'xcheck', 'check_equals', 'xcheck_equals' functions for
-/// use by embedded-swf tests.
-/// This function will internally call add_xtrace_function with the
-/// given parameters
+/** \brief
+ * Add 'check', 'xcheck', 'check_equals', 'xcheck_equals' functions for
+ * use by embedded-swf tests.
+ * This function will internally call add_xtrace_function with the
+ * given parameters
+ */
 void add_dejagnu_functions(SWFMovie mo, int depth, int x, int y, int width, 
int height);
 
-/// Create an outline square shape with given offset, size and colors
+/** \brief
+ * Evaluate ActionScript 'expr' expression updating the global TestState
+ * (make sure you called add_dejagnu_functions before using this function)
+ *
+ * @param mo
+ *   The SWFMovie to add the DO_ACTION block to
+ *
+ * @param expr
+ *   The ActionScript expression
+ *
+ * @param expected_failure
+ *   Set to 1 if a failure is expected
+ */
+void check(SWFMovie mo, const char* expr, int expected_failure);
+
+/** \brief
+ * Evaluate equality of two ActionScript expressions updating the global
+ * TestState accordingly.
+ * (make sure you called add_dejagnu_functions before using this function)
+ *
+ * @param mo
+ *   The SWFMovie to add the DO_ACTION block to
+ *
+ * @param obtained
+ *   The ActionScript expression we are testing
+ *
+ * @param expected
+ *   The ActionScript expression we expect to equal the obtained one
+ *
+ * @param expected_failure
+ *   Set to 1 if a failure is expected
+ */
+void check_equals(SWFMovie mo, const char* obtained, const char* expected, int 
expected_failure);
+
+/** \brief
+ * Print TestState total summary.
+ * (make sure you called add_dejagnu_functions before using this function)
+ *
+ * @param mo
+ *   The SWFMovie to add the DO_ACTION block to
+ */
+void print_tests_summary(SWFMovie mo);
+
+/** \brief
+ * Add an arbitrary ActionScript code in the given movie
+ *
+ * @param mo
+ *   The SWFMovie to add the DO_ACTION block to.
+ *
+ * @param code
+ *   ActionScript code to be compiled in.
+ */
+void add_actions(SWFMovie mo, const char* code);
+
+/** \brief
+ *  Create an outline square shape with given offset, size and colors
+ */
 SWFShape make_square(int x, int y, int width, int height, byte r, byte g, byte 
b);
 
-/// Create a filled square shape with given offset, size and colors
+/** \brief
+ *  Create a filled square shape with given offset, size and colors
+ */
 SWFShape make_fill_square(int x, int y, int width, int height, byte outline_r, 
byte outline_g, byte outline_b, byte fill_r, byte fill_g, byte fill_b);
 
 #endif // GNASH_MING_UTILS_H




reply via email to

[Prev in Thread] Current Thread [Next in Thread]