Commit 9d5f0e9c authored by Emmanuel Milou's avatar Emmanuel Milou

Add unit tests for hook manager

parent f18ae906
......@@ -24,7 +24,7 @@ UrlHook::UrlHook () { }
UrlHook::~UrlHook () { }
void UrlHook::addAction (std::string field_value, std::string command){
int UrlHook::addAction (std::string field_value, std::string command){
std::string command_bg;
......@@ -32,6 +32,9 @@ void UrlHook::addAction (std::string field_value, std::string command){
command_bg = command + " " + field_value + "&" ;
/* Execute a system call */
RUN_COMMAND (command_bg.c_str());
return 0;
}
......@@ -38,7 +38,7 @@ class UrlHook {
*/
~UrlHook ();
void addAction (std::string, std::string);
int addAction (std::string, std::string);
private:
};
......
include ../globals.mak
bin_PROGRAMS = configurationTester pluginmanagerTester audiorecorderTester
bin_PROGRAMS = pluginmanagerTester hookmanagerTester
OBJECT_FILES= \
../src/sflphoned-managerimpl.o \
......@@ -17,66 +17,44 @@ OBJECT_FILES= \
../src/sflphoned-eventthread.o \
../src/plug-in/pluginmanager.o \
../src/plug-in/audiorecorder/audiorecord.o \
../src/sflphoned-samplerateconverter.o
configurationTester_SOURCES = \
configurationTest.cpp \
configurationTest.h \
TestMain.cpp
../src/sflphoned-samplerateconverter.o \
../src/sflphoned-sdp.o \
../src/sflphoned-sdpmedia.o
pluginmanagerTester_SOURCES = \
pluginmanagerTest.h \
pluginmanagerTest.cpp \
TestMain.cpp
audiorecorderTester_SOURCES = \
audiorecorderTest.h \
audiorecorderTest.cpp \
TestMain.cpp
configurationTester_LDADD = \
../src/libsflphone.la \
$(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) \
@ALSA_LIBS@ \
@PULSEAUDIO_LIBS@ \
@CPPUNIT_LIBS@ \
@CCEXT2_LIBS@ \
@CCGNU2_LIBS@ \
@CCRTP_LIBS@ \
@DBUSCPP_LIBS@ \
@SAMPLERATE_LIBS@ \
$(PJSIP_LIBS) \
-luuid \
$(OBJECT_FILES)
pluginmanagerTester_LDADD = \
../src/libsflphone.la \
$(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) \
$(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) \
@ALSA_LIBS@ \
@PULSEAUDIO_LIBS@ \
@CPPUNIT_LIBS@ \
@CCEXT2_LIBS@ \
@CCGNU2_LIBS@ \
@CCRTP_LIBS@ \
@DBUSCPP_LIBS@ \
@SAMPLERATE_LIBS@ \
$(PJSIP_LIBS) \
-luuid \
$(OBJECT_FILES)
audiorecorderTester_LDADD = \
hookmanagerTester_SOURCES = \
hookmanagerTest.cpp \
TestMain.cpp
hookmanagerTester_LDADD = \
../src/libsflphone.la \
$(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) \
$(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) \
@ALSA_LIBS@ \
@PULSEAUDIO_LIBS@ \
@CPPUNIT_LIBS@ \
@CCEXT2_LIBS@ \
@CCGNU2_LIBS@ \
@CCRTP_LIBS@ \
@DBUSCPP_LIBS@ \
@SAMPLERATE_LIBS@ \
$(PJSIP_LIBS) \
-luuid \
$(OBJECT_FILES)
/*
* 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 <dlfcn.h>
#include "hookmanagerTest.h"
using std::cout;
using std::endl;
void HookManagerTest::setUp(){
// Instanciate the hook manager singleton
urlhook = new UrlHook ();
}
void HookManagerTest::testAddAction (){
int status;
status = urlhook->addAction ("www.google.ca", "gnome-www-browser");
CPPUNIT_ASSERT (status == 0);
}
void HookManagerTest::tearDown(){
// Delete the hook manager object
delete urlhook; urlhook=0;
}
/*
* 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 "hooks/urlhook.h"
/*
* @file hookmanagerTest.cpp
* @brief Regroups unitary tests related to the hook manager.
*/
#ifndef _HOOKMANAGER_TEST_
#define _HOOKMANAGER_TEST_
class HookManagerTest : public CppUnit::TestCase {
/**
* Use cppunit library macros to add unit test the factory
*/
CPPUNIT_TEST_SUITE (HookManagerTest);
CPPUNIT_TEST (testAddAction);
CPPUNIT_TEST_SUITE_END ();
public:
HookManagerTest() : CppUnit::TestCase("Hook Manager Tests") {}
/*
* Code factoring - Common resources can be initialized here.
* This method is called by unitcpp before each test
*/
void setUp();
void testAddAction ();
/*
* Code factoring - Common resources can be released here.
* This method is called by unitcpp after each test
*/
inline void tearDown ();
private:
UrlHook *urlhook;
};
/* Register our test module */
CPPUNIT_TEST_SUITE_REGISTRATION( HookManagerTest );
#endif
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