Skip to content
Snippets Groups Projects
Commit 193ef339 authored by Sébastien Blin's avatar Sébastien Blin Committed by Nicolas Jager
Browse files

tests: add tests for newcallmodel


Change-Id: Idf704fca78065ba0db7824e55df66642fdc1d4c3
Reviewed-by: default avatarNicolas Jäger <nicolas.jager@savoirfairelinux.com>
parent a7e3fb50
No related branches found
No related tags found
No related merge requests found
...@@ -881,6 +881,8 @@ IF((${ENABLE_TEST} MATCHES true)) ...@@ -881,6 +881,8 @@ IF((${ENABLE_TEST} MATCHES true))
test/conversationmodeltester.cpp test/conversationmodeltester.cpp
test/contactmodeltester.h test/contactmodeltester.h
test/contactmodeltester.cpp test/contactmodeltester.cpp
test/newcallmodeltester.h
test/newcallmodeltester.cpp
${libringclient_LIB_SRCS} ${libringclient_LIB_SRCS}
${libringclient_PRIVATE_HDRS} ${libringclient_PRIVATE_HDRS}
) )
......
...@@ -54,8 +54,8 @@ public: ...@@ -54,8 +54,8 @@ public:
public Q_SLOTS: // METHODS public Q_SLOTS: // METHODS
bool accept(const QString &callID) bool accept(const QString &callID)
{ {
Q_UNUSED(callID) emit callStateChanged(callID, "CURRENT", -1);
return false; return true;
} }
bool addMainParticipant(const QString &confID) bool addMainParticipant(const QString &confID)
...@@ -143,8 +143,8 @@ public Q_SLOTS: // METHODS ...@@ -143,8 +143,8 @@ public Q_SLOTS: // METHODS
bool hangUp(const QString &callID) bool hangUp(const QString &callID)
{ {
Q_UNUSED(callID) emit callStateChanged(callID, "OVER", -1);
return false; return true;
} }
bool hangUpConference(const QString &confID) bool hangUpConference(const QString &confID)
...@@ -155,8 +155,8 @@ public Q_SLOTS: // METHODS ...@@ -155,8 +155,8 @@ public Q_SLOTS: // METHODS
bool hold(const QString &callID) bool hold(const QString &callID)
{ {
Q_UNUSED(callID) emit callStateChanged(callID, "HOLD", -1);
return false; return true;
} }
bool holdConference(const QString &confID) bool holdConference(const QString &confID)
...@@ -245,8 +245,8 @@ public Q_SLOTS: // METHODS ...@@ -245,8 +245,8 @@ public Q_SLOTS: // METHODS
bool unhold(const QString &callID) bool unhold(const QString &callID)
{ {
Q_UNUSED(callID) emit callStateChanged(callID, "CURRENT", -1);
return false; return true;
} }
bool unholdConference(const QString &confID) bool unholdConference(const QString &confID)
...@@ -272,6 +272,11 @@ public Q_SLOTS: // METHODS ...@@ -272,6 +272,11 @@ public Q_SLOTS: // METHODS
{ {
} }
void emitIncomingCall(const QString &accountID, const QString &callID, const QString &from)
{
emit incomingCall(accountID, callID, from);
}
Q_SIGNALS: // SIGNALS Q_SIGNALS: // SIGNALS
void callStateChanged(const QString &callID, const QString &state, int code); void callStateChanged(const QString &callID, const QString &state, int code);
void transferFailed(); void transferFailed();
......
...@@ -142,8 +142,9 @@ public Q_SLOTS: // METHODS ...@@ -142,8 +142,9 @@ public Q_SLOTS: // METHODS
QStringList getAccountList() QStringList getAccountList()
{ {
auto accountList = QStringList(); auto accountList = QStringList();
accountList << QString("ring0"); accountList << QString("ring0"); // Used in conversationmodeltester
accountList << QString("ring1"); accountList << QString("ring1"); // Used in contactmodeltester
accountList << QString("ring2"); // Used in newcallmodeltester
accountList << QString("sip0"); accountList << QString("sip0");
accountList << QString("sip1"); accountList << QString("sip1");
return accountList; return accountList;
......
/*
* Copyright (C) 2017 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::testAcceptHoldUnholdHangupCall()
{
std::string callId = "ring:contact1";
CallManager::instance().emitIncomingCall("ring2", callId.c_str(), "ring:contact1");
WaitForSignalHelper(*accInfo_.callModel,
SIGNAL(newIncomingCall(const std::string& callId, const std::string& fromId))).wait(1000);
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
/*
* Copyright (C) 2017 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.
*/
#pragma once
// cppunit
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
// std
#include <memory>
// Qt
#include <QObject>
// lrc
#include "api/lrc.h"
#include "api/account.h"
namespace ring
{
namespace test
{
class NewCallModelTester : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(NewCallModelTester);
CPPUNIT_TEST(testCreateAndGetCall);
CPPUNIT_TEST(testAcceptHoldUnholdHangupCall);
CPPUNIT_TEST_SUITE_END();
public:
NewCallModelTester();
/**
* Method automatically called before each test by CppUnit
*/
void setUp();
/**
* Create a call between "ring2" and "contact0" and retrieve it.
*/
void testCreateAndGetCall();
/**
* Simulate an incoming call from "contact1" for "ring2"
* Accept the call, call status should be IN_PROGRESS
* Hold the call, call status should be HOLD
* Unhold the call, call status should be IN_PROGRESS
* then hangUp.
*/
void testAcceptHoldUnholdHangupCall();
/**
* Method automatically called after each test by CppUnit
*/
void tearDown();
protected:
std::unique_ptr<lrc::api::Lrc> lrc_;
const lrc::api::account::Info& accInfo_;
};
} // namespace test
} // namespace ring
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment