fixed new playlist format (w/ playlistElement's and audioClipId's)
This commit is contained in:
parent
0663e46425
commit
690c3e7bc0
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -71,7 +71,7 @@ using namespace boost::posix_time;
|
|||
* the playlist.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class Playlist : public Configurable
|
||||
{
|
||||
|
@ -113,6 +113,17 @@ class Playlist : public Configurable
|
|||
*/
|
||||
Ptr<PlaylistElementListType>::Ref elementList;
|
||||
|
||||
/**
|
||||
* Add a new playlist element to the playlist.
|
||||
*
|
||||
* @param playlistElement the new playlist element to be added
|
||||
* @exception std::invalid_argument if the playlist already contains
|
||||
* a playlist element with the same relative offset
|
||||
*/
|
||||
void
|
||||
addPlaylistElement(Ptr<PlaylistElement>::Ref playlistElement)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -195,10 +206,32 @@ class Playlist : public Configurable
|
|||
return playlength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the playlist is locked for editing.
|
||||
*
|
||||
* @return true if playlist is locked, false if not
|
||||
*/
|
||||
bool
|
||||
getIsLockedForEditing() throw ()
|
||||
{
|
||||
return isLockedForEditing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the playlist is locked for playing.
|
||||
*
|
||||
* @return true if playlist is locked, false if not
|
||||
*/
|
||||
bool
|
||||
getIsLockedForPlaying() throw ()
|
||||
{
|
||||
return isLockedForPlaying;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock or unlock the playlist for editing.
|
||||
*
|
||||
* @return true if successfully obtained or releasedlock;
|
||||
* @return true if successfully obtained or released lock;
|
||||
* false otherwise.
|
||||
*/
|
||||
bool
|
||||
|
@ -208,25 +241,13 @@ class Playlist : public Configurable
|
|||
/**
|
||||
* Lock or unlock the playlist for playing.
|
||||
*
|
||||
* @return true if successfully obtained or releasedlock;
|
||||
* @return true if successfully obtained or released lock;
|
||||
* false otherwise.
|
||||
*/
|
||||
bool
|
||||
setLockedForPlaying(bool lockStatus)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Add a new playlist element to the playlist.
|
||||
*
|
||||
* @param playlistElement the new playlist element to be added
|
||||
* @exception std::invalid_argument if the playlist already contains
|
||||
* a playlist element with the same relative offset as the
|
||||
* new playlist element
|
||||
*/
|
||||
void
|
||||
addPlaylistElement(Ptr<PlaylistElement>::Ref playlistElement)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* The iterator type for this class.
|
||||
*
|
||||
|
@ -252,6 +273,20 @@ class Playlist : public Configurable
|
|||
{
|
||||
return elementList->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new audio clip to the playlist.
|
||||
*
|
||||
* @param relativeOffset the start of the audio clip, relative
|
||||
* to the start of the playlist
|
||||
* @param audioClip the new audio clip to be added
|
||||
* @exception std::invalid_argument if the playlist already contains
|
||||
* an audio clip with the same relative offset
|
||||
*/
|
||||
void
|
||||
addAudioClip(Ptr<UniqueId>::Ref audioClipId,
|
||||
Ptr<time_duration>::Ref relativeOffset)
|
||||
throw (std::invalid_argument);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,7 +72,7 @@ using namespace LiveSupport::Core;
|
|||
* An item in a playlist.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class PlaylistElement : public Configurable
|
||||
{
|
||||
|
@ -127,6 +127,24 @@ class PlaylistElement : public Configurable
|
|||
this->audioClipId = audioClipId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new playlist element, with a new UniqueId,
|
||||
* to be added to a playlist.
|
||||
*
|
||||
* @param audioClipId the ID of the audio clip associated
|
||||
* with the playlist element.
|
||||
* @param relativeOffset the start time of this element, relative to
|
||||
* the start of the playlist.
|
||||
*/
|
||||
PlaylistElement(Ptr<time_duration>::Ref relativeOffset,
|
||||
Ptr<UniqueId>::Ref audioClipId)
|
||||
throw ()
|
||||
{
|
||||
this->id = UniqueId::generateId();
|
||||
this->relativeOffset = relativeOffset;
|
||||
this->audioClipId = audioClipId;
|
||||
}
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Attic/StorageClientInterface.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -61,7 +61,7 @@ namespace Core {
|
|||
* An interface for storage clients.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class StorageClientInterface
|
||||
{
|
||||
|
@ -120,6 +120,17 @@ class StorageClientInterface
|
|||
virtual Ptr<Playlist>::Ref
|
||||
createPlaylist() throw () = 0;
|
||||
|
||||
/**
|
||||
* Tell if an audio clip with a given id exists.
|
||||
*
|
||||
* @param id the id of the audio clip to check for.
|
||||
* @return true if an audio clip with the specified id exists,
|
||||
* false otherwise.
|
||||
*/
|
||||
virtual const bool
|
||||
existsAudioClip(Ptr<const UniqueId>::Ref id) const throw ()
|
||||
= 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -145,6 +145,26 @@ Playlist::addPlaylistElement(Ptr<PlaylistElement>::Ref playlistElement)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Add a new audio clip to the playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist::addAudioClip(Ptr<UniqueId>::Ref audioClipId,
|
||||
Ptr<time_duration>::Ref relativeOffset)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (elementList->find(*relativeOffset) != elementList->end()) {
|
||||
std::string eMsg = "Two playlist elements at the same relative offset";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
Ptr<PlaylistElement>::Ref playlistElement(new PlaylistElement(
|
||||
relativeOffset, audioClipId));
|
||||
|
||||
(*elementList)[*relativeOffset] = playlistElement;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Lock or unlock the playlist for editing.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -50,6 +50,7 @@
|
|||
using namespace std;
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
|
@ -74,6 +75,26 @@ static const std::string configFileName = "etc/playlist.xml";
|
|||
void
|
||||
PlaylistTest :: setUp(void) throw ()
|
||||
{
|
||||
playlist.reset(new Playlist);
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
|
||||
playlist->configure(*root);
|
||||
|
||||
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
|
||||
Ptr<const boost::posix_time::time_duration>::Ref duration
|
||||
= playlist->getPlaylength();
|
||||
CPPUNIT_ASSERT(duration->hours() == 1);
|
||||
CPPUNIT_ASSERT(duration->minutes() == 30);
|
||||
CPPUNIT_ASSERT(duration->seconds() == 0);
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,28 +114,25 @@ void
|
|||
PlaylistTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document = parser->get_document();
|
||||
const xmlpp::Element * root = document->get_root_node();
|
||||
Ptr<Playlist>::Ref playlist(new Playlist());
|
||||
Playlist::const_iterator it = playlist->begin();
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
Ptr<PlaylistElement>::Ref playlistElement = it->second;
|
||||
CPPUNIT_ASSERT(playlistElement->getId()->getId() == 101);
|
||||
Ptr<const time_duration>::Ref relativeOffset
|
||||
= playlistElement->getRelativeOffset();
|
||||
CPPUNIT_ASSERT(relativeOffset->total_seconds() == 0);
|
||||
CPPUNIT_ASSERT(playlistElement->getAudioClipId()->getId() == 10001);
|
||||
|
||||
// cout << "\nconfig elott\n";
|
||||
playlist->configure(*root);
|
||||
// cout << "config utan\n";
|
||||
|
||||
CPPUNIT_ASSERT(playlist->getId()->getId() == 1);
|
||||
Ptr<const boost::posix_time::time_duration>::Ref duration
|
||||
= playlist->getPlaylength();
|
||||
CPPUNIT_ASSERT(duration->hours() == 1);
|
||||
CPPUNIT_ASSERT(duration->minutes() == 30);
|
||||
CPPUNIT_ASSERT(duration->seconds() == 0);
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
CPPUNIT_FAIL("error parsing configuration file");
|
||||
}
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
playlistElement = it->second;
|
||||
CPPUNIT_ASSERT(playlistElement->getId()->getId() == 102);
|
||||
relativeOffset = playlistElement->getRelativeOffset();
|
||||
CPPUNIT_ASSERT(relativeOffset->total_seconds() == 60 * 60);
|
||||
CPPUNIT_ASSERT(playlistElement->getAudioClipId()->getId() == 10002);
|
||||
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it == playlist->end());
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,8 +143,6 @@ void
|
|||
PlaylistTest :: lockTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<Playlist>::Ref playlist(new Playlist());
|
||||
|
||||
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
|
||||
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
|
||||
CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
|
||||
|
@ -141,3 +157,41 @@ PlaylistTest :: lockTest(void)
|
|||
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
|
||||
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if we can add a new audio clip
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlaylistTest :: addAudioClipTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<UniqueId>::Ref audioClipId(new UniqueId(20001));
|
||||
Ptr<time_duration>::Ref relativeOffset(new time_duration(0,10,0,0));
|
||||
// hour, min, sec, frac_sec
|
||||
try {
|
||||
playlist->addAudioClip(audioClipId, relativeOffset);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
string eMsg = "addAudioClip returned with error: ";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
|
||||
Playlist::const_iterator it = playlist->begin();
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
|
||||
++it;
|
||||
Ptr<PlaylistElement>::Ref playlistElement = it->second;
|
||||
CPPUNIT_ASSERT(playlistElement->getAudioClipId()->getId() == 20001);
|
||||
|
||||
Ptr<const time_duration>::Ref otherRelativeOffset
|
||||
= playlistElement->getRelativeOffset();
|
||||
CPPUNIT_ASSERT(otherRelativeOffset->total_seconds() == 10*60);
|
||||
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it != playlist->end());
|
||||
|
||||
++it;
|
||||
CPPUNIT_ASSERT(it == playlist->end());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,7 +58,7 @@ namespace Core {
|
|||
* Unit test for the UploadPlaylistMetohd class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
* @see Playlist
|
||||
*/
|
||||
class PlaylistTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -66,8 +66,16 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST_SUITE(PlaylistTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(lockTest);
|
||||
CPPUNIT_TEST(addAudioClipTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* A playlist to play with.
|
||||
*/
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -86,6 +94,14 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
lockTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Trying to add a new audio clip.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
addAudioClipTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -5,12 +5,27 @@
|
|||
|
||||
<!ELEMENT testStorage (playlist*) >
|
||||
|
||||
<!ELEMENT playlist EMPTY >
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement (audioClip) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
]>
|
||||
<storageClientFactory>
|
||||
<testStorage>
|
||||
<playlist id="1" playlength="01:30:00.00"/>
|
||||
<playlist id="1" playlength="01:30:00.000">
|
||||
<playlistElement id="101" relativeOffset="0" >
|
||||
<audioClip id="10001" playlength="01:00:00.000"/>
|
||||
</playlistElement>
|
||||
<playlistElement id="102" relativeOffset="01:00:00.000" >
|
||||
<audioClip id="10002" playlength="00:30:00.000"/>
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
</testStorage>
|
||||
</storageClientFactory>
|
||||
|
|
|
@ -3,10 +3,25 @@
|
|||
|
||||
<!ELEMENT testStorage (playlist*) >
|
||||
|
||||
<!ELEMENT playlist EMPTY >
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement (audioClip) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
]>
|
||||
<testStorage>
|
||||
<playlist id="1" playlength="01:30:00.00"/>
|
||||
<playlist id="1" playlength="01:30:00.000">
|
||||
<playlistElement id="101" relativeOffset="0" >
|
||||
<audioClip id="10001" playlength="01:00:00.000"/>
|
||||
</playlistElement>
|
||||
<playlistElement id="102" relativeOffset="01:00:00.000" >
|
||||
<audioClip id="10002" playlength="00:30:00.000"/>
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
</testStorage>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -67,7 +67,7 @@ using namespace LiveSupport::Core;
|
|||
* A dummy storage client, only used for test purposes.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class TestStorageClient :
|
||||
virtual public Configurable,
|
||||
|
@ -167,7 +167,7 @@ class TestStorageClient :
|
|||
* @return a vector containing the playlists.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref
|
||||
getAllPlaylists(void) const throw ();
|
||||
getAllPlaylists(void) const throw ();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -178,6 +178,21 @@ class TestStorageClient :
|
|||
virtual Ptr<Playlist>::Ref
|
||||
createPlaylist() throw ();
|
||||
|
||||
/**
|
||||
* Tell if an audio clip with a given id exists.
|
||||
*
|
||||
* @param id the id of the audio clip to check for.
|
||||
* @return true if an audio clip with the specified id exists,
|
||||
* false otherwise.
|
||||
* Note: at this point, this function always returns 'true'.
|
||||
*/
|
||||
virtual const bool
|
||||
existsAudioClip(Ptr<const UniqueId>::Ref id) const
|
||||
throw ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.12 $
|
||||
# Version : $Revision: 1.13 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -122,7 +122,8 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
|
|||
${TMP_DIR}/DeletePlaylistMethod.o \
|
||||
${TMP_DIR}/DisplayPlaylistsMethod.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethod.o \
|
||||
${TMP_DIR}/CreatePlaylistMethod.o
|
||||
${TMP_DIR}/CreatePlaylistMethod.o \
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethod.o
|
||||
|
||||
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
|
@ -148,6 +149,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
|
|||
${TMP_DIR}/DisplayPlaylistsMethodTest.o \
|
||||
${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \
|
||||
${TMP_DIR}/CreatePlaylistMethodTest.o \
|
||||
${TMP_DIR}/AddAudioClipToPlaylistMethodTest.o \
|
||||
${TMP_DIR}/TestRunner.o
|
||||
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl
|
||||
|
||||
|
|
|
@ -1,8 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE playlist [
|
||||
|
||||
<!ELEMENT playlist EMPTY >
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement (audioClip) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
]>
|
||||
<playlist id="1" playlength="01:30:00.000"/>
|
||||
|
||||
<playlist id="1" playlength="01:30:00.000">
|
||||
<playlistElement id="101" relativeOffset="0" >
|
||||
<audioClip id="10001" playlength="01:00:00.000"/>
|
||||
</playlistElement>
|
||||
<playlistElement id="102" relativeOffset="01:00:00.000" >
|
||||
<audioClip id="10002" playlength="00:30:00.000"/>
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
|
|
|
@ -5,12 +5,27 @@
|
|||
|
||||
<!ELEMENT testStorage (playlist*) >
|
||||
|
||||
<!ELEMENT playlist EMPTY >
|
||||
<!ELEMENT playlist (playlistElement*) >
|
||||
<!ATTLIST playlist id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlist playlength NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT playlistElement (audioClip) >
|
||||
<!ATTLIST playlistElement id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST playlistElement relativeOffset NMTOKEN #REQUIRED >
|
||||
|
||||
<!ELEMENT audioClip EMPTY >
|
||||
<!ATTLIST audioClip id NMTOKEN #REQUIRED >
|
||||
<!ATTLIST audioClip playlength NMTOKEN #REQUIRED >
|
||||
]>
|
||||
<storageClientFactory>
|
||||
<testStorage>
|
||||
<playlist id="1" playlength="01:00:00.000"/>
|
||||
<playlist id="1" playlength="01:30:00.000">
|
||||
<playlistElement id="101" relativeOffset="0" >
|
||||
<audioClip id="10001" playlength="01:00:00.000"/>
|
||||
</playlistElement>
|
||||
<playlistElement id="102" relativeOffset="01:00:00.000" >
|
||||
<audioClip id="10002" playlength="00:30:00.000"/>
|
||||
</playlistElement>
|
||||
</playlist>
|
||||
</testStorage>
|
||||
</storageClientFactory>
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -149,7 +149,7 @@ DisplayPlaylistMethodTest :: firstTest(void)
|
|||
|
||||
method->execute(rootParameter, result);
|
||||
CPPUNIT_ASSERT(((int) result["id"]) == 1);
|
||||
CPPUNIT_ASSERT(((int) result["playlength"]) == (60 * 60));
|
||||
CPPUNIT_ASSERT(((int) result["playlength"]) == (90 * 60));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -149,5 +149,5 @@ DisplayPlaylistsMethodTest :: firstTest(void)
|
|||
|
||||
playlist = result[0];
|
||||
CPPUNIT_ASSERT(((int) playlist["id"]) == 1);
|
||||
CPPUNIT_ASSERT(((int) playlist["playlength"]) == (60 * 60));
|
||||
CPPUNIT_ASSERT(((int) playlist["playlength"]) == (90 * 60));
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -280,7 +280,7 @@ DisplayScheduleMethodTest :: intervalTest(void)
|
|||
CPPUNIT_ASSERT(time.tm_mon == 7);
|
||||
CPPUNIT_ASSERT(time.tm_mday == 31);
|
||||
CPPUNIT_ASSERT(time.tm_hour == 11);
|
||||
CPPUNIT_ASSERT(time.tm_min == 0);
|
||||
CPPUNIT_ASSERT(time.tm_min == 30);
|
||||
CPPUNIT_ASSERT(time.tm_sec == 0);
|
||||
|
||||
// check for the interval 2004-07-31 between 9 and 13 o'clock
|
||||
|
@ -317,7 +317,7 @@ DisplayScheduleMethodTest :: intervalTest(void)
|
|||
CPPUNIT_ASSERT(time.tm_mon == 7);
|
||||
CPPUNIT_ASSERT(time.tm_mday == 31);
|
||||
CPPUNIT_ASSERT(time.tm_hour == 11);
|
||||
CPPUNIT_ASSERT(time.tm_min == 0);
|
||||
CPPUNIT_ASSERT(time.tm_min == 30);
|
||||
CPPUNIT_ASSERT(time.tm_sec == 0);
|
||||
|
||||
CPPUNIT_ASSERT((int)(result[1]["playlistId"]) == 1);
|
||||
|
@ -333,7 +333,7 @@ DisplayScheduleMethodTest :: intervalTest(void)
|
|||
CPPUNIT_ASSERT(time.tm_mon == 7);
|
||||
CPPUNIT_ASSERT(time.tm_mday == 31);
|
||||
CPPUNIT_ASSERT(time.tm_hour == 13);
|
||||
CPPUNIT_ASSERT(time.tm_min == 0);
|
||||
CPPUNIT_ASSERT(time.tm_min == 30);
|
||||
CPPUNIT_ASSERT(time.tm_sec == 0);
|
||||
|
||||
// check for the interval 2004-07-31 between 8 and 9 o'clock
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -68,7 +68,8 @@ using namespace LiveSupport::Scheduler;
|
|||
/*------------------------------------------------------------------------------
|
||||
* The name of this XML-RPC method.
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string OpenPlaylistForEditingMethod::methodName = "openPlaylistForEditing";
|
||||
const std::string OpenPlaylistForEditingMethod::methodName
|
||||
= "openPlaylistForEditing";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The ID of this method for error reporting purposes.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -149,7 +149,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
|
|||
|
||||
method->execute(parameter, result);
|
||||
CPPUNIT_ASSERT((int) result["id"] == 1);
|
||||
CPPUNIT_ASSERT((int) result["playlength"] == (60 * 60));
|
||||
CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60));
|
||||
|
||||
parameter.clear();
|
||||
result.clear();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -56,11 +56,20 @@ using namespace LiveSupport::Scheduler;
|
|||
/* =================================================== local data structures */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the playlistId member in the XML-RPC parameter
|
||||
* structure.
|
||||
* The name of the playlist ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string XmlRpcTools::playlistIdName = "playlistId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the audio clip ID member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string XmlRpcTools::audioClipIdName = "audioClipId";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the relative offset member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string XmlRpcTools::relativeOffsetName = "relativeOffset";
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
@ -71,7 +80,7 @@ const std::string XmlRpcTools::playlistIdName = "playlistId";
|
|||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the UniqueId from an XML-RPC function call parameter
|
||||
* Extract the playlist ID from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<UniqueId>::Ref
|
||||
XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
|
@ -86,6 +95,40 @@ XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the audio clip ID from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<UniqueId>::Ref
|
||||
XmlRpcTools :: extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(audioClipIdName)) {
|
||||
throw std::invalid_argument("no audio clip id in parameter structure");
|
||||
}
|
||||
|
||||
Ptr<UniqueId>::Ref id(new UniqueId((int) xmlRpcValue[audioClipIdName]));
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the relative offset from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<time_duration>::Ref
|
||||
XmlRpcTools :: extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(relativeOffsetName)) {
|
||||
throw std::invalid_argument("no relative offset "
|
||||
"in parameter structure");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref relativeOffset(new time_duration(0,0,
|
||||
(int) xmlRpcValue[relativeOffsetName], 0));
|
||||
return relativeOffset;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a Playlist to an XmlRpcValue
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -68,7 +68,7 @@ using namespace LiveSupport::Core;
|
|||
* in the Scheduler.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class XmlRpcTools
|
||||
{
|
||||
|
@ -79,18 +79,54 @@ class XmlRpcTools
|
|||
*/
|
||||
static const std::string playlistIdName;
|
||||
|
||||
/**
|
||||
* The name of the playlistId member in the XML-RPC parameter
|
||||
* structure given as the input to an XmlRpcServerMethod.
|
||||
*/
|
||||
static const std::string audioClipIdName;
|
||||
|
||||
/**
|
||||
* The name of the playlistId member in the XML-RPC parameter
|
||||
* structure given as the input to an XmlRpcServerMethod.
|
||||
*/
|
||||
static const std::string relativeOffsetName;
|
||||
|
||||
/**
|
||||
* Extract the playlist id from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a UniqueId that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no UniqueId
|
||||
* in xmlRpcValue
|
||||
* @exception std::invalid_argument if there was no playlistId
|
||||
* member in xmlRpcValue
|
||||
*/
|
||||
static Ptr<UniqueId>::Ref
|
||||
extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Extract the audio clip id from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a UniqueId that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no audioClipId
|
||||
* member in xmlRpcValue
|
||||
*/
|
||||
static Ptr<UniqueId>::Ref
|
||||
extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Extract the relative offset from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a time_duration that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no relativeOffset
|
||||
* member in xmlRpcValue
|
||||
*/
|
||||
static Ptr<time_duration>::Ref
|
||||
extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a Playlist to an XmlRpcValue
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcToolsTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -136,26 +136,38 @@ XmlRpcToolsTest :: firstTest(void)
|
|||
CPPUNIT_ASSERT(((int) xmlRpcPlaylist["id"]) == 1);
|
||||
CPPUNIT_ASSERT(((int) xmlRpcPlaylist["playlength"]) == (90 * 60));
|
||||
|
||||
XmlRpcValue xmlRpcPlaylistId;
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
int randomNumber = rand();
|
||||
XmlRpcValue xmlRpcPlaylistId;
|
||||
Ptr<UniqueId>::Ref playlistId;
|
||||
Ptr<UniqueId>::Ref audioClipId;
|
||||
Ptr<time_duration>::Ref relativeOffset;
|
||||
|
||||
xmlRpcPlaylistId["playlistId"] = randomNumber;
|
||||
int playlistIdNum = rand();
|
||||
int audioClipIdNum = rand();
|
||||
int relativeOffsetNum = rand();
|
||||
|
||||
// run the unpacking method
|
||||
xmlRpcPlaylistId["playlistId"] = playlistIdNum;
|
||||
xmlRpcPlaylistId["audioClipId"] = audioClipIdNum;
|
||||
xmlRpcPlaylistId["relativeOffset"] = relativeOffsetNum;
|
||||
|
||||
// run the unpacking methods
|
||||
try {
|
||||
playlistId = XmlRpcTools :: extractPlaylistId(xmlRpcPlaylistId);
|
||||
playlistId = XmlRpcTools::extractPlaylistId(xmlRpcPlaylistId);
|
||||
audioClipId = XmlRpcTools::extractAudioClipId(xmlRpcPlaylistId);
|
||||
relativeOffset = XmlRpcTools::extractRelativeOffset(xmlRpcPlaylistId);
|
||||
}
|
||||
catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT((int)(playlistId->getId()) == randomNumber);
|
||||
CPPUNIT_ASSERT((int)(playlistId->getId()) == playlistIdNum);
|
||||
CPPUNIT_ASSERT((int)(audioClipId->getId()) == audioClipIdNum);
|
||||
CPPUNIT_ASSERT((int)(relativeOffset->total_seconds())
|
||||
== relativeOffsetNum);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Testint markError()
|
||||
* Testing markError()
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcToolsTest :: errorTest(void)
|
||||
|
|
Loading…
Reference in New Issue