mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Move mocks to their own interface (#4645)
This commit is contained in:
parent
5d0bdc195e
commit
e1a6c24cf3
12 changed files with 564 additions and 501 deletions
|
@ -174,6 +174,10 @@ include(cmake/resources/generate_resources.cmake)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
if (BUILD_TESTS OR BUILD_BENCHMARKS)
|
||||||
|
add_subdirectory(mocks)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
|
@ -15,6 +15,7 @@ add_executable(${PROJECT_NAME} ${benchmark_SOURCES})
|
||||||
add_sanitizers(${PROJECT_NAME})
|
add_sanitizers(${PROJECT_NAME})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-mocks)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark)
|
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/highlights/HighlightController.hpp"
|
#include "controllers/highlights/HighlightController.hpp"
|
||||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/SharedMessageBuilder.hpp"
|
#include "messages/SharedMessageBuilder.hpp"
|
||||||
|
#include "mocks/EmptyApplication.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
|
@ -45,65 +46,17 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockApplication : IApplication
|
class MockApplication : mock::EmptyApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Theme *getThemes() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
Fonts *getFonts() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
IEmotes *getEmotes() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
AccountController *getAccounts() override
|
AccountController *getAccounts() override
|
||||||
{
|
{
|
||||||
return &this->accounts;
|
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
|
HighlightController *getHighlights() override
|
||||||
{
|
{
|
||||||
return &this->highlights;
|
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;
|
AccountController accounts;
|
||||||
HighlightController highlights;
|
HighlightController highlights;
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
|
using namespace chatterino;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
::benchmark::Initialize(&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] {
|
QtConcurrent::run([&app] {
|
||||||
::benchmark::RunSpecifiedBenchmarks();
|
::benchmark::RunSpecifiedBenchmarks();
|
||||||
|
|
||||||
|
|
55
mocks/.clang-format
Normal file
55
mocks/.clang-format
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
Language: Cpp
|
||||||
|
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignEscapedNewlinesLeft: true
|
||||||
|
AllowShortFunctionsOnASingleLine: false
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLambdasOnASingleLine: Empty
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: false
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
BasedOnStyle: Google
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: "true"
|
||||||
|
AfterControlStatement: "true"
|
||||||
|
AfterFunction: "true"
|
||||||
|
AfterNamespace: "false"
|
||||||
|
BeforeCatch: "true"
|
||||||
|
BeforeElse: "true"
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakConstructorInitializersBeforeComma: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
DerivePointerBinding: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
SortIncludes: CaseInsensitive
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
# Project includes
|
||||||
|
- Regex: '^"[a-zA-Z\._-]+(/[a-zA-Z0-9\._-]+)*"$'
|
||||||
|
Priority: 1
|
||||||
|
# Third party library includes
|
||||||
|
- Regex: '<[[:alnum:].]+/[a-zA-Z0-9\._\/-]+>'
|
||||||
|
Priority: 3
|
||||||
|
# Qt includes
|
||||||
|
- Regex: '^<Q[a-zA-Z0-9\._\/-]+>$'
|
||||||
|
Priority: 3
|
||||||
|
CaseSensitive: true
|
||||||
|
# LibCommuni includes
|
||||||
|
- Regex: "^<Irc[a-zA-Z]+>$"
|
||||||
|
Priority: 3
|
||||||
|
# Misc libraries
|
||||||
|
- Regex: '^<[a-zA-Z_0-9]+\.h(pp)?>$'
|
||||||
|
Priority: 3
|
||||||
|
# Standard library includes
|
||||||
|
- Regex: "^<[a-zA-Z_]+>$"
|
||||||
|
Priority: 4
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
PointerBindsToType: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
Standard: Auto
|
||||||
|
ReflowComments: false
|
7
mocks/CMakeLists.txt
Normal file
7
mocks/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
project(chatterino-mocks)
|
||||||
|
|
||||||
|
add_library(chatterino-mocks INTERFACE)
|
||||||
|
|
||||||
|
target_include_directories(chatterino-mocks INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE gmock)
|
81
mocks/include/mocks/EmptyApplication.hpp
Normal file
81
mocks/include/mocks/EmptyApplication.hpp
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Application.hpp"
|
||||||
|
|
||||||
|
namespace chatterino::mock {
|
||||||
|
|
||||||
|
class EmptyApplication : public IApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Theme *getThemes() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Fonts *getFonts() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEmotes *getEmotes() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountController *getAccounts() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TwitchIrcServer *getTwitch() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatterinoBadges *getChatterinoBadges() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfzBadges *getFfzBadges() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
IUserDataController *getUserData() override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino::mock
|
396
mocks/include/mocks/Helix.hpp
Normal file
396
mocks/include/mocks/Helix.hpp
Normal file
|
@ -0,0 +1,396 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
|
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace chatterino::mock {
|
||||||
|
|
||||||
|
class Helix : public IHelix
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Helix() = default;
|
||||||
|
|
||||||
|
MOCK_METHOD(void, fetchUsers,
|
||||||
|
(QStringList userIds, QStringList userLogins,
|
||||||
|
ResultCallback<std::vector<HelixUser>> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getUserByName,
|
||||||
|
(QString userName, ResultCallback<HelixUser> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
MOCK_METHOD(void, getUserById,
|
||||||
|
(QString userId, ResultCallback<HelixUser> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, fetchUsersFollows,
|
||||||
|
(QString fromId, QString toId,
|
||||||
|
ResultCallback<HelixUsersFollowsResponse> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getUserFollowers,
|
||||||
|
(QString userId,
|
||||||
|
ResultCallback<HelixUsersFollowsResponse> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, fetchStreams,
|
||||||
|
(QStringList userIds, QStringList userLogins,
|
||||||
|
ResultCallback<std::vector<HelixStream>> successCallback,
|
||||||
|
HelixFailureCallback failureCallback,
|
||||||
|
std::function<void()> finallyCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getStreamById,
|
||||||
|
(QString userId,
|
||||||
|
(ResultCallback<bool, HelixStream> successCallback),
|
||||||
|
HelixFailureCallback failureCallback,
|
||||||
|
std::function<void()> finallyCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getStreamByName,
|
||||||
|
(QString userName,
|
||||||
|
(ResultCallback<bool, HelixStream> successCallback),
|
||||||
|
HelixFailureCallback failureCallback,
|
||||||
|
std::function<void()> finallyCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, fetchGames,
|
||||||
|
(QStringList gameIds, QStringList gameNames,
|
||||||
|
(ResultCallback<std::vector<HelixGame>> successCallback),
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, searchGames,
|
||||||
|
(QString gameName,
|
||||||
|
ResultCallback<std::vector<HelixGame>> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getGameById,
|
||||||
|
(QString gameId, ResultCallback<HelixGame> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, createClip,
|
||||||
|
(QString channelId, ResultCallback<HelixClip> successCallback,
|
||||||
|
std::function<void(HelixClipError)> failureCallback,
|
||||||
|
std::function<void()> finallyCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getChannel,
|
||||||
|
(QString broadcasterId,
|
||||||
|
ResultCallback<HelixChannel> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, createStreamMarker,
|
||||||
|
(QString broadcasterId, QString description,
|
||||||
|
ResultCallback<HelixStreamMarker> successCallback,
|
||||||
|
std::function<void(HelixStreamMarkerError)> failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, loadBlocks,
|
||||||
|
(QString userId,
|
||||||
|
ResultCallback<std::vector<HelixBlock>> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, blockUser,
|
||||||
|
(QString targetUserId, std::function<void()> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, unblockUser,
|
||||||
|
(QString targetUserId, std::function<void()> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, updateChannel,
|
||||||
|
(QString broadcasterId, QString gameId, QString language,
|
||||||
|
QString title,
|
||||||
|
std::function<void(NetworkResult)> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, manageAutoModMessages,
|
||||||
|
(QString userID, QString msgID, QString action,
|
||||||
|
std::function<void()> successCallback,
|
||||||
|
std::function<void(HelixAutoModMessageError)> failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getCheermotes,
|
||||||
|
(QString broadcasterId,
|
||||||
|
ResultCallback<std::vector<HelixCheermoteSet>> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getEmoteSetData,
|
||||||
|
(QString emoteSetId,
|
||||||
|
ResultCallback<HelixEmoteSetData> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, getChannelEmotes,
|
||||||
|
(QString broadcasterId,
|
||||||
|
ResultCallback<std::vector<HelixChannelEmote>> successCallback,
|
||||||
|
HelixFailureCallback failureCallback),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, getGlobalBadges,
|
||||||
|
(ResultCallback<HelixGlobalBadges> successCallback,
|
||||||
|
(FailureCallback<HelixGetGlobalBadgesError, QString> failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, getChannelBadges,
|
||||||
|
(QString broadcasterID,
|
||||||
|
ResultCallback<HelixChannelBadges> successCallback,
|
||||||
|
(FailureCallback<HelixGetChannelBadgesError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateUserChatColor,
|
||||||
|
(QString userID, QString color,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateUserChatColorError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, deleteChatMessages,
|
||||||
|
(QString broadcasterID, QString moderatorID, QString messageID,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixDeleteChatMessagesError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, addChannelModerator,
|
||||||
|
(QString broadcasterID, QString userID,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixAddChannelModeratorError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, removeChannelModerator,
|
||||||
|
(QString broadcasterID, QString userID,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixRemoveChannelModeratorError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, sendChatAnnouncement,
|
||||||
|
(QString broadcasterID, QString moderatorID, QString message,
|
||||||
|
HelixAnnouncementColor color, ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixSendChatAnnouncementError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, addChannelVIP,
|
||||||
|
(QString broadcasterID, QString userID,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixAddChannelVIPError, QString> failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, removeChannelVIP,
|
||||||
|
(QString broadcasterID, QString userID,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixRemoveChannelVIPError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, unbanUser,
|
||||||
|
(QString broadcasterID, QString moderatorID, QString userID,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixUnbanUserError, QString> failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD( // /raid
|
||||||
|
void, startRaid,
|
||||||
|
(QString fromBroadcasterID, QString toBroadcasterId,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixStartRaidError, QString> failureCallback)),
|
||||||
|
(override)); // /raid
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD( // /unraid
|
||||||
|
void, cancelRaid,
|
||||||
|
(QString broadcasterID, ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixCancelRaidError, QString> failureCallback)),
|
||||||
|
(override)); // /unraid
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateEmoteMode,
|
||||||
|
(QString broadcasterID, QString moderatorID, bool emoteMode,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateFollowerMode,
|
||||||
|
(QString broadcasterID, QString moderatorID,
|
||||||
|
boost::optional<int> followerModeDuration,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateNonModeratorChatDelay,
|
||||||
|
(QString broadcasterID, QString moderatorID,
|
||||||
|
boost::optional<int> nonModeratorChatDelayDuration,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateSlowMode,
|
||||||
|
(QString broadcasterID, QString moderatorID,
|
||||||
|
boost::optional<int> slowModeWaitTime,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateSubscriberMode,
|
||||||
|
(QString broadcasterID, QString moderatorID,
|
||||||
|
bool subscriberMode,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateUniqueChatMode,
|
||||||
|
(QString broadcasterID, QString moderatorID,
|
||||||
|
bool uniqueChatMode,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
// update chat settings
|
||||||
|
|
||||||
|
// /timeout, /ban
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, banUser,
|
||||||
|
(QString broadcasterID, QString moderatorID, QString userID,
|
||||||
|
boost::optional<int> duration, QString reason,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixBanUserError, QString> failureCallback)),
|
||||||
|
(override)); // /timeout, /ban
|
||||||
|
|
||||||
|
// /w
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, sendWhisper,
|
||||||
|
(QString fromUserID, QString toUserID, QString message,
|
||||||
|
ResultCallback<> successCallback,
|
||||||
|
(FailureCallback<HelixWhisperError, QString> failureCallback)),
|
||||||
|
(override)); // /w
|
||||||
|
|
||||||
|
// getChatters
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, getChatters,
|
||||||
|
(QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
||||||
|
ResultCallback<HelixChatters> successCallback,
|
||||||
|
(FailureCallback<HelixGetChattersError, QString> failureCallback)),
|
||||||
|
(override)); // getChatters
|
||||||
|
|
||||||
|
// /vips
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, getChannelVIPs,
|
||||||
|
(QString broadcasterID,
|
||||||
|
ResultCallback<std::vector<HelixVip>> successCallback,
|
||||||
|
(FailureCallback<HelixListVIPsError, QString> failureCallback)),
|
||||||
|
(override)); // /vips
|
||||||
|
|
||||||
|
// /commercial
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, startCommercial,
|
||||||
|
(QString broadcasterID, int length,
|
||||||
|
ResultCallback<HelixStartCommercialResponse> successCallback,
|
||||||
|
(FailureCallback<HelixStartCommercialError, QString> failureCallback)),
|
||||||
|
(override)); // /commercial
|
||||||
|
|
||||||
|
// /mods
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, getModerators,
|
||||||
|
(QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
(FailureCallback<HelixGetModeratorsError, QString> failureCallback)),
|
||||||
|
(override)); // /mods
|
||||||
|
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateShieldMode,
|
||||||
|
(QString broadcasterID, QString moderatorID, bool isActive,
|
||||||
|
ResultCallback<HelixShieldModeStatus> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateShieldModeError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
MOCK_METHOD(void, update, (QString clientId, QString oauthToken),
|
||||||
|
(override));
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// The extra parenthesis around the failure callback is because its type
|
||||||
|
// contains a comma
|
||||||
|
MOCK_METHOD(void, updateChatSettings,
|
||||||
|
(QString broadcasterID, QString moderatorID, QJsonObject json,
|
||||||
|
ResultCallback<HelixChatSettings> successCallback,
|
||||||
|
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||||
|
failureCallback)),
|
||||||
|
(override));
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino::mock
|
|
@ -33,6 +33,7 @@ add_executable(${PROJECT_NAME} ${test_SOURCES})
|
||||||
add_sanitizers(${PROJECT_NAME})
|
add_sanitizers(${PROJECT_NAME})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-mocks)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE gtest gmock)
|
target_link_libraries(${PROJECT_NAME} PRIVATE gtest gmock)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||||
#include "messages/MessageBuilder.hpp" // for MessageParseArgs
|
#include "messages/MessageBuilder.hpp" // for MessageParseArgs
|
||||||
|
#include "mocks/EmptyApplication.hpp"
|
||||||
|
#include "mocks/Helix.hpp"
|
||||||
#include "mocks/UserData.hpp"
|
#include "mocks/UserData.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/TwitchBadge.hpp" // for Badge
|
#include "providers/twitch/TwitchBadge.hpp" // for Badge
|
||||||
|
@ -24,61 +26,19 @@ using ::testing::Exactly;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MockApplication : IApplication
|
class MockApplication : mock::EmptyApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Theme *getThemes() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
Fonts *getFonts() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
IEmotes *getEmotes() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
AccountController *getAccounts() override
|
AccountController *getAccounts() override
|
||||||
{
|
{
|
||||||
return &this->accounts;
|
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
|
HighlightController *getHighlights() override
|
||||||
{
|
{
|
||||||
return &this->highlights;
|
return &this->highlights;
|
||||||
}
|
}
|
||||||
TwitchIrcServer *getTwitch() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
ChatterinoBadges *getChatterinoBadges() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
FfzBadges *getFfzBadges() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
IUserDataController *getUserData() override
|
IUserDataController *getUserData() override
|
||||||
{
|
{
|
||||||
return &this->userData;
|
return &this->userData;
|
||||||
|
@ -92,361 +52,6 @@ public:
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class MockHelix : public IHelix
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MOCK_METHOD(void, fetchUsers,
|
|
||||||
(QStringList userIds, QStringList userLogins,
|
|
||||||
ResultCallback<std::vector<HelixUser>> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getUserByName,
|
|
||||||
(QString userName, ResultCallback<HelixUser> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
MOCK_METHOD(void, getUserById,
|
|
||||||
(QString userId, ResultCallback<HelixUser> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, fetchUsersFollows,
|
|
||||||
(QString fromId, QString toId,
|
|
||||||
ResultCallback<HelixUsersFollowsResponse> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getUserFollowers,
|
|
||||||
(QString userId,
|
|
||||||
ResultCallback<HelixUsersFollowsResponse> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, fetchStreams,
|
|
||||||
(QStringList userIds, QStringList userLogins,
|
|
||||||
ResultCallback<std::vector<HelixStream>> successCallback,
|
|
||||||
HelixFailureCallback failureCallback,
|
|
||||||
std::function<void()> finallyCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getStreamById,
|
|
||||||
(QString userId,
|
|
||||||
(ResultCallback<bool, HelixStream> successCallback),
|
|
||||||
HelixFailureCallback failureCallback,
|
|
||||||
std::function<void()> finallyCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getStreamByName,
|
|
||||||
(QString userName,
|
|
||||||
(ResultCallback<bool, HelixStream> successCallback),
|
|
||||||
HelixFailureCallback failureCallback,
|
|
||||||
std::function<void()> finallyCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, fetchGames,
|
|
||||||
(QStringList gameIds, QStringList gameNames,
|
|
||||||
(ResultCallback<std::vector<HelixGame>> successCallback),
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, searchGames,
|
|
||||||
(QString gameName,
|
|
||||||
ResultCallback<std::vector<HelixGame>> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getGameById,
|
|
||||||
(QString gameId, ResultCallback<HelixGame> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, createClip,
|
|
||||||
(QString channelId, ResultCallback<HelixClip> successCallback,
|
|
||||||
std::function<void(HelixClipError)> failureCallback,
|
|
||||||
std::function<void()> finallyCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getChannel,
|
|
||||||
(QString broadcasterId,
|
|
||||||
ResultCallback<HelixChannel> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, createStreamMarker,
|
|
||||||
(QString broadcasterId, QString description,
|
|
||||||
ResultCallback<HelixStreamMarker> successCallback,
|
|
||||||
std::function<void(HelixStreamMarkerError)> failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, loadBlocks,
|
|
||||||
(QString userId,
|
|
||||||
ResultCallback<std::vector<HelixBlock>> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, blockUser,
|
|
||||||
(QString targetUserId, std::function<void()> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, unblockUser,
|
|
||||||
(QString targetUserId, std::function<void()> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, updateChannel,
|
|
||||||
(QString broadcasterId, QString gameId, QString language,
|
|
||||||
QString title,
|
|
||||||
std::function<void(NetworkResult)> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, manageAutoModMessages,
|
|
||||||
(QString userID, QString msgID, QString action,
|
|
||||||
std::function<void()> successCallback,
|
|
||||||
std::function<void(HelixAutoModMessageError)> failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getCheermotes,
|
|
||||||
(QString broadcasterId,
|
|
||||||
ResultCallback<std::vector<HelixCheermoteSet>> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getEmoteSetData,
|
|
||||||
(QString emoteSetId,
|
|
||||||
ResultCallback<HelixEmoteSetData> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, getChannelEmotes,
|
|
||||||
(QString broadcasterId,
|
|
||||||
ResultCallback<std::vector<HelixChannelEmote>> successCallback,
|
|
||||||
HelixFailureCallback failureCallback),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, getGlobalBadges,
|
|
||||||
(ResultCallback<HelixGlobalBadges> successCallback,
|
|
||||||
(FailureCallback<HelixGetGlobalBadgesError, QString> failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, getChannelBadges,
|
|
||||||
(QString broadcasterID,
|
|
||||||
ResultCallback<HelixChannelBadges> successCallback,
|
|
||||||
(FailureCallback<HelixGetChannelBadgesError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateUserChatColor,
|
|
||||||
(QString userID, QString color,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateUserChatColorError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, deleteChatMessages,
|
|
||||||
(QString broadcasterID, QString moderatorID, QString messageID,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixDeleteChatMessagesError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, addChannelModerator,
|
|
||||||
(QString broadcasterID, QString userID,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixAddChannelModeratorError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, removeChannelModerator,
|
|
||||||
(QString broadcasterID, QString userID,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixRemoveChannelModeratorError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, sendChatAnnouncement,
|
|
||||||
(QString broadcasterID, QString moderatorID, QString message,
|
|
||||||
HelixAnnouncementColor color, ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixSendChatAnnouncementError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, addChannelVIP,
|
|
||||||
(QString broadcasterID, QString userID,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixAddChannelVIPError, QString> failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, removeChannelVIP,
|
|
||||||
(QString broadcasterID, QString userID,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixRemoveChannelVIPError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, unbanUser,
|
|
||||||
(QString broadcasterID, QString moderatorID, QString userID,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixUnbanUserError, QString> failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD( // /raid
|
|
||||||
void, startRaid,
|
|
||||||
(QString fromBroadcasterID, QString toBroadcasterId,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixStartRaidError, QString> failureCallback)),
|
|
||||||
(override)); // /raid
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD( // /unraid
|
|
||||||
void, cancelRaid,
|
|
||||||
(QString broadcasterID, ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixCancelRaidError, QString> failureCallback)),
|
|
||||||
(override)); // /unraid
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateEmoteMode,
|
|
||||||
(QString broadcasterID, QString moderatorID, bool emoteMode,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateFollowerMode,
|
|
||||||
(QString broadcasterID, QString moderatorID,
|
|
||||||
boost::optional<int> followerModeDuration,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateNonModeratorChatDelay,
|
|
||||||
(QString broadcasterID, QString moderatorID,
|
|
||||||
boost::optional<int> nonModeratorChatDelayDuration,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateSlowMode,
|
|
||||||
(QString broadcasterID, QString moderatorID,
|
|
||||||
boost::optional<int> slowModeWaitTime,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateSubscriberMode,
|
|
||||||
(QString broadcasterID, QString moderatorID,
|
|
||||||
bool subscriberMode,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateUniqueChatMode,
|
|
||||||
(QString broadcasterID, QString moderatorID,
|
|
||||||
bool uniqueChatMode,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
// update chat settings
|
|
||||||
|
|
||||||
// /timeout, /ban
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, banUser,
|
|
||||||
(QString broadcasterID, QString moderatorID, QString userID,
|
|
||||||
boost::optional<int> duration, QString reason,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixBanUserError, QString> failureCallback)),
|
|
||||||
(override)); // /timeout, /ban
|
|
||||||
|
|
||||||
// /w
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, sendWhisper,
|
|
||||||
(QString fromUserID, QString toUserID, QString message,
|
|
||||||
ResultCallback<> successCallback,
|
|
||||||
(FailureCallback<HelixWhisperError, QString> failureCallback)),
|
|
||||||
(override)); // /w
|
|
||||||
|
|
||||||
// getChatters
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, getChatters,
|
|
||||||
(QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
|
||||||
ResultCallback<HelixChatters> successCallback,
|
|
||||||
(FailureCallback<HelixGetChattersError, QString> failureCallback)),
|
|
||||||
(override)); // getChatters
|
|
||||||
|
|
||||||
// /vips
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, getChannelVIPs,
|
|
||||||
(QString broadcasterID,
|
|
||||||
ResultCallback<std::vector<HelixVip>> successCallback,
|
|
||||||
(FailureCallback<HelixListVIPsError, QString> failureCallback)),
|
|
||||||
(override)); // /vips
|
|
||||||
|
|
||||||
// /commercial
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, startCommercial,
|
|
||||||
(QString broadcasterID, int length,
|
|
||||||
ResultCallback<HelixStartCommercialResponse> successCallback,
|
|
||||||
(FailureCallback<HelixStartCommercialError, QString> failureCallback)),
|
|
||||||
(override)); // /commercial
|
|
||||||
|
|
||||||
// /mods
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(
|
|
||||||
void, getModerators,
|
|
||||||
(QString broadcasterID, int maxModeratorsToFetch,
|
|
||||||
ResultCallback<std::vector<HelixModerator>> successCallback,
|
|
||||||
(FailureCallback<HelixGetModeratorsError, QString> failureCallback)),
|
|
||||||
(override)); // /mods
|
|
||||||
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateShieldMode,
|
|
||||||
(QString broadcasterID, QString moderatorID, bool isActive,
|
|
||||||
ResultCallback<HelixShieldModeStatus> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateShieldModeError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(void, update, (QString clientId, QString oauthToken),
|
|
||||||
(override));
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// The extra parenthesis around the failure callback is because its type contains a comma
|
|
||||||
MOCK_METHOD(void, updateChatSettings,
|
|
||||||
(QString broadcasterID, QString moderatorID, QJsonObject json,
|
|
||||||
ResultCallback<HelixChatSettings> successCallback,
|
|
||||||
(FailureCallback<HelixUpdateChatSettingsError, QString>
|
|
||||||
failureCallback)),
|
|
||||||
(override));
|
|
||||||
};
|
|
||||||
|
|
||||||
static QString DEFAULT_SETTINGS = R"!(
|
static QString DEFAULT_SETTINGS = R"!(
|
||||||
{
|
{
|
||||||
"accounts": {
|
"accounts": {
|
||||||
|
@ -582,7 +187,7 @@ protected:
|
||||||
ASSERT_TRUE(settingsFile.flush());
|
ASSERT_TRUE(settingsFile.flush());
|
||||||
settingsFile.close();
|
settingsFile.close();
|
||||||
|
|
||||||
this->mockHelix = new MockHelix;
|
this->mockHelix = new mock::Helix;
|
||||||
|
|
||||||
initializeHelix(this->mockHelix);
|
initializeHelix(this->mockHelix);
|
||||||
|
|
||||||
|
@ -618,7 +223,7 @@ protected:
|
||||||
|
|
||||||
std::unique_ptr<HighlightController> controller;
|
std::unique_ptr<HighlightController> controller;
|
||||||
|
|
||||||
MockHelix *mockHelix;
|
mock::Helix *mockHelix;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(HighlightControllerTest, A)
|
TEST_F(HighlightControllerTest, A)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
|
#include "mocks/EmptyApplication.hpp"
|
||||||
#include "mocks/UserData.hpp"
|
#include "mocks/UserData.hpp"
|
||||||
#include "providers/twitch/TwitchBadge.hpp"
|
#include "providers/twitch/TwitchBadge.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
|
@ -19,61 +20,13 @@ using namespace chatterino;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MockApplication : IApplication
|
class MockApplication : mock::EmptyApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Theme *getThemes() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
Fonts *getFonts() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
IEmotes *getEmotes() override
|
IEmotes *getEmotes() override
|
||||||
{
|
{
|
||||||
return &this->emotes;
|
return &this->emotes;
|
||||||
}
|
}
|
||||||
AccountController *getAccounts() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
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 nullptr;
|
|
||||||
}
|
|
||||||
TwitchIrcServer *getTwitch() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
ChatterinoBadges *getChatterinoBadges() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
FfzBadges *getFfzBadges() override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
IUserDataController *getUserData() override
|
IUserDataController *getUserData() override
|
||||||
{
|
{
|
||||||
return &this->userData;
|
return &this->userData;
|
||||||
|
|
Loading…
Reference in a new issue