gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog utilities/processor.cpp testsui...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog utilities/processor.cpp testsui...
Date: Sat, 24 Feb 2007 10:37:57 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/02/24 10:37:57

Modified files:
        .              : ChangeLog 
        utilities      : processor.cpp 
        testsuite/actionscript.all: LoadVars.as 

Log message:
                * utilities/processor.cpp:
                  Fix waitforadvance handling. Wait 1 seconds before
                  kicking movie to next frame. This allows for testing
                  intervals and similar time-dependent features.
                * testsuite/actionscript.all/LoadVars.as:
                  Add test for LoadVars.load, LoadVars.getBytesTotal,
                  LoadVars.getBytesLoaded and LoadVars.onLoad.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2450&r2=1.2451
http://cvs.savannah.gnu.org/viewcvs/gnash/utilities/processor.cpp?cvsroot=gnash&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/LoadVars.as?cvsroot=gnash&r1=1.7&r2=1.8

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2450
retrieving revision 1.2451
diff -u -b -r1.2450 -r1.2451
--- ChangeLog   24 Feb 2007 10:14:25 -0000      1.2450
+++ ChangeLog   24 Feb 2007 10:37:57 -0000      1.2451
@@ -2,6 +2,13 @@
 
        * server/asobj/LoadVars.cpp: 
          Made code more robust, and hopefully also cleaner.
+       * utilities/processor.cpp:
+         Fix waitforadvance handling. Wait 1 seconds before
+         kicking movie to next frame. This allows for testing
+         intervals and similar time-dependent features.
+       * testsuite/actionscript.all/LoadVars.as:
+         Add test for LoadVars.load, LoadVars.getBytesTotal,
+         LoadVars.getBytesLoaded and LoadVars.onLoad.
 
 2007-02-23 Sandro Santilli <address@hidden>
 

