Skip to content
Snippets Groups Projects
Select Git revision
  • caabdcd29a1089571d7948a3273b60499b365fd9
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/releaseTest
  • release/releaseWindowsTest
  • release/windowsReleaseTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 1.0.0
  • 0.3.0
  • 0.2.1
  • 0.2.0
  • 0.1.0
26 results

newcallmodeltester.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    newcallmodeltester.cpp 3.58 KiB
    /*
     *  Copyright (C) 2017-2018 Savoir-faire Linux Inc.
     *  Author: Sébastien Blin <sebastien.blin@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 "newcallmodeltester.h"
    
    // Qt
    #include <QString>
    #include "utils/waitforsignalhelper.h"
    
    // Lrc
    #include <api/newaccountmodel.h>
    #include <api/newcallmodel.h>
    #include <api/conversationmodel.h>
    #include <api/call.h>
    #include <dbus/callmanager.h>
    
    namespace ring
    {
    namespace test
    {
    
    CPPUNIT_TEST_SUITE_REGISTRATION(NewCallModelTester);
    
    NewCallModelTester::NewCallModelTester()
    : lrc_(new lrc::api::Lrc())
    , accInfo_(lrc_->getAccountModel().getAccountInfo("ring2"))
    {
    
    }
    
    void
    NewCallModelTester::setUp()
    {
    
    }
    
    void
    NewCallModelTester::testCreateAndGetCall()
    {
        auto callId = accInfo_.callModel->createCall("ring:contact0");
        CPPUNIT_ASSERT(!callId.empty());
        CPPUNIT_ASSERT(accInfo_.callModel->hasCall(callId));
        auto& call = accInfo_.callModel->getCallFromURI("ring:contact0");
        auto& callFromId = accInfo_.callModel->getCall(call.id);
        CPPUNIT_ASSERT_EQUAL(callFromId.peer, std::string("ring:contact0"));
    }
    
    void
    NewCallModelTester::testCreateAndGetAudioOnlyCall()
    {
        auto callId = accInfo_.callModel->createCall("ring:contact0", true);
        CPPUNIT_ASSERT(!callId.empty());
        CPPUNIT_ASSERT(accInfo_.callModel->hasCall(callId));
        auto& call = accInfo_.callModel->getCallFromURI("ring:contact0");
        auto& callFromId = accInfo_.callModel->getCall(call.id);
        CPPUNIT_ASSERT_EQUAL(callFromId.peer, std::string("ring:contact0"));
    }
    
    void
    NewCallModelTester::testAcceptHoldUnholdHangupCall()
    {
        std::string callId = "ring:contact1";
    
        auto incomingCallSigsCaught = WaitForSignalHelper([&]() {
                CallManager::instance().emitIncomingCall("ring2", callId.c_str(), "ring:contact1");
            })
            .addSignal("newIncomingCall", *accInfo_.callModel, SIGNAL(newIncomingCall(const std::string&, const std::string&)))
            .wait(1000);
        CPPUNIT_ASSERT_EQUAL(incomingCallSigsCaught["newIncomingCall"], 1);
    
        CPPUNIT_ASSERT(accInfo_.callModel->hasCall(callId));
        accInfo_.callModel->accept(callId);
        auto& call = accInfo_.callModel->getCallFromURI("ring:contact1");
        CPPUNIT_ASSERT_EQUAL((int)call.status, (int)lrc::api::call::Status::IN_PROGRESS);
        accInfo_.callModel->togglePause(callId);
        auto& callHold = accInfo_.callModel->getCallFromURI("ring:contact1");
        CPPUNIT_ASSERT_EQUAL((int)callHold.status, (int)lrc::api::call::Status::PAUSED);
        accInfo_.callModel->togglePause(callId);
        auto& callUnhold = accInfo_.callModel->getCallFromURI("ring:contact1");
        CPPUNIT_ASSERT_EQUAL((int)callUnhold.status, (int)lrc::api::call::Status::IN_PROGRESS);
        accInfo_.callModel->hangUp(callId);
        auto& callOver = accInfo_.callModel->getCallFromURI("ring:contact1");
        CPPUNIT_ASSERT_EQUAL((int)callOver.status, (int)lrc::api::call::Status::ENDED);
    }
    
    
    void
    NewCallModelTester::tearDown()
    {
    
    }
    
    } // namespace test
    } // namespace ring