mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Linting
This commit is contained in:
parent
37ff1398b7
commit
9def76aa08
4 changed files with 669 additions and 696 deletions
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@ 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" },
|
||||||
|
@ -32,8 +31,7 @@ TEST(EventCollection, Deserialize)
|
||||||
{ "origin_server_ts", 1323238293289323LL },
|
{ "origin_server_ts", 1323238293289323LL },
|
||||||
{ "state_key", "" },
|
{ "state_key", "" },
|
||||||
{ "type", "m.room.name" } },
|
{ "type", "m.room.name" } },
|
||||||
QJsonObject{
|
QJsonObject{ { "content", QJsonObject{ { "topic", "Topic" } } },
|
||||||
{"content", QJsonObject{{"topic", "Topic"}}},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "prev_content", QJsonObject{ { "topic", "Previous Topic" } } },
|
{ "prev_content", QJsonObject{ { "topic", "Previous Topic" } } },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
|
@ -68,8 +66,7 @@ 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" },
|
||||||
|
@ -77,8 +74,7 @@ TEST(EventCollection, DeserializationException)
|
||||||
{ "origin_server_ts", 1323238293289323LL },
|
{ "origin_server_ts", 1323238293289323LL },
|
||||||
{ "state_key", "" },
|
{ "state_key", "" },
|
||||||
{ "type", "m.room.topic" } },
|
{ "type", "m.room.topic" } },
|
||||||
QJsonObject{
|
QJsonObject{ { "content", QJsonObject{ { "topic", "Topic" } } },
|
||||||
{"content", QJsonObject{{"topic", "Topic"}}},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "prev_content", QJsonObject{ { "topic", "Previous Topic" } } },
|
{ "prev_content", QJsonObject{ { "topic", "Previous Topic" } } },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "RoomEvent.h"
|
#include "RoomEvent.h"
|
||||||
|
@ -22,8 +22,7 @@ using namespace matrix::events;
|
||||||
TEST(BaseEvent, Deserialization)
|
TEST(BaseEvent, Deserialization)
|
||||||
{
|
{
|
||||||
// NameEventContent
|
// NameEventContent
|
||||||
auto data = QJsonObject{
|
auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Room Name" } } },
|
||||||
{"content", QJsonObject{{"name", "Room Name"}}},
|
|
||||||
{ "type", "m.room.name" } };
|
{ "type", "m.room.name" } };
|
||||||
|
|
||||||
Event<NameEventContent> name_event;
|
Event<NameEventContent> name_event;
|
||||||
|
@ -32,8 +31,7 @@ TEST(BaseEvent, Deserialization)
|
||||||
EXPECT_EQ(name_event.serialize(), data);
|
EXPECT_EQ(name_event.serialize(), data);
|
||||||
|
|
||||||
// TopicEventContent
|
// TopicEventContent
|
||||||
data = QJsonObject{
|
data = QJsonObject{ { "content", QJsonObject{ { "topic", "Room Topic" } } },
|
||||||
{"content", QJsonObject{{"topic", "Room Topic"}}},
|
|
||||||
{ "type", "m.room.topic" } };
|
{ "type", "m.room.topic" } };
|
||||||
|
|
||||||
Event<TopicEventContent> topic_event;
|
Event<TopicEventContent> topic_event;
|
||||||
|
@ -42,8 +40,7 @@ TEST(BaseEvent, Deserialization)
|
||||||
EXPECT_EQ(topic_event.serialize(), data);
|
EXPECT_EQ(topic_event.serialize(), data);
|
||||||
|
|
||||||
// AvatarEventContent
|
// AvatarEventContent
|
||||||
data = QJsonObject{
|
data = QJsonObject{ { "content", QJsonObject{ { "url", "https://matrix.org" } } },
|
||||||
{"content", QJsonObject{{"url", "https://matrix.org"}}},
|
|
||||||
{ "type", "m.room.avatar" } };
|
{ "type", "m.room.avatar" } };
|
||||||
|
|
||||||
Event<AvatarEventContent> avatar_event;
|
Event<AvatarEventContent> avatar_event;
|
||||||
|
@ -52,8 +49,10 @@ TEST(BaseEvent, Deserialization)
|
||||||
EXPECT_EQ(avatar_event.serialize(), data);
|
EXPECT_EQ(avatar_event.serialize(), data);
|
||||||
|
|
||||||
// AliasesEventContent
|
// AliasesEventContent
|
||||||
data = QJsonObject{
|
data =
|
||||||
{"content", QJsonObject{{"aliases", QJsonArray{"#test:matrix.org", "#test2:matrix.org"}}}},
|
QJsonObject{ { "content",
|
||||||
|
QJsonObject{
|
||||||
|
{ "aliases", QJsonArray{ "#test:matrix.org", "#test2:matrix.org" } } } },
|
||||||
{ "type", "m.room.aliases" } };
|
{ "type", "m.room.aliases" } };
|
||||||
|
|
||||||
Event<AliasesEventContent> aliases_event;
|
Event<AliasesEventContent> aliases_event;
|
||||||
|
@ -62,8 +61,7 @@ TEST(BaseEvent, Deserialization)
|
||||||
EXPECT_EQ(aliases_event.serialize(), data);
|
EXPECT_EQ(aliases_event.serialize(), data);
|
||||||
|
|
||||||
// CreateEventContent
|
// CreateEventContent
|
||||||
data = QJsonObject{
|
data = QJsonObject{ { "content", QJsonObject{ { "creator", "@alice:matrix.org" } } },
|
||||||
{"content", QJsonObject{{"creator", "@alice:matrix.org"}}},
|
|
||||||
{ "type", "m.room.create" } };
|
{ "type", "m.room.create" } };
|
||||||
|
|
||||||
Event<CreateEventContent> create_event;
|
Event<CreateEventContent> create_event;
|
||||||
|
@ -72,8 +70,7 @@ TEST(BaseEvent, Deserialization)
|
||||||
EXPECT_EQ(create_event.serialize(), data);
|
EXPECT_EQ(create_event.serialize(), data);
|
||||||
|
|
||||||
// JoinRulesEventContent
|
// JoinRulesEventContent
|
||||||
data = QJsonObject{
|
data = QJsonObject{ { "content", QJsonObject{ { "join_rule", "private" } } },
|
||||||
{"content", QJsonObject{{"join_rule", "private"}}},
|
|
||||||
{ "type", "m.room.join_rules" } };
|
{ "type", "m.room.join_rules" } };
|
||||||
|
|
||||||
Event<JoinRulesEventContent> join_rules_event;
|
Event<JoinRulesEventContent> join_rules_event;
|
||||||
|
@ -84,15 +81,13 @@ TEST(BaseEvent, Deserialization)
|
||||||
|
|
||||||
TEST(BaseEvent, DeserializationException)
|
TEST(BaseEvent, DeserializationException)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data = QJsonObject{ { "content", QJsonObject{ { "rule", "private" } } },
|
||||||
{"content", QJsonObject{{"rule", "private"}}},
|
|
||||||
{ "type", "m.room.join_rules" } };
|
{ "type", "m.room.join_rules" } };
|
||||||
|
|
||||||
Event<JoinRulesEventContent> event1;
|
Event<JoinRulesEventContent> event1;
|
||||||
ASSERT_THROW(event1.deserialize(data), DeserializationException);
|
ASSERT_THROW(event1.deserialize(data), DeserializationException);
|
||||||
|
|
||||||
data = QJsonObject{
|
data = QJsonObject{ { "contents", QJsonObject{ { "join_rule", "private" } } },
|
||||||
{"contents", QJsonObject{{"join_rule", "private"}}},
|
|
||||||
{ "type", "m.room.join_rules" } };
|
{ "type", "m.room.join_rules" } };
|
||||||
|
|
||||||
Event<JoinRulesEventContent> event2;
|
Event<JoinRulesEventContent> event2;
|
||||||
|
@ -101,8 +96,7 @@ TEST(BaseEvent, DeserializationException)
|
||||||
|
|
||||||
TEST(RoomEvent, Deserialization)
|
TEST(RoomEvent, Deserialization)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } },
|
||||||
{"content", QJsonObject{{"name", "Name"}}},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -122,8 +116,7 @@ TEST(RoomEvent, Deserialization)
|
||||||
|
|
||||||
TEST(RoomEvent, DeserializationException)
|
TEST(RoomEvent, DeserializationException)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } },
|
||||||
{"content", QJsonObject{{"name", "Name"}}},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "origin_server_ts", 1323238293289323LL },
|
{ "origin_server_ts", 1323238293289323LL },
|
||||||
|
@ -140,8 +133,7 @@ TEST(RoomEvent, DeserializationException)
|
||||||
|
|
||||||
TEST(StateEvent, Deserialization)
|
TEST(StateEvent, Deserialization)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } },
|
||||||
{"content", QJsonObject{{"name", "Name"}}},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "state_key", "some_state_key" },
|
{ "state_key", "some_state_key" },
|
||||||
{ "prev_content", QJsonObject{ { "name", "Previous Name" } } },
|
{ "prev_content", QJsonObject{ { "name", "Previous Name" } } },
|
||||||
|
@ -165,8 +157,7 @@ TEST(StateEvent, Deserialization)
|
||||||
|
|
||||||
TEST(StateEvent, DeserializationException)
|
TEST(StateEvent, DeserializationException)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data = 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" },
|
||||||
|
@ -185,24 +176,35 @@ TEST(StateEvent, DeserializationException)
|
||||||
|
|
||||||
TEST(EventType, Mapping)
|
TEST(EventType, Mapping)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.aliases"}}), EventType::RoomAliases);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.aliases" } }),
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.avatar"}}), EventType::RoomAvatar);
|
EventType::RoomAliases);
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.canonical_alias"}}), EventType::RoomCanonicalAlias);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.avatar" } }),
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.create"}}), EventType::RoomCreate);
|
EventType::RoomAvatar);
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.history_visibility"}}), EventType::RoomHistoryVisibility);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.canonical_alias" } }),
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.join_rules"}}), EventType::RoomJoinRules);
|
EventType::RoomCanonicalAlias);
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.member"}}), EventType::RoomMember);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.create" } }),
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.message"}}), EventType::RoomMessage);
|
EventType::RoomCreate);
|
||||||
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.history_visibility" } }),
|
||||||
|
EventType::RoomHistoryVisibility);
|
||||||
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.join_rules" } }),
|
||||||
|
EventType::RoomJoinRules);
|
||||||
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.member" } }),
|
||||||
|
EventType::RoomMember);
|
||||||
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.message" } }),
|
||||||
|
EventType::RoomMessage);
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.name" } }), EventType::RoomName);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.name" } }), EventType::RoomName);
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.power_levels"}}), EventType::RoomPowerLevels);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.power_levels" } }),
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.topic"}}), EventType::RoomTopic);
|
EventType::RoomPowerLevels);
|
||||||
EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.unknown"}}), EventType::Unsupported);
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.topic" } }),
|
||||||
|
EventType::RoomTopic);
|
||||||
|
EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.unknown" } }),
|
||||||
|
EventType::Unsupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(AliasesEventContent, Deserialization)
|
TEST(AliasesEventContent, Deserialization)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data =
|
||||||
{"aliases", QJsonArray{"#test:matrix.org", "#test2:matrix.org"}}};
|
QJsonObject{ { "aliases", QJsonArray{ "#test:matrix.org", "#test2:matrix.org" } } };
|
||||||
|
|
||||||
AliasesEventContent content;
|
AliasesEventContent content;
|
||||||
content.deserialize(data);
|
content.deserialize(data);
|
||||||
|
@ -221,8 +223,7 @@ TEST(AliasesEventContent, NotAnObject)
|
||||||
|
|
||||||
TEST(AliasesEventContent, MissingKey)
|
TEST(AliasesEventContent, MissingKey)
|
||||||
{
|
{
|
||||||
auto data = QJsonObject{
|
auto data = QJsonObject{ { "key", QJsonArray{ "#test:matrix.org", "#test2:matrix.org" } } };
|
||||||
{"key", QJsonArray{"#test:matrix.org", "#test2:matrix.org"}}};
|
|
||||||
|
|
||||||
AliasesEventContent content;
|
AliasesEventContent content;
|
||||||
ASSERT_THROW(content.deserialize(data), DeserializationException);
|
ASSERT_THROW(content.deserialize(data), DeserializationException);
|
||||||
|
|
|
@ -19,19 +19,15 @@ 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{
|
auto content = QJsonObject{ { "body", "Bee Gees - Stayin' Alive" },
|
||||||
{"body", "Bee Gees - Stayin' Alive"},
|
|
||||||
{ "msgtype", "m.audio" },
|
{ "msgtype", "m.audio" },
|
||||||
{ "url", "mxc://localhost/2sdfj23f33r3faad" },
|
{ "url", "mxc://localhost/2sdfj23f33r3faad" },
|
||||||
{ "info", info } };
|
{ "info", info } };
|
||||||
|
|
||||||
auto event = QJsonObject{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -49,12 +45,9 @@ TEST(MessageEvent, Audio)
|
||||||
|
|
||||||
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{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -70,26 +63,21 @@ TEST(MessageEvent, Emote)
|
||||||
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{
|
auto file_info = QJsonObject{ { "size", 24242424 },
|
||||||
{"size", 24242424},
|
|
||||||
{ "mimetype", "application/msword" },
|
{ "mimetype", "application/msword" },
|
||||||
{ "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
|
{ "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
|
||||||
{ "thumbnail_info", thumbnail_info } };
|
{ "thumbnail_info", thumbnail_info } };
|
||||||
|
|
||||||
auto content = QJsonObject{
|
auto content = QJsonObject{ { "body", "something-important.doc" },
|
||||||
{"body", "something-important.doc"},
|
|
||||||
{ "filename", "something-important.doc" },
|
{ "filename", "something-important.doc" },
|
||||||
{ "url", "mxc://localhost/23d233d32r3r2r" },
|
{ "url", "mxc://localhost/23d233d32r3r2r" },
|
||||||
{ "info", file_info },
|
{ "info", file_info },
|
||||||
{ "msgtype", "m.file" } };
|
{ "msgtype", "m.file" } };
|
||||||
|
|
||||||
auto event = QJsonObject{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -111,10 +99,7 @@ TEST(MessageEvent, File)
|
||||||
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{
|
auto imginfo = QJsonObject{
|
||||||
|
@ -126,14 +111,12 @@ TEST(MessageEvent, Image)
|
||||||
{ "thumbnail_info", thumbinfo },
|
{ "thumbnail_info", thumbinfo },
|
||||||
};
|
};
|
||||||
|
|
||||||
auto content = QJsonObject{
|
auto content = QJsonObject{ { "body", "Image title" },
|
||||||
{"body", "Image title"},
|
|
||||||
{ "msgtype", "m.image" },
|
{ "msgtype", "m.image" },
|
||||||
{ "url", "https://images.com/image.jpg" },
|
{ "url", "https://images.com/image.jpg" },
|
||||||
{ "info", imginfo } };
|
{ "info", imginfo } };
|
||||||
|
|
||||||
auto event = QJsonObject{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -154,23 +137,18 @@ TEST(MessageEvent, Image)
|
||||||
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{
|
auto info = QJsonObject{ { "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
|
||||||
{"thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3"},
|
|
||||||
{ "thumbnail_info", thumbnail_info } };
|
{ "thumbnail_info", thumbnail_info } };
|
||||||
|
|
||||||
auto content = QJsonObject{
|
auto content = QJsonObject{ { "body", "Big Ben, London, UK" },
|
||||||
{"body", "Big Ben, London, UK"},
|
|
||||||
{ "geo_uri", "geo:51.5008,0.1247" },
|
{ "geo_uri", "geo:51.5008,0.1247" },
|
||||||
{ "info", info },
|
{ "info", info },
|
||||||
{ "msgtype", "m.location" } };
|
{ "msgtype", "m.location" } };
|
||||||
|
|
||||||
auto event = QJsonObject{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -189,12 +167,9 @@ TEST(MessageEvent, Location)
|
||||||
|
|
||||||
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{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -209,12 +184,9 @@ TEST(MessageEvent, Notice)
|
||||||
|
|
||||||
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{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -230,13 +202,10 @@ TEST(MessageEvent, Text)
|
||||||
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{
|
auto video_info = QJsonObject{ { "h", 222 },
|
||||||
{"h", 222},
|
|
||||||
{ "w", 333 },
|
{ "w", 333 },
|
||||||
{ "duration", 232323 },
|
{ "duration", 232323 },
|
||||||
{ "size", 24242424 },
|
{ "size", 24242424 },
|
||||||
|
@ -244,14 +213,12 @@ TEST(MessageEvent, Video)
|
||||||
{ "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
|
{ "thumbnail_url", "mxc://localhost/adfaefaFAFSDFF3" },
|
||||||
{ "thumbnail_info", thumbnail_info } };
|
{ "thumbnail_info", thumbnail_info } };
|
||||||
|
|
||||||
auto content = QJsonObject{
|
auto content = QJsonObject{ { "body", "Gangnam Style" },
|
||||||
{"body", "Gangnam Style"},
|
|
||||||
{ "url", "mxc://localhost/23d233d32r3r2r" },
|
{ "url", "mxc://localhost/23d233d32r3r2r" },
|
||||||
{ "info", video_info },
|
{ "info", video_info },
|
||||||
{ "msgtype", "m.video" } };
|
{ "msgtype", "m.video" } };
|
||||||
|
|
||||||
auto event = QJsonObject{
|
auto event = QJsonObject{ { "content", content },
|
||||||
{"content", content},
|
|
||||||
{ "event_id", "$asdfafdf8af:matrix.org" },
|
{ "event_id", "$asdfafdf8af:matrix.org" },
|
||||||
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
{ "room_id", "!aasdfaeae23r9:matrix.org" },
|
||||||
{ "sender", "@alice:matrix.org" },
|
{ "sender", "@alice:matrix.org" },
|
||||||
|
@ -272,39 +239,48 @@ TEST(MessageEvent, Video)
|
||||||
|
|
||||||
TEST(MessageEvent, Types)
|
TEST(MessageEvent, Types)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.audio" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.audio" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Audio);
|
MessageEventType::Audio);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.emote" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.emote" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Emote);
|
MessageEventType::Emote);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.file" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.file" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::File);
|
MessageEventType::File);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.image" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.image" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Image);
|
MessageEventType::Image);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.location" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.location" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Location);
|
MessageEventType::Location);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.notice" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.notice" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Notice);
|
MessageEventType::Notice);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.text" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.text" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Text);
|
MessageEventType::Text);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.video" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.video" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Video);
|
MessageEventType::Video);
|
||||||
EXPECT_EQ(extractMessageEventType(QJsonObject{
|
EXPECT_EQ(
|
||||||
|
extractMessageEventType(QJsonObject{
|
||||||
{ "content", QJsonObject{ { "msgtype", "m.random" } } }, { "type", "m.room.message" },
|
{ "content", QJsonObject{ { "msgtype", "m.random" } } }, { "type", "m.room.message" },
|
||||||
}),
|
}),
|
||||||
MessageEventType::Unknown);
|
MessageEventType::Unknown);
|
||||||
|
|
Loading…
Reference in a new issue