Commit b4082cb0 authored by Emmanuel Milou's avatar Emmanuel Milou

add init audio layer tests

parent f8f07467
......@@ -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);
}
......
......@@ -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(){
}
......@@ -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();
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment