gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r12301: Test key events especially f


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r12301: Test key events especially for buttons, showing that they should be handled
Date: Wed, 14 Jul 2010 10:18:01 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 12301 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2010-07-14 10:18:01 +0200
message:
  Test key events especially for buttons, showing that they should be handled
  differently from how Gnash does it.
  
  Drop most 'key listeners', only handling Buttons like this. It is the
  same behaviour as before and still incorrect.
  
  Drop various obsolete functions.
added:
  testsuite/misc-ming.all/KeyEventOrder.c
  testsuite/misc-ming.all/KeyEventOrderRunner.cpp
modified:
  libcore/MovieClip.cpp
  libcore/MovieClip.h
  libcore/movie_root.cpp
  libcore/movie_root.h
  testsuite/misc-ming.all/Makefile.am
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp     2010-07-10 15:29:18 +0000
+++ b/libcore/MovieClip.cpp     2010-07-13 06:16:31 +0000
@@ -379,9 +379,6 @@
 MovieClip::~MovieClip()
 {
     stopStreamSound();
-
-    stage().remove_key_listener(this);
-
     deleteChecked(_loadVariableRequests.begin(), _loadVariableRequests.end());
 }
 
@@ -1713,14 +1710,6 @@
 }
 
 
-/// Register DisplayObjects as key listeners if they have clip key events
-/// defined. Don't call twice for the same character.
-void
-MovieClip::registerAsListener()
-{
-    stage().add_key_listener(this);
-}
-
 void
 MovieClip::constructAsScriptObject()
 {
@@ -1779,9 +1768,6 @@
     // Register this movieclip as a live one
     stage().addLiveChar(this);
 
-    // Register this movieclip as a core broadcasters listener
-    registerAsListener();
-
     // It seems it's legal to place 0-framed movieclips on stage.
     // See testsuite/misc-swfmill.all/zeroframe_definemovieclip.swf
 

=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h       2010-07-10 13:11:41 +0000
+++ b/libcore/MovieClip.h       2010-07-13 06:16:31 +0000
@@ -728,14 +728,6 @@
 
     void stopStreamSound();
 
-    /// Register this sprite as a listener of core broadcasters
-    //
-    /// This is currently only used for key events broadcaster
-    /// and it's supposed to be called only once (or should we
-    /// also call it whenever onKey* user-defined function is defined ?
-    ///
-    void registerAsListener();
-
     /// Return value of the 'enabled' property cast to a boolean value.
     //
     /// This is true if not found (undefined to bool evaluates to false).

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2010-07-12 10:05:25 +0000
+++ b/libcore/movie_root.cpp    2010-07-14 07:48:35 +0000
@@ -42,6 +42,7 @@
 #include "Renderer.h"
 #include "ExternalInterface.h"
 #include "TextField.h"
+#include "Button.h"
 
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -94,15 +95,12 @@
     as_object* getBuiltinObject(movie_root& mr, string_table::key cl);
     void advanceLiveChar(MovieClip* ch);
 
-    /// Erase unloaded DisplayObjects from the given listeners list
-    void cleanupListeners(movie_root::Listeners& ll);
-
     /// Push a DisplayObject listener to the front of given container, if not
     /// already present
-    void add_listener(movie_root::Listeners& ll, InteractiveObject* elem);
+    void add_listener(movie_root::Listeners& ll, Button* elem);
 
     /// Remove a listener from the list
-    void remove_listener(movie_root::Listeners& ll, InteractiveObject* elem);
+    void remove_listener(movie_root::Listeners& ll, Button* elem);
 
 }
 
@@ -292,7 +290,6 @@
     // Cleanup the stack.
     _vm.getStack().clear();
 
-    cleanupUnloadedListeners();
     cleanupDisplayList();
     GC::get().fuzzyCollect();
 }
@@ -315,7 +312,7 @@
     {
         // don't leak overloaded levels
 
-        LevelMovie lm = it->second;
+        MovieClip* lm = it->second;
         if (lm == _rootMovie)
         {
             // NOTE: this is not enough to trigger
@@ -600,23 +597,20 @@
         _unreleasedKeys.set(keycode, down);
     }
 
-    Listeners copy = _keyListeners;
-
-    for (Listeners::iterator iter = copy.begin(), itEnd=copy.end();
+    LiveChars copy = _liveChars;
+    for (LiveChars::iterator iter = copy.begin(), itEnd=copy.end();
             iter != itEnd; ++iter) {
 
         // sprite, button & input_edit_text DisplayObjects
         InteractiveObject* const ch = *iter;
-        if (!ch->unloaded()) {
-            if (down) {
-                // KEY_UP and KEY_DOWN events are unrelated to any key!
-                ch->notifyEvent(event_id(event_id::KEY_DOWN, key::INVALID)); 
-                // Pass the unique Gnash key code!
-                ch->notifyEvent(event_id(event_id::KEY_PRESS, k));
-            }
-            else {
-                ch->notifyEvent(event_id(event_id::KEY_UP, key::INVALID));   
-            }
+        if (ch->unloaded()) continue;
+
+        if (down) {
+            ch->notifyEvent(event_id(event_id::KEY_DOWN, key::INVALID)); 
+            ch->notifyEvent(event_id(event_id::KEY_PRESS, k));
+        }
+        else {
+            ch->notifyEvent(event_id(event_id::KEY_UP, key::INVALID));   
         }
     }
 
@@ -643,6 +637,25 @@
             clearActionQueue();
         }
     }
+    
+    // Then any button keys are notified.
+    Listeners lcopy = _keyListeners;
+    for (Listeners::iterator iter = lcopy.begin(), itEnd = lcopy.end();
+            iter != itEnd; ++iter) {
+
+        // sprite, button & input_edit_text DisplayObjects
+        Button* const ch = *iter;
+        if (ch->unloaded()) continue;
+
+        if (down) {
+            ch->notifyEvent(event_id(event_id::KEY_DOWN, key::INVALID)); 
+            ch->notifyEvent(event_id(event_id::KEY_PRESS, k));
+        }
+        else {
+            ch->notifyEvent(event_id(event_id::KEY_UP, key::INVALID));   
+        }
+    }
+
 
     // If we're focused on an editable text field, finally the text is updated
     if (down) {
@@ -1718,8 +1731,6 @@
     }
 #endif
     
-    // NOTE: cleanupUnloadedListeners() should have cleaned up all unloaded
-    // key listeners. The remaining ones should be marked by their parents
 #if ( GNASH_PARANOIA_LEVEL > 1 ) || 
defined(ALLOW_GC_RUN_DURING_ACTIONS_EXECUTION)
     for (Listeners::const_iterator i=_keyListeners.begin(),
             e=_keyListeners.end(); i!=e; ++i) {
@@ -1894,20 +1905,14 @@
 }
 
 void
-movie_root::cleanupUnloadedListeners()
-{
-    cleanupListeners(_keyListeners);
-}
-
-void
-movie_root::add_key_listener(InteractiveObject* listener)
+movie_root::add_key_listener(Button* listener)
 {
     add_listener(_keyListeners, listener);
 }
 
 /// Remove a DisplayObject listener for key events
 void
-movie_root::remove_key_listener(InteractiveObject* listener)
+movie_root::remove_key_listener(Button* listener)
 {
     remove_listener(_keyListeners, listener);
 }
@@ -2251,9 +2256,8 @@
                 os.str()));
 
     /// Live DisplayObjects tree
-    for (LiveChars::const_iterator i=_liveChars.begin(), e=_liveChars.end();
-                                                               i != e; ++i)
-    {
+    for (LiveChars::const_iterator i = _liveChars.begin(), e = 
_liveChars.end();
+            i != e; ++i) {
         (*i)->getMovieInfo(tr, localIter);
     }
 
@@ -2573,7 +2577,7 @@
 }
 
 void
-add_listener(movie_root::Listeners& ll, InteractiveObject* listener)
+add_listener(movie_root::Listeners& ll, Button* listener)
 {
     assert(listener);
 
@@ -2585,59 +2589,10 @@
 
 
 void
-remove_listener(movie_root::Listeners& ll, InteractiveObject* listener)
+remove_listener(movie_root::Listeners& ll, Button* listener)
 {
     assert(listener);
-    ll.remove_if(std::bind2nd(std::equal_to<InteractiveObject*>(), listener));
-}
-
-void
-cleanupListeners(movie_root::Listeners& ll)
-{
-    bool needScan;
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-    int scansCount = 0;
-#endif
-
-    do
-    {
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-      scansCount++;
-      int cleaned =0;
-#endif
-
-      needScan=false;
-
-      // remove unloaded DisplayObject listeners from movie_root
-      for (movie_root::Listeners::iterator iter = ll.begin();
-              iter != ll.end(); ) {
-          InteractiveObject* const ch = *iter;
-          if ( ch->unloaded() )
-          {
-            if ( ! ch->isDestroyed() )
-            {
-              ch->destroy();
-              needScan=true; // ->destroy() might mark already-scanned chars 
as unloaded
-            }
-            iter = ll.erase(iter);
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-            cleaned++;
-#endif
-
-          }
-
-          else ++iter;
-      }
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
-      cout << " Scan " << scansCount << " cleaned " << cleaned << " instances" 
<< endl;
-#endif
-
-    } while (needScan);
-    
+    ll.remove_if(std::bind2nd(std::equal_to<Button*>(), listener));
 }
 
 

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2010-07-12 07:48:07 +0000
+++ b/libcore/movie_root.h      2010-07-14 07:48:35 +0000
@@ -58,9 +58,7 @@
 ///
 /// - bool movie_root::notify_mouse_moved(int x, int y);
 /// - bool movie_root::notify_mouse_clicked(bool mouse_pressed, int mask);
-/// - bool movie_root::notify_key_event(key::code k, bool down);
-/// 
-/// 
+/// - bool keyEvent(key::code k, bool down);
 
 
 #ifndef GNASH_MOVIE_ROOT_H
@@ -114,6 +112,7 @@
     class VirtualClock;
     class IOChannel;
     class RunResources;
+    class Button;
 }
 
 namespace gnash
@@ -150,7 +149,7 @@
 public:
     
     /// Listeners container
-    typedef std::list<InteractiveObject*> Listeners;
+    typedef std::list<Button*> Listeners;
 
     class LoadCallback {
     public:
@@ -208,8 +207,8 @@
     /// SWF playback, so for normal playback this pointer should not be
     /// used.
     Movie* init(movie_definition* def,
-               const MovieClip::MovieVariables& variables,
-               const MovieClip::MovieVariables& scriptables);
+            const MovieClip::MovieVariables& variables,
+            const MovieClip::MovieVariables& scriptables);
 
     /// Return the movie at the given level (0 if unloaded level).
     //
@@ -457,10 +456,10 @@
     size_t nextUnnamedInstance();
 
     /// Push a new DisplayObject listener for key events
-    void add_key_listener(InteractiveObject* listener);
+    void add_key_listener(Button* listener);
 
     /// Remove a DisplayObject listener for key events
-    void remove_key_listener(InteractiveObject* listener);
+    void remove_key_listener(Button* listener);
 
     /// Get the DisplayObject having focus
     //
@@ -601,19 +600,14 @@
 
     /// Action priority levels
     enum ActionPriorityLevel {
-       
         /// Init actions, Init event handlers
         PRIORITY_INIT,
-       
         /// Construct event handlers
         PRIORITY_CONSTRUCT,
-
         /// Frame actions, load handlers, unload handlers
         PRIORITY_DOACTION,
-
         /// Last element used to easy computation of size...
         PRIORITY_SIZE
-        
     };
 
     /// Push an executable code to the ActionQueue
@@ -888,11 +882,11 @@
     void getCharacterTree(tree<StringPair>& tr, tree<StringPair>::iterator it);
 #endif
 
-       /// Get URL of the SWF movie used to initialize this VM
-       //
-       /// This information will be used for security checks
-       ///
-       const std::string& getOriginalURL() const { return _originalURL; }
+    /// Get URL of the SWF movie used to initialize this VM
+    //
+    /// This information will be used for security checks
+    ///
+    const std::string& getOriginalURL() const { return _originalURL; }
 
     const RunResources& runResources() const { return _runResources; }
 
@@ -983,9 +977,6 @@
     /// Execute expired timers
     void executeTimers();
 
