/*------------------------------------------------------------------------------ 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.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClipTest.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/AudioClip.h" #include "LiveSupport/Core/Playlist.h" #include "AudioClipTest.h" using namespace std; using namespace LiveSupport::Core; /* =================================================== local data structures */ /* ================================================ local constants & macros */ CPPUNIT_TEST_SUITE_REGISTRATION(AudioClipTest); /** * The name of the configuration file for the audio clip. */ static const std::string configFileName = "etc/audioClip.xml"; /* =============================================== local function prototypes */ /* ============================================================= module code */ /*------------------------------------------------------------------------------ * Set up the test environment *----------------------------------------------------------------------------*/ void AudioClipTest :: setUp(void) throw () { } /*------------------------------------------------------------------------------ * Clean up the test environment *----------------------------------------------------------------------------*/ void AudioClipTest :: tearDown(void) throw () { } /*------------------------------------------------------------------------------ * Test to see if the singleton Hello object is accessible *----------------------------------------------------------------------------*/ void AudioClipTest :: firstTest(void) throw (CPPUNIT_NS::Exception) { try { Ptr::Ref parser( new xmlpp::DomParser(configFileName, false)); const xmlpp::Document * document = parser->get_document(); const xmlpp::Element * root = document->get_root_node(); Ptr::Ref audioClip(new AudioClip()); audioClip->configure(*root); CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x1); Ptr::Ref duration = audioClip->getPlaylength(); CPPUNIT_ASSERT(duration->hours() == 0); CPPUNIT_ASSERT(duration->minutes() == 18); CPPUNIT_ASSERT(duration->seconds() == 30); Ptr::Ref title = audioClip->getTitle(); CPPUNIT_ASSERT(title); CPPUNIT_ASSERT(*title == "File Title txt"); Ptr::Ref subject = audioClip ->getMetadata("subject", "dc"); CPPUNIT_ASSERT(subject); CPPUNIT_ASSERT(*subject == "Keywords: qwe, asd, zcx"); Ptr::Ref alternativeTitle = audioClip ->getMetadata("alternative", "dcterms"); CPPUNIT_ASSERT(alternativeTitle); CPPUNIT_ASSERT(*alternativeTitle == "Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ"); CPPUNIT_ASSERT(*audioClip->getXmlString() == ""); //std::cerr << "\nxml: '" << *audioClip->getXmlString() << "'" << std::endl; //std::cerr << "\nmetadata: " << *audioClip->getMetadataString() << std::endl; } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { std::string eMsg = "error parsing configuration file\n"; eMsg += e.what(); CPPUNIT_FAIL(eMsg); } } /*------------------------------------------------------------------------------ * Test conversion to and from Playable *----------------------------------------------------------------------------*/ void AudioClipTest :: conversionTest(void) throw (CPPUNIT_NS::Exception) { Ptr::Ref audioClip(new AudioClip()); try { Ptr::Ref parser( new xmlpp::DomParser(configFileName, false)); const xmlpp::Document * document = parser->get_document(); const xmlpp::Element * root = document->get_root_node(); audioClip->configure(*root); } catch (std::invalid_argument &e) { CPPUNIT_FAIL("semantic error in configuration file"); } catch (xmlpp::exception &e) { std::string eMsg = "error parsing configuration file\n"; eMsg += e.what(); CPPUNIT_FAIL(eMsg); } Ptr::Ref playable = audioClip; CPPUNIT_ASSERT(playable->getType() == Playable::AudioClipType); Ptr::Ref otherAudioClip = playable->getAudioClip(); CPPUNIT_ASSERT(otherAudioClip == audioClip); Ptr::Ref playlist = playable->getPlaylist(); CPPUNIT_ASSERT(!playlist); }