2021-04-16 17:18:09 -04:00
|
|
|
/*
|
2025-02-06 21:47:26 -04:00
|
|
|
* Copyright (C) 2021-2025 Savoir-faire Linux Inc.
|
2021-04-16 17:18:09 -04:00
|
|
|
*
|
|
|
|
* 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>
|
2021-05-07 10:38:19 -04:00
|
|
|
#include <QStandardPaths>
|
|
|
|
|
2024-08-07 10:37:06 -04:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
#define DATA_DIR "JAMI_DATA_HOME"
|
|
|
|
#define CONFIG_DIR "JAMI_CONFIG_HOME"
|
|
|
|
#define CACHE_DIR "JAMI_CACHE_HOME"
|
|
|
|
#else
|
|
|
|
#define DATA_DIR "XDG_DATA_HOME"
|
|
|
|
#define CONFIG_DIR "XDG_CONFIG_HOME"
|
|
|
|
#define CACHE_DIR "XDG_CACHE_HOME"
|
|
|
|
#endif
|
|
|
|
|
2021-06-15 11:13:22 -04:00
|
|
|
TestEnvironment globalEnv;
|
2021-04-16 17:18:09 -04:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
|
|
|
{
|
2021-07-26 10:46:47 -04:00
|
|
|
QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
|
|
|
|
|
2024-08-07 10:37:06 -04:00
|
|
|
auto jamiDataDir = tempDir.absolutePath() + "/jami_test/jami";
|
|
|
|
auto jamiConfigDir = tempDir.absolutePath() + "/jami_test/.config";
|
|
|
|
auto jamiCacheDir = tempDir.absolutePath() + "/jami_test/.cache";
|
|
|
|
|
|
|
|
// Clean up the temp directories.
|
|
|
|
QDir(jamiDataDir).removeRecursively();
|
|
|
|
QDir(jamiConfigDir).removeRecursively();
|
|
|
|
QDir(jamiCacheDir).removeRecursively();
|
2021-07-26 10:46:47 -04:00
|
|
|
|
2024-08-07 10:37:06 -04:00
|
|
|
bool envSet = qputenv(DATA_DIR, jamiDataDir.toLocal8Bit());
|
|
|
|
envSet &= qputenv(CONFIG_DIR, jamiConfigDir.toLocal8Bit());
|
|
|
|
envSet &= qputenv(CACHE_DIR, jamiCacheDir.toLocal8Bit());
|
2021-07-26 10:46:47 -04:00
|
|
|
if (!envSet)
|
|
|
|
return 1;
|
|
|
|
|
2023-03-29 13:07:51 -04:00
|
|
|
// We likely want to mute the daemon for log clarity.
|
2023-06-27 07:58:48 -04:00
|
|
|
Utils::remove_argument(argv, argc, "--mutejamid", [&]() { globalEnv.muteDaemon = true; });
|
2021-04-16 17:18:09 -04:00
|
|
|
|
2023-03-29 13:07:51 -04:00
|
|
|
// Allow the user to enable fatal warnings for certain tests.
|
|
|
|
Utils::remove_argument(argv, argc, "--failonwarn", [&]() { qputenv("QT_FATAL_WARNINGS", "1"); });
|
2021-04-16 17:18:09 -04:00
|
|
|
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
a.processEvents();
|
2021-06-15 11:13:22 -04:00
|
|
|
|
2021-04-16 17:18:09 -04:00
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
2021-06-15 11:13:22 -04:00
|
|
|
globalEnv.SetUp();
|
|
|
|
auto result = RUN_ALL_TESTS();
|
|
|
|
globalEnv.TearDown();
|
|
|
|
|
|
|
|
return result;
|
2021-04-16 17:18:09 -04:00
|
|
|
}
|