diff --git a/livesupport/modules/playlistExecutor/etc/playlist.xml b/livesupport/modules/playlistExecutor/etc/playlist.xml
index b8b2e217d..8cfb0fef3 100644
--- a/livesupport/modules/playlistExecutor/etc/playlist.xml
+++ b/livesupport/modules/playlistExecutor/etc/playlist.xml
@@ -43,7 +43,7 @@
uri="file:var/test10002.mp3" />
+ fadeOut="0" />
@@ -52,7 +52,7 @@
title = "three"
uri="file:var/test10003.mp3" />
+ fadeIn="00:00:03"
+ fadeOut="00:00:03" />
diff --git a/livesupport/modules/storage/src/WebStorageClientTest.cxx b/livesupport/modules/storage/src/WebStorageClientTest.cxx
index 50861e909..17c93ad1b 100644
--- a/livesupport/modules/storage/src/WebStorageClientTest.cxx
+++ b/livesupport/modules/storage/src/WebStorageClientTest.cxx
@@ -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::Ref audioClipId = wsc->getAudioClipIds()->at(2);
+ CPPUNIT_ASSERT(wsc->getAudioClipIds()->size() >= 4);
+ Ptr::Ref audioClipId = wsc->getAudioClipIds()->at(3);
Ptr::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::Ref audioClip0 = wsc->getAudioClipIds()->at(0);
Ptr::Ref audioClip1 = wsc->getAudioClipIds()->at(1);
Ptr::Ref audioClip2 = wsc->getAudioClipIds()->at(2);
Ptr::Ref audioClip3 = wsc->getAudioClipIds()->at(3);
Ptr::Ref audioClip4 = wsc->getAudioClipIds()->at(4);
+ Ptr::Ref audioClip5 = wsc->getAudioClipIds()->at(5);
CPPUNIT_ASSERT(wsc->getPlaylistIds()->size() >= 1);
Ptr::Ref playlist0 = wsc->getPlaylistIds()->at(0);
+ Ptr::Ref playlist1 = wsc->getPlaylistIds()->at(1);
Ptr::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::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) {
diff --git a/livesupport/modules/storageServer/var/tests/mdata10001.xml b/livesupport/modules/storageServer/var/tests/mdata10001.xml
index 2364cfae3..74cb6cc6d 100644
--- a/livesupport/modules/storageServer/var/tests/mdata10001.xml
+++ b/livesupport/modules/storageServer/var/tests/mdata10001.xml
@@ -8,6 +8,6 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
one
- 01:00:00.000000
+ 00:00:11.000000
diff --git a/livesupport/modules/storageServer/var/tests/mdata10002.xml b/livesupport/modules/storageServer/var/tests/mdata10002.xml
index 56b7941eb..94460807c 100644
--- a/livesupport/modules/storageServer/var/tests/mdata10002.xml
+++ b/livesupport/modules/storageServer/var/tests/mdata10002.xml
@@ -8,6 +8,6 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
two
- 00:30:00.000000
+ 00:00:12.200000
diff --git a/livesupport/modules/storageServer/var/tests/mdata10003.xml b/livesupport/modules/storageServer/var/tests/mdata10003.xml
new file mode 100644
index 000000000..1743ab0d2
--- /dev/null
+++ b/livesupport/modules/storageServer/var/tests/mdata10003.xml
@@ -0,0 +1,13 @@
+
+
+
+ three
+ 00:00:11.500000
+
+
diff --git a/livesupport/modules/storageServer/var/tests/plist2.xml b/livesupport/modules/storageServer/var/tests/plist2.xml
new file mode 100644
index 000000000..885c2f0a6
--- /dev/null
+++ b/livesupport/modules/storageServer/var/tests/plist2.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ My Second Playlist
+ Nobody
+ 00:00:29.700000
+
+
diff --git a/livesupport/modules/storageServer/var/tests/sampleData.php b/livesupport/modules/storageServer/var/tests/sampleData.php
index 9e1dbc5f9..75653fe09 100644
--- a/livesupport/modules/storageServer/var/tests/sampleData.php
+++ b/livesupport/modules/storageServer/var/tests/sampleData.php
@@ -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',
diff --git a/livesupport/modules/storageServer/var/tests/test10001.mp3 b/livesupport/modules/storageServer/var/tests/test10001.mp3
index f774c2164..5fe526402 100644
Binary files a/livesupport/modules/storageServer/var/tests/test10001.mp3 and b/livesupport/modules/storageServer/var/tests/test10001.mp3 differ
diff --git a/livesupport/modules/storageServer/var/tests/test10002.mp3 b/livesupport/modules/storageServer/var/tests/test10002.mp3
index f774c2164..1219a9056 100644
Binary files a/livesupport/modules/storageServer/var/tests/test10002.mp3 and b/livesupport/modules/storageServer/var/tests/test10002.mp3 differ
diff --git a/livesupport/modules/storageServer/var/tests/test10003.mp3 b/livesupport/modules/storageServer/var/tests/test10003.mp3
new file mode 100644
index 000000000..c0685a294
Binary files /dev/null and b/livesupport/modules/storageServer/var/tests/test10003.mp3 differ
diff --git a/livesupport/products/gLiveSupport/etc/Makefile.in b/livesupport/products/gLiveSupport/etc/Makefile.in
index 9e64c1648..33e54ee1c 100644
--- a/livesupport/products/gLiveSupport/etc/Makefile.in
+++ b/livesupport/products/gLiveSupport/etc/Makefile.in
@@ -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
diff --git a/livesupport/products/gLiveSupport/etc/audioPlayer.xml b/livesupport/products/gLiveSupport/etc/audioPlayer.xml
new file mode 100644
index 000000000..0d7c6505b
--- /dev/null
+++ b/livesupport/products/gLiveSupport/etc/audioPlayer.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+]>
+
+
+
diff --git a/livesupport/products/gLiveSupport/etc/authenticationClient.xml b/livesupport/products/gLiveSupport/etc/authenticationClient.xml
new file mode 100644
index 000000000..f13840213
--- /dev/null
+++ b/livesupport/products/gLiveSupport/etc/authenticationClient.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+]>
+
+
+
+
+
diff --git a/livesupport/products/gLiveSupport/etc/storageClient.xml b/livesupport/products/gLiveSupport/etc/storageClient.xml
new file mode 100644
index 000000000..93dda22df
--- /dev/null
+++ b/livesupport/products/gLiveSupport/etc/storageClient.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+]>
+
+
+
+
+
diff --git a/livesupport/products/gLiveSupport/src/AudioPlayerTest.cxx b/livesupport/products/gLiveSupport/src/AudioPlayerTest.cxx
new file mode 100644
index 000000000..463b18ebd
--- /dev/null
+++ b/livesupport/products/gLiveSupport/src/AudioPlayerTest.cxx
@@ -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
+#else
+#error "Need unistd.h"
+#endif
+
+
+#include
+#include
+
+#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::Ref parser(
+ new xmlpp::DomParser(audioPlayerConfigFileName, true));
+ const xmlpp::Document * document = parser->get_document();
+ const xmlpp::Element * root = document->get_root_node();
+
+ Ptr::Ref audioPlayerFactory;
+
+ audioPlayerFactory = AudioPlayerFactory::getInstance();
+ audioPlayerFactory->configure(*root);
+
+ // initialize the audio player configured by the factory
+ Ptr::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::Ref parser(
+ new xmlpp::DomParser(storageClientConfigFileName, true));
+ const xmlpp::Document * document = parser->get_document();
+ const xmlpp::Element * root = document->get_root_node();
+
+ Ptr::Ref storageClientFactory;
+
+ storageClientFactory = StorageClientFactory::getInstance();
+ storageClientFactory->configure(*root);
+
+ // initialize the storage client configured by the factory
+ Ptr::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::Ref parser(
+ new xmlpp::DomParser(authenticationClientConfigFileName, true));
+ const xmlpp::Document * document = parser->get_document();
+ const xmlpp::Element * root = document->get_root_node();
+
+ Ptr::Ref authentClientFactory;
+
+ authentClientFactory = AuthenticationClientFactory::getInstance();
+ authentClientFactory->configure(*root);
+
+ // log in using the authentication client
+ Ptr::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::Ref audioPlayerFactory;
+ audioPlayerFactory = AudioPlayerFactory::getInstance();
+ Ptr::Ref audioPlayer;
+ audioPlayer = audioPlayerFactory->getAudioPlayer();
+ audioPlayer->deInitialize();
+
+ // log out using the authentication client
+ Ptr::Ref authentClientFactory;
+ authentClientFactory = AuthenticationClientFactory::getInstance();
+ Ptr::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::Ref audioPlayerFactory;
+
+ audioPlayerFactory = AudioPlayerFactory::getInstance();
+ CPPUNIT_ASSERT(audioPlayerFactory.get());
+
+ Ptr::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::Ref
+ audioPlayerFactory = AudioPlayerFactory::getInstance();
+ Ptr::Ref
+ audioPlayer = audioPlayerFactory->getAudioPlayer();
+
+ Ptr::Ref
+ storageClientFactory = StorageClientFactory::getInstance();
+ Ptr::Ref
+ storage = storageClientFactory->getStorageClient();
+
+ Ptr::Ref audioClipId(new UniqueId(0x10001));
+ Ptr::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::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::Ref
+ audioPlayerFactory = AudioPlayerFactory::getInstance();
+ Ptr::Ref
+ audioPlayer = audioPlayerFactory->getAudioPlayer();
+
+ Ptr::Ref
+ storageClientFactory = StorageClientFactory::getInstance();
+ Ptr::Ref
+ storage = storageClientFactory->getStorageClient();
+
+ Ptr::Ref audioClipId(new UniqueId(2));
+ Ptr::Ref playlist;
+ CPPUNIT_ASSERT_NO_THROW(
+ playlist = storage->acquirePlaylist(sessionId, audioClipId)
+ );
+
+ CPPUNIT_ASSERT_NO_THROW(
+ audioPlayer->openAndStart(playlist)
+ );
+
+ CPPUNIT_ASSERT(audioPlayer->isPlaying());
+
+ Ptr::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();
+}
+
diff --git a/livesupport/products/gLiveSupport/src/AudioPlayerTest.h b/livesupport/products/gLiveSupport/src/AudioPlayerTest.h
new file mode 100644
index 000000000..d32cf936c
--- /dev/null
+++ b/livesupport/products/gLiveSupport/src/AudioPlayerTest.h
@@ -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
+
+#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::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
+
diff --git a/livesupport/products/gLiveSupport/src/TestRunner.cxx b/livesupport/products/gLiveSupport/src/TestRunner.cxx
new file mode 100644
index 000000000..feaa5f53b
--- /dev/null
+++ b/livesupport/products/gLiveSupport/src/TestRunner.cxx
@@ -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
+#else
+#error "Need unistd.h"
+#endif
+
+#if HAVE_GETOPT_H
+#include
+#else
+#error "Need getopt.h"
+#endif
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#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::Ref xmlOutFileName;
+
+/**
+ * The XSLT attached to the output file.
+ */
+static Ptr::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;
+}
+