From a36e14391c76d8ef3a954f3284e1d044b0c609d0 Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Thu, 9 Oct 2008 12:12:45 -0400 Subject: [PATCH] add the possibility to load default values for the unit tests --- src/managerimpl.cpp | 5 +++-- src/managerimpl.h | 2 +- test/configurationTest.cpp | 39 +++++++++++++++++++------------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index a09d059b0e..678d2c3712 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -982,7 +982,7 @@ ManagerImpl::createSettingsPath (void) { * Initialization: Main Thread */ void -ManagerImpl::initConfigFile (void) +ManagerImpl::initConfigFile ( bool load_user_value ) { std::string mes = gettext("Init config file\n"); _debug("%s",mes.c_str()); @@ -1028,7 +1028,7 @@ ManagerImpl::initConfigFile (void) fill_config_int(CONFIG_PA_VOLUME_CTRL , YES_STR); // Loads config from ~/.sflphone/sflphonedrc or so.. - if (createSettingsPath() == 1) { + if (createSettingsPath() == 1 && load_user_value) { _exist = _config.populateFromFile(_path); } @@ -1110,6 +1110,7 @@ ManagerImpl::getActiveCodecList( void ) std::stringstream ss; ss << active[i]; v.push_back((ss.str()).data()); + _debug("%s\n", ss.str().data()); i++; } return v; diff --git a/src/managerimpl.h b/src/managerimpl.h index a57bb33281..3fbffe3110 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -782,7 +782,7 @@ class ManagerImpl { * Fills the local _config (Conf::ConfigTree) with the default contents. * Called in main.cpp, just before Manager::init(). */ - void initConfigFile (void); + void initConfigFile ( bool load_user_value = true ); /** * Tell if the setup was already loaded diff --git a/test/configurationTest.cpp b/test/configurationTest.cpp index aa4a1dc7dd..f7c0ae7a6a 100644 --- a/test/configurationTest.cpp +++ b/test/configurationTest.cpp @@ -6,6 +6,7 @@ #include "manager.h" #include "global.h" +#include "user_cfg.h" #include <stdio.h> @@ -25,28 +26,28 @@ class ConfigurationTest : public CppUnit::TestCase { ConfigurationTest() : CppUnit::TestCase("Configuration Tests") {} void testDefaultValueAudio(){ - CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, ALSA_CARD_ID_IN ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, ALSA_CARD_ID_IN ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, ALSA_SAMPLE_RATE ) == 44100 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, ALSA_FRAME_SIZE ) == 20 ); - CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, ALSA_PLUGIN ) == "default" ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, VOLUME_SPKR ) == 100 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( AUDIO, VOLUME_MICRO ) == 50 ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, ALSA_CARD_ID_IN ) == ALSA_DFT_CARD) ; + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, ALSA_CARD_ID_OUT ) == ALSA_DFT_CARD ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, ALSA_SAMPLE_RATE ) == DFT_SAMPLE_RATE); + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, ALSA_FRAME_SIZE ) == DFT_FRAME_SIZE) ; + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, ALSA_PLUGIN ) == PCM_DEFAULT ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, VOLUME_SPKR ) == DFT_VOL_SPKR_STR); + CPPUNIT_ASSERT( Manager::instance().getConfigString( AUDIO, VOLUME_MICRO ) == DFT_VOL_MICRO_STR); } void testDefaultValuePreferences(){ - CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, ZONE_TONE ) == "North America" ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_ZEROCONF ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_DIALPAD ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_RINGTONE ) == 1 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_SEARCHBAR ) == 1 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_START ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_POPUP ) == 1 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_NOTIFY ) == 1 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_MAIL_NOTIFY ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_VOLUME ) == 0 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, REGISTRATION_EXPIRE ) == 180 ); - CPPUNIT_ASSERT( Manager::instance().getConfigInt( PREFERENCES, CONFIG_AUDIO ) == 0 ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, ZONE_TONE ) == DFT_ZONE ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_ZEROCONF ) == CONFIG_ZEROCONF_DEFAULT_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_DIALPAD ) == YES_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_RINGTONE ) == YES_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_SEARCHBAR ) == YES_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_START ) == NO_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_POPUP ) == YES_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_NOTIFY ) == YES_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_MAIL_NOTIFY ) == NO_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_VOLUME ) == YES_STR ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, REGISTRATION_EXPIRE ) == DFT_EXPIRE_VALUE ); + CPPUNIT_ASSERT( Manager::instance().getConfigString( PREFERENCES, CONFIG_AUDIO ) == DFT_AUDIO_MANAGER ); } -- GitLab