gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp test...


From: Zou Lunkai
Subject: [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp test...
Date: Mon, 28 May 2007 09:35:36 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Zou Lunkai <zoulunkai>  07/05/28 09:35:35

Modified files:
        .              : ChangeLog 
        server         : sprite_instance.cpp 
Added files:
        testsuite/misc-ming.all: key_event_test2.c 
                                 key_event_test2runner.cpp 

Log message:
        partly fix the increasing key listeners when loop back

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3376&r2=1.3377
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.282&r2=1.283
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/key_event_test2.c?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/key_event_test2runner.cpp?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3376
retrieving revision 1.3377
diff -u -b -r1.3376 -r1.3377
--- ChangeLog   28 May 2007 08:56:51 -0000      1.3376
+++ ChangeLog   28 May 2007 09:35:33 -0000      1.3377
@@ -1,3 +1,11 @@
+2007-05-28 Zou Lunkai <address@hidden>
+
+       * testsuite/misc-ming.all: Makefile.am, key_event_test2.c, 
+         key_event_test2runner.cpp: add tests for key listeners.
+       * server/sprite_instance.cpp: call "unload" for characters removed
+         in ::resetDisplayList, partly fix the increasing key listeners
+         problem when loop back.
+       
 2007-05-28 Sandro Santilli <address@hidden>
 
        * testsuite/misc-ming.all/matrix_test.c: round numbers

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -b -r1.282 -r1.283
--- server/sprite_instance.cpp  25 May 2007 11:54:11 -0000      1.282
+++ server/sprite_instance.cpp  28 May 2007 09:35:34 -0000      1.283
@@ -2512,7 +2512,8 @@
                // actually updating the displaylist !
                set_invalidated(); 
 
-               m_display_list = _frame0_chars;                 
+               //m_display_list = _frame0_chars;       
+               m_display_list.clear_except(_frame0_chars, true); // call unload
        };
 }
 

Index: testsuite/misc-ming.all/key_event_test2.c
===================================================================
RCS file: testsuite/misc-ming.all/key_event_test2.c
diff -N testsuite/misc-ming.all/key_event_test2.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/key_event_test2.c   28 May 2007 09:35:35 -0000      
1.1
@@ -0,0 +1,102 @@
+/*
+ *   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */ 
+
+/*
+ *  frame1: set _root.x1 to zero;
+ *  frame2: 
+ *    place a static movieclip "mc" at depth 20 with a onClipKeyDown event 
handler;
+ *    increases _root.x1;
+ *  frame3: nothing
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION  6
+#define OUTPUT_FILENAME  "key_event_test2.swf"
+
+
+SWFDisplayItem
+add_static_mc(SWFMovie mo, const char* name, int depth)
+{
+  SWFMovieClip mc;
+  SWFDisplayItem it;
+
+  mc = newSWFMovieClip();
+  SWFMovieClip_nextFrame(mc);
+
+  it = SWFMovie_add(mo, (SWFBlock)mc);
+  SWFDisplayItem_setDepth(it, depth); 
+  SWFDisplayItem_setName(it, name);
+
+  return it;
+}
+
+
+int
+main(int argc, char** argv)
+{
+  SWFMovie mo;
+  SWFMovieClip  dejagnuclip;
+  SWFDisplayItem  it;
+
+  const char *srcdir=".";
+  if ( argc>1 ) 
+    srcdir=argv[1];
+  else
+  {
+      fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+      return 1;
+  }
+
+  Ming_init();
+  mo = newSWFMovieWithVersion(OUTPUT_VERSION);
+  SWFMovie_setDimension(mo, 800, 600);
+  SWFMovie_setRate (mo, 12.0);
+
+  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 
800, 600);
+  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+  add_actions(mo, "x1=0;");
+  SWFMovie_nextFrame(mo);  /* 1st frame */
+
+  // place a static movieclip "mc" at depth 20
+  it = add_static_mc(mo, "mc", 20);
+
+  // Define onClipKeyDown for "mc"
+  SWFDisplayItem_addAction(it,
+    newSWFAction(" _root.note('onClipKeyDown triggered'); "
+                 " _root.x1++; "
+                 // TODO: enable this self-contained check after fix
+                 // " _root.check_equals(_root.x1, 1);"
+                ), 
+    SWFACTION_KEYDOWN);    
+    
+  SWFMovie_nextFrame(mo); /* 2nd frame */
+  
+  
+  //Output movie
+  puts("Saving " OUTPUT_FILENAME );
+  SWFMovie_save(mo, OUTPUT_FILENAME);
+
+  return 0;
+}
+
+

