mirror-chatterino2/tests/src/main.cpp
nerix 1bc423d9c4
Make tests more platform agnostic (#4650)
Use QTemporaryDir to create the test directory
Add option to use httpbin over local docker
Increase delay for opening a connection

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
2023-05-26 12:54:23 +00:00

49 lines
1.1 KiB
C++

#include "common/NetworkManager.hpp"
#include "singletons/Settings.hpp"
#include <gtest/gtest.h>
#include <QApplication>
#include <QJsonArray>
#include <QLoggingCategory>
#include <QtConcurrent>
#include <QTimer>
#include <chrono>
#include <thread>
using namespace chatterino;
#define SUPPORT_QT_NETWORK_TESTS
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
#ifdef SUPPORT_QT_NETWORK_TESTS
QApplication app(argc, argv);
// make sure to always debug-log
QLoggingCategory::setFilterRules("*.debug=true");
chatterino::NetworkManager::init();
// Ensure settings are initialized before any tests are run
QTemporaryDir settingsDir;
settingsDir.setAutoRemove(false); // we'll remove it manually
qDebug() << "Settings directory:" << settingsDir.path();
chatterino::Settings settings(settingsDir.path());
QtConcurrent::run([&app, &settingsDir]() mutable {
auto res = RUN_ALL_TESTS();
chatterino::NetworkManager::deinit();
settingsDir.remove();
app.exit(res);
});
return app.exec();
#else
return RUN_ALL_TESTS();
#endif
}