LCOV - code coverage report
Current view: top level - test/sip - test_SIP.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 12 12 100.0 %
Date: 2024-11-15 09:04:49 Functions: 8 8 100.0 %

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

Generated by: LCOV version 1.14