Line data Source code
1 : /* 2 : * Copyright (C) 2004-2024 Savoir-faire Linux Inc. 3 : * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> 4 : * Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> 5 : * Author: Olivier Gregoire <olivier.gregoire@savoirfairelinux.com> 6 : * 7 : * This program is free software; you can redistribute it and/or modify 8 : * it under the terms of the GNU General Public License as published by 9 : * the Free Software Foundation; either version 3 of the License, or 10 : * (at your option) any later version. 11 : * 12 : * This program is distributed in the hope that it will be useful, 13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 : * GNU General Public License for more details. 16 : * 17 : * You should have received a copy of the GNU General Public License 18 : * along with this program; if not, write to the Free Software 19 : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 : * 21 : */ 22 : #pragma once 23 : 24 : // Cppunit import 25 : #include <cppunit/extensions/HelperMacros.h> 26 : #include <cppunit/TestCaller.h> 27 : #include <cppunit/TestCase.h> 28 : #include <cppunit/TestSuite.h> 29 : 30 : // Application import 31 : #include "manager.h" 32 : 33 : #include "sip/sipvoiplink.h" 34 : #include "connectivity/sip_utils.h" 35 : 36 : #include <atomic> 37 : 38 : #include <thread> 39 : class RAIIThread 40 : { 41 : public: 42 1 : RAIIThread() = default; 43 : 44 1 : RAIIThread(std::thread&& t) 45 1 : : thread_ {std::move(t)} {}; 46 : 47 2 : ~RAIIThread() { join(); } 48 : 49 3 : void join() 50 : { 51 3 : if (thread_.joinable()) 52 1 : thread_.join(); 53 3 : } 54 : 55 : RAIIThread(RAIIThread&&) = default; 56 1 : RAIIThread& operator=(RAIIThread&&) = default; 57 : 58 : private: 59 : std::thread thread_; 60 : }; 61 : 62 : /* 63 : * @file Test-sip.h 64 : * @brief Regroups unitary tests related to the SIP module 65 : */ 66 : 67 : class test_SIP : public CppUnit::TestFixture 68 : { 69 : public: 70 : /* 71 : * Code factoring - Common resources can be initialized here. 72 : * This method is called by unitcpp before each test 73 : */ 74 : void setUp(); 75 : 76 : /* 77 : * Code factoring - Common resources can be released here. 78 : * This method is called by unitcpp after each test 79 : */ 80 : void tearDown(); 81 : 82 : private: 83 : void testSIPURI(void); 84 : 85 : /** 86 : * Use cppunit library macros to add unit test to the factory 87 : */ 88 2 : CPPUNIT_TEST_SUITE(test_SIP); 89 1 : CPPUNIT_TEST(testSIPURI); 90 4 : CPPUNIT_TEST_SUITE_END(); 91 : 92 : RAIIThread eventLoop_; 93 : std::atomic_bool running_; 94 : };