-    /// Remove unloaded key and mouselisteners.
-    void cleanupUnloadedListeners();
-
     /// Cleanup references to unloaded DisplayObjects and run the GC.
     void cleanupAndCollect();
 
@@ -1117,8 +1108,7 @@
     /// @todo fold this into m_mouse_button_state?
     drag_state m_drag_state;
 
-    typedef MovieClip* LevelMovie;
-    typedef std::map<int, LevelMovie> Levels;
+    typedef std::map<int, MovieClip*> Levels;
 
     /// The movie instance wrapped by this movie_root
     //
@@ -1137,14 +1127,14 @@
 
     /// This is set to true if execution of scripts
     /// aborted due to action limit set or whatever else
-    bool               _disableScripts;
-    int                        _processingActionLevel;
+    bool _disableScripts;
+    int _processingActionLevel;
     
     /// filedescriptor to write to for host application requests
     //
     /// -1 if none
-    int                        _hostfd;
-    int                        _controlfd;
+    int _hostfd;
+    int _controlfd;
 
     /// The display quality of the entire movie.
     //
@@ -1153,10 +1143,10 @@
     Quality _quality;
 
     /// The alignment of the Stage
-    std::bitset<4u>    _alignMode;
+    std::bitset<4u> _alignMode;
 
     AllowScriptAccessMode _allowScriptAccess;
-    bool               _marshallExceptions;
+    bool _marshallExceptions;
 
     /// Whether to show the menu or not.
     bool _showMenu;
@@ -1168,10 +1158,10 @@
     DisplayState _displayState;
     
     // Maximum number of recursions set in the ScriptLimits tag.
-    boost::uint16_t    _recursionLimit;
+    boost::uint16_t _recursionLimit;
 
     // Timeout in seconds for script execution, set in the ScriptLimits tag.
-    boost::uint16_t    _timeoutLimit;
+    boost::uint16_t _timeoutLimit;
 
     // delay between movie advancement, in milliseconds
     size_t _movieAdvancementDelay;

=== added file 'testsuite/misc-ming.all/KeyEventOrder.c'
--- a/testsuite/misc-ming.all/KeyEventOrder.c   1970-01-01 00:00:00 +0000
+++ b/testsuite/misc-ming.all/KeyEventOrder.c   2010-07-13 06:02:26 +0000
@@ -0,0 +1,229 @@
+/*
+ *   Copyright (C) 2005, 2006, 2007, 2009, 2010 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 3 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
+ *
+ */ 
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION  7
+#define OUTPUT_FILENAME  "KeyEventOrder.swf"
+
+/// This test checks the event order of key events.
+//
+/// Known listeners are:
+/// 1. MovieClips with a defined key event
+/// 2. Button with a defined key event
+/// 3. Anything added to Key listeners in ActionScript.
+//
+/// The test adds objects in this order:
+//
+/// Frame 1:
+/// 1. mc1
+/// 3. button1 (responds to 'a')
+/// 3. o1 (actionscript key listener object)
+/// 4. mc2
+///
+/// Frame 2:
+/// 5. button2 (responds to 'a')
+/// 6. button3 (responds to 'b')
+/// 3. o2 (actionscript key listener object)
+//
+/// The test shows that, irrespective of construction order:
+/// 1. MovieClips are notified first
+/// 2. ActionScript listeners are notified second.
+/// 3. Buttons are notified last.
+//
+/// Additionally:
+//
+/// 1. Only one button action can respond to any key.
+int
+main(int argc, char** argv)
+{
+  SWFMovie mo;
+  SWFMovieClip mc, dejagnuclip;
+  SWFButtonRecord br;
+  SWFButton bu;
+  SWFDisplayItem it1, it, it2;
+  SWFShape sh1, sh2;
+
+  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);
+
+  SWFMovie_nextFrame(mo);
+
+  add_actions(mo,
+          "_root.order = '';"
+          "_root.note('Press \"a\" then \"b\"');"
+          "_root.note('Do not press any other keys!');"
+          );
+
+  mc = newSWFMovieClip();
+  it = SWFMovie_add(mo, (SWFBlock)mc);
+  SWFDisplayItem_setName(it, "mc1");
+  SWFDisplayItem_addAction(it,
+          newSWFAction("trace('mc1'); _root.order += 'mc1,';"),
+          SWFACTION_KEYDOWN);
+
+  bu = newSWFButton();
+  
+  sh1 = make_fill_square(200, 0, 40, 40, 0, 0, 0, 0, 0, 0);
+  sh2 = make_fill_square(200, 0, 40, 40, 0, 0, 0, 0, 255, 0);
+
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
+  SWFButtonRecord_setDepth(br, 3);
+  
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_UP);
+  SWFButtonRecord_setDepth(br, 4);
+
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_OVER);
+  SWFButtonRecord_setDepth(br, 5);
+
+  SWFButton_addAction(bu,
+          newSWFAction("trace('button1'); _root.order += 'button1,';"),
+                 SWFBUTTON_KEYPRESS('a'));
+
+  it1 = SWFMovie_add(mo, (SWFBlock)bu);
+  SWFDisplayItem_setName(it, "button1");
+
+  SWFMovie_add(mo, newSWFAction(
+              "o1 = {};"
+              "o1.onKeyDown = function() {"
+              "    trace('o1'); "
+              "    _root.order += 'o1,';"
+              "};"
+              "Key.addListener(o1);"
+              ));
+
+  mc = newSWFMovieClip();
+  it = SWFMovie_add(mo, (SWFBlock)mc);
+  SWFDisplayItem_setName(it, "mc2");
+  SWFDisplayItem_addAction(it,
+          newSWFAction("trace('mc2'); _root.order += 'mc2,';"),
+          SWFACTION_KEYDOWN);
+
+  SWFMovie_nextFrame(mo); // Frame 2
+
+  bu = newSWFButton();
+  
+  sh1 = make_fill_square(240, 0, 40, 40, 0, 0, 0, 0, 0, 0);
+  sh2 = make_fill_square(240, 0, 40, 40, 0, 0, 0, 0, 255, 0);
+
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
+  SWFButtonRecord_setDepth(br, 3);
+  
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_UP);
+  SWFButtonRecord_setDepth(br, 4);
+
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_OVER);
+  SWFButtonRecord_setDepth(br, 5);
+
+  SWFButton_addAction(bu,
+          newSWFAction("trace('button2'); _root.order += 'button2,';"),
+                 SWFBUTTON_KEYPRESS('a'));
+
+  it2 = SWFMovie_add(mo, (SWFBlock)bu);
+  SWFDisplayItem_setName(it, "button2");
+  
+  bu = newSWFButton();
+  
+  sh1 = make_fill_square(280, 0, 40, 40, 0, 0, 0, 0, 0, 0);
+  sh2 = make_fill_square(280, 0, 40, 40, 0, 0, 0, 0, 255, 0);
+
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
+  SWFButtonRecord_setDepth(br, 3);
+  
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh1, SWFBUTTON_UP);
+  SWFButtonRecord_setDepth(br, 4);
+
+  br = SWFButton_addCharacter(bu, (SWFCharacter)sh2, SWFBUTTON_OVER);
+  SWFButtonRecord_setDepth(br, 5);
+
+  SWFButton_addAction(bu,
+          newSWFAction(
+              "trace('button3'); "
+              "_root.order += 'button3,';"
+              "play();"
+              ),
+                 SWFBUTTON_KEYPRESS('b'));
+
+  it = SWFMovie_add(mo, (SWFBlock)bu);
+  SWFDisplayItem_setName(it, "button3");
+  
+  SWFMovie_add(mo, newSWFAction(
+              "o2 = {};"
+              "o2.onKeyDown = function() {"
+              "    trace('o2'); "
+              "    _root.order += 'o2,';"
+              "};"
+              "Key.addListener(o2);"
+              "stop();"
+              ));
+
+  SWFMovie_nextFrame(mo);
+
+  xcheck_equals(mo, "_root.order",
+          "'mc2,mc1,o1,o2,button1,mc2,mc1,o1,o2,button3,'");
+  
+  SWFMovie_nextFrame(mo);
+
+  SWFDisplayItem_remove(it2);
+  
+  add_actions(mo,
+          "_root.order = '';"
+          "_root.note('Press \"a\" then \"b\" again');"
+          "_root.note('Do not press any other keys!');"
+          "stop();"
+          );
+  SWFMovie_nextFrame(mo);
+
+  // Check that removing the second button associated with 'a' does not
+  // remove the key trigger for button2. There's no reason to think it should,
+  // but it could happen if it's implemented badly!
+  check_equals(mo, "_root.order",
+          "'mc2,mc1,o1,o2,button1,mc2,mc1,o1,o2,button3,'");
+
+  SWFMovie_add(mo, newSWFAction("stop();"));
+
+  //Output movie
+  puts("Saving " OUTPUT_FILENAME );
+  SWFMovie_save(mo, OUTPUT_FILENAME);
+
+  return 0;
+}
+
+
+

