gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11375: Restore tests to correct ver


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11375: Restore tests to correct versions. Please fix Gnash rather than breaking
Date: Thu, 06 Aug 2009 10:47:22 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11375 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-08-06 10:47:22 +0200
message:
  Restore tests to correct versions. Please fix Gnash rather than breaking
  the tests.
  
  The classes.all tests for Camera and Microphone also need attention. 
  Microphone fails on the PP, the Camera one fails if no camera is present.
  
  Fix various compiler warnings, many of them real bugs.
modified:
  libamf/sol.cpp
  libmedia/AudioInput.cpp
  libmedia/gst/AudioInputGst.cpp
  libmedia/gst/VideoInputGst.cpp
  testsuite/actionscript.all/Camera.as
  testsuite/actionscript.all/Microphone.as
=== modified file 'libamf/sol.cpp'
--- a/libamf/sol.cpp    2009-08-04 03:12:19 +0000
+++ b/libamf/sol.cpp    2009-08-06 06:56:21 +0000
@@ -472,6 +472,7 @@
            oldel = newel;
        }
    }
+   return true;
 }
 
 bool
@@ -479,6 +480,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     _amfobjs[index] = el;    
+    return true;
 }
 
 ///  \brief Dump the internal data of this class in a human readable form.

=== modified file 'libmedia/AudioInput.cpp'
--- a/libmedia/AudioInput.cpp   2009-08-05 21:00:19 +0000
+++ b/libmedia/AudioInput.cpp   2009-08-06 07:26:58 +0000
@@ -22,17 +22,18 @@
 namespace media {
     
     //constructor
-    AudioInput::AudioInput() {
+    AudioInput::AudioInput()
+        :
         //actionscript default values
-        _rate = 8000;
-        _activityLevel = -1;
-#ifdef USE_GST
-        _gain = 5000;
-#endif
-        _index = 0;
-        _silenceLevel = 10;
-        _silenceTimeout = 2000; //in milliseconds
-        _useEchoSuppression = false;
+        _activityLevel(-1),
+        _gain(5000),
+        _index(0),
+        _muted(false),
+        _rate(8000),
+        _silenceLevel(10),
+        _silenceTimeout(2000), // in milliseconds
+        _useEchoSuppression(false)
+    {
     } 
     
 } //media namespace

=== modified file 'libmedia/gst/AudioInputGst.cpp'
--- a/libmedia/gst/AudioInputGst.cpp    2009-08-05 20:24:59 +0000
+++ b/libmedia/gst/AudioInputGst.cpp    2009-08-06 07:29:55 +0000
@@ -41,8 +41,7 @@
         findAudioDevs();
         
         //enumerate names array for actionscript accessibility
-        int i;
-        for (i = 0; i < _audioVect.size(); ++i) {
+        for (size_t i = 0; i < _audioVect.size(); ++i) {
             _names.push_back(_audioVect[i]->getProductName());
         }
         
@@ -84,12 +83,11 @@
         GstPropertyProbe *probe;
         GValueArray *devarr;
         element = NULL;
-        gint i;
         
         element = gst_element_factory_make ("pulsesrc", "pulsesrc");
         probe = GST_PROPERTY_PROBE (element);
         devarr = gst_property_probe_probe_and_get_values_name (probe, 
"device");
-        for (i = 0; devarr != NULL && i < devarr->n_values; ++i) {
+        for (size_t i = 0; devarr != NULL && i < devarr->n_values; ++i) {
             GValue *val;
             gchar *dev_name = NULL;
             
@@ -98,7 +96,8 @@
             gst_element_set_state (element, GST_STATE_PLAYING);
             g_object_get (element, "device-name", &dev_name, NULL);
             gst_element_set_state (element, GST_STATE_NULL);
-            if (dev_name == "null" || (strstr(dev_name, "Monitor") != NULL)) {
+            if (g_strcmp0(dev_name, "null") ||
+                    (std::strstr(dev_name, "Monitor") != NULL)) {
                 log_trace("No pulse audio input devices.");
             }
             else { 
@@ -119,16 +118,14 @@
     }
     
     bool
-    AudioInputGst::checkSupportedFormats(GnashAudio *aud, GstCaps *caps) {
-        gint i;
+    AudioInputGst::checkSupportedFormats(GnashAudio* /*aud*/, GstCaps *caps) {
         gint num_structs;
         
         num_structs = gst_caps_get_size (caps);
         bool ok = false;
         
-        for (i=0; i < num_structs; i++) {
+        for (gint i = 0; i < num_structs; i++) {
             GstStructure *structure;
-            const GValue *width, *height;
             
             //this structure is used to probe the source for information
             structure = gst_caps_get_structure (caps, i);
@@ -147,11 +144,15 @@
     }
     
     void
-    AudioInputGst::getSelectedCaps(int devselect) {
-        if (devselect > (_audioVect.size() - 1) || devselect < 0) {
+    AudioInputGst::getSelectedCaps(int devselect)
+    {
+
+        if (devselect < 0 ||
+                (static_cast<size_t>(devselect) >= _audioVect.size())) {
             log_error("%s: passed an invalid devselect argument", 
__FUNCTION__);
             exit(EXIT_FAILURE);
         }
+
         GstElement *pipeline;
         gchar *command;
         GError *error = NULL;
@@ -187,7 +188,6 @@
             if ((return_val == GST_STATE_CHANGE_SUCCESS) && (message == NULL)) 
{
                 GstElement *src;
                 GstPad *pad;
-                gchar *name;
                 GstCaps *caps;
                 
                 gst_element_set_state(pipeline, GST_STATE_PAUSED);
@@ -203,9 +203,8 @@
                     log_error("%s: Template pad isn't an object for some 
reason",
                         __FUNCTION__);
                 }
-                bool ok;
-                ok = checkSupportedFormats(data_struct, caps);
-                if (ok != true) {
+                bool ok = checkSupportedFormats(data_struct, caps);
+                if (ok) {
                     log_error("The input device you selected isn't supported 
(yet)");
                 } else {
                     gst_caps_unref(caps);
@@ -228,7 +227,10 @@
     
     GnashAudioPrivate*
     AudioInputGst::transferToPrivate(int devselect) {
-        if ((devselect > (_audioVect.size() - 1)) || devselect < 0) {
+
+        if (devselect < 0 ||
+                (static_cast<size_t>(devselect) >= _audioVect.size())) {
+
             log_error("%s: Passed a bad devselect value", __FUNCTION__);
             exit (EXIT_FAILURE);
         }
@@ -244,7 +246,8 @@
     }
     
     gboolean
-    AudioInputGst::audioChangeSourceBin(GnashAudioPrivate *audio) {
+    AudioInputGst::audioChangeSourceBin(GnashAudioPrivate *audio)
+    {
         GError *error = NULL;
         gchar *command = NULL;
         
@@ -253,22 +256,24 @@
         }
         
         //delete the old source bin if necessary
-        if (!GST_ELEMENT_PARENT(audio->_audioSourceBin) == NULL) {
-            gst_bin_remove(GST_BIN(audio->_audioMainBin), 
audio->_audioSourceBin);
+        if (!GST_ELEMENT_PARENT(audio->_audioSourceBin)) {
+            gst_bin_remove(GST_BIN(audio->_audioMainBin),
+                    audio->_audioSourceBin);
             audio->_audioSourceBin = NULL;
         }
         
-        if(g_strcmp0(audio->_deviceName, "audiotest") == 0) {
+        if (g_strcmp0(audio->_deviceName, "audiotest") == 0) {
             log_trace("%s: You don't have any mics chosen, using audiotestsrc",
                 __FUNCTION__);
             audio->_audioSourceBin = gst_parse_bin_from_description (
                 "audiotestsrc name=audioSource",
                 TRUE, &error);
             log_debug("Command: audiotestsrc name=audioSource");
-            audio->audioSource = gst_bin_get_by_name (GST_BIN 
(audio->_audioSourceBin),
-                        "audioSource");
+            audio->audioSource = gst_bin_get_by_name (
+                    GST_BIN (audio->_audioSourceBin), "audioSource");
             return true;
-        } else {
+        } 
+
         command = g_strdup_printf ("%s name=audioSource device=%s ! capsfilter 
name=capsfilter 
caps=audio/x-raw-int,signed=true,channels=2,rate=%i;audio/x-raw-float,channels=2,rate=%i
 ! rgvolume pre-amp=%f",
             audio->_audioDevice->getGstreamerSrc(),
             audio->_audioDevice->getDevLocation(),
@@ -286,27 +291,28 @@
             return false;
         }
         g_free(command);
-        audio->audioSource = gst_bin_get_by_name (GST_BIN 
(audio->_audioSourceBin),
-                    "audioSource");
+        audio->audioSource = gst_bin_get_by_name(
+                GST_BIN (audio->_audioSourceBin), "audioSource");
                     
         gboolean result;
-        result = gst_bin_add(GST_BIN(audio->_audioMainBin), 
audio->_audioSourceBin);
-        if (result != true) {
+        result = gst_bin_add(GST_BIN(audio->_audioMainBin),
+                audio->_audioSourceBin);
+        if (!result) {
             log_error("%s: couldn't drop the sourcebin back into the main bin",
                 __FUNCTION__);
-        } else {
-            GstElement *tee = 
gst_bin_get_by_name(GST_BIN(audio->_audioMainBin),
-                "tee");
-            result = gst_element_link(audio->_audioSourceBin, tee);
-            if (result != true) {
-                log_error("%s: couldn't link up sourcebin and tee", 
__FUNCTION__);
-                return false;
-            } else {
-                _globalAudio = audio;
-                return true;
-            }
-        }
-        }
+            return false;
+        }
+
+        GstElement *tee = gst_bin_get_by_name(GST_BIN(audio->_audioMainBin),
+            "tee");
+        result = gst_element_link(audio->_audioSourceBin, tee);
+
+        if (!result) {
+            log_error("%s: couldn't link up sourcebin and tee", __FUNCTION__);
+            return false;
+        } 
+        _globalAudio = audio;
+        return true;
     } 
     
     gboolean
@@ -456,7 +462,6 @@
             gst_bin_add(GST_BIN(audio->_pipeline), audio->_audioPlaybackBin);
         }
         
-        gboolean ok;
         GstPad *audioPlaybackQueueSrc, *audioPlaybackBinSink;
         GstPadLinkReturn padreturn;
         
@@ -515,9 +520,7 @@
     
     //to handle messages while the main capture loop is running
     gboolean
-    audio_bus_call (GstBus     *bus,
-              GstMessage *msg,
-              gpointer data)
+    audio_bus_call (GstBus* /*bus*/, GstMessage *msg, gpointer /*data*/)
     {
       switch (GST_MESSAGE_TYPE (msg)) {
 
@@ -547,7 +550,6 @@
     AudioInputGst::audioCreateSaveBin(GnashAudioPrivate* audio) {
         GstElement *audioConvert, *audioEnc, *filesink;
         GstPad* pad;
-        gboolean ok;
         
         audio->_audioSaveBin = gst_bin_new ("audioSaveBin");
         
@@ -579,13 +581,15 @@
         
         //gst_bin_add (GST_BIN(audio->_pipeline), audio->_audioSaveBin);
         
-        ok = gst_element_link_many(audioConvert, audioEnc, audio->_mux,
+        bool ok = gst_element_link_many(audioConvert, audioEnc, audio->_mux,
                 filesink, NULL);
-        if (ok != true) {
+
+        if (!ok) {
             log_error("%s: Something went wrong in linking", __FUNCTION__);
-        } else {
-            return true;
+            return false;
         }
+
+        return true;
     }
     
     gboolean
@@ -652,7 +656,6 @@
     AudioInputGst::audioPlay(GnashAudioPrivate *audio) {
         GstStateChangeReturn state;
         GstBus *bus;
-        GMainLoop *loop;
         gint ret;
         
         //setup bus to watch pipeline for messages
@@ -699,9 +702,12 @@
         }
         
         //make sure device selection is a valid input device
-        if ((rcfile.getAudioInputDevice() > (_audioVect.size() -1)) ||
-            rcfile.getAudioInputDevice() < 0) {
-            log_error("You have an invalid microphone selected. Check your 
gnashrc file");
+        const int audioDevice = rcfile.getAudioInputDevice();
+
+        if (audioDevice < 0 ||
+                static_cast<size_t>(audioDevice) >= _audioVect.size()) {
+            log_error("You have an invalid microphone selected. Check "
+                    "your gnashrc file");
             exit(EXIT_FAILURE);
         } else {
             //set _name value for actionscript

=== modified file 'libmedia/gst/VideoInputGst.cpp'
--- a/libmedia/gst/VideoInputGst.cpp    2009-08-04 17:46:54 +0000
+++ b/libmedia/gst/VideoInputGst.cpp    2009-08-06 07:27:30 +0000
@@ -47,8 +47,7 @@
         findVidDevs();
         
         //enumerate names array for actionscript accessibility
-        int i;
-        for (i=0; i < _vidVect.size(); ++i) {
+        for (size_t i = 0; i < _vidVect.size(); ++i) {
             _names.push_back(_vidVect[i]->getProductName());
         }
         
@@ -94,12 +93,11 @@
         GstPropertyProbe *probe;
         GValueArray *devarr;
         element = NULL;
-        gint i;
         
         element = gst_element_factory_make ("v4lsrc", "v4lvidsrc");
         probe = GST_PROPERTY_PROBE (element);
         devarr = gst_property_probe_probe_and_get_values_name (probe, 
"device");
-        for (i = 0; devarr != NULL && i < devarr->n_values; ++i) {
+        for (size_t i = 0; devarr != NULL && i < devarr->n_values; ++i) {
             GValue *val;
             gchar *dev_name = NULL;
             
@@ -108,7 +106,7 @@
             gst_element_set_state (element, GST_STATE_PLAYING);
             g_object_get (element, "device-name", &dev_name, NULL);
             gst_element_set_state (element, GST_STATE_NULL);
-            if (dev_name == "null") {
+            if (!g_strcmp0(dev_name, "null")) {
                 log_trace("No v4l video sources. Checking for other vid 
inputs");
             }
             else { 
@@ -136,7 +134,7 @@
         element = gst_element_factory_make ("v4l2src", "v4l2vidsrc");
         probe = GST_PROPERTY_PROBE (element);
         devarr = gst_property_probe_probe_and_get_values_name (probe, 
"device");
-        for (i = 0; devarr != NULL && i < devarr->n_values; ++i) {
+        for (size_t i = 0; devarr != NULL && i < devarr->n_values; ++i) {
             GValue *val;
             gchar *dev_name = NULL;
             
@@ -145,7 +143,7 @@
             gst_element_set_state (element, GST_STATE_PLAYING);
             g_object_get (element, "device-name", &dev_name, NULL);
             gst_element_set_state (element, GST_STATE_NULL);
-            if (dev_name == "null") {
+            if (g_strcmp0(dev_name, "null")) {
                 log_trace("no v4l2 video sources found.");
             }
             else { 
@@ -322,18 +320,22 @@
                 dev_select);
         }
         //make sure that the device selected is actually valid
-        if ((rcfile.getWebcamDevice() > (_vidVect.size() - 1)) || 
rcfile.getWebcamDevice() < 0) {
-            log_error("You have an invalid camera selected. Please check your 
gnashrc file");
+
+        const int webcamDevice = rcfile.getWebcamDevice();
+        if (webcamDevice < 0 ||
+                static_cast<size_t>(webcamDevice) >= _vidVect.size()) {
+
+            log_error("You have an invalid camera selected. Please "
+                    "check your gnashrc file");
             exit(EXIT_FAILURE);
-        } else {
-            
-            //set _name value for actionscript
-            _name = _vidVect[dev_select]->getProductName();
-            
-            //now that a selection has been made, get capabilities of that 
device
-            getSelectedCaps(rcfile.getWebcamDevice());
-            return rcfile.getWebcamDevice();
         }
+            
+        //set _name value for actionscript
+        _name = _vidVect[dev_select]->getProductName();
+        
+        //now that a selection has been made, get capabilities of that device
+        getSelectedCaps(rcfile.getWebcamDevice());
+        return rcfile.getWebcamDevice();
     }
 
     //called after a device selection, this starts enumerating the device's
@@ -352,15 +354,19 @@
         GstElement *element;
         element = data_struct->getElementPtr();
         
+        if (dev_select < 0 ||
+                static_cast<size_t>(dev_select) >= _vidVect.size()) {
+            log_error("%s: Passed an invalid argument (not a valid "
+                "dev_select value)", __FUNCTION__);
+            exit(EXIT_FAILURE);
+        }
+
         //create tester pipeline to enumerate properties
         if (dev_select == 0) {
             command = g_strdup_printf ("%s name=src ! fakesink",
                 data_struct->getGstreamerSrc());
-        } else if ((dev_select > (_vidVect.size() - 1)) || dev_select < 0) {
-            log_error("%s: Passed an invalid argument (not a valid dev_select 
value)",
-                __FUNCTION__);
-            exit(EXIT_FAILURE);
-        } else {
+        }
+        else {
             command = g_strdup_printf ("%s name=src device=%s ! fakesink",
                 data_struct->getGstreamerSrc(), data_struct->getDevLocation());
         }
@@ -386,7 +392,6 @@
             if ((return_val == GST_STATE_CHANGE_SUCCESS) && (message == NULL)) 
{
                 GstElement *src;
                 GstPad *pad;
-                gchar *name;
                 GstCaps *caps;
                 
                 gst_element_set_state(pipeline, GST_STATE_PAUSED);
@@ -508,7 +513,9 @@
     GnashWebcamPrivate*
     VideoInputGst::transferToPrivate(gint dev_select)
     {
-        if ((dev_select > (_vidVect.size() - 1)) || dev_select < 0) {
+        if (dev_select < 0 ||
+                static_cast<size_t>(dev_select) >= _vidVect.size()) {
+
             log_error("%s: Passed an invalid argument (bad dev_select value)",
                 __FUNCTION__);
                 exit(EXIT_FAILURE);
@@ -647,16 +654,15 @@
     }
     
     gboolean
-    VideoInputGst::checkForSupportedFramerate (GnashWebcamPrivate *webcam, int 
fps) {
-        gint fNum, fDenom, i, val;
+    VideoInputGst::checkForSupportedFramerate(GnashWebcamPrivate *webcam,
+            int fps) {
         
-        for (i = 0; i < webcam->_currentFormat->numFramerates; ++i) {
-            val = std::ceil(webcam->_currentFormat->framerates[i].numerator /
-                       webcam->_currentFormat->framerates[i].denominator);
+        for (int i = 0; i < webcam->_currentFormat->numFramerates; ++i) {
+            int val = std::ceil(
+                    webcam->_currentFormat->framerates[i].numerator /
+                   webcam->_currentFormat->framerates[i].denominator);
             if (val == fps) {
                 return true;
-            } else {
-                continue;
             }
         }
         return false;
@@ -972,7 +978,6 @@
             gst_bin_add (GST_BIN(webcam->_pipeline), webcam->_videoDisplayBin);
         }
         
-        gboolean ok;
         GstPad *video_display_queue_src, *video_display_bin_sink;
         
         video_display_queue_src = gst_element_get_pad(webcam->_webcamMainBin,
@@ -1156,9 +1161,7 @@
     
     //to handle messages while the main capture loop is running
     gboolean
-    bus_call (GstBus     *bus,
-              GstMessage *msg,
-              gpointer data)
+    bus_call (GstBus * /*bus*/, GstMessage *msg, gpointer /*data*/)
     {
       switch (GST_MESSAGE_TYPE (msg)) {
 
@@ -1190,7 +1193,6 @@
     VideoInputGst::webcamPlay(GnashWebcamPrivate *webcam) {
         GstStateChangeReturn state;
         GstBus *bus;
-        GMainLoop *loop;
         gint ret;
             //setup bus to watch pipeline for messages
             bus = gst_pipeline_get_bus (GST_PIPELINE (webcam->_pipeline));

=== modified file 'testsuite/actionscript.all/Camera.as'
--- a/testsuite/actionscript.all/Camera.as      2009-08-05 20:24:59 +0000
+++ b/testsuite/actionscript.all/Camera.as      2009-08-06 08:38:19 +0000
@@ -36,7 +36,7 @@
 check(Camera);
 var cameraObj = new Camera;
 check(cameraObj);
-var cameraObj2 = new Camera;
+var cameraObj2 = new Camera();
 check(cameraObj2);
 
 check(cameraObj != cameraObj2);
@@ -45,14 +45,24 @@
 // The .get() method is a class method, not exported
 // to instances.
 check(Camera.get);
-check(Camera.prototype.hasOwnProperty("get")); 
+xcheck_equals(cameraObj.get, undefined); 
 
 trace("Camera.get() returns: "+Camera.get());
 
 // test that the methods do not exist in the class
-check(Camera.prototype.hasOwnProperty("setMode")); 
-check(Camera.prototype.hasOwnProperty("setMotionLevel"));
-check(Camera.prototype.hasOwnProperty("setQuality"));
+xcheck_equals(Camera.setmode, undefined);
+xcheck_equals(Camera.setmotionlevel, undefined);
+xcheck_equals(Camera.setquality, undefined);
+
+#if OUTPUT_VERSION < 7
+check (cameraObj.setmode); 
+check (cameraObj.setmotionlevel);
+check (cameraObj.setquality);
+#else
+xcheck_equals (cameraObj.setmode, undefined); 
+xcheck_equals (cameraObj.setmotionlevel, undefined);
+xcheck_equals (cameraObj.setquality, undefined);
+#endif
 
 #endif // OUTPUT_VERSION >= 6
 totals();

=== modified file 'testsuite/actionscript.all/Microphone.as'
--- a/testsuite/actionscript.all/Microphone.as  2009-08-05 20:24:59 +0000
+++ b/testsuite/actionscript.all/Microphone.as  2009-08-06 08:38:19 +0000
@@ -41,19 +41,19 @@
 check(Microphone.prototype.hasOwnProperty("setUseEchoSuppression"));
 
 // These aren't present yet.
-check(Microphone.prototype.hasOwnProperty("get"));
-check(Microphone.prototype.hasOwnProperty("activityLevel"));
-check(Microphone.prototype.hasOwnProperty("gain"));
-check(Microphone.prototype.hasOwnProperty("index"));
-check(Microphone.prototype.hasOwnProperty("muted"));
-check(Microphone.prototype.hasOwnProperty("name"));
-check(Microphone.prototype.hasOwnProperty("names"));
-xcheck(Microphone.prototype.hasOwnProperty("onActivity"));
-xcheck(Microphone.prototype.hasOwnProperty("onStatus"));
-check(Microphone.prototype.hasOwnProperty("rate"));
-check(Microphone.prototype.hasOwnProperty("silenceLevel"));
-check(Microphone.prototype.hasOwnProperty("silenceTimeOut"));
-check(Microphone.prototype.hasOwnProperty("useEchoSuppression"));
+xcheck(!Microphone.prototype.hasOwnProperty("get"));
+check(!Microphone.prototype.hasOwnProperty("activityLevel"));
+check(!Microphone.prototype.hasOwnProperty("gain"));
+check(!Microphone.prototype.hasOwnProperty("index"));
+check(!Microphone.prototype.hasOwnProperty("muted"));
+check(!Microphone.prototype.hasOwnProperty("name"));
+check(!Microphone.prototype.hasOwnProperty("names"));
+check(!Microphone.prototype.hasOwnProperty("onActivity"));
+check(!Microphone.prototype.hasOwnProperty("onStatus"));
+check(!Microphone.prototype.hasOwnProperty("rate"));
+check(!Microphone.prototype.hasOwnProperty("silenceLevel"));
+check(!Microphone.prototype.hasOwnProperty("silenceTimeOut"));
+check(!Microphone.prototype.hasOwnProperty("useEchoSuppression"));
 
 f = new Microphone;
 
@@ -61,115 +61,118 @@
 // properties.
 check_equals(typeof(f), 'object');
 check_equals(typeof(f.setGain), 'function')
-check_equals(typeof(f.gain), 'number')
-check_equals(typeof(f.rate), 'number')
+check_equals(typeof(f.gain), 'undefined')
+check_equals(typeof(f.rate), 'undefined')
 
 // Still not present
-check(Microphone.prototype.hasOwnProperty("get"));
-check(Microphone.prototype.hasOwnProperty("activityLevel"));
-check(Microphone.prototype.hasOwnProperty("gain"));
-check(Microphone.prototype.hasOwnProperty("index"));
-check(Microphone.prototype.hasOwnProperty("muted"));
-check(Microphone.prototype.hasOwnProperty("name"));
-check(Microphone.prototype.hasOwnProperty("names"));
+xcheck(!Microphone.prototype.hasOwnProperty("get"));
+check(!Microphone.prototype.hasOwnProperty("activityLevel"));
+check(!Microphone.prototype.hasOwnProperty("gain"));
+check(!Microphone.prototype.hasOwnProperty("index"));
+check(!Microphone.prototype.hasOwnProperty("muted"));
+check(!Microphone.prototype.hasOwnProperty("name"));
+check(!Microphone.prototype.hasOwnProperty("names"));
 check(!Microphone.prototype.hasOwnProperty("onActivity"));
 check(!Microphone.prototype.hasOwnProperty("onStatus"));
-check(Microphone.prototype.hasOwnProperty("rate"));
-check(Microphone.prototype.hasOwnProperty("silenceLevel"));
-check(Microphone.prototype.hasOwnProperty("silenceTimeOut"));
-check(Microphone.prototype.hasOwnProperty("useEchoSuppression"));
+check(!Microphone.prototype.hasOwnProperty("rate"));
+check(!Microphone.prototype.hasOwnProperty("silenceLevel"));
+check(!Microphone.prototype.hasOwnProperty("silenceTimeOut"));
+check(!Microphone.prototype.hasOwnProperty("useEchoSuppression"));
 
 // Documented to be an array.
-check ( Microphone.hasOwnProperty("names"));
+xcheck ( Microphone.hasOwnProperty("names"));
 xcheck_equals (typeof (Microphone.names), 'object');
 
 // test the Microphone constuctor
 var microphoneObj = Microphone.get();
-check_equals (typeof(microphoneObj), 'object');
+xcheck_equals (typeof(microphoneObj), 'object');
 
 // Microphone.get() adds these properties.
 // Other properties are probably dependent on whether a microphone
 // is present or not.
-check(Microphone.prototype.hasOwnProperty("get"));
-check(Microphone.prototype.hasOwnProperty("activityLevel"));
-check(Microphone.prototype.hasOwnProperty("gain"));
-check(Microphone.prototype.hasOwnProperty("index"));
-check(Microphone.prototype.hasOwnProperty("muted"));
-check(Microphone.prototype.hasOwnProperty("name"));
-check(Microphone.prototype.hasOwnProperty("rate"));
-check(Microphone.prototype.hasOwnProperty("silenceLevel"));
-check(Microphone.prototype.hasOwnProperty("useEchoSuppression"));
+xcheck(!Microphone.prototype.hasOwnProperty("get"));
+xcheck(Microphone.prototype.hasOwnProperty("activityLevel"));
+xcheck(Microphone.prototype.hasOwnProperty("gain"));
+xcheck(Microphone.prototype.hasOwnProperty("index"));
+xcheck(Microphone.prototype.hasOwnProperty("muted"));
+xcheck(Microphone.prototype.hasOwnProperty("name"));
+xcheck(Microphone.prototype.hasOwnProperty("rate"));
+xcheck(Microphone.prototype.hasOwnProperty("silenceLevel"));
+xcheck(Microphone.prototype.hasOwnProperty("useEchoSuppression"));
+
+// test that Microphone.get() returns a singleton
+check_equals(microphoneObj, Microphone.get());
 
 // test that get() method is NOT exported to instances
-check_equals (typeof(microphoneObj.get), 'function');
+check_equals (typeof(microphoneObj.get), 'undefined');
 
 // test the Microphone::setGain method
-check_equals ( typeof(microphoneObj.setGain), 'function' );
+xcheck_equals ( typeof(microphoneObj.setGain), 'function' );
 
 // test the Microphone::setRate method
-check_equals ( typeof(microphoneObj.setRate), 'function' );
+xcheck_equals ( typeof(microphoneObj.setRate), 'function' );
 
 // test the Microphone::setSilenceLevel method
-check_equals ( typeof(microphoneObj.setSilenceLevel), 'function' );
+xcheck_equals ( typeof(microphoneObj.setSilenceLevel), 'function' );
 
 // test the Microphone::setUseEchoSuppression method
-check_equals ( typeof(microphoneObj.setUseEchoSuppression), 'function' );
+xcheck_equals ( typeof(microphoneObj.setUseEchoSuppression), 'function' );
 
 /// Microphone properties
 
-check_equals ( typeof(microphoneObj.activityLevel), 'number' );
-check_equals ( typeof(microphoneObj.gain), 'number' );
-check_equals ( typeof(microphoneObj.index), 'number' );
-check_equals ( typeof(microphoneObj.muted), 'boolean' );
-check_equals ( typeof(microphoneObj.name), 'string' );
-check_equals ( typeof(microphoneObj.rate), 'number' );
-check_equals ( typeof(microphoneObj.silenceTimeOut), 'number' );
+xcheck_equals ( typeof(microphoneObj.activityLevel), 'number' );
+xcheck_equals ( typeof(microphoneObj.gain), 'number' );
+xcheck_equals ( typeof(microphoneObj.index), 'number' );
+xcheck_equals ( typeof(microphoneObj.muted), 'boolean' );
+xcheck_equals ( typeof(microphoneObj.name), 'string' );
+xcheck_equals ( typeof(microphoneObj.rate), 'number' );
+xcheck_equals ( typeof(microphoneObj.silenceTimeout), 'number' );
 // Documented to be boolean
-check_equals ( typeof(microphoneObj.useEchoSuppression), 'boolean' );
+xcheck_equals ( typeof(microphoneObj.useEchoSuppression), 'number' );
 
 // Starting values // values before microphone is activated
-check_equals ( microphoneObj.activityLevel, -1 );
-//check_equals ( microphoneObj.gain, 50 );
-check_equals ( microphoneObj.index, 0 );
-xcheck_equals ( microphoneObj.muted, true);
-check_equals ( microphoneObj.rate, 8 );
-check_equals ( microphoneObj.silenceTimeOut, 2000 );
+xcheck_equals ( microphoneObj.activityLevel, -1 );
+xcheck_equals ( microphoneObj.gain, 50 );
+xcheck_equals ( microphoneObj.index, 0 );
+xcheck_equals ( microphoneObj.muted, true );
+xcheck_equals ( microphoneObj.rate, 8 );
+xcheck_equals ( microphoneObj.silenceTimeout, 2000 );
 
 
 // Setting and getting
 
 microphoneObj.setGain(5);
-check_equals (microphoneObj.gain, 5);
+xcheck_equals (microphoneObj.gain, 5);
 
 microphoneObj.setSilenceLevel(16);
-check_equals (microphoneObj.silenceLevel, 16);
+xcheck_equals (microphoneObj.silenceLevel, 16);
 
 
 // 5, 8, 11, 22, or 44 documented...
 microphoneObj.setRate(1);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 5);
 microphoneObj.setRate(7);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 8);
 microphoneObj.setRate(10);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 11);
 microphoneObj.setRate(15);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 16);
 microphoneObj.setRate(17);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 22);
 microphoneObj.setRate(27);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 44);
 microphoneObj.setRate(34);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 44);
 microphoneObj.setRate(1000000);
-check_equals (microphoneObj.rate, 11);
+xcheck_equals (microphoneObj.rate, 44);
 
 
 /// It's still a number, though.
 microphoneObj.setUseEchoSuppression(false);
-check_equals (microphoneObj.useEchoSuppression, false);
+xcheck_equals (microphoneObj.useEchoSuppression, false);
 
 microphoneObj.setUseEchoSuppression(16);
-check_equals (microphoneObj.useEchoSuppression, true);
+xcheck_equals (microphoneObj.useEchoSuppression, true);
 
 // listen to the microphone.
 _root.attachAudio(microphoneObj);


reply via email to

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