[hydra-commits] hydra/media_format_ulaw.git branch "master" updated.

Commits to the Hydra project code repositories hydra-commits at lists.digium.com
Mon Aug 2 14:42:17 CDT 2010


branch "master" has been updated
       via  38553bd109341ab055863122c14415bef9a853c8 (commit)
      from  6a750050b6182408a6c31a3193cdc3d19540c119 (commit)

Summary of changes:
 test/TestMediaFormatULAW.cpp |  155 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 152 insertions(+), 3 deletions(-)


- Log -----------------------------------------------------------------
commit 38553bd109341ab055863122c14415bef9a853c8
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Aug 2 16:57:43 2010 -0300

    Add a test driver for the ulaw media format component. It confirms that the media format service
    can be found using all three types it supports, and also confirms that the concrete class it returns
    contains exactly what it is supposed to contain.

diff --git a/test/TestMediaFormatULAW.cpp b/test/TestMediaFormatULAW.cpp
index d48d7f9..7069b7a 100644
--- a/test/TestMediaFormatULAW.cpp
+++ b/test/TestMediaFormatULAW.cpp
@@ -7,9 +7,11 @@
 
 #include <Ice/Ice.h>
 
+#include "service_locator.h"
 #include "media.h"
 
 using namespace std;
+using namespace Hydra::Location::V1;
 using namespace Hydra::Media::V1;
 
 /* Cache the command line arguments so that Ice can be initialized within the global fixture. */
@@ -28,8 +30,17 @@ static ArgCacheType mCachedArgs;
 struct SharedTestData
 {
 public:
+	/**
+	 * ICE Communicator used for talking to the service locator and eventually media format service.
+	 */
+	Ice::CommunicatorPtr communicator;
+
+	/**
+	 * A proxy to the service locator service.
+	 */
+	ServiceLocatorPrx locator;
 };
-//static SharedTestData Testbed;
+static SharedTestData Testbed;
 
 /**
  * A global fixture for Ice initialization.
@@ -39,15 +50,44 @@ struct GlobalIceFixture
 {
 	GlobalIceFixture()
 	        {
-			BOOST_TEST_MESSAGE("Setting up MediaFormatULAW test fixture");
+			BOOST_TEST_MESSAGE("Setting up ulaw media format test fixture");
 
 			::boost::debug::detect_memory_leaks(false);
 			::boost::unit_test::unit_test_log.set_stream( std::cout );
+
+			int status = 0;
+			try
+				{
+					Testbed.communicator = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
+
+					Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -p 2657"));
+
+					if (!Testbed.locator) {
+						throw "Invalid service locator proxy";
+					}
+				}
+			catch (const Ice::Exception& ex)
+				{
+					cerr << ex << endl;
+					status = 1;
+				}
+			catch (const char* msg)
+				{
+					cerr << msg << endl;
+					status = 1;
+				}
+
 		} // end Fixture() constructor
 
 	~GlobalIceFixture()
 	        {
-			BOOST_TEST_MESSAGE("Tearing down MediaFormatULAW test fixture");
+			BOOST_TEST_MESSAGE("Tearing down ulaw media format test fixture");
+
+
+			if (Testbed.communicator) {
+				Testbed.communicator->shutdown();
+				Testbed.communicator = 0;
+			}
 		}
 private:
 };
@@ -65,3 +105,112 @@ int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
 	mCachedArgs.argv = argv;
 	return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
 }
+
+/**
+ * Confirm that we find the ulaw media format service based on name
+ */
+BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
+{
+	bool found = false;
+
+	try {
+		FormatDiscoveryNamePtr params = new FormatDiscoveryName();
+		params->category = "media_format";
+		params->name = "ulaw8 at 20";
+
+		Testbed.locator->locate(params);
+
+		found = true;
+	} catch (const Ice::Exception &e) {
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	} catch (...) {
+	}
+
+	BOOST_CHECK(found);
+}
+
+/**
+ * Confirm that we find the ulaw media format service based on SDP
+ */
+BOOST_AUTO_TEST_CASE(ServiceFoundUsingSDP)
+{
+	bool found = false;
+
+	try {
+		FormatDiscoverySDPPtr params = new FormatDiscoverySDP();
+		params->category = "media_format";
+		params->payload = 0;
+		params->type = "audio";
+		params->subtype = "PCMU";
+		params->samplerate = 8000;
+
+		Testbed.locator->locate(params);
+
+		found = true;
+	} catch (const Ice::Exception &e) {
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	} catch (...) {
+	}
+
+	BOOST_CHECK(found);
+}
+
+/**
+ * Confirm that we find the ulaw media format service based on generic audio details
+ */
+BOOST_AUTO_TEST_CASE(ServiceFoundUsingGenericAudio)
+{
+	bool found = false;
+
+	try {
+		FormatDiscoveryGenericAudioPtr params = new FormatDiscoveryGenericAudio();
+		params->category = "media_format";
+		params->name = "ulaw";
+		params->samplerate = 8000;
+		params->channels = 1;
+
+		Testbed.locator->locate(params);
+
+		found = true;
+	} catch (const Ice::Exception &e) {
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	} catch (...) {
+	}
+
+	BOOST_CHECK(found);
+}
+
+/**
+ * Confirm that we get the expected ulaw media format concrete class back from the media format service
+ */
+BOOST_AUTO_TEST_CASE(ConfirmUlawMediaFormatContents)
+{
+	bool valid = false;
+
+	try {
+		FormatDiscoveryNamePtr params = new FormatDiscoveryName();
+		params->category = "media_format";
+		params->name = "ulaw8 at 20";
+
+		MediaFormatServicePrx service = MediaFormatServicePrx::uncheckedCast(Testbed.locator->locate(params));
+		AudioFormatPtr ulaw_format = AudioFormatPtr::dynamicCast(service->getFormat(params));
+
+		if (ulaw_format->name == "ulaw" &&
+		    ulaw_format->sampleRate == 8000 &&
+		    ulaw_format->frameSize == 20 &&
+		    ulaw_format->maximumFrameSize == 20 &&
+		    ulaw_format->minimumFrameSize == 20)
+		{
+			valid = true;
+		}
+	} catch (const Ice::Exception &e) {
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	} catch (...) {
+	}
+
+	BOOST_CHECK(valid);
+}

-----------------------------------------------------------------------


-- 
hydra/media_format_ulaw.git




More information about the asterisk-scf-commits mailing list