minor edit: openned -> opened; fixed a comment; brought the tests up to date with the recent API changes

This commit is contained in:
fgerlits 2006-11-01 10:36:46 +00:00
parent 5ad021fde3
commit 90fd4b1ca8
4 changed files with 75 additions and 51 deletions

View file

@ -730,10 +730,10 @@ GLiveSupport :: getAudioClip(Ptr<const UniqueId>::Ref id)
{ {
Ptr<AudioClip>::Ref clip; Ptr<AudioClip>::Ref clip;
clip = (*opennedAudioClips)[id->getId()]; clip = (*openedAudioClips)[id->getId()];
if (!clip.get()) { if (!clip.get()) {
clip = storage->getAudioClip(sessionId, id); clip = storage->getAudioClip(sessionId, id);
(*opennedAudioClips)[id->getId()] = clip; (*openedAudioClips)[id->getId()] = clip;
} }
return clip; return clip;
@ -751,10 +751,10 @@ GLiveSupport :: acquireAudioClip(Ptr<const UniqueId>::Ref id)
{ {
Ptr<AudioClip>::Ref clip; Ptr<AudioClip>::Ref clip;
clip = (*opennedAudioClips)[id->getId()]; clip = (*openedAudioClips)[id->getId()];
if (!clip.get() || !clip->getToken().get()) { if (!clip.get() || !clip->getToken().get()) {
clip = storage->acquireAudioClip(sessionId, id); clip = storage->acquireAudioClip(sessionId, id);
(*opennedAudioClips)[id->getId()] = clip; (*openedAudioClips)[id->getId()] = clip;
} }
return clip; return clip;
@ -772,10 +772,10 @@ GLiveSupport :: getPlaylist(Ptr<const UniqueId>::Ref id)
{ {
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
playlist = (*opennedPlaylists)[id->getId()]; playlist = (*openedPlaylists)[id->getId()];
if (!playlist.get()) { if (!playlist.get()) {
playlist = storage->getPlaylist(sessionId, id); playlist = storage->getPlaylist(sessionId, id);
(*opennedPlaylists)[id->getId()] = playlist; (*openedPlaylists)[id->getId()] = playlist;
} }
return playlist; return playlist;
@ -793,10 +793,10 @@ GLiveSupport :: acquirePlaylist(Ptr<const UniqueId>::Ref id)
{ {
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
playlist = (*opennedPlaylists)[id->getId()]; playlist = (*openedPlaylists)[id->getId()];
if (!playlist.get() || !playlist->getUri().get()) { if (!playlist.get() || !playlist->getUri().get()) {
playlist = storage->acquirePlaylist(sessionId, id); playlist = storage->acquirePlaylist(sessionId, id);
(*opennedPlaylists)[id->getId()] = playlist; (*openedPlaylists)[id->getId()] = playlist;
} }
return playlist; return playlist;
@ -854,7 +854,7 @@ GLiveSupport :: acquirePlayable(Ptr<const UniqueId>::Ref id)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Release all openned audio clips. * Remove a playlist from the playlist cache.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
@ -863,28 +863,28 @@ GLiveSupport :: uncachePlaylist(Ptr<const UniqueId>::Ref id)
{ {
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
PlaylistMap::iterator it; PlaylistMap::iterator it;
PlaylistMap::iterator end = opennedPlaylists->end(); PlaylistMap::iterator end = openedPlaylists->end();
if ((it = opennedPlaylists->find(id->getId())) != end) { if ((it = openedPlaylists->find(id->getId())) != end) {
playlist = (*opennedPlaylists)[id->getId()]; playlist = (*openedPlaylists)[id->getId()];
if (playlist->getUri().get()) { if (playlist->getUri().get()) {
storage->releasePlaylist(playlist); storage->releasePlaylist(playlist);
} }
opennedPlaylists->erase(it); openedPlaylists->erase(it);
} }
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Release all openned audio clips. * Release all opened audio clips.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: releaseOpennedAudioClips(void) throw (XmlRpcException) GLiveSupport :: releaseOpenedAudioClips(void) throw (XmlRpcException)
{ {
AudioClipMap::iterator it = opennedAudioClips->begin(); AudioClipMap::iterator it = openedAudioClips->begin();
AudioClipMap::iterator end = opennedAudioClips->end(); AudioClipMap::iterator end = openedAudioClips->end();
while (it != end) { while (it != end) {
Ptr<AudioClip>::Ref clip = (*it).second; Ptr<AudioClip>::Ref clip = (*it).second;
@ -896,19 +896,19 @@ GLiveSupport :: releaseOpennedAudioClips(void) throw (XmlRpcException)
++it; ++it;
} }
opennedAudioClips->clear(); openedAudioClips->clear();
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Release all openned playlists. * Release all opened playlists.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: releaseOpennedPlaylists(void) throw (XmlRpcException) GLiveSupport :: releaseOpenedPlaylists(void) throw (XmlRpcException)
{ {
PlaylistMap::iterator it = opennedPlaylists->begin(); PlaylistMap::iterator it = openedPlaylists->begin();
PlaylistMap::iterator end = opennedPlaylists->end(); PlaylistMap::iterator end = openedPlaylists->end();
while (it != end) { while (it != end) {
Ptr<Playlist>::Ref playlist = (*it).second; Ptr<Playlist>::Ref playlist = (*it).second;
@ -920,7 +920,7 @@ GLiveSupport :: releaseOpennedPlaylists(void) throw (XmlRpcException)
++it; ++it;
} }
opennedPlaylists->clear(); openedPlaylists->clear();
} }

View file

@ -203,15 +203,15 @@ class GLiveSupport : public LocalizedConfigurable,
/** /**
* A map, holding references to all AudioClip objects that are * A map, holding references to all AudioClip objects that are
* openned. * opened.
*/ */
Ptr<AudioClipMap>::Ref opennedAudioClips; Ptr<AudioClipMap>::Ref openedAudioClips;
/** /**
* A map, holding references to all Playlist objects that are * A map, holding references to all Playlist objects that are
* openned. * opened.
*/ */
Ptr<PlaylistMap>::Ref opennedPlaylists; Ptr<PlaylistMap>::Ref openedPlaylists;
/** /**
* The one and only playlist that may be edited at any one time. * The one and only playlist that may be edited at any one time.
@ -360,8 +360,8 @@ class GLiveSupport : public LocalizedConfigurable,
: outputPlayerIsPaused(false), : outputPlayerIsPaused(false),
cuePlayerIsPaused(false) cuePlayerIsPaused(false)
{ {
opennedAudioClips.reset(new AudioClipMap()); openedAudioClips.reset(new AudioClipMap());
opennedPlaylists.reset(new PlaylistMap()); openedPlaylists.reset(new PlaylistMap());
} }
/** /**
@ -377,11 +377,11 @@ class GLiveSupport : public LocalizedConfigurable,
cuePlayer->deInitialize(); cuePlayer->deInitialize();
} }
try { try {
releaseOpennedAudioClips(); releaseOpenedAudioClips();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
} }
try { try {
releaseOpennedPlaylists(); releaseOpenedPlaylists();
} catch(XmlRpcException &e) { } catch(XmlRpcException &e) {
} }
} }
@ -602,7 +602,7 @@ class GLiveSupport : public LocalizedConfigurable,
* GLiveSupport object. * GLiveSupport object.
* *
* @param id the audio clip id. * @param id the audio clip id.
* @return the audio clip openned. * @return the audio clip opened.
* @exception XmlRpcException if no audio clip with the specified * @exception XmlRpcException if no audio clip with the specified
* id exists, or there was a communication problem. * id exists, or there was a communication problem.
*/ */
@ -647,7 +647,7 @@ class GLiveSupport : public LocalizedConfigurable,
* GLiveSupport object. * GLiveSupport object.
* *
* @param id the playlist id. * @param id the playlist id.
* @return the playlist openned. * @return the playlist opened.
* @exception XmlRpcException if no playlist with the specified * @exception XmlRpcException if no playlist with the specified
* id exists, or there was a communication problem. * id exists, or there was a communication problem.
*/ */
@ -718,16 +718,16 @@ class GLiveSupport : public LocalizedConfigurable,
throw (XmlRpcException); throw (XmlRpcException);
/** /**
* Release all openned audio clips. * Release all opened audio clips.
*/ */
void void
releaseOpennedAudioClips(void) throw (XmlRpcException); releaseOpenedAudioClips(void) throw (XmlRpcException);
/** /**
* Release all openned playlists. * Release all opened playlists.
*/ */
void void
releaseOpennedPlaylists(void) throw (XmlRpcException); releaseOpenedPlaylists(void) throw (XmlRpcException);
/** /**
* Add a file to the Live Mode, and update it. * Add a file to the Live Mode, and update it.

View file

@ -153,6 +153,11 @@ GLiveSupportTest :: setUp(void) throw (CPPUNIT_NS::Exception)
if (!gLiveSupport->login(login, password)) { if (!gLiveSupport->login(login, password)) {
std::cerr << "gLiveSupport unable to log in" << std::endl; std::cerr << "gLiveSupport unable to log in" << std::endl;
} }
CPPUNIT_ASSERT_NO_THROW(
storage = gLiveSupport->getStorageClient();
);
CPPUNIT_ASSERT(storage);
} }
@ -192,8 +197,8 @@ GLiveSupportTest :: openAudioClipTest(void)
Ptr<UniqueId>::Ref id; Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref clip; Ptr<Playable>::Ref clip;
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 7); CPPUNIT_ASSERT(sampleData()->size() >= 7);
id = gLiveSupport->getSearchResults()->at(6)->getId(); id = sampleData()->at(6)->getId();
try { try {
clip = gLiveSupport->getAudioClip(id); clip = gLiveSupport->getAudioClip(id);
@ -205,7 +210,7 @@ GLiveSupportTest :: openAudioClipTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
gLiveSupport->releaseOpennedAudioClips(); gLiveSupport->releaseOpenedAudioClips();
try { try {
clip = gLiveSupport->getAudioClip(id); clip = gLiveSupport->getAudioClip(id);
@ -226,8 +231,8 @@ GLiveSupportTest :: acquireAudioClipTest(void)
Ptr<UniqueId>::Ref id; Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref clip; Ptr<Playable>::Ref clip;
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 7); CPPUNIT_ASSERT(sampleData()->size() >= 7);
id = gLiveSupport->getSearchResults()->at(6)->getId(); id = sampleData()->at(6)->getId();
try { try {
clip = gLiveSupport->acquireAudioClip(id); clip = gLiveSupport->acquireAudioClip(id);
@ -241,7 +246,7 @@ GLiveSupportTest :: acquireAudioClipTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
gLiveSupport->releaseOpennedAudioClips(); gLiveSupport->releaseOpenedAudioClips();
try { try {
clip = gLiveSupport->acquireAudioClip(id); clip = gLiveSupport->acquireAudioClip(id);
@ -263,8 +268,8 @@ GLiveSupportTest :: openPlaylistTest(void)
Ptr<UniqueId>::Ref id; Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref playlist; Ptr<Playable>::Ref playlist;
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 2); CPPUNIT_ASSERT(sampleData()->size() >= 2);
id = gLiveSupport->getSearchResults()->at(1)->getId(); id = sampleData()->at(1)->getId();
try { try {
playlist = gLiveSupport->getPlaylist(id); playlist = gLiveSupport->getPlaylist(id);
@ -276,7 +281,7 @@ GLiveSupportTest :: openPlaylistTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
gLiveSupport->releaseOpennedPlaylists(); gLiveSupport->releaseOpenedPlaylists();
try { try {
playlist = gLiveSupport->getPlaylist(id); playlist = gLiveSupport->getPlaylist(id);
@ -297,8 +302,8 @@ GLiveSupportTest :: acquirePlaylistTest(void)
Ptr<UniqueId>::Ref id; Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref playlist; Ptr<Playable>::Ref playlist;
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 2); CPPUNIT_ASSERT(sampleData()->size() >= 2);
id = gLiveSupport->getSearchResults()->at(1)->getId(); id = sampleData()->at(1)->getId();
try { try {
playlist = gLiveSupport->acquirePlaylist(id); playlist = gLiveSupport->acquirePlaylist(id);
@ -312,7 +317,7 @@ GLiveSupportTest :: acquirePlaylistTest(void)
CPPUNIT_FAIL(e.what()); CPPUNIT_FAIL(e.what());
} }
gLiveSupport->releaseOpennedPlaylists(); gLiveSupport->releaseOpenedPlaylists();
try { try {
playlist = gLiveSupport->acquirePlaylist(id); playlist = gLiveSupport->acquirePlaylist(id);

View file

@ -82,9 +82,28 @@ class GLiveSupportTest : public BaseTestMethod
private: private:
/** /**
* The GLiveSupport object we're testing * The GLiveSupport object we're testing.
*/ */
Ptr<GLiveSupport>::Ref gLiveSupport; Ptr<GLiveSupport>::Ref gLiveSupport;
/**
* The storage object we get from gLiveSupport.
*/
Ptr<StorageClientInterface>::Ref storage;
/**
* Get the list of test Playable objects.
* This gets the result of the latest "local search", which in
* this case is reset(), which loads the sample data into the
* local storage.
*
* @return a list of Playable items loaded by reset().
*/
Ptr<StorageClientInterface::SearchResultsType>::Ref
sampleData(void) throw ()
{
return storage->getLocalSearchResults();
}
protected: protected: