remotes/origin/HEAD
Konstantinos Sideris 7 years ago
parent 37ff1398b7
commit 9def76aa08
  1. 4
      src/MainWindow.cc
  2. 150
      tests/event_collection.cc
  3. 813
      tests/events.cc
  4. 490
      tests/message_events.cc

@ -18,12 +18,12 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "Config.h" #include "Config.h"
#include <QApplication>
#include <QLayout> #include <QLayout>
#include <QNetworkReply> #include <QNetworkReply>
#include <QSettings> #include <QSettings>
#include <QSystemTrayIcon>
#include <QShortcut> #include <QShortcut>
#include <QApplication> #include <QSystemTrayIcon>
MainWindow *MainWindow::instance_ = nullptr; MainWindow *MainWindow::instance_ = nullptr;

@ -22,94 +22,90 @@ using namespace matrix::events;
TEST(EventCollection, Deserialize) TEST(EventCollection, Deserialize)
{ {
auto events = QJsonArray{ auto events = QJsonArray{
QJsonObject{ QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } },
{"content", QJsonObject{{"name", "Name"}}}, { "event_id", "$asdfafdf8af:matrix.org" },
{"event_id", "$asdfafdf8af:matrix.org"}, { "prev_content", QJsonObject{ { "name", "Previous Name" } } },
{"prev_content", QJsonObject{{"name", "Previous Name"}}}, { "room_id", "!aasdfaeae23r9:matrix.org" },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "sender", "@alice:matrix.org" },
{"sender", "@alice:matrix.org"}, { "origin_server_ts", 1323238293289323LL },
{"origin_server_ts", 1323238293289323LL}, { "state_key", "" },
{"state_key", ""}, { "type", "m.room.name" } },
{"type", "m.room.name"}}, QJsonObject{ { "content", QJsonObject{ { "topic", "Topic" } } },
QJsonObject{ { "event_id", "$asdfafdf8af:matrix.org" },
{"content", QJsonObject{{"topic", "Topic"}}}, { "prev_content", QJsonObject{ { "topic", "Previous Topic" } } },
{"event_id", "$asdfafdf8af:matrix.org"}, { "room_id", "!aasdfaeae23r9:matrix.org" },
{"prev_content", QJsonObject{{"topic", "Previous Topic"}}}, { "state_key", "" },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "sender", "@alice:matrix.org" },
{"state_key", ""}, { "origin_server_ts", 1323238293289323LL },
{"sender", "@alice:matrix.org"}, { "type", "m.room.topic" } },
{"origin_server_ts", 1323238293289323LL}, };
{"type", "m.room.topic"}},
};
for (const auto &event : events) { for (const auto &event : events) {
EventType ty = extractEventType(event.toObject()); EventType ty = extractEventType(event.toObject());
if (ty == EventType::RoomName) { if (ty == EventType::RoomName) {
StateEvent<NameEventContent> name_event; StateEvent<NameEventContent> name_event;
name_event.deserialize(event); name_event.deserialize(event);
EXPECT_EQ(name_event.content().name(), "Name"); EXPECT_EQ(name_event.content().name(), "Name");
EXPECT_EQ(name_event.previousContent().name(), "Previous Name"); EXPECT_EQ(name_event.previousContent().name(), "Previous Name");
} else if (ty == EventType::RoomTopic) { } else if (ty == EventType::RoomTopic) {
StateEvent<TopicEventContent> topic_event; StateEvent<TopicEventContent> topic_event;
topic_event.deserialize(event); topic_event.deserialize(event);
EXPECT_EQ(topic_event.content().topic(), "Topic"); EXPECT_EQ(topic_event.content().topic(), "Topic");
EXPECT_EQ(topic_event.previousContent().topic(), "Previous Topic"); EXPECT_EQ(topic_event.previousContent().topic(), "Previous Topic");
} else { } else {
ASSERT_EQ(false, true); ASSERT_EQ(false, true);
} }
} }
} }
TEST(EventCollection, DeserializationException) TEST(EventCollection, DeserializationException)
{ {
// Using wrong event types. // Using wrong event types.
auto events = QJsonArray{ auto events = QJsonArray{
QJsonObject{ QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } },
{"content", QJsonObject{{"name", "Name"}}}, { "event_id", "$asdfafdf8af:matrix.org" },
{"event_id", "$asdfafdf8af:matrix.org"}, { "prev_content", QJsonObject{ { "name", "Previous Name" } } },
{"prev_content", QJsonObject{{"name", "Previous Name"}}}, { "room_id", "!aasdfaeae23r9:matrix.org" },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "sender", "@alice:matrix.org" },
{"sender", "@alice:matrix.org"}, { "origin_server_ts", 1323238293289323LL },
{"origin_server_ts", 1323238293289323LL}, { "state_key", "" },
{"state_key", ""}, { "type", "m.room.topic" } },
{"type", "m.room.topic"}}, QJsonObject{ { "content", QJsonObject{ { "topic", "Topic" } } },
QJsonObject{ { "event_id", "$asdfafdf8af:matrix.org" },
{"content", QJsonObject{{"topic", "Topic"}}}, { "prev_content", QJsonObject{ { "topic", "Previous Topic" } } },
{"event_id", "$asdfafdf8af:matrix.org"}, { "room_id", "!aasdfaeae23r9:matrix.org" },
{"prev_content", QJsonObject{{"topic", "Previous Topic"}}}, { "state_key", "" },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "sender", "@alice:matrix.org" },
{"state_key", ""}, { "origin_server_ts", 1323238293289323LL },
{"sender", "@alice:matrix.org"}, { "type", "m.room.name" } },
{"origin_server_ts", 1323238293289323LL}, };
{"type", "m.room.name"}},
};
for (const auto &event : events) { for (const auto &event : events) {
EventType ty = extractEventType(event.toObject()); EventType ty = extractEventType(event.toObject());
if (ty == EventType::RoomName) { if (ty == EventType::RoomName) {
StateEvent<NameEventContent> name_event; StateEvent<NameEventContent> name_event;
try { try {
name_event.deserialize(event); name_event.deserialize(event);
} catch (const DeserializationException &e) { } catch (const DeserializationException &e) {
ASSERT_STREQ("name key is missing", e.what()); ASSERT_STREQ("name key is missing", e.what());
} }
} else if (ty == EventType::RoomTopic) { } else if (ty == EventType::RoomTopic) {
StateEvent<TopicEventContent> topic_event; StateEvent<TopicEventContent> topic_event;
try { try {
topic_event.deserialize(event); topic_event.deserialize(event);
} catch (const DeserializationException &e) { } catch (const DeserializationException &e) {
ASSERT_STREQ("topic key is missing", e.what()); ASSERT_STREQ("topic key is missing", e.what());
} }
} else { } else {
ASSERT_EQ(false, true); ASSERT_EQ(false, true);
} }
} }
} }

