Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
742a7693
Commit
742a7693
authored
Mar 15, 2010
by
Julien Bonjean
Browse files
[#2535] Cleaned daemon unit tests
parent
eb3f8dd2
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/managerimpl.cpp
View file @
742a7693
...
...
@@ -3858,7 +3858,7 @@ std::string ManagerImpl::addAccount (
if
(
_dbus
)
_dbus
->
getConfigurationManager
()
->
accountsChanged
();
return
newA
ccountID
;
return
a
ccountID
.
str
()
;
}
void
ManagerImpl
::
deleteAllCredential
(
const
AccountID
&
accountID
)
{
...
...
sflphone-common/src/managerimpl.h
View file @
742a7693
...
...
@@ -1299,7 +1299,7 @@ class ManagerImpl {
//
ConferenceMap
_conferencemap
;
private:
...
...
sflphone-common/test/Makefile.am
View file @
742a7693
include
../globals.mak
noinst_PROGRAMS
=
numbercleanerTester pluginmanagerTester hookmanagerTester audiolayerTester historyTester mainbufferTester sdesnegotiatorTester
#rtpTester
OBJECT_FILES
=
\
TESTS
=
main
check_PROGRAMS
=
$(TESTS)
main_CXXFLAGS
=
$(CPPUNIT_CFLAGS)
main_LDADD
=
$(LLIBS)
main_LDFLAGS
=
-ldl
main_SOURCES
=
main.cpp
\
validator.cpp
\
validator.h
\
accounttest.h
\
accounttest.cpp
LLIBS
=
$(CPPUNIT_LIBS)
\
../src/libsflphone.la
\
$(ZEROCONFLIB)
\
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
../src/sflphoned-logger.o
\
../src/sflphoned-managerimpl.o
\
../src/sflphoned-account.o
\
...
...
@@ -26,145 +51,4 @@ OBJECT_FILES= \
../src/plug-in/pluginmanager.o
\
../src/plug-in/audiorecorder/audiorecord.o
\
../src/audio/samplerateconverter.o
\
../src/history/historymanager.o
../
numbercleanerTester_SOURCES
=
\
numbercleanerTest.h
\
numbercleanerTest.cpp
\
TestMain.cpp
numbercleanerTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@SAMPLERATE_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
pluginmanagerTester_SOURCES
=
\
pluginmanagerTest.h
\
pluginmanagerTest.cpp
\
TestMain.cpp
pluginmanagerTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
hookmanagerTester_SOURCES
=
\
hookmanagerTest.cpp
\
TestMain.cpp
hookmanagerTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
audiolayerTester_SOURCES
=
\
audiolayerTest.h
\
audiolayerTest.cpp
\
TestMain.cpp
audiolayerTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
historyTester_SOURCES
=
\
historyTest.h
\
historyTest.cpp
\
TestMain.cpp
historyTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
mainbufferTester_SOURCES
=
\
mainbufferTest.h
\
mainbufferTest.cpp
\
TestMain.cpp
mainbufferTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
sdesnegotiatorTester_SOURCES
=
\
sdesnegotiatorTest.h
\
sdesnegotiatorTest.cpp
\
TestMain.cpp
sdesnegotiatorTester_LDADD
=
\
../src/libsflphone.la
\
$(SFLPHONE_LIBS)
$(ZEROCONFLIB)
$(LIB_DNSSD)
\
@ALSA_LIBS@
\
@PULSEAUDIO_LIBS@
\
@CPPUNIT_LIBS@
\
@CCEXT2_LIBS@
\
@CCGNU2_LIBS@
\
@CCRTP_LIBS@
\
@ZRTPCPP_LIBS@
\
@libssl_LIBS@
\
@SAMPLERATE_LIBS@
\
$(PJSIP_LIBS)
\
$(OBJECT_FILES)
../src/history/historymanager.o
\ No newline at end of file
sflphone-common/test/README
deleted
100644 → 0
View file @
eb3f8dd2
The daemon has to be recompiled before compiling the unitary tests.
sflphone-common/test/TestMain.cpp
deleted
100644 → 0
View file @
eb3f8dd2
#include
<cppunit/TextTestRunner.h>
#include
<cppunit/extensions/TestFactoryRegistry.h>
int
main
(
int
argc
,
const
char
*
argv
[])
{
CppUnit
::
TextTestRunner
runner
;
runner
.
addTest
(
CppUnit
::
TestFactoryRegistry
::
getRegistry
().
makeTest
());
return
runner
.
run
();
}
sflphone-common/test/
hookmanagerT
est.cpp
→
sflphone-common/test/
accountt
est.cpp
View file @
742a7693
/*
* Copyright (C) 200
9
Savoir-Faire Linux inc.
* Author:
Emmanuel Milou <emmanuel.milou
@savoirfairelinux.com>
* Copyright (C) 200
4-2007
Savoir-Faire Linux inc.
* Author:
Julien Bonjean <julien.bonjean
@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
...
...
@@ -17,41 +17,26 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include
<stdio.h>
#include
<sstream>
#include
<dlfcn.h>
#include
<cppunit/extensions/HelperMacros.h>
#include
<map>
#include
"accounttest.h"
#include
"manager.h"
#include
"logger.h"
#include
"validator.h"
#include
"hookmanager
Test
.h"
CPPUNIT_TEST_SUITE_REGISTRATION
(
Account
Test
);
using
std
::
cout
;
using
std
::
endl
;
void
AccountTest
::
TestAddRemove
(
void
)
{
std
::
map
<
std
::
string
,
std
::
string
>
details
;
details
[
CONFIG_ACCOUNT_TYPE
]
=
"SIP"
;
details
[
CONFIG_ACCOUNT_ENABLE
]
=
"false"
;
void
HookManagerTest
::
setUp
()
{
// Instanciate the hook manager singleton
urlhook
=
new
UrlHook
();
}
void
HookManagerTest
::
testAddAction
()
{
std
::
string
accountId
=
Manager
::
instance
().
addAccount
(
details
);
CPPUNIT_ASSERT
(
Validator
::
isNotNull
(
accountId
));
CPPUNIT_ASSERT
(
Manager
::
instance
().
accountExists
(
accountId
));
int
status
;
status
=
urlhook
->
addAction
(
"http://www.google.ca/?arg1=arg1&arg2=nvls&x=2&y=45&z=1"
,
"x-www-browser"
);
CPPUNIT_ASSERT
(
status
==
0
);
}
void
HookManagerTest
::
testLargeUrl
()
{
std
::
string
url
;
std
::
cout
<<
url
.
max_size
()
<<
std
::
endl
;
}
Manager
::
instance
().
removeAccount
(
accountId
);
void
HookManagerTest
::
tearDown
()
{
// Delete the hook manager object
delete
urlhook
;
urlhook
=
0
;
CPPUNIT_ASSERT
(
!
Manager
::
instance
().
accountExists
(
accountId
));
}
sflphone-common/test/a
udiorecorderT
est.
cpp
→
sflphone-common/test/a
ccountt
est.
h
View file @
742a7693
/*
* Copyright (C) 200
9
Savoir-Faire Linux inc.
* Author:
Emmanuel Milou <emmanuel.milou
@savoirfairelinux.com>
* Copyright (C) 200
4-2007
Savoir-Faire Linux inc.
* Author:
Julien Bonjean <julien.bonjean
@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
...
...
@@ -13,49 +13,24 @@
* 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
-
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#i
nclude
<stdio.h>
#
include
<sstream>
#i
fndef ACCOUNTTEST_H_
#
define ACCOUNTTEST_H_
#include
"audiorecorderTest.h"
#include
<cppunit/TestFixture.h>
#include
<cppunit/extensions/HelperMacros.h>
using
std
::
cout
;
using
std
::
endl
;
class
AccountTest
:
public
CppUnit
::
TestFixture
{
void
AudioRecorderTest
::
setUp
()
{
// Instanciate the object
_ar
=
new
AudioRecord
();
}
CPPUNIT_TEST_SUITE
(
AccountTest
);
CPPUNIT_TEST
(
TestAddRemove
);
CPPUNIT_TEST_SUITE_END
();
void
AudioRecorderTest
::
testRecordData
()
{
public:
void
TestAddRemove
(
void
);
};
/*
FILE_TYPE ft = FILE_WAV;
SOUND_FORMAT sf = INT16;
_ar->setSndSamplingRate(44100);
_ar->openFile("theWavFile.wav",ft,sf);
cout << "file opened!";
SFLDataFormat buf [2];
for (SFLDataFormat i = -32768; i < 32767; i++ ){
buf[0] = i;
buf[1] = i;
_ar->recData(buf,2);
}
_ar->closeFile();
*/
}
void
AudioRecorderTest
::
tearDown
()
{
// Delete the audio recorder module
delete
_ar
;
_ar
=
NULL
;
}
#endif
/* ACCOUNTTEST_H_ */
sflphone-common/test/audiolayerTest.cpp
deleted
100644 → 0
View file @
eb3f8dd2
/*
* 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
::
setUp
()
{
// Instanciate the manager
Manager
::
instance
().
init
();
Manager
::
instance
().
initConfigFile
();
// _audiodriver = Manager::instance().getAudioDriver();
// std::string alsaPlugin;
// AlsaLayer *alsalayer;
// int numCardIn, numCardOut, sampleRate, frameSize;
// layer = _audiodriver->getLayerType();
/*
alsaPlugin = Manager::instance().getConfigString( AUDIO , ALSA_PLUGIN );
numCardIn = Manager::instance().getConfigInt( AUDIO , ALSA_CARD_ID_IN );
numCardOut = Manager::instance().getConfigInt( AUDIO , ALSA_CARD_ID_OUT );
sampleRate = Manager::instance().getConfigInt( AUDIO , ALSA_SAMPLE_RATE );
if (sampleRate <=0 || sampleRate > 48000) {
sampleRate = 44100;
}
frameSize = Manager::instance().getConfigInt(AUDIO, ALSA_FRAME_SIZE );
*/
// get a pointer to the audio layer
// _audiodriver = Manager::instance().getAudioDriver();
}
void
AudioLayerTest
::
testAudioLayerConfig
()
{
int
sampling_rate
=
Manager
::
instance
().
getConfigInt
(
AUDIO
,
AUDIO_SAMPLE_RATE
);
int
frame_size
=
Manager
::
instance
().
getConfigInt
(
AUDIO
,
ALSA_FRAME_SIZE
);
frame_size
=
0
;
// frame size in config not used anymore
int
layer
=
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
();
if
(
layer
!=
ALSA
)
Manager
::
instance
().
switchAudioManager
();
CPPUNIT_ASSERT
(
(
int
)
Manager
::
instance
().
getAudioDriver
()
->
getSampleRate
()
==
sampling_rate
);
CPPUNIT_ASSERT
(
(
int
)
Manager
::
instance
().
getAudioDriver
()
->
getFrameSize
()
==
frame_size
);
}
void
AudioLayerTest
::
testAudioLayerSwitch
()
{
_debug
(
"---------- AudioLayerTest::testAudioLayerSwitch ---------------------------"
);
int
previous_layer
=
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
();
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
_debug
(
"---------- AudioLayerTest::testAudioLayerSwitch - %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 ---------------------------"
);
ManagerImpl
*
manager
;
manager
=
&
Manager
::
instance
();
// _pulselayer = new PulseLayer (manager);
_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
);
// CPPUNIT_ASSERT (_pulselayer->getPlaybackStream()->pulseStream() != NULL);
// CPPUNIT_ASSERT (_pulselayer->getRecordStream()->pulseStream() != NULL);
// Must return Access failure "PA_ERR_ACCESS" == 2
// CPPUNIT_ASSERT (_pulselayer->getPlaybackStream()->getStreamState() == 2);
// CPPUNIT_ASSERT (_pulselayer->getRecordStream()->getStreamState() == 2);
_debug
(
"--------------------------
\n
"
);
_pulselayer
->
startStream
();
// usleep(1000000);
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
);
// usleep(1000000);
CPPUNIT_ASSERT
(
_pulselayer
->
disconnectAudioStream
()
==
true
);
}
void
AudioLayerTest
::
testAlsaConnect
()
{
_debug
(
"---------- AudioLayerTest::testAlsaConnect ---------------------------"
);
int
layer
=
Manager
::
instance
().
getAudioDriver
()
->
getLayerType
();
std
::
string
alsaPlugin
;
if
(
layer
!=
ALSA
)
{
Manager
::
instance
().
switchAudioManager
();
usleep
(
100000
);
}
// _audiolayer = Manager::instance().getAudioDriver();
// CPPUNIT_ASSERT(_audiolayer->closeLayer() == true);
// usleep(100000);
// delete _audiolayer; _audiolayer == NULL;
Manager
::
instance
().
setConfig
(
PREFERENCES
,
CONFIG_AUDIO
,
ALSA
);
// _audiolayer->setErrorMessage(-1);
// CPPUNIT_ASSERT(Manager::instance().initAudioDriver() == true);
// _audiolayer = Manager::instance().getAudioDriver();
// CPPUNIT_ASSERT(_audiolayer->getLayerType() == ALSA);
}
void
AudioLayerTest
::
tearDown
()
{
// Delete the audio recorder module
// delete _ar; _ar = NULL;
}
sflphone-common/test/audiolayerTest.h
deleted
100644 → 0
View file @
eb3f8dd2
/*
* 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.
*/
// 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"
/*
* @file audiorecorderTest.cpp