|
|
|
@ -19,19 +19,15 @@ using namespace matrix::events; |
|
|
|
|
|
|
|
|
|
TEST(MessageEvent, Audio) |
|
|
|
|
{ |
|
|
|
|
auto info = QJsonObject{ |
|
|
|
|
{"duration", 2140786}, |
|
|
|
|
{"mimetype", "audio/mpeg"}, |
|
|
|
|
{"size", 1563688}}; |
|
|
|
|
auto info = |
|
|
|
|
QJsonObject{ { "duration", 2140786 }, { "mimetype", "audio/mpeg" }, { "size", 1563688 } }; |
|
|
|
|
|
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "Bee Gees - Stayin' Alive"}, |
|
|
|
|
auto content = QJsonObject{ { "body", "Bee Gees - Stayin' Alive" }, |
|
|
|
|
{ "msgtype", "m.audio" }, |
|
|
|
|
{ "url", "mxc://localhost/2sdfj23f33r3faad" }, |
|
|
|
|
{ "info", info } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -49,12 +45,9 @@ TEST(MessageEvent, Audio) |
|
|
|
|
|
|
|
|
|
TEST(MessageEvent, Emote) |
|
|
|
|
{ |
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "emote message"}, |
|
|
|
|
{"msgtype", "m.emote"}}; |
|
|
|
|
auto content = QJsonObject{ { "body", "emote message" }, { "msgtype", "m.emote" } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -70,26 +63,21 @@ TEST(MessageEvent, Emote) |
|
|
|
|
TEST(MessageEvent, File) |
|
|
|
|
{ |
|
|
|
|
auto thumbnail_info = QJsonObject{ |
|
|
|
|
{"h", 300}, |
|
|
|
|
{"w", 400}, |
|
|
|
|
{"size", 3432434}, |
|
|
|
|
{"mimetype", "image/jpeg"}}; |
|
|
|
|
{ "h", 300 }, { "w", 400 }, { "size", 3432434 }, { "mimetype", "image/jpeg" } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
auto file_info = QJsonObject{ |
|
|
|
|
{"size", 24242424}, |
|
|
|
|
auto file_info = QJsonObject{ { "size", 24242424 }, |
|
|
|
|
{ "mimetype", "application/msword" }, |
|
|
|
|
{ "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" }, |
|
|
|
|
{ "thumbnail_info", thumbnail_info } }; |
|
|
|
|
|
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "something-important.doc"}, |
|
|
|
|
auto content = QJsonObject{ { "body", "something-important.doc" }, |
|
|
|
|
{ "filename", "something-important.doc" }, |
|
|
|
|
{ "url", "mxc://localhost/23d233d32r3r2r" }, |
|
|
|
|
{ "info", file_info }, |
|
|
|
|
{ "msgtype", "m.file" } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -111,10 +99,7 @@ TEST(MessageEvent, File) |
|
|
|
|
TEST(MessageEvent, Image) |
|
|
|
|
{ |
|
|
|
|
auto thumbinfo = QJsonObject{ |
|
|
|
|
{"h", 11}, |
|
|
|
|
{"w", 22}, |
|
|
|
|
{"size", 212}, |
|
|
|
|
{"mimetype", "img/jpeg"}, |
|
|
|
|
{ "h", 11 }, { "w", 22 }, { "size", 212 }, { "mimetype", "img/jpeg" }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
auto imginfo = QJsonObject{ |
|
|
|
@ -126,14 +111,12 @@ TEST(MessageEvent, Image) |
|
|
|
|
{ "thumbnail_info", thumbinfo }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "Image title"}, |
|
|
|
|
auto content = QJsonObject{ { "body", "Image title" }, |
|
|
|
|
{ "msgtype", "m.image" }, |
|
|
|
|
{ "url", "https://images.com/image.jpg" }, |
|
|
|
|
{ "info", imginfo } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -154,23 +137,18 @@ TEST(MessageEvent, Image) |
|
|
|
|
TEST(MessageEvent, Location) |
|
|
|
|
{ |
|
|
|
|
auto thumbnail_info = QJsonObject{ |
|
|
|
|
{"h", 300}, |
|
|
|
|
{"w", 400}, |
|
|
|
|
{"size", 3432434}, |
|
|
|
|
{"mimetype", "image/jpeg"}}; |
|
|
|
|
{ "h", 300 }, { "w", 400 }, { "size", 3432434 }, { "mimetype", "image/jpeg" } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
auto info = QJsonObject{ |
|
|
|
|
{"thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3"}, |
|
|
|
|
auto info = QJsonObject{ { "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" }, |
|
|
|
|
{ "thumbnail_info", thumbnail_info } }; |
|
|
|
|
|
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "Big Ben, London, UK"}, |
|
|
|
|
auto content = QJsonObject{ { "body", "Big Ben, London, UK" }, |
|
|
|
|
{ "geo_uri", "geo:51.5008,0.1247" }, |
|
|
|
|
{ "info", info }, |
|
|
|
|
{ "msgtype", "m.location" } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -189,12 +167,9 @@ TEST(MessageEvent, Location) |
|
|
|
|
|
|
|
|
|
TEST(MessageEvent, Notice) |
|
|
|
|
{ |
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "notice message"}, |
|
|
|
|
{"msgtype", "m.notice"}}; |
|
|
|
|
auto content = QJsonObject{ { "body", "notice message" }, { "msgtype", "m.notice" } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -209,12 +184,9 @@ TEST(MessageEvent, Notice) |
|
|
|
|
|
|
|
|
|
TEST(MessageEvent, Text) |
|
|
|
|
{ |
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "text message"}, |
|
|
|
|
{"msgtype", "m.text"}}; |
|
|
|
|
auto content = QJsonObject{ { "body", "text message" }, { "msgtype", "m.text" } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -230,13 +202,10 @@ TEST(MessageEvent, Text) |
|
|
|
|
TEST(MessageEvent, Video) |
|
|
|
|
{ |
|
|
|
|
auto thumbnail_info = QJsonObject{ |
|
|
|
|
{"h", 300}, |
|
|
|
|
{"w", 400}, |
|
|
|
|
{"size", 3432434}, |
|
|
|
|
{"mimetype", "image/jpeg"}}; |
|
|
|
|
{ "h", 300 }, { "w", 400 }, { "size", 3432434 }, { "mimetype", "image/jpeg" } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
auto video_info = QJsonObject{ |
|
|
|
|
{"h", 222}, |
|
|
|
|
auto video_info = QJsonObject{ { "h", 222 }, |
|
|
|
|
{ "w", 333 }, |
|
|
|
|
{ "duration", 232323 }, |
|
|
|
|
{ "size", 24242424 }, |
|
|
|
@ -244,14 +213,12 @@ TEST(MessageEvent, Video) |
|
|
|
|
{ "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" }, |
|
|
|
|
{ "thumbnail_info", thumbnail_info } }; |
|
|
|
|
|
|
|
|
|
auto content = QJsonObject{ |
|
|
|
|
{"body", "Gangnam Style"}, |
|
|
|
|
auto content = QJsonObject{ { "body", "Gangnam Style" }, |
|
|
|
|
{ "url", "mxc://localhost/23d233d32r3r2r" }, |
|
|
|
|
{ "info", video_info }, |
|
|
|
|
{ "msgtype", "m.video" } }; |
|
|
|
|
|
|
|
|
|
auto event = QJsonObject{ |
|
|
|
|
{"content", content}, |
|
|
|
|
auto event = QJsonObject{ { "content", content }, |
|
|
|
|
{ "event_id", "$asdfafdf8af:matrix.org" }, |
|
|
|
|
{ "room_id", "!aasdfaeae23r9:matrix.org" }, |
|
|
|
|
{ "sender", "@alice:matrix.org" }, |
|
|
|
@ -272,39 +239,48 @@ TEST(MessageEvent, Video) |
|
|
|
|
|
|
|
|
|
TEST(MessageEvent, Types) |
|
|
|
|
{ |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.audio" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Audio); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.emote" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Emote); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.file" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::File); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.image" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Image); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.location" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Location); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.notice" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Notice); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.text" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Text); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.video" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Video); |
|
|
|
|
EXPECT_EQ(extractMessageEventType(QJsonObject{ |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
extractMessageEventType(QJsonObject{ |
|
|
|
|
{ "content", QJsonObject{ { "msgtype", "m.random" } } }, { "type", "m.room.message" }, |
|
|
|
|
}), |
|
|
|
|
MessageEventType::Unknown); |
|
|
|
|