Move mocks to their own interface (#4645)

This commit is contained in:
pajlada
2023-05-20 12:54:50 +02:00
committed by GitHub
parent 5d0bdc195e
commit e1a6c24cf3
12 changed files with 564 additions and 501 deletions
+1
View File
@@ -15,6 +15,7 @@ add_executable(${PROJECT_NAME} ${benchmark_SOURCES})
add_sanitizers(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-mocks)
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark)
+3 -50
View File
@@ -1,11 +1,12 @@
#include "Application.hpp"
#include "singletons/Settings.hpp"
#include "common/Channel.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/highlights/HighlightPhrase.hpp"
#include "messages/Message.hpp"
#include "messages/SharedMessageBuilder.hpp"
#include "mocks/EmptyApplication.hpp"
#include "singletons/Settings.hpp"
#include "util/Helpers.hpp"
#include <benchmark/benchmark.h>
@@ -45,65 +46,17 @@ public:
}
};
class MockApplication : IApplication
class MockApplication : mock::EmptyApplication
{
public:
Theme *getThemes() override
{
return nullptr;
}
Fonts *getFonts() override
{
return nullptr;
}
IEmotes *getEmotes() override
{
return nullptr;
}
AccountController *getAccounts() override
{
return &this->accounts;
}
HotkeyController *getHotkeys() override
{
return nullptr;
}
WindowManager *getWindows() override
{
return nullptr;
}
Toasts *getToasts() override
{
return nullptr;
}
CommandController *getCommands() override
{
return nullptr;
}
NotificationController *getNotifications() override
{
return nullptr;
}
HighlightController *getHighlights() override
{
return &this->highlights;
}
TwitchIrcServer *getTwitch() override
{
return nullptr;
}
ChatterinoBadges *getChatterinoBadges() override
{
return nullptr;
}
FfzBadges *getFfzBadges() override
{
return nullptr;
}
IUserDataController *getUserData() override
{
return nullptr;
}
AccountController accounts;
HighlightController highlights;
+7
View File
@@ -1,13 +1,20 @@
#include "singletons/Settings.hpp"
#include <benchmark/benchmark.h>
#include <QApplication>
#include <QtConcurrent>
using namespace chatterino;
int main(int argc, char **argv)
{
QApplication app(argc, argv);
::benchmark::Initialize(&argc, argv);
// Ensure settings are initialized before any tests are run
chatterino::Settings settings("/tmp/c2-empty-test");
QtConcurrent::run([&app] {
::benchmark::RunSpecifiedBenchmarks();