Index: testsuite/misc-ming.all/key_event_test2runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/key_event_test2runner.cpp
diff -N testsuite/misc-ming.all/key_event_test2runner.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/key_event_test2runner.cpp   28 May 2007 09:35:35 
-0000      1.1
@@ -0,0 +1,111 @@
+/* 
+ *   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ */ 
+
+#define INPUT_FILENAME "key_event_test2.swf"
+
+#include "MovieTester.h"
+#include "sprite_instance.h"
+#include "character.h"
+#include "dlist.h"
+#include "container.h"
+#include "log.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+
+using namespace gnash;
+using namespace std;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+  string filename =  string(INPUT_FILENAME);
+  MovieTester tester(filename);
+
+  gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+  dbglogfile.setVerbosity(1);
+
+  sprite_instance* root = tester.getRootMovie();
+  assert(root);
+
+  check_equals(root->get_frame_count(), 2);
+  check_equals(root->get_current_frame(), 0);
+
+  tester.advance();
+  check_equals(root->get_current_frame(), 1);
+
+  character* mc = const_cast<character*>(tester.findDisplayItemByName(*root, 
"mc"));
+  check(mc);
+
+  as_value tmp;
+  check(root->get_member("x1", &tmp));
+  check_equals(tmp.to_number(), 0);
+  
+  // press key 'A' and checks
+  tester.pressKey(key::A);
+  tester.releaseKey(key::A);
+
+  // check that KeyDown have been triggered
+  check(root->get_member("x1", &tmp));
+  check_equals(tmp.to_number(), 1);
+
+  
+  tester.advance(); // loop back to frame1
+  // press key 'A' and checks
+  // tester.pressKey(key::A);
+  // tester.releaseKey(key::A);
+  // check that no KeyDown was triggered(no key event handler at frame1);
+  // check(root->get_member("x1", &tmp));
+  // xcheck_equals(tmp.to_number(), 0);
+  tester.advance(); // advance to frame2
+  check_equals(root->get_current_frame(), 1);
+
+  // press key 'A' and checks
+  tester.pressKey(key::A);
+  tester.releaseKey(key::A);
+
+  // check that KeyDown have been triggered
+  check(root->get_member("x1", &tmp));
+  // gnash fails because the key listener didn't get removed when loop back
+  // and get added to the list again;
+  check_equals(tmp.to_number(), 1); 
+
+  tester.advance(); // loop back to frame1
+  // press key 'A' and checks
+  // tester.pressKey(key::A);
+  // tester.releaseKey(key::A);
+  // check that no KeyDown was triggered(no key event handler at frame1);
+  // check(root->get_member("x1", &tmp));
+  // xcheck_equals(tmp.to_number(), 0);
+  tester.advance(); // advance to frame2
+  check_equals(root->get_current_frame(), 1);
+
+  // press key 'A' and checks
+  tester.pressKey(key::A);
+  tester.releaseKey(key::A);
+
+  // check that KeyDown have been triggered
+  check(root->get_member("x1", &tmp));
+  // gnash fails because the key listener didn't get removed when loop back
+  // and get added to the list again;
+  check_equals(tmp.to_number(), 1);
+  
+  return 0; 
+}




reply via email to

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