=== added file 'testsuite/misc-ming.all/KeyEventOrderRunner.cpp'
--- a/testsuite/misc-ming.all/KeyEventOrderRunner.cpp   1970-01-01 00:00:00 
+0000
+++ b/testsuite/misc-ming.all/KeyEventOrderRunner.cpp   2010-07-12 12:10:22 
+0000
@@ -0,0 +1,80 @@
+/* 
+ *   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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 3 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 "KeyEventOrder.swf"
+
+#include "MovieTester.h"
+#include "MovieClip.h"
+#include "DisplayObject.h"
+#include "DisplayList.h"
+#include "log.h"
+#include "VM.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);
+
+  MovieClip* root = tester.getRootMovie();
+  assert(root);
+
+  check_equals(root->get_frame_count(), 6);
+  check_equals(root->get_current_frame(), 0);
+
+  tester.advance();
+  tester.advance();
+  
+  check_equals(root->get_current_frame(), 2);
+  
+  // provide a key press to continue the test
+  tester.pressKey(key::a);
+  tester.releaseKey(key::a);
+  
+  tester.pressKey(key::b);
+  tester.releaseKey(key::b);
+  
+  tester.advance();
+  tester.advance();
+
+  check_equals(root->get_current_frame(), 4);
+
+  // provide a key press to continue the test
+  tester.pressKey(key::a);
+  tester.releaseKey(key::a);
+  
+  tester.pressKey(key::b);
+  tester.releaseKey(key::b);
+  
+  tester.advance();
+  tester.advance();
+  check_equals(root->get_current_frame(), 5);
+  
+}

=== modified file 'testsuite/misc-ming.all/Makefile.am'
--- a/testsuite/misc-ming.all/Makefile.am       2010-07-07 10:56:03 +0000
+++ b/testsuite/misc-ming.all/Makefile.am       2010-07-12 11:52:24 +0000
@@ -176,7 +176,9 @@
        duplicate_movie_clip_test2 \
        event_handler_scope_test \
        masks_testrunner \
+       KeyEventOrder \
        key_event_test \
+       KeyEventOrderRunner \
        key_event_testrunner \
        static_vs_dynamic1 \
        static_vs_dynamic2 \
@@ -818,6 +820,28 @@
        $(top_builddir)/testsuite/libtestsuite.la \
        $(NULL)
 
+KeyEventOrder_SOURCES = KeyEventOrder.c
+KeyEventOrder_LDADD = libgnashmingutils.la
+
+KeyEventOrder.swf: KeyEventOrder
+       ./KeyEventOrder $(abs_mediadir)
+
+KeyEventOrderRunner_SOURCES = \
+       KeyEventOrderRunner.cpp \
+       $(NULL)
+KeyEventOrderRunner_LDADD = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(AM_LDFLAGS) \
+       $(NULL)
+KeyEventOrderRunner_CXXFLAGS = \
+       -DSRCDIR='"$(srcdir)"' \
+       -DTGTDIR='"$(abs_builddir)"' \
+       $(NULL)
+KeyEventOrderRunner_DEPENDENCIES = \
+       KeyEventOrder.swf \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(NULL)
+
 place_object_test_SOURCES = place_object_test.c        
 place_object_test_LDADD = libgnashmingutils.la
 
@@ -2186,6 +2210,7 @@
        event_handler_scope_testrunner \
        masks_testrunner \
        masks_test2runner \
+       KeyEventOrderRunner \
        key_event_testrunner \
        static_vs_dynamic1_testrunner \
        static_vs_dynamic2_testrunner \


reply via email to

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