got fading to work, mostly;

added test of storage -> audio player playback to products/gLiveSupport
This commit is contained in:
fgerlits 2005-03-04 21:30:10 +00:00
parent 01745e8374
commit 4b060aeca0
17 changed files with 871 additions and 38 deletions

View File

@ -43,7 +43,7 @@
uri="file:var/test10002.mp3" />
<fadeInfo id="0000000000009902"
fadeIn="00:00:05"
fadeOut="00:00:04" />
fadeOut="0" />
</playlistElement>
<playlistElement id="0000000000000103"
relativeOffset="00:00:18.200000" >
@ -52,7 +52,7 @@
title = "three"
uri="file:var/test10003.mp3" />
<fadeInfo id="0000000000009903"
fadeIn="00:00:06"
fadeOut="00:00:04" />
fadeIn="00:00:03"
fadeOut="00:00:03" />
</playlistElement>
</playlist>

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.37 $
Version : $Revision: 1.38 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
------------------------------------------------------------------------------*/
@ -187,8 +187,8 @@ WebStorageClientTest :: playlistTest(void)
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() >= 3);
Ptr<UniqueId>::Ref audioClipId = wsc->getAudioClipIds()->at(2);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() >= 4);
Ptr<UniqueId>::Ref audioClipId = wsc->getAudioClipIds()->at(3);
Ptr<SessionId>::Ref sessionId;
try {
@ -555,17 +555,6 @@ WebStorageClientTest :: simplePlaylistTest(void)
CPPUNIT_ASSERT(newPlaylist->getTitle().get());
CPPUNIT_ASSERT(*newPlaylist->getTitle() == *title);
/*
// this is not needed here
// releasePlaylist() is the closing pair of acquirePlaylist()
try {
wsc->releasePlaylist(sessionId, newPlaylist);
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(!newPlaylist->getUri());
*/
try{
authentication->logout(sessionId);
} catch (XmlRpcException &e) {
@ -586,14 +575,16 @@ WebStorageClientTest :: searchTest(void)
} catch (XmlRpcException &e) {
CPPUNIT_FAIL(e.what());
}
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() >= 5);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() >= 6);
Ptr<UniqueId>::Ref audioClip0 = wsc->getAudioClipIds()->at(0);
Ptr<UniqueId>::Ref audioClip1 = wsc->getAudioClipIds()->at(1);
Ptr<UniqueId>::Ref audioClip2 = wsc->getAudioClipIds()->at(2);
Ptr<UniqueId>::Ref audioClip3 = wsc->getAudioClipIds()->at(3);
Ptr<UniqueId>::Ref audioClip4 = wsc->getAudioClipIds()->at(4);
Ptr<UniqueId>::Ref audioClip5 = wsc->getAudioClipIds()->at(5);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() >= 1);
Ptr<UniqueId>::Ref playlist0 = wsc->getPlaylistIds()->at(0);
Ptr<UniqueId>::Ref playlist1 = wsc->getPlaylistIds()->at(1);
Ptr<SessionId>::Ref sessionId;
try {
@ -610,7 +601,7 @@ WebStorageClientTest :: searchTest(void)
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 1);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() == 1);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip2);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip3);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL(e.what());
@ -624,9 +615,10 @@ WebStorageClientTest :: searchTest(void)
criteria->addCondition("dcterms:extent", ">=", "0");
criteria->setLimit(10);
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 1);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() == 1);
CPPUNIT_ASSERT(numberFound >= 2);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() >= 2);
CPPUNIT_ASSERT(*wsc->getPlaylistIds()->at(0) == *playlist0);
CPPUNIT_ASSERT(*wsc->getPlaylistIds()->at(1) == *playlist1);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL(e.what());
@ -643,7 +635,7 @@ WebStorageClientTest :: searchTest(void)
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 1);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() == 1);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip3);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip4);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() == 0);
} catch (std::invalid_argument &e) {
@ -654,16 +646,16 @@ WebStorageClientTest :: searchTest(void)
try {
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria("all", "or"));
criteria->addCondition("dcterms:extent", "<", "00:30:00.000000");
criteria->addCondition("dcterms:extent", ">", "00:00:15.000000");
criteria->addCondition("dc:title", "prefix", "My");
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 4);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() == 3);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip2);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(1) == *audioClip3);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(2) == *audioClip4);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() == 1);
CPPUNIT_ASSERT(numberFound >= 4);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() >= 2);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip4);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(1) == *audioClip5);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() >= 2);
CPPUNIT_ASSERT(*wsc->getPlaylistIds()->at(0) == *playlist0);
CPPUNIT_ASSERT(*wsc->getPlaylistIds()->at(1) == *playlist1);
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL(e.what());
@ -676,12 +668,12 @@ WebStorageClientTest :: searchTest(void)
criteria->setType("all");
criteria->addCondition("dc:title", "partial", "t");
criteria->setLimit(2);
criteria->setOffset(2);
criteria->setOffset(3);
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 5);
CPPUNIT_ASSERT(numberFound >= 5);
CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() == 2);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip3);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(1) == *audioClip4);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(0) == *audioClip4);
CPPUNIT_ASSERT(*wsc->getAudioClipIds()->at(1) == *audioClip5);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() == 0);
} catch (std::invalid_argument &e) {

View File

@ -8,6 +8,6 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
<dc:title>one</dc:title>
<dcterms:extent>01:00:00.000000</dcterms:extent>
<dcterms:extent>00:00:11.000000</dcterms:extent>
</metadata>
</audioClip>

View File

@ -8,6 +8,6 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
<dc:title >two</dc:title>
<dcterms:extent >00:30:00.000000</dcterms:extent>
<dcterms:extent >00:00:12.200000</dcterms:extent>
</metadata>
</audioClip>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<audioClip>
<metadata
xmlns="http://mdlf.org/livesupport/elements/1.0/"
xmlns:ls="http://mdlf.org/livesupport/elements/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
<dc:title>three</dc:title>
<dcterms:extent>00:00:11.500000</dcterms:extent>
</metadata>
</audioClip>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<playlist id="0000000000000001"
title="My Second Playlist"
playlength="00:00:29.700000" >
<playlistElement id="0000000000000101"
relativeOffset="0" >
<audioClip id="0000000000010001"
playlength="00:00:11"
title = "one"
uri="file:var/test10001.mp3" />
<fadeInfo id="0000000000009901"
fadeIn="0"
fadeOut="00:00:05" />
</playlistElement>
<playlistElement id="0000000000000102"
relativeOffset="00:00:06" >
<audioClip id="0000000000010002"
playlength="00:00:12.200000"
title = "two"
uri="file:var/test10002.mp3" />
<fadeInfo id="0000000000009902"
fadeIn="00:00:05"
fadeOut="0" />
</playlistElement>
<playlistElement id="0000000000000103"
relativeOffset="00:00:18.200000" >
<audioClip id="0000000000010003"
playlength="00:00:11.500000"
title = "three"
uri="file:var/test10003.mp3" />
<fadeInfo id="0000000000009903"
fadeIn="00:00:03"
fadeOut="00:00:03" />
</playlistElement>
<metadata xmlns="http://mdlf.org/livesupport/elements/1.0/"
xmlns:ls="http://mdlf.org/livesupport/elements/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xml="http://www.w3.org/XML/1998/namespace" >
<dc:title>My Second Playlist</dc:title>
<dc:creator>Nobody</dc:creator>
<dcterms:extent>00:00:29.700000</dcterms:extent>
</metadata>
</playlist>

View File

@ -12,6 +12,12 @@
'xml' => '../tests/mdata10002.xml',
'gunid' => '0000000000010002'
),
array(
'type' => 'audioclip',
'media' => '../tests/test10003.mp3',
'xml' => '../tests/mdata10003.xml',
'gunid' => '0000000000010003'
),
array(
'type' => 'audioclip',
'media' => '../tests/ex1.mp3',
@ -34,6 +40,11 @@
'xml' => '../tests/plist1.xml',
'gunid' => '0000000000000001'
),
array(
'type' => 'playlist',
'xml' => '../tests/plist2.xml',
'gunid' => '0000000000000002'
),
array(
'type' => 'webstream',
'xml' => '../tests/wstream1.xml',

View File

@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: maroy $
# Version : $Revision: 1.23 $
# Author : $Author: fgerlits $
# Version : $Revision: 1.24 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
#
# @configure_input@
@ -210,6 +210,7 @@ G_LIVESUPPORT_EXE_LIBS = -l${PLAYLIST_EXECUTOR_LIB} \
-lxmlrpc++ -lssl
TEST_RUNNER_OBJS = ${G_LIVESUPPORT_OBJS} \
${TMP_DIR}/AudioPlayerTest.o \
${TMP_DIR}/TestRunner.o
TEST_RUNNER_LIBS = ${G_LIVESUPPORT_EXE_LIBS} -lcppunit -ldl
@ -248,7 +249,7 @@ depclean: clean
distclean: clean docclean
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/*.m4
check: all ${TEST_RUNNER} run_tests
check: all ${TEST_RUNNER} storage_server_init run_tests
run_tests: ${TEST_RUNNER}
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
@ -270,6 +271,9 @@ uninstall: ${SCHEDULER_EXE}
-${MAKE} -C ${SCHEDULER_DIR} uninstall_web
-${MAKE} -C ${STORAGE_SERVER_DIR} db_clean
storage_server_init:
${MAKE} -C ${STORAGE_SERVER_DIR}
#-------------------------------------------------------------------------------
# Specific targets

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE audioPlayer [
<!ELEMENT audioPlayer (helixPlayer) >
<!ELEMENT helixPlayer EMPTY >
<!ATTLIST helixPlayer dllPath CDATA #REQUIRED >
]>
<audioPlayer>
<helixPlayer dllPath = "../../usr/lib/helix"
/>
</audioPlayer>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE authenticationClientFactory [
<!ELEMENT authenticationClientFactory (testAuthentication|
webAuthentication)>
<!ELEMENT webAuthentication (location) >
<!ELEMENT location EMPTY >
<!ATTLIST location server CDATA #REQUIRED >
<!ATTLIST location port NMTOKEN #REQUIRED >
<!ATTLIST location path CDATA #REQUIRED >
]>
<authenticationClientFactory>
<webAuthentication>
<location server="localhost" port="80"
path="/livesupportStorageServer/xmlrpc/xrLocStor.php" />
</webAuthentication>
</authenticationClientFactory>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE storageClientFactory [
<!ELEMENT storageClientFactory (webStorage|testStorage) >
<!ELEMENT webStorage (location) >
<!ATTLIST webStorage tempFiles CDATA #REQUIRED >
<!ELEMENT location EMPTY >
<!ATTLIST location server CDATA #REQUIRED >
<!ATTLIST location port NMTOKEN #REQUIRED >
<!ATTLIST location path CDATA #REQUIRED >
]>
<storageClientFactory>
<webStorage tempFiles="file:///tmp/webStorageClient" >
<location server="localhost" port="80"
path="/livesupportStorageServer/xmlrpc/xrLocStor.php" />
</webStorage>
</storageClientFactory>

View File

@ -0,0 +1,301 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport 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.
LiveSupport 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 LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/AudioPlayerTest.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#include <string>
#include <iostream>
#include "LiveSupport/Core/TimeConversion.h"
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
#include "LiveSupport/Storage/StorageClientFactory.h"
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
#include "LiveSupport/Core/AudioClip.h"
#include "LiveSupport/Core/Playlist.h"
#include "AudioPlayerTest.h"
using namespace LiveSupport::PlaylistExecutor;
using namespace LiveSupport::Core;
using namespace LiveSupport::Storage;
using namespace LiveSupport::Authentication;
using namespace LiveSupport::gLiveSupport;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
CPPUNIT_TEST_SUITE_REGISTRATION(AudioPlayerTest);
/**
* The name of the configuration file for the Helix player.
*/
static const std::string audioPlayerConfigFileName
= "etc/audioPlayer.xml";
/**
* The name of the configuration file for the local storage.
*/
static const std::string storageClientConfigFileName
= "etc/storageClient.xml";
/**
* The name of the configuration file for the authentication client.
*/
static const std::string authenticationClientConfigFileName
= "etc/authenticationClient.xml";
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Set up the test environment
*----------------------------------------------------------------------------*/
void
AudioPlayerTest :: setUp(void) throw ()
{
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(audioPlayerConfigFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
audioPlayerFactory = AudioPlayerFactory::getInstance();
audioPlayerFactory->configure(*root);
// initialize the audio player configured by the factory
Ptr<AudioPlayerInterface>::Ref audioPlayer;
audioPlayer = audioPlayerFactory->getAudioPlayer();
audioPlayer->initialize();
} catch (std::invalid_argument &e) {
std::cerr << "semantic error in audio player configuration file: "
<< e.what() << std::endl;
} catch (xmlpp::exception &e) {
std::cerr << "syntax error in audio player configuration file: "
<< e.what() << std::endl;
}
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(storageClientConfigFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
Ptr<StorageClientFactory>::Ref storageClientFactory;
storageClientFactory = StorageClientFactory::getInstance();
storageClientFactory->configure(*root);
// initialize the storage client configured by the factory
Ptr<StorageClientInterface>::Ref storage;
storage = storageClientFactory->getStorageClient();
storage->reset();
} catch (std::invalid_argument &e) {
std::cerr << "semantic error in storage client configuration file: "
<< e.what() << std::endl;
} catch (xmlpp::exception &e) {
std::cerr << "syntax error in storage client configuration file: "
<< e.what() << std::endl;
}
try {
Ptr<xmlpp::DomParser>::Ref parser(
new xmlpp::DomParser(authenticationClientConfigFileName, true));
const xmlpp::Document * document = parser->get_document();
const xmlpp::Element * root = document->get_root_node();
Ptr<AuthenticationClientFactory>::Ref authentClientFactory;
authentClientFactory = AuthenticationClientFactory::getInstance();
authentClientFactory->configure(*root);
// log in using the authentication client
Ptr<AuthenticationClientInterface>::Ref authent;
authent = authentClientFactory->getAuthenticationClient();
sessionId = authent->login("root", "q");
} catch (std::invalid_argument &e) {
std::cerr << "semantic error in authentication client "
"configuration file: "
<< e.what() << std::endl;
} catch (xmlpp::exception &e) {
std::cerr << "syntax error in authentication client "
"configuration file: "
<< e.what() << std::endl;
}
}
/*------------------------------------------------------------------------------
* Clean up the test environment
*----------------------------------------------------------------------------*/
void
AudioPlayerTest :: tearDown(void) throw ()
{
// de-initialize the audio player configured by the factory
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
audioPlayerFactory = AudioPlayerFactory::getInstance();
Ptr<AudioPlayerInterface>::Ref audioPlayer;
audioPlayer = audioPlayerFactory->getAudioPlayer();
audioPlayer->deInitialize();
// log out using the authentication client
Ptr<AuthenticationClientFactory>::Ref authentClientFactory;
authentClientFactory = AuthenticationClientFactory::getInstance();
Ptr<AuthenticationClientInterface>::Ref authent;
authent = authentClientFactory->getAuthenticationClient();
CPPUNIT_ASSERT_NO_THROW(authent->logout(sessionId));
}
/*------------------------------------------------------------------------------
* Test to see if the HelixPlayer engine can be started and stopped
*----------------------------------------------------------------------------*/
void
AudioPlayerTest :: firstTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
audioPlayerFactory = AudioPlayerFactory::getInstance();
CPPUNIT_ASSERT(audioPlayerFactory.get());
Ptr<AudioPlayerInterface>::Ref audioPlayer;
audioPlayer = audioPlayerFactory->getAudioPlayer();
CPPUNIT_ASSERT(audioPlayer.get());
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
}
/*------------------------------------------------------------------------------
* Play an audio clip from storage.
*----------------------------------------------------------------------------*/
void
AudioPlayerTest :: playAudioClipTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<AudioPlayerFactory>::Ref
audioPlayerFactory = AudioPlayerFactory::getInstance();
Ptr<AudioPlayerInterface>::Ref
audioPlayer = audioPlayerFactory->getAudioPlayer();
Ptr<StorageClientFactory>::Ref
storageClientFactory = StorageClientFactory::getInstance();
Ptr<StorageClientInterface>::Ref
storage = storageClientFactory->getStorageClient();
Ptr<UniqueId>::Ref audioClipId(new UniqueId(0x10001));
Ptr<AudioClip>::Ref audioClip;
CPPUNIT_ASSERT_NO_THROW(
audioClip = storage->acquireAudioClip(sessionId, audioClipId)
);
CPPUNIT_ASSERT_NO_THROW(
audioPlayer->open(*audioClip->getUri())
);
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
CPPUNIT_ASSERT_NO_THROW(audioPlayer->start());
CPPUNIT_ASSERT(audioPlayer->isPlaying());
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
while (audioPlayer->isPlaying()) {
TimeConversion::sleep(sleepT);
}
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
CPPUNIT_ASSERT_NO_THROW(
storage->releaseAudioClip(sessionId, audioClip)
);
audioPlayer->close();
}
/*------------------------------------------------------------------------------
* Play a playlist from storage.
*----------------------------------------------------------------------------*/
void
AudioPlayerTest :: playPlaylistTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<AudioPlayerFactory>::Ref
audioPlayerFactory = AudioPlayerFactory::getInstance();
Ptr<AudioPlayerInterface>::Ref
audioPlayer = audioPlayerFactory->getAudioPlayer();
Ptr<StorageClientFactory>::Ref
storageClientFactory = StorageClientFactory::getInstance();
Ptr<StorageClientInterface>::Ref
storage = storageClientFactory->getStorageClient();
Ptr<UniqueId>::Ref audioClipId(new UniqueId(2));
Ptr<Playlist>::Ref playlist;
CPPUNIT_ASSERT_NO_THROW(
playlist = storage->acquirePlaylist(sessionId, audioClipId)
);
CPPUNIT_ASSERT_NO_THROW(
audioPlayer->openAndStart(playlist)
);
CPPUNIT_ASSERT(audioPlayer->isPlaying());
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
while (audioPlayer->isPlaying()) {
TimeConversion::sleep(sleepT);
}
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
CPPUNIT_ASSERT_NO_THROW(
storage->releasePlaylist(sessionId, playlist)
);
audioPlayer->close();
}

