Commit e116a772 authored by Gregoire Olivier's avatar Gregoire Olivier Committed by Guillaume Roguez

test: add sip and base64 tests

sip
* testMultipleOutgoingIpCall()
* testHoldIpCall()
* testSIPURI()
* testSimpleIncomingIpCall()
* testMultipleIncomingIpCall() wip

*base64
*test_video_input
tests done by Florian Wiesweg
https://gerrit-ring.savoirfairelinux.com/#/c/6652/

Change-Id: I748318cfade68ac1c42050f6a1d734a029b5128c
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 12853b51
......@@ -382,7 +382,7 @@ AS_IF([test "x$with_dbus" = "xyes"], [
AS_IF([test "x$CLANG" = "xyes"], [
AC_MSG_ERROR([dbus does not compile when clang is used, rerun with --without-dbus])
]);
AM_CONDITIONAL(RING_DBUS, true)],
AM_CONDITIONAL(RING_DBUS, true)],TESTS= $(check_PROGRAMS)
AM_CONDITIONAL(RING_DBUS, false));
dnl Ring name service is default-enabled
......@@ -731,6 +731,9 @@ AC_CONFIG_FILES([Makefile \
ringtones/Makefile \
test/Makefile\
test/sip/Makefile \
test/base64/Makefile \
test/media/Makefile \
test/media/video/Makefile \
man/Makefile \
doc/Makefile \
doc/doxygen/Makefile])
......
*.o
# test result files
*.log
*.trs
.dirstamp
SUBDIRS=sip
SUBDIRS+=base64
SUBDIRS+=media
*.o
# test result files
*.log
*.trs
#test binaries
sip
base64
include $(top_srcdir)/globals.mk
AM_CXXFLAGS=-I$(top_srcdir)/src/media/video -I$(top_srcdir)/src
check_PROGRAMS=
#
# base64 testsuite
#
check_PROGRAMS+= base64
base64_SOURCES= base64.cpp
base64_LDADD= $(CPPUNIT_LIBS) $(top_builddir)/src/libring.la
#
# video_input testsuite
#
#check_PROGRAMS+= test_video_input
#test_video_input_SOURCES= media/video/test_video_input.cpp media/video/test_video_input.h
#test_video_input_LDADD= $(top_builddir)/src/libring.la $(top_builddir)/src/media/video/libvideo.la $(YAML_LIBS)
##################
# EXCLUDED_TEST SUITES #
##################
# test_video_rtp
# reason: compilation fails
# test_video_rtp.cpp:38:19: error: no matching function for call to ‘ring::video::VideoRtpSession::start()’
#
# test_video_rtp_SOURCES= media/video/test_video_rtp.cpp
# test_video_rtp_LDADD= $(top_builddir)/src/libring.la $(top_builddir)/src/media/video/libvideo.la $(YAML_LIBS)
#
#
# test_shm (compilation fails, include file not in repository?)
# reason: compilation fails, include file not in repository:
# test_video_input.cpp.cpp:21:22: fatal error: shm_sink.h: No such file or directory
#
# if HAVE_LINUX
# test_shm_SOURCES= media/video/test_shm.cpp media/video/shm_src.cpp media/video/shm_src.h
# test_shm_LDADD= $(top_builddir)/src/libring.la $(top_builddir)/src/media/video/libvideo.la $(YAML_LIBS) -lrt
# test_shm_CXXFLAGS=$(AM_CXXFLAGS)
# endif
TESTS= $(check_PROGRAMS)
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "test_runner.hpp"
#include "base64.h"
namespace ring_test {
class Base64Test : public CppUnit::TestFixture {
public:
static std::string name() { return "base64"; }
private:
void encodingTest();
void decodingTestSuccess();
void decodingTestFail();
CPPUNIT_TEST_SUITE(Base64Test);
CPPUNIT_TEST(encodingTest);
CPPUNIT_TEST(decodingTestSuccess);
CPPUNIT_TEST(decodingTestFail);
CPPUNIT_TEST_SUITE_END();
const std::vector<uint8_t> test_bytes = { 23, 45, 67, 87, 89, 34, 2, 45, 9, 10 };
const std::string test_base64 = "Fy1DV1kiAi0JCg==";
const std::string test_invalid_base64 = "ERSAÄÖöädt4-++asd==";
};
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Base64Test, Base64Test::name());
void Base64Test::encodingTest()
{
const std::string output = ring::base64::encode(test_bytes);
CPPUNIT_ASSERT(test_base64.compare(output) == 0);
}
void Base64Test::decodingTestSuccess()
{
const std::vector<uint8_t> output = ring::base64::decode(test_base64);
CPPUNIT_ASSERT(std::equal(test_bytes.begin(), test_bytes.end(), output.begin()));
}
void Base64Test::decodingTestFail()
{
// Currently, the input is not validated, i.e. the function most not throw an
// exception if decoding fails to make sure calling code not expecting any
// is no broken. (Some validation should be implemented sometimes later, though.
ring::base64::decode(test_invalid_base64);
CPPUNIT_ASSERT(true);
}
} // namespace tests
RING_TEST_RUNNER(ring_test::Base64Test::name())
#include <iostream>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/CompilerOutputter.h>
#define RING_TEST_RUNNER(suite_name) \
int main() \
{ \
CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry(suite_name); \
CppUnit::Test *suite = registry.makeTest(); \
if(suite->countTestCases() == 0) { \
std::cout << "No test cases specified for suite \"" << suite_name << "\"\n"; \
return 1; \
} \
CppUnit::TextUi::TestRunner runner; \
runner.addTest(suite); \
return runner.run() ? 0 : 1; \
}
include $(top_srcdir)/globals.mk
SUBDIRS= video
include $(top_srcdir)/globals.mk
check_PROGRAMS=
#
# video_input testsuite
#
check_PROGRAMS+= test_video_input
test_video_input_SOURCES= test_video_input.cpp test_video_input.h
test_video_input_LDADD= $(top_builddir)/src/libring.la $(top_builddir)/src/media/video/libvideo.la $(YAML_LIBS)
TESTS= $(check_PROGRAMS)
c++ shm_src.cpp shmclient.cpp -o shmclient `pkg-config --cflags --libs clutter-1.0` -lrt -pthread -O2
/*
* Copyright (C) 2011-2017 Savoir-faire Linux Inc.
*
* Author: Tristan Matthews <tristan.matthews@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "test_video_input.h"
#include "media/video/video_input.h"
#include "media_const.h"
#include <map>
#include <string>
namespace ring { namespace video { namespace test {
void VideoInputTest::testInput()
{
static const std::string sep = DRing::Media::VideoProtocolPrefix::SEPARATOR;
std::string resource = DRing::Media::VideoProtocolPrefix::DISPLAY + sep + std::string(getenv("DISPLAY") ? : ":0.0");
VideoInput video;
video.switchInput(resource);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}}} // namespace ring::video::test
int main ()
{
for (int i = 0; i < 20; ++i) {
ring::video::test::VideoInputTest test;
test.testInput();
}
return 0;
}
/*
* Copyright (C) 2011-2017 Savoir-faire Linux Inc.
*
* Author: Tristan Matthews <tristan.matthews@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _VIDEO_INPUT_TEST_
#define _VIDEO_INPUT_TEST_
namespace ring { namespace video { namespace test {
class VideoInputTest {
public:
void testInput();
};
}}} // namespace ring::video::test
#endif // _VIDEO_INPUT_TEST_
*.o
# test result files
*.log
*.trs
#test binaries
sip
dring-sample.yml.bak
# Rules for the test code (use `make check` to execute)
include ../../globals.mk
include $(top_srcdir)/globals.mk
TESTS = sip
check_PROGRAMS = $(TESTS)
sip_LDADD = ./../../src/libring.la
sip_LDADD = $(top_builddir)/src/libring.la
sip_SOURCES = sip.cpp test_SIP.h test_SIP.cpp ../../manager.h
sip_CXXFLAGS = $(CPPUNIT_CFLAGS)
sip_LDFLAGS = $(CPPUNIT_LIBS) -ldl
This diff is collapsed.
......@@ -2,6 +2,7 @@
* Copyright (C) 2004-2017 Savoir-Faire Linux Inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
* Author: Olivier Gregoire <olivier.gregoire@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
......@@ -28,6 +29,7 @@
// Application import
#include "manager.h"
#include "sip/sipvoiplink.h"
#include "sip/sip_utils.h"
......@@ -80,33 +82,35 @@ public:
void tearDown();
private:
// Create a simple IP call and test his state
void testSimpleOutgoingIpCall(void);
//void testSimpleIncomingIpCall(void);
// Receive a new incoming call and test his state
void testSimpleIncomingIpCall(void);
void testTwoOutgoingIpCall(void);
// Test with multiple outgoing calls
void testMultipleOutgoingIpCall(void);
//void testTwoIncomingIpCall(void);
// TODO this test bug, the new calls are sometimes
// put in hold
void testMultipleIncomingIpCall(void);
// Test the hold state
void testHoldIpCall(void);
//void testIncomingIpCallSdp(void);
//void testSIPURI();
void testSIPURI(void);
//void testParseDisplayName();
/**
* Use cppunit library macros to add unit test the factory
* Use cppunit library macros to add unit test to the factory
*/
CPPUNIT_TEST_SUITE(test_SIP);
CPPUNIT_TEST ( testSIPURI );
/*CPPUNIT_TEST ( testHoldIpCall );
CPPUNIT_TEST ( testSimpleOutgoingIpCall );
//CPPUNIT_TEST ( testParseDisplayName );
//CPPUNIT_TEST ( testSimpleIncomingIpCall );
//CPPUNIT_TEST ( testTwoOutgoingIpCall );
//CPPUNIT_TEST ( testTwoIncomingIpCall );
//CPPUNIT_TEST ( testHoldIpCall );
//CPPUNIT_TEST ( testIncomingIpCallSdp );
CPPUNIT_TEST ( testMultipleOutgoingIpCall );
CPPUNIT_TEST ( testSimpleIncomingIpCall );*/
//CPPUNIT_TEST ( testMultipleIncomingIpCall );
CPPUNIT_TEST_SUITE_END();
RAIIThread eventLoop_;
......
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