1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-04-21 21:52:03 +02:00
jami-client-qt/tests/unittests/main_unittest.cpp
Amin Bandali 8d46acedf1 misc: Update copyright years to 2023
Change-Id: Idf38e82631a4e22540aa5dec8ec2db0ab4a38c2e
2023-02-06 01:47:15 -05:00

64 lines
2.1 KiB
C++

/*
* Copyright (C) 2021-2023 Savoir-faire Linux Inc.
* Author: Albert Babí Oller <albert.babi@savoirfairelinux.com>
* Author: Mingrui Zhang <mingrui.zhang@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, see <https://www.gnu.org/licenses/>.
*/
#include "globaltestenvironment.h"
#include <QApplication>
#include <QStandardPaths>
TestEnvironment globalEnv;
int
main(int argc, char* argv[])
{
QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
auto jamiDataDir = tempDir.absolutePath() + "\\jami_test\\jami";
auto jamiConfigDir = tempDir.absolutePath() + "\\jami_test\\.config";
auto jamiCacheDir = tempDir.absolutePath() + "\\jami_test\\.cache";
bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit());
envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit());
envSet &= qputenv("JAMI_CACHE_HOME", jamiCacheDir.toLocal8Bit());
if (!envSet)
return 1;
// Remove "-mutejamid" from argv, as quick_test_main_with_setup() will
// fail if given an invalid command-line argument.
auto end = std::remove_if(argv + 1, argv + argc, [](char* argv) {
return (strcmp(argv, "-mutejamid") == 0);
});
if (end != argv + argc) {
globalEnv.muteDring = true;
// Adjust the argument count.
argc = std::distance(argv, end);
}
QApplication a(argc, argv);
a.processEvents();
::testing::InitGoogleTest(&argc, argv);
globalEnv.SetUp();
auto result = RUN_ALL_TESTS();
globalEnv.TearDown();
return result;
}