Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-daemon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
145
Issues
145
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-daemon
Commits
5be88657
Commit
5be88657
authored
Mar 24, 2010
by
Julien Bonjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#2535] Cleaned unit test
parent
4cbf6758
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
4017 additions
and
21 deletions
+4017
-21
sflphone-common/test/Makefile.am
sflphone-common/test/Makefile.am
+24
-7
sflphone-common/test/accounttest.cpp
sflphone-common/test/accounttest.cpp
+1
-2
sflphone-common/test/accounttest.h
sflphone-common/test/accounttest.h
+2
-0
sflphone-common/test/audiolayertest.cpp
sflphone-common/test/audiolayertest.cpp
+133
-0
sflphone-common/test/audiolayertest.h
sflphone-common/test/audiolayertest.h
+72
-0
sflphone-common/test/configurationtest.cpp
sflphone-common/test/configurationtest.cpp
+141
-0
sflphone-common/test/configurationtest.h
sflphone-common/test/configurationtest.h
+88
-0
sflphone-common/test/constants.h
sflphone-common/test/constants.h
+18
-0
sflphone-common/test/history-sample
sflphone-common/test/history-sample
+21
-0
sflphone-common/test/history-sample.tpl
sflphone-common/test/history-sample.tpl
+20
-0
sflphone-common/test/historytest.cpp
sflphone-common/test/historytest.cpp
+215
-0
sflphone-common/test/historytest.h
sflphone-common/test/historytest.h
+94
-0
sflphone-common/test/hookmanagertest.cpp
sflphone-common/test/hookmanagertest.cpp
+60
-0
sflphone-common/test/hookmanagertest.h
sflphone-common/test/hookmanagertest.h
+71
-0
sflphone-common/test/main.cpp
sflphone-common/test/main.cpp
+76
-12
sflphone-common/test/mainbuffertest.cpp
sflphone-common/test/mainbuffertest.cpp
+1758
-0
sflphone-common/test/mainbuffertest.h
sflphone-common/test/mainbuffertest.h
+137
-0
sflphone-common/test/numbercleanertest.cpp
sflphone-common/test/numbercleanertest.cpp
+139
-0
sflphone-common/test/numbercleanertest.h
sflphone-common/test/numbercleanertest.h
+99
-0
sflphone-common/test/pluginmanagertest.cpp
sflphone-common/test/pluginmanagertest.cpp
+124
-0
sflphone-common/test/pluginmanagertest.h
sflphone-common/test/pluginmanagertest.h
+95
-0
sflphone-common/test/rtptest.cpp
sflphone-common/test/rtptest.cpp
+110
-0
sflphone-common/test/rtptest.h
sflphone-common/test/rtptest.h
+110
-0
sflphone-common/test/sdesnegotiatortest.cpp
sflphone-common/test/sdesnegotiatortest.cpp
+223
-0
sflphone-common/test/sdesnegotiatortest.h
sflphone-common/test/sdesnegotiatortest.h
+107
-0
sflphone-common/test/sflphonedrc-sample
sflphone-common/test/sflphonedrc-sample
+74
-0
sflphone-common/test/validator.cpp
sflphone-common/test/validator.cpp
+4
-0
sflphone-common/test/validator.h
sflphone-common/test/validator.h
+1
-0
No files found.
sflphone-common/test/Makefile.am
View file @
5be88657
include
../globals.mak
TESTS
=
main
TESTS
=
test
check_PROGRAMS
=
$(TESTS)
main
_CXXFLAGS
=
$(CPPUNIT_CFLAGS)
main
_LDADD
=
$(LLIBS)
main
_LDFLAGS
=
-ldl
main
_SOURCES
=
main.cpp
\
test
_CXXFLAGS
=
$(CPPUNIT_CFLAGS)
test
_LDADD
=
$(LLIBS)
test
_LDFLAGS
=
-ldl
test
_SOURCES
=
main.cpp
\
validator.cpp
\
validator.h
\
accounttest.h
\
accounttest.cpp
accounttest.cpp
\
audiolayertest.h
\
audiolayertest.cpp
\
configurationtest.h
\
configurationtest.cpp
\
historytest.h
\
historytest.cpp
\
hookmanagertest.h
\
hookmanagertest.cpp
\
mainbuffertest.h
\
mainbuffertest.cpp
\
numbercleanertest.h
\
numbercleanertest.cpp
\
pluginmanagertest.h
\
pluginmanagertest.cpp
\
rtptest.h
\
rtptest.cpp
\
sdesnegotiatortest.h
\
sdesnegotiatortest.cpp
...
...
sflphone-common/test/accounttest.cpp
View file @
5be88657
...
...
@@ -24,9 +24,8 @@
#include "logger.h"
#include "validator.h"
CPPUNIT_TEST_SUITE_REGISTRATION
(
AccountTest
);
void
AccountTest
::
TestAddRemove
(
void
)
{
_debug
(
"-------------------- AccountTest::TestAddRemove --------------------
\n
"
);
std
::
map
<
std
::
string
,
std
::
string
>
details
;
details
[
CONFIG_ACCOUNT_TYPE
]
=
"SIP"
;
...
...
sflphone-common/test/accounttest.h
View file @
5be88657
...
...
@@ -32,5 +32,7 @@ class AccountTest : public CppUnit::TestFixture {
public:
void
TestAddRemove
(
void
);
};
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
(
AccountTest
,
"AccountTest"
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
AccountTest
);
#endif
/* ACCOUNTTEST_H_ */
sflphone-common/test/audiolayertest.cpp
0 → 100644
View file @
5be88657
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <sstream>
#include "audiolayertest.h"
#include <unistd.h>
using
std
::
cout
;
using
std
::
endl
;
void
AudioLayerTest
::
testAudioLayerConfig
()
{
_debug
(
"-------------------- AudioLayerTest::testAudioLayerConfig --------------------
\n
"
);
int
sampling_rate
=
Manager
::
instance
().
getConfigInt
(
AUDIO
,
AUDIO_SAMPLE_RATE
);
int
frame_size
=
Manager
::
instance
().
getConfigInt
(
AUDIO
,
ALSA_FRAME_SIZE
);
int
layer
=
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
();
if
(
layer
!=
ALSA
)
Manager
::
instance
().
switchAudioManager
();
// TODO: Fix tests
//CPPUNIT_ASSERT ( (int) Manager::instance().getAudioDriver()->getSampleRate() == sampling_rate);
//CPPPUNIT_ASSERT ( (int) Manager::instance().getAudioDriver()->getFrameSize() == frame_size);
}
void
AudioLayerTest
::
testAudioLayerSwitch
()
{
_debug
(
"-------------------- AudioLayerTest::testAudioLayerSwitch --------------------
\n
"
);
int
previous_layer
=
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
();
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
_debug
(
"iter - %i"
,
i
);
Manager
::
instance
().
switchAudioManager
();
if
(
previous_layer
==
ALSA
)
{
CPPUNIT_ASSERT
(
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
()
==
PULSEAUDIO
);
}
else
{
CPPUNIT_ASSERT
(
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
()
==
ALSA
);
}
previous_layer
=
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
();
usleep
(
100000
);
}
}
void
AudioLayerTest
::
testPulseConnect
()
{
_debug
(
"-------------------- AudioLayerTest::testPulseConnect --------------------
\n
"
);
if
(
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
()
==
ALSA
)
return
;
ManagerImpl
*
manager
;
manager
=
&
Manager
::
instance
();
_pulselayer
=
(
PulseLayer
*
)
Manager
::
instance
().
getAudioDriver
();
CPPUNIT_ASSERT
(
_pulselayer
->
getLayerType
()
==
PULSEAUDIO
);
std
::
string
alsaPlugin
;
int
numCardIn
,
numCardOut
,
sampleRate
,
frameSize
;
alsaPlugin
=
manager
->
getConfigString
(
AUDIO
,
ALSA_PLUGIN
);
numCardIn
=
manager
->
getConfigInt
(
AUDIO
,
ALSA_CARD_ID_IN
);
numCardOut
=
manager
->
getConfigInt
(
AUDIO
,
ALSA_CARD_ID_OUT
);
sampleRate
=
manager
->
getConfigInt
(
AUDIO
,
AUDIO_SAMPLE_RATE
);
frameSize
=
manager
->
getConfigInt
(
AUDIO
,
ALSA_FRAME_SIZE
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
==
NULL
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
==
NULL
);
_pulselayer
->
setErrorMessage
(
-
1
);
try
{
CPPUNIT_ASSERT
(
_pulselayer
->
openDevice
(
numCardIn
,
numCardOut
,
sampleRate
,
frameSize
,
SFL_PCM_BOTH
,
alsaPlugin
)
==
true
);
}
catch
(...)
{
_debug
(
"Exception occured wile opening device! "
);
}
usleep
(
100000
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
==
NULL
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
==
NULL
);
_debug
(
"--------------------------
\n
"
);
_pulselayer
->
startStream
();
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
pulseStream
()
!=
NULL
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
pulseStream
()
!=
NULL
);
// Must return No error "PA_OK" == 1
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
getStreamState
()
==
1
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
->
getStreamState
()
==
1
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
disconnectStream
()
==
true
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
->
disconnectStream
()
==
true
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
connectStream
()
==
true
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
->
connectStream
()
==
true
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
getStreamState
()
==
1
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
->
getStreamState
()
==
1
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
connectStream
()
==
true
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
->
connectStream
()
==
true
);
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
->
getStreamState
()
==
1
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
->
getStreamState
()
==
1
);
CPPUNIT_ASSERT
(
_pulselayer
->
disconnectAudioStream
()
==
true
);
}
sflphone-common/test/audiolayertest.h
0 → 100644
View file @
5be88657
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* @file audiorecorderTest.cpp
* @brief Regroups unitary tests related to the plugin manager.
*/
#ifndef _AUDIOLAYER_TEST_
#define _AUDIOLAYER_TEST_
// Cppunit import
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <assert.h>
// Application import
#include "manager.h"
#include "config/config.h"
#include "user_cfg.h"
#include "audio/audiolayer.h"
#include "audio/alsa/alsalayer.h"
#include "audio/pulseaudio/pulselayer.h"
class
AudioLayerTest
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
AudioLayerTest
);
CPPUNIT_TEST
(
testAudioLayerConfig
);
CPPUNIT_TEST
(
testPulseConnect
);
//TODO: this test ends the test sequence when using on a alsa only system
//CPPUNIT_TEST(testAudioLayerSwitch);
CPPUNIT_TEST_SUITE_END
();
public:
void
testAudioLayerConfig
();
void
testPulseConnect
();
void
testAudioLayerSwitch
();
private:
ManagerImpl
*
manager
;
PulseLayer
*
_pulselayer
;
int
layer
;
};
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
(
AudioLayerTest
,
"AudioLayerTest"
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
AudioLayerTest
);
#endif
sflphone-common/test/configurationtest.cpp
0 → 100644
View file @
5be88657
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <sstream>
#include "configurationtest.h"
#include "constants.h"
using
std
::
cout
;
using
std
::
endl
;
void
ConfigurationTest
::
testDefaultValueAudio
()
{
_debug
(
"-------------------- ConfigurationTest::testDefaultValueAudio() --------------------
\n
"
);
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
,
AUDIO_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
ConfigurationTest
::
testDefaultValuePreferences
()
{
_debug
(
"-------------------- ConfigurationTest::testDefaultValuePreferences --------------------
\n
"
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
PREFERENCES
,
ZONE_TONE
)
==
DFT_ZONE
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
PREFERENCES
,
CONFIG_DIALPAD
)
==
NO_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
)
==
NO_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
)
==
NO_STR
);
//CPPUNIT_ASSERT (Manager::instance().getConfigString (PREFERENCES, REGISTRATION_EXPIRE) == DFT_EXPIRE_VALUE);
//CPPUNIT_ASSERT (Manager::instance().getConfigString (PREFERENCES, CONFIG_AUDIO) == DFT_AUDIO_MANAGER);
}
void
ConfigurationTest
::
testDefaultValueSignalisation
()
{
_debug
(
"-------------------- ConfigurationTest::testDefaultValueSignalisation --------------------
\n
"
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
SIGNALISATION
,
SYMMETRIC
)
==
YES_STR
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
SIGNALISATION
,
PLAY_DTMF
)
==
YES_STR
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
SIGNALISATION
,
PLAY_TONES
)
==
YES_STR
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
SIGNALISATION
,
PULSE_LENGTH
)
==
DFT_PULSE_LENGTH_STR
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
getConfigString
(
SIGNALISATION
,
SEND_DTMF_AS
)
==
SIP_INFO_STR
);
}
void
ConfigurationTest
::
testLoadSIPAccount
()
{
_debug
(
"-------------------- ConfigurationTest::testLoadSIPAccount --------------------
\n
"
);
AccountMap
accounts
;
Account
*
current
;
std
::
ostringstream
ss
;
int
nb_account
;
// Must be 1
// 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
());
CPPUNIT_ASSERT
(
0
==
current
->
getVoIPLink
());
iter
++
;
}
}
void
ConfigurationTest
::
testUnloadSIPAccount
()
{
_debug
(
"-------------------- ConfigurationTest::testUnloadSIPAccount --------------------
\n
"
);
AccountMap
accounts
;
// Load the accounts from the user file
Manager
::
instance
().
loadAccountMap
();
// Unload the accounts
Manager
::
instance
().
unloadAccountMap
();
// Save the account information
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
()
{
_debug
(
"-------------------- ConfigurationTest::testInitVolume --------------------
\n
"
);
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
()
{
_debug
(
"-------------------- ConfigurationTest::testInitAudioDriver --------------------
\n
"
);
// 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"
);
}
sflphone-common/test/configurationtest.h
0 → 100644
View file @
5be88657
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* @file configurationTest.cpp
* @brief Regroups unitary tests related to the user configuration.
* Check if the default configuration has been successfully loaded
*/
#ifndef _CONFIGURATION_TEST_
#define _CONFIGURATION_TEST_
// Cppunit import
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>
#include <assert.h>
// Application import
#include "manager.h"
#include "audio/audiolayer.h"
#include "global.h"
#include "user_cfg.h"
class
ConfigurationTest
:
public
CppUnit
::
TestFixture
{
/*
* Use cppunit library macros to add unit test the factory
*/
CPPUNIT_TEST_SUITE
(
ConfigurationTest
);
CPPUNIT_TEST
(
testInitVolume
);
CPPUNIT_TEST
(
testDefaultValueAudio
);
CPPUNIT_TEST
(
testDefaultValuePreferences
);
CPPUNIT_TEST
(
testDefaultValueSignalisation
);
CPPUNIT_TEST
(
testInitAudioDriver
);
CPPUNIT_TEST_SUITE_END
();
public:
/*
* Unit tests related to the audio preferences
*/
void
testDefaultValueAudio
();
/*
* Unit tests related to the global settings
*/
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
();
};
/* Register our test module */
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
(
ConfigurationTest
,
"ConfigurationTest"
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
ConfigurationTest
);
#endif
sflphone-common/test/constants.h
0 → 100644
View file @
5be88657
/*
* constants.h
*
* Created on: 2010-03-15
* Author: jb
*/
#ifndef CONSTANTS_H_
#define CONSTANTS_H_
#define YES_STR "1"
#define NO_STR "0"
#define HISTORY_SAMPLE "history-sample"
#define HISTORY_SAMPLE_SIZE 3
#define CONFIG_SAMPLE "sflphonedrc-sample"
#define HUGE_HISTORY_LIMIT 20000
#endif
/* CONSTANTS_H_ */
sflphone-common/test/history-sample
0 → 100644
View file @
5be88657
[144562436]
accountid=
name=Savoir-faire Linux
number=514-276-5468
timestamp_stop=144562458
type=0
[747638685]
accountid=Account:1239059899
name=Emmanuel Milou
number=136
timestamp_stop=747638765
type=2
[775354456]
accountid=Account:43789459478
name=
number=5143848557
timestamp_stop=775354987
type=1
sflphone-common/test/history-sample.tpl
0 → 100644
View file @
5be88657
[144562436]
number=514-276-5468
name=Savoir-faire Linux
type=0
timestamp_stop=144562458
accountid=
[747638685]
name=Emmanuel Milou
timestamp_stop=747638765
number=136
type=2
accountid=Account:1239059899
[775354456]
number=5143848557
name=
timestamp_stop=775354987
type=1
accountid=Account:43789459478
sflphone-common/test/historytest.cpp
0 → 100644
View file @
5be88657
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <sstream>
#include "historytest.h"
#include "manager.h"
#include "constants.h"
#include "validator.h"
using
std
::
cout
;
using
std
::
endl
;
void
HistoryTest
::
setUp
()
{
// Instanciate the cleaner singleton
history
=
new
HistoryManager
();
}
void
HistoryTest
::
test_create_history_path
()
{
_debug
(
"-------------------- HistoryTest::test_create_history_path --------------------
\n
"
);
int
result
;
char
*
cpath
;
std
::
string
path
;
cpath
=
getenv
(
"XDG_DATA_HOME"
);
(
cpath
!=
NULL
)
?
path
=
std
::
string
(
cpath
)
:
path
=
std
::
string
(
HOMEDIR
)
+
"/.local/share/sflphone/history"
;
result
=
history
->
create_history_path
();
CPPUNIT_ASSERT
(
result
==
0
);
CPPUNIT_ASSERT
(
!
history
->
is_loaded
());
CPPUNIT_ASSERT
(
history
->
_history_path
==
path
);
}
void
HistoryTest
::
test_load_history_from_file
()
{
_debug
(
"-------------------- HistoryTest::test_load_history_from_file --------------------
\n
"
);
bool
res
;
Conf
::
ConfigTree
history_list
;
history
->
create_history_path
();
res
=
history
->
load_history_from_file
(
&
history_list
);
CPPUNIT_ASSERT
(
history
->
is_loaded
());
CPPUNIT_ASSERT
(
res
==
true
);
}