View File

@ -0,0 +1,136 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport 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.
LiveSupport 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 LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/AudioPlayerTest.h,v $
------------------------------------------------------------------------------*/
#ifndef AudioPlayerTest_h
#define AudioPlayerTest_h
#ifndef __cplusplus
#error This is a C++ include file
#endif
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <cppunit/extensions/HelperMacros.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/SessionId.h"
namespace LiveSupport {
namespace gLiveSupport {
using namespace LiveSupport::Core;
/* ================================================================ constants */
/* =================================================================== macros */
/* =============================================================== data types */
/**
* Testing the AudioPlayerInterface::openAndStart() method.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @see AudioPlayerFactory
*/
class AudioPlayerTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(AudioPlayerTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(playAudioClipTest);
CPPUNIT_TEST(playPlaylistTest);
CPPUNIT_TEST_SUITE_END();
private:
/**
* The session ID returned by the authentication client login.
*/
Ptr<SessionId>::Ref sessionId;
protected:
/**
* A simple test.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
firstTest(void) throw (CPPUNIT_NS::Exception);
/**
* Play an audio clip from storage.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
playAudioClipTest(void) throw (CPPUNIT_NS::Exception);
/**
* Play a playlist from storage.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
playPlaylistTest(void) throw (CPPUNIT_NS::Exception);
public:
/**
* Set up the environment for the test case.
*/
void
setUp(void) throw ();
/**
* Clean up the environment after the test case.
*/
void
tearDown(void) throw ();
};
/* ================================================= external data structures */
/* ====================================================== function prototypes */
} // namespace gLiveSupport
} // namespace LiveSupport
#endif // AudioPlayerTest_h