Index: utilities/processor.cpp
===================================================================
RCS file: /sources/gnash/gnash/utilities/processor.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- utilities/processor.cpp     16 Feb 2007 09:32:27 -0000      1.48
+++ utilities/processor.cpp     24 Feb 2007 10:37:57 -0000      1.49
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: processor.cpp,v 1.48 2007/02/16 09:32:27 strk Exp $ */
+/* $Id: processor.cpp,v 1.49 2007/02/24 10:37:57 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -36,6 +36,9 @@
 
 #include <iostream>
 #include <cstdio>
+#include <sys/time.h>
+#include <time.h>
+
 extern "C"{
        #include <unistd.h>
 #ifdef HAVE_GETOPT_H
@@ -49,7 +52,7 @@
 
 // How many seconds to wait for a frame advancement 
 // before kicking the movie (forcing it to next frame)
-static const size_t waitforadvance = 5;
+static const double waitforadvance = 1;
 
 // How many time do we allow for loop backs
 // (goto frame < current frame)
@@ -108,6 +111,23 @@
 // How many time do we allow to hit the end ?
 static size_t allowed_end_hits = 1;
 
+double lastAdvanceTimer;
+
+void
+resetLastAdvanceTimer()
+{
+       using namespace tu_timer;
+       lastAdvanceTimer = ticks_to_seconds(get_ticks());
+}
+
+double
+secondsSinceLastAdvance()
+{
+       using namespace tu_timer;
+       double now = ticks_to_seconds(get_ticks());
+       return ( now - lastAdvanceTimer);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -298,11 +318,7 @@
 
     md->completeLoad();
     
-    // How many times we allow a movie to be STOPPED
-    // in the same frame ?
-    float fps = md->get_frame_rate();
-    int maxstops=waitforadvance*(int)fps;
-
+    resetLastAdvanceTimer();
     int        kick_count = 0;
     int stop_count=0;
     size_t loop_back_count=0;
@@ -346,17 +362,18 @@
        if (curr_frame == last_frame)
        {
                // Max stop counts reached, kick it
-               if ( ++stop_count >= maxstops)
+               if ( secondsSinceLastAdvance() > waitforadvance )
                {
                        stop_count=0;
 
                        // Kick the movie.
                        if ( last_frame + 1 > md->get_frame_count() -1 )
                        {
-                               printf("exiting after %d times in STOP mode at 
last frame\n", maxstops);
+                               fprintf(stderr, "Exiting after %g seconds in 
STOP mode at last frame\n", waitforadvance);
                                break;
                        }
-                       printf("kicking movie after %d frames in STOP mode, 
kick ct = %d\n", maxstops, kick_count);
+                       fprintf(stderr, "Kicking movie after %g seconds in STOP 
mode, kick ct = %d\n", waitforadvance, kick_count);
+                       fflush(stderr);
                        m.goto_frame(last_frame + 1);
                        m.set_play_state(gnash::sprite_instance::PLAY);
                        kick_count++;
@@ -365,6 +382,8 @@
                                printf("movie is stalled; giving up on playing 
it through.\n");
                                break;
                        }
+
+                       resetLastAdvanceTimer(); // It's like we advanced
                }
        }
        
@@ -385,6 +404,7 @@
        {
            kick_count = 0;
            stop_count = 0;
+           resetLastAdvanceTimer();
        }
     }
     

Index: testsuite/actionscript.all/LoadVars.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/LoadVars.as,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/actionscript.all/LoadVars.as      11 Jan 2007 11:26:50 -0000      
1.7
+++ testsuite/actionscript.all/LoadVars.as      24 Feb 2007 10:37:57 -0000      
1.8
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: LoadVars.as,v 1.7 2007/01/11 11:26:50 strk Exp $";
+rcsid="$Id: LoadVars.as,v 1.8 2007/02/24 10:37:57 strk Exp $";
 
 #include "check.as"
 
@@ -59,4 +59,72 @@
 // test the LoadVars::tostring method
 check_equals (typeof(loadvarsObj.toString), 'function');
 
+//--------------------------------------------------------------------------
+// Test LoadVars::load()
+//--------------------------------------------------------------------------
+
+varsloaded = 0;
+datareceived = 0;
+//var1 = undefined;
+//var2 = undefined;
+loadvarsObj.onLoad = function() {
+       varsloaded++;
+       note("LoadVars.onLoad called "+varsloaded+". "
+               +"Bytes loaded: "+loadvarsObj.getBytesLoaded()
+               +"/"+loadvarsObj.getBytesTotal());
+
+       //delete loadvarsObj; // this to test robustness
+
+       check(varsloaded < 3);
+
+       // onLoad is called after all vars have been called
+       check_equals( loadvarsObj.getBytesLoaded(), loadvarsObj.getBytesTotal() 
);
+
+       //for (var i in _root) { note("_root["+i+"] = "+_root[i]); }
+
+       if ( varsloaded == 2 )
+       {
+               check_equals(loadvarsObj['var1'], 'val1');
+               check_equals(loadvarsObj['var2'], 'val2');
+               check_equals(loadvarsObj['v2_var1'], 'val1');
+               check_equals(loadvarsObj['v2_var2'], 'val2');
+               play();
+       }
+};
+
+// If LoadVars.onData is defined, onLoad won't be called !
+// (at least this is what I see)
+#if 0
+loadvarsObj.onData = function() {
+       datareceived++;
+       note("LoadVars.onData called ("+datareceived+"), byte loaded: "
+               +loadvarsObj.getBytesLoaded()
+               +"/"+loadvarsObj.getBytesTotal());
+       //check_equals(loadvarsObj['var1'], 'val1');
+       //check_equals(loadvarsObj['var2'], 'val2');
+       //for (var i in _root) { note("_root["+i+"] = "+_root[i]); }
+       //play();
+};
+#endif
+
+loadvarsObj.var1 = "previous val1";
+
+// We expect the loaded file to return this string:
+//
+//     "var1=val1&var2=val2&"
+//
+// The final '&' char is important, and it must
+// not start with a '?' char.
+// 
+check( loadvarsObj.load( MEDIA(vars.txt) ) );
+check( loadvarsObj.load( MEDIA(vars2.txt) ) );
+//loadvarsObj.load( 'vars.cgi' );
+
+check_equals(varsloaded, 0);
+check_equals(loadvarsObj['var1'], 'previous val1'); // will be overridden
+check_equals(loadvarsObj['var2'], undefined);
+//delete loadvarsObj; // this to test robustness
+
+stop();
+
 #endif //  OUTPUT_VERSION >= 6




reply via email to

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