Files
chatterino2/tests/src/main.cpp
nerix 33fa3e0a97 Use New 7TV Cosmetics System (#4512)
* feat(seventv): use new cosmetics system

* chore: add changelog entry

* fix: old `clang-format`

* fix: small suggestions pt1

* refactor: add 7tv api wrapper

* fix: small clang-tidy things

* fix: remove unused constants

* fix: old clangtidy

* refactor: rename

* fix: increase interval to 60s

* fix: newline

* fix: Twitch

* docs: add comment

* fix: remove v2 badges endpoint

* fix: deadlock

This is actually really sad.

* fix: remove api entry

* fix: old clang-format

* Sort functions in SeventvBadges.hpp/cpp

* Remove unused vector include

* Add comments to SeventvBadges.hpp functions

* Rename `addBadge` to `registerBadge`

* fix: cleanup eventloop

* ci(test): add timeout

---------

Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
2023-07-29 09:49:44 +00:00

58 lines
1.5 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());
QTimer::singleShot(0, [&]() {
auto res = RUN_ALL_TESTS();
chatterino::NetworkManager::deinit();
settingsDir.remove();
// Pick up the last events from the eventloop
// Using a loop to catch events queueing other events (e.g. deletions)
for (size_t i = 0; i < 32; i++)
{
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
}
QApplication::exit(res);
});
return QApplication::exec();
#else
return RUN_ALL_TESTS();
#endif
}