diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 678d2c371296a9012a2432501d9df486a0fa0d0e..ce32f5a3d7f9b805fe052405e7d5673ec1558e09 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1526,8 +1526,11 @@ ManagerImpl::getCurrentAudioOutputPlugin( void ) void ManagerImpl::initAudioDriver(void) { - _debugInit("AudioLayer Creation"); + int error; + + _debugInit("AudioLayer Creation"); + if( getConfigInt( PREFERENCES , CONFIG_AUDIO ) == ALSA ) _audiodriver = new AlsaLayer( this ); else if( getConfigInt( PREFERENCES , CONFIG_AUDIO ) == PULSEAUDIO ) @@ -1538,7 +1541,7 @@ ManagerImpl::initAudioDriver(void) if (_audiodriver == 0) { _debug("Init audio driver error\n"); } else { - int error = getAudioDriver()->getErrorMessage(); + error = getAudioDriver()->getErrorMessage(); if (error == -1) { _debug("Init audio driver: %i\n", error); } diff --git a/test/configurationTest.cpp b/test/configurationTest.cpp index d9c3a3675a10cb058414e9845e20d39b93f1726d..8208c9944fa6699baa92d5aabf63ff621af995c5 100644 --- a/test/configurationTest.cpp +++ b/test/configurationTest.cpp @@ -69,13 +69,17 @@ void ConfigurationTest::testLoadSIPAccount(){ AccountMap accounts; Account *current; std::ostringstream ss; + int nb_account; // Must be 1 - // Load the accounts from the user file - Manager::instance().loadAccountMap(); + // Load the account from the user file + nb_account = Manager::instance().loadAccountMap(); + CPPUNIT_ASSERT_EQUAL( 1, nb_account ); // Save the account information accounts = Manager::instance()._accountMap; AccountMap::iterator iter = accounts.begin(); + CPPUNIT_ASSERT( Manager::instance().accountExists( iter->first ) == true ); + while( iter != accounts.end() ){ current = iter->second; CPPUNIT_ASSERT( iter->first == current->getAccountID() ); @@ -96,8 +100,38 @@ void ConfigurationTest::testUnloadSIPAccount(){ accounts = Manager::instance()._accountMap; AccountMap::iterator iter = accounts.begin(); + CPPUNIT_ASSERT( Manager::instance().accountExists( iter->first ) == false ); + if( iter != accounts.end() ){ CPPUNIT_FAIL("Unload account map failed\n"); } } +void ConfigurationTest::testInitVolume(){ + + Manager::instance().initVolume(); + + CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, VOLUME_SPKR) == Manager::instance().getSpkrVolume() ); + CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, VOLUME_MICRO) == Manager::instance().getMicVolume() ); +} + +void ConfigurationTest::testInitAudioDriver(){ + + // Load the audio driver + Manager::instance().initAudioDriver(); + + // Check the creation + if( Manager::instance().getAudioDriver() == NULL ) + CPPUNIT_FAIL("Error while loading audio layer"); + + // Check if it has been created with the right type + if( Manager::instance().getConfigInt( PREFERENCES, CONFIG_AUDIO ) == ALSA ) + CPPUNIT_ASSERT_EQUAL( Manager::instance().getAudioDriver()->getLayerType(), ALSA ); + else if( Manager::instance().getConfigInt( PREFERENCES, CONFIG_AUDIO ) == PULSEAUDIO ) + CPPUNIT_ASSERT_EQUAL( Manager::instance().getAudioDriver()->getLayerType(), PULSEAUDIO ); + else + CPPUNIT_FAIL("Wrong audio layer type"); +} + +void ConfigurationTest::testSelectAudioDriver(){ +} diff --git a/test/configurationTest.h b/test/configurationTest.h index cdb891025fe3f061caf44ac8392e3f887ece90e7..87828521eed303cbe2b195684f0ffbe45048db74 100644 --- a/test/configurationTest.h +++ b/test/configurationTest.h @@ -27,6 +27,7 @@ // Application import #include "manager.h" +#include "audio/audiolayer.h" #include "global.h" #include "user_cfg.h" @@ -50,6 +51,9 @@ class ConfigurationTest : public CppUnit::TestCase { CPPUNIT_TEST( testDefaultValueSignalisation ); CPPUNIT_TEST( testLoadSIPAccount ); CPPUNIT_TEST( testUnloadSIPAccount ); + CPPUNIT_TEST( testInitVolume ); + CPPUNIT_TEST( testInitAudioDriver ); + CPPUNIT_TEST( testSelectAudioDriver ); CPPUNIT_TEST_SUITE_END(); public: @@ -79,10 +83,22 @@ class ConfigurationTest : public CppUnit::TestCase { */ void testDefaultValuePreferences(); + /* + * Unit tests related to the global settings + */ void testDefaultValueSignalisation(); + /* + * Try to load one SIP account. + * So be sure to have only one SIP account so that the test could succeed + */ void testLoadSIPAccount(); void testUnloadSIPAccount(); + + void testInitVolume(); + + void testInitAudioDriver(); + void testSelectAudioDriver(); };