View File

@ -0,0 +1,281 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport 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.
LiveSupport 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 LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/TestRunner.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#error "Need unistd.h"
#endif
#if HAVE_GETOPT_H
#include <getopt.h>
#else
#error "Need getopt.h"
#endif
#include <fstream>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include "LiveSupport/Core/Ptr.h"
using namespace LiveSupport::Core;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/**
* Our copyright notice, should be at most 80 columns
*/
static const char copyrightNotice[] =
"Copyright (c) 2004 Media Development Loan Fund under the GNU GPL";
/**
* String describing the short options.
*/
static const char options[] = "ho:s:v";
/**
* Structure describing the long options
*/
static const struct option longOptions[] = {
{ "help", no_argument, 0, 'h' },
{ "output", required_argument, 0, 'o' },
{ "stylesheet", required_argument, 0, 's' },
{ "version", no_argument, 0, 'v' },
{ 0, 0, 0, 0 }
};
/**
* The encoding to use for the output file.
*/
static const std::string encoding = "utf-8";
/**
* The output XML file name.
*/
static Ptr<std::string>::Ref xmlOutFileName;
/**
* The XSLT attached to the output file.
*/
static Ptr<std::string>::Ref xsltFileName;
/* =============================================== local function prototypes */
/**
* Print program version.
*
* @param os the std::ostream to print to.
*/
static void
printVersion ( std::ostream & os );
/**
* Print program usage information.
*
* @param invocation the command line command used to invoke this program.
* @param os the std::ostream to print to.
*/
static void
printUsage ( const char invocation[],
std::ostream & os );
/**
* Process command line arguments.
*
* @param argc the number of arguments.
* @param argv the arguments themselves.
* @return true of all went well, false in case the program should exit
* after this call.
*/
static bool
processArguments(int argc, char *argv[]);
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Run all tests
*----------------------------------------------------------------------------*/
int
main( int argc,
char * argv[] ) throw ()
{
if (!processArguments(argc, argv)) {
return 0;
}
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
// Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
// Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
outputter.setLocationFormat("%p:%l:");
outputter.write();
// also generate an XML document as an output
std::ofstream xmlOutFile(xmlOutFileName->c_str());
CPPUNIT_NS::XmlOutputter xmlOutputter(&result, xmlOutFile, encoding);
xmlOutputter.setStandalone(false);
if (xsltFileName) {
xmlOutputter.setStyleSheet(*xsltFileName);
}
xmlOutputter.write();
xmlOutFile.flush();
xmlOutFile.close();
return result.wasSuccessful() ? 0 : 1;
}
/*------------------------------------------------------------------------------
* Process command line arguments.
*----------------------------------------------------------------------------*/
static bool
processArguments(int argc, char *argv[])
{
int i;
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
switch (i) {
case 'h':
printUsage(argv[0], std::cout);
return false;
case 'o':
xmlOutFileName.reset(new std::string(optarg));
break;
case 's':
xsltFileName.reset(new std::string(optarg));
break;
case 'v':
printVersion(std::cout);
return false;
default:
printUsage(argv[0], std::cout);
return false;
}
}
if (optind < argc) {
std::cerr << "error processing command line arguments" << std::endl;
printUsage(argv[0], std::cout);
return false;
}
if (!xmlOutFileName) {
std::cerr << "mandatory option output file name not specified"
<< std::endl;
printUsage(argv[0], std::cout);
return false;
}
std::cerr << "writing output to '" << *xmlOutFileName << '\'' << std::endl;
if (xsltFileName) {
std::cerr << "using XSLT file '" << *xsltFileName << '\'' << std::endl;
}
return true;
}
/*------------------------------------------------------------------------------
* Print program version.
*----------------------------------------------------------------------------*/
static void
printVersion ( std::ostream & os )
{
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
<< "Unit test runner" << std::endl
<< copyrightNotice << std::endl;
}
/*------------------------------------------------------------------------------
* Print program usage.
*----------------------------------------------------------------------------*/
static void
printUsage ( const char invocation[],
std::ostream & os )
{
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
<< "Unit test runner" << std::endl
<< std::endl
<< "Usage: " << invocation << " [OPTION]"
<< std::endl
<< " mandatory options:" << std::endl
<< " -o, --output=file.name write test results into this XML file"
<< std::endl
<< " optional options:" << std::endl
<< " -s, --stylesheet specify this XSLT for the output file"
<< std::endl
<< " this is either an absolute URI, or a"
<< std::endl
<< " relative path for the output document"
<< std::endl
<< " -h, --help display this help and exit" << std::endl
<< " -v, --version display version information and exit"
<< std::endl
<< std::endl
<< "Report bugs to " << PACKAGE_BUGREPORT << std::endl;
}