aboutsummaryrefslogtreecommitdiff
path: root/quotest
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-06 22:17:55 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-08 17:43:58 +0200
commite7a4b5a545b0f59b95ca8097009dbf6eea534db1 (patch)
treea46e434c077cba00307053169b856142304e5e41 /quotest
parent41f630cf7be6e806e498cb31711f403bf6919ff8 (diff)
downloadlibquotient-e7a4b5a545b0f59b95ca8097009dbf6eea534db1.tar.gz
libquotient-e7a4b5a545b0f59b95ca8097009dbf6eea534db1.zip
Generalise DEFINE_SIMPLE_EVENT
This macro was defined in accountdataevents.h but adding one more parameter (base class) makes it applicable to pretty much any event with the content that has one key-value pair (though state events already have a non-macro solution in the form of `StateEvent<EventContent::SingleKeyValue>`). Now CustomEvent definition in quotest.cpp can be replaced with a single line.
Diffstat (limited to 'quotest')
-rw-r--r--quotest/quotest.cpp18
1 files changed, 1 insertions, 17 deletions
diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp
index 861cfba0..b14442b9 100644
--- a/quotest/quotest.cpp
+++ b/quotest/quotest.cpp
@@ -523,23 +523,7 @@ bool TestSuite::checkFileSendingOutcome(const TestToken& thisTest,
return true;
}
-class CustomEvent : public RoomEvent {
-public:
- DEFINE_EVENT_TYPEID("quotest.custom", CustomEvent)
-
- CustomEvent(const QJsonObject& jo)
- : RoomEvent(typeId(), jo)
- {}
- CustomEvent(int testValue)
- : RoomEvent(TypeId,
- Event::basicJson(TypeId,
- QJsonObject { { "testValue"_ls,
- toJson(testValue) } }))
- {}
-
- auto testValue() const { return contentPart<int>("testValue"_ls); }
-};
-REGISTER_EVENT_TYPE(CustomEvent)
+DEFINE_SIMPLE_EVENT(CustomEvent, RoomEvent, "quotest.custom", int, testValue)
TEST_IMPL(sendCustomEvent)
{