File diff suppressed because it is too large Load Diff

@ -19,293 +19,269 @@ using namespace matrix::events;
TEST(MessageEvent, Audio) TEST(MessageEvent, Audio)
{ {
auto info = QJsonObject{ auto info =
{"duration", 2140786}, QJsonObject{ { "duration", 2140786 }, { "mimetype", "audio/mpeg" }, { "size", 1563688 } };
{"mimetype", "audio/mpeg"},
{"size", 1563688}}; auto content = QJsonObject{ { "body", "Bee Gees - Stayin' Alive" },
{ "msgtype", "m.audio" },
auto content = QJsonObject{ { "url", "mxc://localhost/2sdfj23f33r3faad" },
{"body", "Bee Gees - Stayin' Alive"}, { "info", info } };
{"msgtype", "m.audio"},
{"url", "mxc://localhost/2sdfj23f33r3faad"}, auto event = QJsonObject{ { "content", content },
{"info", info}}; { "event_id", "$asdfafdf8af:matrix.org" },
{ "room_id", "!aasdfaeae23r9:matrix.org" },
auto event = QJsonObject{ { "sender", "@alice:matrix.org" },
{"content", content}, { "origin_server_ts", 1323238293289323LL },
{"event_id", "$asdfafdf8af:matrix.org"}, { "type", "m.room.message" } };
{"room_id", "!aasdfaeae23r9:matrix.org"},
{"sender", "@alice:matrix.org"}, MessageEvent<messages::Audio> audio;
{"origin_server_ts", 1323238293289323LL}, audio.deserialize(event);
{"type", "m.room.message"}};
EXPECT_EQ(audio.msgContent().info().duration, 2140786);
MessageEvent<messages::Audio> audio; EXPECT_EQ(audio.msgContent().info().size, 1563688);
audio.deserialize(event); EXPECT_EQ(audio.msgContent().info().mimetype, "audio/mpeg");
EXPECT_EQ(audio.content().body(), "Bee Gees - Stayin' Alive");
EXPECT_EQ(audio.msgContent().info().duration, 2140786);
EXPECT_EQ(audio.msgContent().info().size, 1563688);
EXPECT_EQ(audio.msgContent().info().mimetype, "audio/mpeg");
EXPECT_EQ(audio.content().body(), "Bee Gees - Stayin' Alive");
} }
TEST(MessageEvent, Emote) TEST(MessageEvent, Emote)
{ {
auto content = QJsonObject{ auto content = QJsonObject{ { "body", "emote message" }, { "msgtype", "m.emote" } };
{"body", "emote message"},
{"msgtype", "m.emote"}}; auto event = QJsonObject{ { "content", content },
{ "event_id", "$asdfafdf8af:matrix.org" },
auto event = QJsonObject{ { "room_id", "!aasdfaeae23r9:matrix.org" },
{"content", content}, { "sender", "@alice:matrix.org" },
{"event_id", "$asdfafdf8af:matrix.org"}, { "origin_server_ts", 1323238293289323LL },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "type", "m.room.message" } };
{"sender", "@alice:matrix.org"},
{"origin_server_ts", 1323238293289323LL}, MessageEvent<messages::Emote> emote;
{"type", "m.room.message"}}; emote.deserialize(event);
MessageEvent<messages::Emote> emote; EXPECT_EQ(emote.content().body(), "emote message");
emote.deserialize(event);
EXPECT_EQ(emote.content().body(), "emote message");
} }
TEST(MessageEvent, File) TEST(MessageEvent, File)
{ {
auto thumbnail_info = QJsonObject{ auto thumbnail_info = QJsonObject{
{"h", 300}, { "h", 300 }, { "w", 400 }, { "size", 3432434 }, { "mimetype", "image/jpeg" }
{"w", 400}, };
{"size", 3432434},
{"mimetype", "image/jpeg"}}; auto file_info = QJsonObject{ { "size", 24242424 },
{ "mimetype", "application/msword" },
auto file_info = QJsonObject{ { "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
{"size", 24242424}, { "thumbnail_info", thumbnail_info } };
{"mimetype", "application/msword"},
{"thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3"}, auto content = QJsonObject{ { "body", "something-important.doc" },
{"thumbnail_info", thumbnail_info}}; { "filename", "something-important.doc" },
{ "url", "mxc://localhost/23d233d32r3r2r" },
auto content = QJsonObject{ { "info", file_info },
{"body", "something-important.doc"}, { "msgtype", "m.file" } };
{"filename", "something-important.doc"},
{"url", "mxc://localhost/23d233d32r3r2r"}, auto event = QJsonObject{ { "content", content },
{"info", file_info}, { "event_id", "$asdfafdf8af:matrix.org" },
{"msgtype", "m.file"}}; { "room_id", "!aasdfaeae23r9:matrix.org" },
{ "sender", "@alice:matrix.org" },
auto event = QJsonObject{ { "origin_server_ts", 1323238293289323LL },
{"content", content}, { "type", "m.room.message" } };
{"event_id", "$asdfafdf8af:matrix.org"},
{"room_id", "!aasdfaeae23r9:matrix.org"}, MessageEvent<messages::File> file;
{"sender", "@alice:matrix.org"}, file.deserialize(event);
{"origin_server_ts", 1323238293289323LL},
{"type", "m.room.message"}}; EXPECT_EQ(file.content().body(), "something-important.doc");
EXPECT_EQ(file.msgContent().info().thumbnail_info.h, 300);
MessageEvent<messages::File> file; EXPECT_EQ(file.msgContent().info().thumbnail_info.w, 400);
file.deserialize(event); EXPECT_EQ(file.msgContent().info().thumbnail_info.mimetype, "image/jpeg");
EXPECT_EQ(file.msgContent().info().mimetype, "application/msword");
EXPECT_EQ(file.content().body(), "something-important.doc"); EXPECT_EQ(file.msgContent().info().size, 24242424);
EXPECT_EQ(file.msgContent().info().thumbnail_info.h, 300); EXPECT_EQ(file.content().body(), "something-important.doc");
EXPECT_EQ(file.msgContent().info().thumbnail_info.w, 400);
EXPECT_EQ(file.msgContent().info().thumbnail_info.mimetype, "image/jpeg");
EXPECT_EQ(file.msgContent().info().mimetype, "application/msword");
EXPECT_EQ(file.msgContent().info().size, 24242424);
EXPECT_EQ(file.content().body(), "something-important.doc");
} }
TEST(MessageEvent, Image) TEST(MessageEvent, Image)
{ {
auto thumbinfo = QJsonObject{ auto thumbinfo = QJsonObject{
{"h", 11}, { "h", 11 }, { "w", 22 }, { "size", 212 }, { "mimetype", "img/jpeg" },
{"w", 22}, };
{"size", 212},
{"mimetype", "img/jpeg"}, auto imginfo = QJsonObject{
}; { "h", 110 },
{ "w", 220 },
auto imginfo = QJsonObject{ { "size", 2120 },
{"h", 110}, { "mimetype", "img/jpeg" },
{"w", 220}, { "thumbnail_url", "https://images.com/image-thumb.jpg" },
{"size", 2120}, { "thumbnail_info", thumbinfo },
{"mimetype", "img/jpeg"}, };
{"thumbnail_url", "https://images.com/image-thumb.jpg"},
{"thumbnail_info", thumbinfo}, auto content = QJsonObject{ { "body", "Image title" },
}; { "msgtype", "m.image" },
{ "url", "https://images.com/image.jpg" },
auto content = QJsonObject{ { "info", imginfo } };
{"body", "Image title"},
{"msgtype", "m.image"}, auto event = QJsonObject{ { "content", content },
{"url", "https://images.com/image.jpg"}, { "event_id", "$asdfafdf8af:matrix.org" },
{"info", imginfo}}; { "room_id", "!aasdfaeae23r9:matrix.org" },
{ "sender", "@alice:matrix.org" },
auto event = QJsonObject{ { "origin_server_ts", 1323238293289323LL },
{"content", content}, { "type", "m.room.message" } };
{"event_id", "$asdfafdf8af:matrix.org"},
{"room_id", "!aasdfaeae23r9:matrix.org"}, MessageEvent<messages::Image> img;
{"sender", "@alice:matrix.org"}, img.deserialize(event);
{"origin_server_ts", 1323238293289323LL},
{"type", "m.room.message"}}; EXPECT_EQ(img.content().body(), "Image title");
EXPECT_EQ(img.msgContent().info().h, 110);
MessageEvent<messages::Image> img; EXPECT_EQ(img.msgContent().info().w, 220);
img.deserialize(event); EXPECT_EQ(img.msgContent().info().thumbnail_info.w, 22);
EXPECT_EQ(img.msgContent().info().mimetype, "img/jpeg");
EXPECT_EQ(img.content().body(), "Image title"); EXPECT_EQ(img.msgContent().info().thumbnail_url, "https://images.com/image-thumb.jpg");
EXPECT_EQ(img.msgContent().info().h, 110);
EXPECT_EQ(img.msgContent().info().w, 220);
EXPECT_EQ(img.msgContent().info().thumbnail_info.w, 22);
EXPECT_EQ(img.msgContent().info().mimetype, "img/jpeg");
EXPECT_EQ(img.msgContent().info().thumbnail_url, "https://images.com/image-thumb.jpg");
} }
TEST(MessageEvent, Location) TEST(MessageEvent, Location)
{ {
auto thumbnail_info = QJsonObject{ auto thumbnail_info = QJsonObject{
{"h", 300}, { "h", 300 }, { "w", 400 }, { "size", 3432434 }, { "mimetype", "image/jpeg" }
{"w", 400}, };
{"size", 3432434},
{"mimetype", "image/jpeg"}}; auto info = QJsonObject{ { "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
{ "thumbnail_info", thumbnail_info } };
auto info = QJsonObject{
{"thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3"}, auto content = QJsonObject{ { "body", "Big Ben, London, UK" },
{"thumbnail_info", thumbnail_info}}; { "geo_uri", "geo:51.5008,0.1247" },
{ "info", info },
auto content = QJsonObject{ { "msgtype", "m.location" } };
{"body", "Big Ben, London, UK"},
{"geo_uri", "geo:51.5008,0.1247"}, auto event = QJsonObject{ { "content", content },
{"info", info}, { "event_id", "$asdfafdf8af:matrix.org" },
{"msgtype", "m.location"}}; { "room_id", "!aasdfaeae23r9:matrix.org" },
{ "sender", "@alice:matrix.org" },
auto event = QJsonObject{ { "origin_server_ts", 1323238293289323LL },
{"content", content}, { "type", "m.room.message" } };
{"event_id", "$asdfafdf8af:matrix.org"},
{"room_id", "!aasdfaeae23r9:matrix.org"}, MessageEvent<messages::Location> location;
{"sender", "@alice:matrix.org"}, location.deserialize(event);
{"origin_server_ts", 1323238293289323LL},
{"type", "m.room.message"}}; EXPECT_EQ(location.msgContent().info().thumbnail_info.h, 300);
EXPECT_EQ(location.msgContent().info().thumbnail_info.w, 400);
MessageEvent<messages::Location> location; EXPECT_EQ(location.msgContent().info().thumbnail_info.mimetype, "image/jpeg");
location.deserialize(event); EXPECT_EQ(location.msgContent().info().thumbnail_url, "mxc://localhost/adfaefaFAFSDFF3");
EXPECT_EQ(location.content().body(), "Big Ben, London, UK");
EXPECT_EQ(location.msgContent().info().thumbnail_info.h, 300);
EXPECT_EQ(location.msgContent().info().thumbnail_info.w, 400);
EXPECT_EQ(location.msgContent().info().thumbnail_info.mimetype, "image/jpeg");
EXPECT_EQ(location.msgContent().info().thumbnail_url, "mxc://localhost/adfaefaFAFSDFF3");
EXPECT_EQ(location.content().body(), "Big Ben, London, UK");
} }
TEST(MessageEvent, Notice) TEST(MessageEvent, Notice)
{ {
auto content = QJsonObject{ auto content = QJsonObject{ { "body", "notice message" }, { "msgtype", "m.notice" } };
{"body", "notice message"},
{"msgtype", "m.notice"}}; auto event = QJsonObject{ { "content", content },
{ "event_id", "$asdfafdf8af:matrix.org" },
auto event = QJsonObject{ { "room_id", "!aasdfaeae23r9:matrix.org" },
{"content", content}, { "sender", "@alice:matrix.org" },
{"event_id", "$asdfafdf8af:matrix.org"}, { "origin_server_ts", 1323238293289323LL },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "type", "m.room.message" } };
{"sender", "@alice:matrix.org"},
{"origin_server_ts", 1323238293289323LL}, MessageEvent<messages::Notice> notice;
{"type", "m.room.message"}}; notice.deserialize(event);
MessageEvent<messages::Notice> notice; EXPECT_EQ(notice.content().body(), "notice message");
notice.deserialize(event);
EXPECT_EQ(notice.content().body(), "notice message");
} }
TEST(MessageEvent, Text) TEST(MessageEvent, Text)
{ {
auto content = QJsonObject{ auto content = QJsonObject{ { "body", "text message" }, { "msgtype", "m.text" } };
{"body", "text message"},
{"msgtype", "m.text"}}; auto event = QJsonObject{ { "content", content },
{ "event_id", "$asdfafdf8af:matrix.org" },
auto event = QJsonObject{ { "room_id", "!aasdfaeae23r9:matrix.org" },
{"content", content}, { "sender", "@alice:matrix.org" },
{"event_id", "$asdfafdf8af:matrix.org"}, { "origin_server_ts", 1323238293289323LL },
{"room_id", "!aasdfaeae23r9:matrix.org"}, { "type", "m.room.message" } };
{"sender", "@alice:matrix.org"},
{"origin_server_ts", 1323238293289323LL}, MessageEvent<messages::Text> text;
{"type", "m.room.message"}}; text.deserialize(event);
MessageEvent<messages::Text> text; EXPECT_EQ(text.content().body(), "text message");
text.deserialize(event);
EXPECT_EQ(text.content().body(), "text message");
} }
TEST(MessageEvent, Video) TEST(MessageEvent, Video)
{ {
auto thumbnail_info = QJsonObject{ auto thumbnail_info = QJsonObject{
{"h", 300}, { "h", 300 }, { "w", 400 }, { "size", 3432434 }, { "mimetype", "image/jpeg" }
{"w", 400}, };
{"size", 3432434},
{"mimetype", "image/jpeg"}}; auto video_info = QJsonObject{ { "h", 222 },
{ "w", 333 },
auto video_info = QJsonObject{ { "duration", 232323 },
{"h", 222}, { "size", 24242424 },
{"w", 333}, { "mimetype", "video/mp4" },
{"duration", 232323}, { "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
{"size", 24242424}, { "thumbnail_info", thumbnail_info } };
{"mimetype", "video/mp4"},
{"thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3"}, auto content = QJsonObject{ { "body", "Gangnam Style" },
{"thumbnail_info", thumbnail_info}}; { "url", "mxc://localhost/23d233d32r3r2r" },
{ "info", video_info },
auto content = QJsonObject{ { "msgtype", "m.video" } };
{"body", "Gangnam Style"},
{"url", "mxc://localhost/23d233d32r3r2r"}, auto event = QJsonObject{ { "content", content },
{"info", video_info}, { "event_id", "$asdfafdf8af:matrix.org" },
{"msgtype", "m.video"}}; { "room_id", "!aasdfaeae23r9:matrix.org" },
{ "sender", "@alice:matrix.org" },
auto event = QJsonObject{ { "origin_server_ts", 1323238293289323LL },
{"content", content}, { "type", "m.room.message" } };
{"event_id", "$asdfafdf8af:matrix.org"},
{"room_id", "!aasdfaeae23r9:matrix.org"}, MessageEvent<messages::Video> video;
{"sender", "@alice:matrix.org"}, video.deserialize(event);
{"origin_server_ts", 1323238293289323LL},
{"type", "m.room.message"}}; EXPECT_EQ(video.msgContent().info().thumbnail_info.h, 300);
EXPECT_EQ(video.msgContent().info().thumbnail_info.w, 400);
MessageEvent<messages::Video> video; EXPECT_EQ(video.msgContent().info().thumbnail_info.mimetype, "image/jpeg");
video.deserialize(event); EXPECT_EQ(video.msgContent().info().duration, 232323);
EXPECT_EQ(video.msgContent().info().size, 24242424);
EXPECT_EQ(video.msgContent().info().thumbnail_info.h, 300); EXPECT_EQ(video.msgContent().info().mimetype, "video/mp4");
EXPECT_EQ(video.msgContent().info().thumbnail_info.w, 400); EXPECT_EQ(video.content().body(), "Gangnam Style");
EXPECT_EQ(video.msgContent().info().thumbnail_info.mimetype, "image/jpeg");
EXPECT_EQ(video.msgContent().info().duration, 232323);
EXPECT_EQ(video.msgContent().info().size, 24242424);
EXPECT_EQ(video.msgContent().info().mimetype, "video/mp4");
EXPECT_EQ(video.content().body(), "Gangnam Style");
} }
TEST(MessageEvent, Types) TEST(MessageEvent, Types)
{ {
EXPECT_EQ(extractMessageEventType(QJsonObject{ EXPECT_EQ(
{"content", QJsonObject{{"msgtype", "m.audio"}}}, {"type", "m.room.message"}, extractMessageEventType(QJsonObject{
}), { "content", QJsonObject{ { "msgtype", "m.audio" } } }, { "type", "m.room.message" },
MessageEventType::Audio); }),
EXPECT_EQ(extractMessageEventType(QJsonObject{ MessageEventType::Audio);
{"content", QJsonObject{{"msgtype", "m.emote"}}}, {"type", "m.room.message"}, EXPECT_EQ(
}), extractMessageEventType(QJsonObject{
MessageEventType::Emote); { "content", QJsonObject{ { "msgtype", "m.emote" } } }, { "type", "m.room.message" },
EXPECT_EQ(extractMessageEventType(QJsonObject{ }),
{"content", QJsonObject{{"msgtype", "m.file"}}}, {"type", "m.room.message"}, MessageEventType::Emote);
}), EXPECT_EQ(
MessageEventType::File); extractMessageEventType(QJsonObject{
EXPECT_EQ(extractMessageEventType(QJsonObject{ { "content", QJsonObject{ { "msgtype", "m.file" } } }, { "type", "m.room.message" },
{"content", QJsonObject{{"msgtype", "m.image"}}}, {"type", "m.room.message"}, }),
}), MessageEventType::File);
MessageEventType::Image); EXPECT_EQ(
EXPECT_EQ(extractMessageEventType(QJsonObject{ extractMessageEventType(QJsonObject{
{"content", QJsonObject{{"msgtype", "m.location"}}}, {"type", "m.room.message"}, { "content", QJsonObject{ { "msgtype", "m.image" } } }, { "type", "m.room.message" },
}), }),
MessageEventType::Location); MessageEventType::Image);
EXPECT_EQ(extractMessageEventType(QJsonObject{ EXPECT_EQ(
{"content", QJsonObject{{"msgtype", "m.notice"}}}, {"type", "m.room.message"}, extractMessageEventType(QJsonObject{
}), { "content", QJsonObject{ { "msgtype", "m.location" } } }, { "type", "m.room.message" },
MessageEventType::Notice); }),
EXPECT_EQ(extractMessageEventType(QJsonObject{ MessageEventType::Location);
{"content", QJsonObject{{"msgtype", "m.text"}}}, {"type", "m.room.message"}, EXPECT_EQ(
}), extractMessageEventType(QJsonObject{
MessageEventType::Text); { "content", QJsonObject{ { "msgtype", "m.notice" } } }, { "type", "m.room.message" },
EXPECT_EQ(extractMessageEventType(QJsonObject{ }),
{"content", QJsonObject{{"msgtype", "m.video"}}}, {"type", "m.room.message"}, MessageEventType::Notice);
}), EXPECT_EQ(
MessageEventType::Video); extractMessageEventType(QJsonObject{
EXPECT_EQ(extractMessageEventType(QJsonObject{ { "content", QJsonObject{ { "msgtype", "m.text" } } }, { "type", "m.room.message" },
{"content", QJsonObject{{"msgtype", "m.random"}}}, {"type", "m.room.message"}, }),
}), MessageEventType::Text);
MessageEventType::Unknown); EXPECT_EQ(
extractMessageEventType(QJsonObject{
{ "content", QJsonObject{ { "msgtype", "m.video" } } }, { "type", "m.room.message" },
}),
MessageEventType::Video);
EXPECT_EQ(
extractMessageEventType(QJsonObject{
{ "content", QJsonObject{ { "msgtype", "m.random" } } }, { "type", "m.room.message" },
}),
MessageEventType::Unknown);
} }

Loading…
Cancel
Save