mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-04-21 21:52:03 +02:00

Cf. https://review.jami.net/c/jami-daemon/+/29901 Change-Id: I46a0d1297c2e60ca43dc5524fd6e8a192bc45139
89 lines
2.9 KiB
C++
89 lines
2.9 KiB
C++
/*
|
|
* Copyright (C) 2021-2025 Savoir-faire Linux Inc.
|
|
*
|
|
* 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, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "globaltestenvironment.h"
|
|
|
|
/*!
|
|
* Test fixture for AccountAdapter testing
|
|
*/
|
|
class AccountFixture : public ::testing::Test
|
|
{
|
|
public:
|
|
// Prepare unit test context. Called at
|
|
// prior each unit test execution
|
|
void SetUp() override {}
|
|
|
|
// Close unit test context. Called
|
|
// after each unit test ending
|
|
void TearDown() override {}
|
|
};
|
|
|
|
/*!
|
|
* WHEN There is no account initially.
|
|
* THEN Account list should be empty.
|
|
*/
|
|
TEST_F(AccountFixture, InitialAccountListCheck)
|
|
{
|
|
auto accountListSize = globalEnv.lrcInstance->accountModel().getAccountCount();
|
|
|
|
ASSERT_EQ(accountListSize, 0);
|
|
}
|
|
|
|
/*!
|
|
* WHEN An SIP account is created.
|
|
* THEN The size of the account list should be one.
|
|
*/
|
|
TEST_F(AccountFixture, CreateSIPAccountTest)
|
|
{
|
|
// AccountAdded signal spy
|
|
QSignalSpy accountAddedSpy(&globalEnv.lrcInstance->accountModel(), &AccountModel::accountAdded);
|
|
|
|
// Create SIP Acc
|
|
globalEnv.accountAdapter->createSIPAccount(QVariantMap());
|
|
|
|
accountAddedSpy.wait();
|
|
EXPECT_EQ(accountAddedSpy.count(), 1);
|
|
|
|
QList<QVariant> accountAddedArguments = accountAddedSpy.takeFirst();
|
|
EXPECT_TRUE(accountAddedArguments.at(0).typeId() == qMetaTypeId<QString>());
|
|
|
|
// Select the created account
|
|
globalEnv.lrcInstance->set_currentAccountId(accountAddedArguments.at(0).toString());
|
|
|
|
auto accountListSize = globalEnv.lrcInstance->accountModel().getAccountCount();
|
|
ASSERT_EQ(accountListSize, 1);
|
|
|
|
// Make sure the account setup is done
|
|
QSignalSpy accountStatusChangedSpy(&globalEnv.lrcInstance->accountModel(),
|
|
&AccountModel::accountStatusChanged);
|
|
|
|
accountStatusChangedSpy.wait();
|
|
EXPECT_GE(accountStatusChangedSpy.count(), 1);
|
|
|
|
// Remove the account
|
|
QSignalSpy accountRemovedSpy(&globalEnv.lrcInstance->accountModel(),
|
|
&AccountModel::accountRemoved);
|
|
|
|
globalEnv.lrcInstance->accountModel().removeAccount(
|
|
globalEnv.lrcInstance->get_currentAccountId());
|
|
|
|
accountRemovedSpy.wait();
|
|
EXPECT_EQ(accountRemovedSpy.count(), 1);
|
|
|
|
accountListSize = globalEnv.lrcInstance->accountModel().getAccountCount();
|
|
ASSERT_EQ(accountListSize, 0);
|
|
}
|