gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10096: Improve the eventSoundTest.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10096: Improve the eventSoundTest.
Date: Sat, 25 Oct 2008 14:46:01 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10096
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2008-10-25 14:46:01 +0200
message:
  Improve the eventSoundTest.
modified:
  testsuite/misc-ming.all/Makefile.am
  testsuite/misc-ming.all/eventSoundTest1-Runner.cpp
  testsuite/misc-ming.all/eventSoundTest1.c
=== modified file 'testsuite/misc-ming.all/Makefile.am'
--- a/testsuite/misc-ming.all/Makefile.am       2008-10-24 10:45:51 +0000
+++ b/testsuite/misc-ming.all/Makefile.am       2008-10-25 12:46:01 +0000
@@ -454,7 +454,8 @@
 eventSoundTest1_LDADD = libgnashmingutils.la
 
 eventSoundTest1.swf: eventSoundTest1
-       ./eventSoundTest1 $(srcdir)/../media/sound1.mp3
+       ./eventSoundTest1 $(srcdir)/../media/brokenchord.wav \
+       $(srcdir)/../media/
 
 eventSoundTest1_Runner_SOURCES = \
        eventSoundTest1-Runner.cpp \

=== modified file 'testsuite/misc-ming.all/eventSoundTest1-Runner.cpp'
--- a/testsuite/misc-ming.all/eventSoundTest1-Runner.cpp        2008-06-29 
20:17:35 +0000
+++ b/testsuite/misc-ming.all/eventSoundTest1-Runner.cpp        2008-10-25 
12:46:01 +0000
@@ -26,6 +26,8 @@
 #include "DisplayList.h"
 #include "log.h"
 #include "GnashException.h"
+#include "GnashSleep.h"
+#include "VM.h"
 
 #include "check.h"
 
@@ -58,13 +60,15 @@
        tester.advance();
 
        gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
-       dbglogfile.setVerbosity(1);
-       dbglogfile.setActionDump(1);
+       //dbglogfile.setActionDump(1);
 
        sprite_instance* root = tester.getRootMovie();
        assert(root);
 
-       check_equals(root->get_frame_count(), 20);
+       VM& vm = root->getVM();
+       string_table& st = vm.getStringTable();
+
+       //check_equals(root->get_frame_count(), 20);
 
        if ( ! tester.canTestSound() )
        {
@@ -72,23 +76,50 @@
                return EXIT_SUCCESS; // so testing doesn't abort
        } 
 
+       const int totalFrames = root->get_frame_count();
+
+       // Make sure you adjust this with the test!
+       cerr << "Total frames: " <<  totalFrames;
+       assert (totalFrames == 14);
+
+       int numSoundsStarted[] = {
+               0,
+               4,
+               6
+       };
+
+       bool testPasses[] = {
+               true,
+               true,
+               false
+       };
+
        // Advance and check...
-       int frame = root->get_current_frame(); // 1
-       int sounds = 1;
-       while (frame < 21) {
-//             check_equals(root->get_current_frame(), frame);
-               check_equals(tester.soundsStarted(), sounds);
-               tester.advance();
-               frame++;
+       int frame = root->get_current_frame();
+       int test = 0;
+       while (frame <= totalFrames) {
+               as_value testReady;
+               if (root->get_member(st.find("testReady"), &testReady))
+               {
+                       root->delProperty(st.find("testReady"));
+                       
+                       // When a test is ready, check the result of the 
previous test.
+                       if (testPasses[test]) {
+                               check_equals(tester.soundsStarted(), 
numSoundsStarted[test]);
+                       }
+                       else {
+                               xcheck_equals(tester.soundsStarted(), 
numSoundsStarted[test]);
+                       }
+                       check_equals(tester.soundsStopped(), 
tester.soundsStarted());
+                       ++test;
+                       tester.click();
 
-//             check_equals(root->get_current_frame(), frame);
-               check_equals(tester.soundsStopped(), sounds);
+               }
                tester.advance();
                frame++;
-               sounds++;               
+               // Frame length should be 2 seconds.
+               gnashSleep(2000000);
        }
 
-       check_equals(tester.soundsStopped(), tester.soundsStarted());
-
 }
 

=== modified file 'testsuite/misc-ming.all/eventSoundTest1.c'
--- a/testsuite/misc-ming.all/eventSoundTest1.c 2007-07-01 09:53:45 +0000
+++ b/testsuite/misc-ming.all/eventSoundTest1.c 2008-10-25 12:46:01 +0000
@@ -34,45 +34,220 @@
 #define OUTPUT_VERSION 6
 #define OUTPUT_FILENAME "eventSoundTest1.swf"
 
+void setupMovie(SWFMovie mo, const char* srcdir);
+SWFSound setupSounds(const char* filename);
+void runMultipleSoundsTest(SWFMovie mo, SWFSound so, int* frame);
+void runNoMultipleSoundsTest(SWFMovie mo, SWFSound so, int* frame);
+void pauseForNextTest(SWFMovie mo);
+void printFrameInfo(SWFMovie mo, int i, const char* desc);
+
+void pauseForNextTest(SWFMovie mo)
+{
+  add_actions(mo, "_root.onMouseDown = function() {"
+                  "play(); Mouse.removeListener(_root); };"
+                  "Mouse.addListener(_root);"
+                  );
+  add_actions(mo, "note('Click and "
+                  "wait for the test.');"
+                 "testReady = true; stop();");
+}
+
+void setupMovie(SWFMovie mo, const char* srcdir)
+{
+  SWFDisplayItem it;
+  char fdbfont[256];
+  SWFFont font;
+  SWFMovieClip dejagnuclip;
+  FILE* font_file;
+  
+  sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);
+  font_file = fopen(fdbfont, "r");
+  if (font_file == NULL)
+  {
+    perror(fdbfont);
+    exit(1);
+  }
+
+  font = loadSWFFontFromFile(font_file);
+
+
+  /* Add output textfield and DejaGnu stuff */
+  dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 800, 400);
+  it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+  SWFDisplayItem_setDepth(it, 200); 
+  SWFDisplayItem_move(it, 200, 0); 
+
+}
+
+SWFSound setupSounds(const char* filename)
+{
+  FILE *soundfile;
+  SWFSound so;
+  
+  printf("Opening sound file: %s\n", filename);
+
+  soundfile = fopen(filename, "r");
+
+  if (!soundfile) {
+    perror(filename);
+    exit(EXIT_FAILURE);
+  }
+
+  so = newSWFSound(soundfile,
+     SWF_SOUND_NOT_COMPRESSED |
+     SWF_SOUND_22KHZ |
+     SWF_SOUND_16BITS |
+     SWF_SOUND_STEREO);
+     
+  return so;
+}
+
+
+void
+printFrameInfo(SWFMovie mo, int i, const char* desc)
+{
+    char descBuf[200];
+    char frameBuf[50];
+
+    sprintf(descBuf, "note('%s');", desc);
+    sprintf(frameBuf, "note('Frame: ' + %d);", i);
+
+    /* Display frame number and description
+    at the beginning of each frame */
+    add_actions(mo, frameBuf);
+    add_actions(mo, descBuf);
+}
+
+void
+runMultipleSoundsTest(SWFMovie mo, SWFSound so, int* frame)
+{
+    const char* frameDesc[5];
+    int i;
+
+    SWFMovie_nextFrame(mo);
+    add_actions(mo, "note('Multiple Sound Test.\nThe notes should start "
+              "exactly at the beginning "
+              "of a frame (to coincide with the appearance of the description "
+              "text). Test should start in two seconds.');");
+
+    /* This is what is supposed to happen in each frame */
+    frameDesc[0] = "Two notes (C, E)";
+    frameDesc[1] = "Two notes (G-C, E)";
+    frameDesc[2] = "Two notes (G-C, E)";
+    frameDesc[3] = "Two notes (G-C, E)";
+    frameDesc[4] = "Nothing";
+
+    for (i = 0; i < 4; i++)
+    {
+        SWFMovie_nextFrame(mo);
+
+        (*frame)++;
+
+        printFrameInfo(mo, i, frameDesc[i]);
+
+        SWFMovie_startSound(mo, so);
+    }
+
+    SWFMovie_nextFrame(mo);
+
+    printFrameInfo(mo, i, frameDesc[i]);
+    SWFMovie_stopSound(mo, so);
+
+}
+
+
+void
+runNoMultipleSoundsTest(SWFMovie mo, SWFSound so, int* frame)
+{
+  const char* frameDesc[5];
+  int i;
+
+  SWFMovie_nextFrame(mo);
+  add_actions(mo, "note('Non-multiple Sound Test\n"
+              "The notes should start exactly at the beginning "
+              "of a frame (to coincide with the appearance of the description "
+              "text). Test should start in two seconds.');");
+            
+
+  /* This is what is supposed to happen in each frame */
+  frameDesc[0] = "Two notes (C, E)";
+  frameDesc[1] = "One note (G)";
+  frameDesc[2] = "Two notes (C, E) ";
+  frameDesc[3] = "One note (G)";
+  frameDesc[4] = "Nothing";
+
+
+    for (i = 0; i < 4; i++)
+    {
+        SWFMovie_nextFrame(mo);
+
+        (*frame)++;
+
+        printFrameInfo(mo, i, frameDesc[i]);
+
+        SWFSoundInstance so_in = SWFMovie_startSound(mo, so);
+        SWFSoundInstance_setNoMultiple(so_in);
+    }
+
+    SWFMovie_nextFrame(mo);
+
+    printFrameInfo(mo, i, frameDesc[i]);
+    SWFMovie_stopSound(mo, so);
+
+}
+
 
 int
 main(int argc, char** argv)
 {
   SWFMovie mo;
-  SWFSound  so;
-  FILE *sound_f;
-  int i;
-  const char* sound_filename;
-
-  if ( argc>1 ) {
-    sound_filename=argv[1];
-  } else {
-    sound_filename="sound1.mp3";
-  }
-
-  sound_f = fopen(sound_filename, "r");
-  if ( ! sound_f ) {
-    perror(sound_filename);
-    return 1;
-  }
-
-  Ming_init();
-  Ming_useSWFVersion (OUTPUT_VERSION);
-  
+  SWFSound so;
+  const char* soundFile;
+  const char* srcdir;
+  int frame;
+
+  if (argc > 1) {
+    soundFile = argv[1];
+  }
+  else {
+    soundFile = "brokenchord.wav";
+  }
+  if (argc > 2) {
+    srcdir = argv[2];
+  }
+  else {
+    srcdir = ".";
+  }
+
+  /* setup ming and basic movie properties */
+  Ming_init();  
+  Ming_useSWFVersion(OUTPUT_VERSION);
+
   mo = newSWFMovie();
-  SWFMovie_setDimension(mo, 100, 100);
-
-  SWFMovie_setRate(mo, 1);
-  so =  newSWFSound(sound_f, SWF_SOUND_MP3_COMPRESSED | SWF_SOUND_44KHZ | 
SWF_SOUND_16BITS |SWF_SOUND_STEREO);
-  for(i=0; i<20; i++)
-  {
-    SWFSoundInstance so_in = SWFMovie_startSound(mo, so);
-    SWFMovie_nextFrame(mo);
-    ++i;
-    SWFMovie_stopSound(mo, so);
-    SWFMovie_nextFrame(mo);
-  }
-
+  SWFMovie_setDimension(mo, 800, 600);
+  SWFMovie_setRate(mo, 0.5);
+
+  setupMovie(mo, srcdir);
+  so = setupSounds(soundFile);
+
+  add_actions(mo, "c = 0;");
+
+  SWFMovie_nextFrame(mo);
+
+  add_actions(mo, "note('You will hear several short tests with a succession\n"
+                 "of sounds. Each frame is two seconds long. The movie will 
describe\n"
+                 " what you should hear at the beginning of the frame.');"
+                 );
+                 
+  frame = 0;
+
+  pauseForNextTest(mo);
+  runMultipleSoundsTest(mo, so, &frame);
+  
+  pauseForNextTest(mo);
+  runNoMultipleSoundsTest(mo, so, &frame);
+
+  pauseForNextTest(mo);
   //Output movie
   puts("Saving " OUTPUT_FILENAME );
   SWFMovie_save(mo, OUTPUT_FILENAME);


reply via email to

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