Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112682
D144.1732341918.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
45 KB
Referenced Files
None
Subscribers
None
D144.1732341918.diff
View Options
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,12 +38,7 @@
include(ECMQtDeclareLoggingCategory)
include(ECMDeprecationSettings)
include(ECMQmlModule)
-remove_definitions(
- -DQT_NO_CAST_TO_ASCII
- -DQT_NO_CAST_FROM_ASCII
- -DQT_NO_URL_CAST_FROM_STRING
- -DQT_NO_CAST_FROM_BYTEARRAY
-)
+
ecm_set_disabled_deprecation_versions(
QT 5.15.14
KF 5.116.0
diff --git a/src/kazv-clipboard.cpp b/src/kazv-clipboard.cpp
--- a/src/kazv-clipboard.cpp
+++ b/src/kazv-clipboard.cpp
@@ -6,6 +6,8 @@
#include <QStringList>
#include <QMimeDatabase>
+using namespace Qt::Literals::StringLiterals;
+
KazvClipboard::KazvClipboard(QObject *parent)
: QObject(parent)
, m_tmpDir()
@@ -63,16 +65,16 @@
{
auto *clipboard = QGuiApplication::clipboard();
m_tmpFilesCount++;
- auto name = QString("%1").arg(m_tmpFilesCount);
- auto mimes = clipboard->mimeData()->formats().filter("image/");
+ auto name = u"%1"_s.arg(m_tmpFilesCount);
+ auto mimes = clipboard->mimeData()->formats().filter(u"image/"_s);
QString type;
if (mimes.size() < 1) {
qDebug() << "Saving clipboard image, but no image MIME found";
- type = "";
+ type = u""_s;
} else {
type = QMimeDatabase().mimeTypeForName(mimes.at(0)).preferredSuffix();
}
- auto path = m_tmpDir.filePath(type.isEmpty() ? name : name.append(".").append(type));
+ auto path = m_tmpDir.filePath(type.isEmpty() ? name : name.append(u'.').append(type));
clipboard->image().save(path);
return QUrl::fromLocalFile(path);
}
diff --git a/src/kazv-config.cpp b/src/kazv-config.cpp
--- a/src/kazv-config.cpp
+++ b/src/kazv-config.cpp
@@ -10,16 +10,18 @@
#include <KSharedConfig>
#include <KConfigGroup>
+using namespace Qt::Literals::StringLiterals;
+
struct KazvConfigPrivate
{
- KSharedConfigPtr sessionrc{KSharedConfig::openConfig("kazvsessionrc")};
- KConfigGroup sessionGroup{sessionrc, "Sessions"};
+ KSharedConfigPtr sessionrc{KSharedConfig::openConfig(u"kazvsessionrc"_s)};
+ KConfigGroup sessionGroup{sessionrc, u"Sessions"_s};
- KSharedConfigPtr shortcutsrc{KSharedConfig::openConfig("kazv/shortcutsrc")};
- KConfigGroup shortcutsGroup{shortcutsrc, "Shortcuts"};
+ KSharedConfigPtr shortcutsrc{KSharedConfig::openConfig(u"kazv/shortcutsrc"_s)};
+ KConfigGroup shortcutsGroup{shortcutsrc, u"Shortcuts"_s};
- KSharedConfigPtr cacheDirectoryrc{KSharedConfig::openConfig("kazv/cacheDirectoryrc")};
- KConfigGroup cacheDirectoryGroup{cacheDirectoryrc, "CacheDirectory"};
+ KSharedConfigPtr cacheDirectoryrc{KSharedConfig::openConfig(u"kazv/cacheDirectoryrc"_s)};
+ KConfigGroup cacheDirectoryGroup{cacheDirectoryrc, u"CacheDirectory"_s};
};
KazvConfig::KazvConfig(QObject *parent)
diff --git a/src/kazv-io-job.cpp b/src/kazv-io-job.cpp
--- a/src/kazv-io-job.cpp
+++ b/src/kazv-io-job.cpp
@@ -27,6 +27,8 @@
#include <optional>
#include <string>
+using namespace Qt::Literals::StringLiterals;
+
struct KazvIOBaseJobPrivate
{
QPointer<KIO::TransferJob> job;
@@ -223,7 +225,7 @@
m_d->file->cancelWriting();
return;
}
- if (!m_d->hash.isEmpty() && QString(m_d->file->hash()) != m_d->hash) {
+ if (!m_d->hash.isEmpty() && QString::fromUtf8(m_d->file->hash()) != m_d->hash) {
emitResult(HashError);
return;
}
@@ -255,10 +257,10 @@
if (setFile(fileName)) {
auto kazvUploadJob = Kazv::Api::UploadContentJob(serverUrl.toString().toStdString(),
token.toStdString(), Kazv::FileDesc(std::string()));
- auto job = KIO::http_post(QString(kazvUploadJob.url().data()), m_d->file.data());
- job->addMetaData("customHTTPHeader", QStringLiteral("Authorization: ")
- .append(kazvUploadJob.requestHeader()->at("Authorization").data()));
- job->addMetaData("PropagateHttpHeader", "true");
+ auto job = KIO::http_post(QUrl(QString::fromStdString(kazvUploadJob.url())), m_d->file.data());
+ job->addMetaData(u"customHTTPHeader"_s, QStringLiteral("Authorization: ")
+ .append(QString::fromStdString(kazvUploadJob.requestHeader()->at("Authorization"))));
+ job->addMetaData(u"PropagateHttpHeader"_s, u"true"_s);
setJob(job);
if (roomList) {
m_d->room.reset(roomList->room(roomId));
@@ -280,7 +282,7 @@
{
KazvIOBaseJob::connectJob();
connect(this->job(), &KIO::TransferJob::data, this,
- [this](KJob * /* job */, const QByteArray &data) { m_d->response.append(data); });
+ [this](KJob * /* job */, const QByteArray &data) { m_d->response.append(QString::fromUtf8(data)); });
connect(this->job(), &KJob::result, this, &KazvIOUploadJob::handleResult);
connect(this->job(), &KIO::TransferJob::mimeTypeFound, this,
[this](KJob * /* job */, const QString &mimeType) { m_d->mimeType = mimeType; });
diff --git a/src/kazv-io-manager.cpp b/src/kazv-io-manager.cpp
--- a/src/kazv-io-manager.cpp
+++ b/src/kazv-io-manager.cpp
@@ -28,6 +28,8 @@
#include <string>
#include <algorithm>
+using namespace Qt::Literals::StringLiterals;
+
static const QString ROOMLESS = QStringLiteral("not-a-room");
struct KazvIOManagerPrivate
@@ -62,7 +64,7 @@
const QString &key, const QString &iv) const
{
QPointer<KazvIODownloadJob> job{};
- if (key == "") {
+ if (key.isEmpty()) {
job = new KazvIODownloadJob{localFileUrl.toLocalFile(), serverUrl, hash, std::nullopt};
} else {
auto aes = Kazv::AES256CTRDesc{key.toStdString(), iv.toStdString()};
@@ -195,11 +197,11 @@
void KazvIOManager::setCacheDirectory(QString cacheDirectory)
{
- if (cacheDirectory == "") {
+ if (cacheDirectory.isEmpty()) {
m_d->cacheDir = QDir{m_d->tmpDir.path()};
} else {
auto cacheDir = QDir{QUrl{cacheDirectory}.toLocalFile()};
- if (!cacheDir.mkpath(".")) {
+ if (!cacheDir.mkpath(u"."_s)) {
return;
}
m_d->cacheDir = cacheDir;
diff --git a/src/l10n-provider.cpp b/src/l10n-provider.cpp
--- a/src/l10n-provider.cpp
+++ b/src/l10n-provider.cpp
@@ -18,14 +18,16 @@
#include "kazv-path-config.hpp"
+using namespace Qt::Literals::StringLiterals;
+
static QString l10nConfigFile()
{
- return QString(":/l10n/config.json");
+ return u":/l10n/config.json"_s;
}
static QString dirForLocale(QString locale)
{
- return QString(":/l10n/") + locale;
+ return u":/l10n/"_s + locale;
}
static QString readWholeFile(QString path)
@@ -35,11 +37,7 @@
throw std::runtime_error("Cannot open " + path.toStdString() + " for reading.");
}
QTextStream stream(&f);
-#if KAZV_KF_QT_MAJOR_VERSION == 5
- stream.setCodec("UTF-8");
-#else
stream.setEncoding(QStringConverter::Utf8);
-#endif
return stream.readAll();
}
@@ -60,7 +58,7 @@
auto fn = l10nConfigFile();
auto content = readWholeFile(fn);
auto j = QJsonDocument::fromJson(content.toUtf8());
- auto availableLocales = j["availableLocales"].toObject();
+ auto availableLocales = j[u"availableLocales"_s].toObject();
cachedLocaleToNameMap = std::move(availableLocales);
}
@@ -73,10 +71,10 @@
}
auto dn = dirForLocale(locale);
- auto files = QDir(dn).entryInfoList(QStringList{QStringLiteral("*.ftl")}, QDir::NoFilter, QDir::Name);
+ auto files = QDir(dn).entryInfoList(QStringList{u"*.ftl"_s}, QDir::NoFilter, QDir::Name);
QString s;
- const QString newline = "\n";
+ const QString newline = u"\n"_s;
for (auto f : files) {
auto fn = f.absoluteFilePath();
diff --git a/src/main.cpp b/src/main.cpp
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,14 +20,16 @@
#include "kazv-platform.hpp"
#include "kazv-path-config.hpp"
+using namespace Qt::Literals::StringLiterals;
+
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
- QCoreApplication::setOrganizationName("project-kazv");
- QCoreApplication::setOrganizationDomain("mxc.kazv.moe");
- QCoreApplication::setApplicationName("kazv");
- QGuiApplication::setDesktopFileName("moe.kazv.mxc.kazv.desktop");
+ QCoreApplication::setOrganizationName(u"project-kazv"_s);
+ QCoreApplication::setOrganizationDomain(u"mxc.kazv.moe"_s);
+ QCoreApplication::setApplicationName(u"kazv"_s);
+ QGuiApplication::setDesktopFileName(u"moe.kazv.mxc.kazv.desktop"_s);
#if KAZV_IS_WINDOWS
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
@@ -41,7 +43,7 @@
iconThemeToSet = QStringLiteral("breeze");
#endif
QCommandLineParser parser;
- QCommandLineOption iconThemeOption("i", "Icon theme", "theme");
+ QCommandLineOption iconThemeOption(u"i"_s, u"Icon theme"_s, u"theme"_s);
parser.addOption(iconThemeOption);
parser.process(app);
if (!parser.value(iconThemeOption).isEmpty()) {
@@ -62,7 +64,7 @@
if (!iconThemeToSet.isEmpty()) {
QIcon::setThemeName(iconThemeToSet);
}
- engine.loadFromModule("moe.kazv.mxc.kazvqml", "Main");
+ engine.loadFromModule(u"moe.kazv.mxc.kazvqml"_s, u"Main"_s);
if (engine.rootObjects().isEmpty()) {
return -1;
diff --git a/src/matrix-link.cpp b/src/matrix-link.cpp
--- a/src/matrix-link.cpp
+++ b/src/matrix-link.cpp
@@ -9,19 +9,22 @@
#include <QUrl>
#include <QUrlQuery>
#include <QDebug>
+#include <QString>
#include "matrix-link.hpp"
+using namespace Qt::Literals::StringLiterals;
+
std::pair<MatrixLink::Type, QString> parseMatrixToComp(QString comp)
{
- comp = QUrl("foo:#" + comp).fragment(QUrl::FullyDecoded);
- if (comp.startsWith('@')) {
+ comp = QUrl(u"foo:#"_s + comp).fragment(QUrl::FullyDecoded);
+ if (comp.startsWith(u'@')) {
return {MatrixLink::User, comp};
- } else if (comp.startsWith('#')) {
+ } else if (comp.startsWith(u'#')) {
return {MatrixLink::RoomAlias, comp};
- } else if (comp.startsWith('!')) {
+ } else if (comp.startsWith(u'!')) {
return {MatrixLink::RoomId, comp};
- } else if (comp.startsWith('$')) {
+ } else if (comp.startsWith(u'$')) {
return {MatrixLink::Event, comp};
} else {
return {MatrixLink::None, comp};
@@ -31,21 +34,21 @@
QStringList parseMatrixToQuery(QString query)
{
auto q = QUrlQuery(query);
- return q.allQueryItemValues("via");
+ return q.allQueryItemValues(u"via"_s);
}
MatrixLink::MatrixLink(const QUrl &url)
{
// matrix.to link
- if (url.scheme() == "https"
- && url.host() == "matrix.to") {
+ if (url.scheme() == u"https"_s
+ && url.host() == u"matrix.to"_s) {
auto frag = url.fragment();
- auto parts = frag.split('?');
+ auto parts = frag.split(u'?');
QString ids = parts[0];
- QString query = parts.size() > 1 ? parts[1] : "";
+ QString query = parts.size() > 1 ? parts[1] : u""_s;
- auto comps = ids.split('/');
- if (comps.empty() || comps[0] != "") {
+ auto comps = ids.split(u'/');
+ if (comps.empty() || !comps[0].isEmpty()) {
return;
}
comps.pop_front();
diff --git a/src/matrix-room.hpp b/src/matrix-room.hpp
--- a/src/matrix-room.hpp
+++ b/src/matrix-room.hpp
@@ -136,7 +136,7 @@
Q_INVOKABLE MatrixPromise *kickUser(const QString &userId, const QString &reason) const;
- Q_INVOKABLE MatrixPromise *banUser(const QString &userId, const QString &reason = "") const;
+ Q_INVOKABLE MatrixPromise *banUser(const QString &userId, const QString &reason = QStringLiteral()) const;
Q_INVOKABLE MatrixPromise *unbanUser(const QString &userId) const;
diff --git a/src/matrix-room.cpp b/src/matrix-room.cpp
--- a/src/matrix-room.cpp
+++ b/src/matrix-room.cpp
@@ -27,6 +27,7 @@
#include "helper.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
static const int typingDebounceMs = 500;
@@ -133,7 +134,7 @@
return;
}
- if (relType == "m.in_reply_to") {
+ if (relType == u"m.in_reply_to"_s) {
msg["content"]["m.relates_to"] = nlohmann::json{
{"m.in_reply_to", {
{"event_id", relatedTo},
@@ -160,7 +161,7 @@
};
std::string replyToBody;
- if (relType == "m.in_reply_to" && !relatedTo.isEmpty()) {
+ if (relType == u"m.in_reply_to"_s && !relatedTo.isEmpty()) {
auto replyToContent = replyToEvent.content().get();
if (replyToContent.contains("format")
&& replyToContent["format"] == HTML_FORMAT
@@ -194,7 +195,7 @@
};
}
- if (relType == "m.replace" && !relatedTo.isEmpty()) {
+ if (relType == u"m.replace"_s && !relatedTo.isEmpty()) {
msg["content"]["m.new_content"] = msg["content"];
}
@@ -211,7 +212,7 @@
void MatrixRoom::sendTextMessage(QString text, const QString &relType, QString relatedTo) const
{
- Event replyToEvent = (relType == "m.in_reply_to" && !relatedTo.isEmpty())
+ Event replyToEvent = (relType == u"m.in_reply_to"_s && !relatedTo.isEmpty())
? m_room.message(lager::make_constant(relatedTo.toStdString())).make().get()
: Event();
auto j = makeTextMessageJson(text, relType, relatedTo, replyToEvent);
@@ -270,7 +271,7 @@
{
static auto available_msgtype = std::array<std::string, 3>{"m.audio", "m.video", "m.image"};
auto try_msgtype = std::find(available_msgtype.begin(), available_msgtype.end(),
- QStringLiteral("m.").append(mimeType.split(QChar('/'))[0]).toStdString());
+ u"m."_s.append(mimeType.split(u'/')[0]).toStdString());
std::string msgtype;
if (try_msgtype == available_msgtype.end()) {
msgtype = "m.file";
@@ -297,7 +298,7 @@
{
static auto available_msgtype = std::array<std::string, 3>{"m.audio", "m.video", "m.image"};
auto try_msgtype = std::find(available_msgtype.begin(), available_msgtype.end(),
- QStringLiteral("m.").append(mimeType.split(QChar('/'))[0]).toStdString());
+ u"m."_s.append(mimeType.split(u'/')[0]).toStdString());
std::string msgtype;
if (try_msgtype == available_msgtype.end()) {
msgtype = "m.file";
diff --git a/src/matrix-sdk.cpp b/src/matrix-sdk.cpp
--- a/src/matrix-sdk.cpp
+++ b/src/matrix-sdk.cpp
@@ -45,6 +45,8 @@
#include "kazv-log.hpp"
#include "matrix-utils.hpp"
#include "kazv-session-lock-guard.hpp"
+
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
// Sdk with qt event loop, identity transform and no enhancers
@@ -207,7 +209,7 @@
// store metadata
{
KConfig metadata(QString::fromStdString(metadataFile.string()));
- KConfigGroup mdGroup(&metadata, "Metadata");
+ KConfigGroup mdGroup(&metadata, u"Metadata"_s);
mdGroup.writeEntry("kazvVersion", QString::fromStdString(kazvVersionString()));
mdGroup.writeEntry("archiveFormat", "text");
}
@@ -365,7 +367,7 @@
](auto res) {
if (!res.success()) {
// FIXME use real error codes and msgs when available in libkazv
- Q_EMIT this->discoverFailed("", "");
+ Q_EMIT this->discoverFailed(u""_s, u""_s);
return res;
}
@@ -478,13 +480,13 @@
if (std::filesystem::exists(metadataFile)) {
KConfig metadata(QString::fromStdString(metadataFile.string()));
- KConfigGroup mdGroup(&metadata, "Metadata");
- auto format = mdGroup.readEntry("archiveFormat");
+ KConfigGroup mdGroup(&metadata, u"Metadata"_s);
+ auto format = mdGroup.readEntry(u"archiveFormat"_s);
if (format != QStringLiteral("text")) {
qDebug() << "Unknown archive format:" << format;
return SessionFormatUnknown;
}
- auto version = mdGroup.readEntry("kazvVersion");
+ auto version = mdGroup.readEntry(u"kazvVersion"_s);
auto curVersion = kazvVersionString();
if (version != QString::fromStdString(curVersion)) {
qDebug() << "A different version from the current one, making a backup";
@@ -524,7 +526,7 @@
qDebug() << "in loadSession(), sessionName=" << sessionName;
auto userDataDir = StdPath(m_d->userDataDir);
- auto parts = sessionName.split('/');
+ auto parts = sessionName.split(u'/');
if (parts.size() == 2) {
auto userId = parts[0].toStdString();
auto sessionId = parts[1].toStdString();
@@ -546,7 +548,7 @@
using StdPath = std::filesystem::path;
qDebug() << "in deleteSession(), sessionName=" << sessionName;
auto userDataDir = StdPath(kazvUserDataDir().toStdString());
- auto parts = sessionName.split('/');
+ auto parts = sessionName.split(u'/');
if (parts.size() == 2) {
auto userId = parts[0].toStdString();
auto sessionId = parts[1].toStdString();
diff --git a/src/matrix-sticker-pack.cpp b/src/matrix-sticker-pack.cpp
--- a/src/matrix-sticker-pack.cpp
+++ b/src/matrix-sticker-pack.cpp
@@ -12,6 +12,7 @@
#include "matrix-event.hpp"
#include "matrix-sticker-pack.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
MatrixStickerPack::MatrixStickerPack(lager::reader<MatrixStickerPackSource> source, QObject *parent)
@@ -94,15 +95,15 @@
auto &sticker = eventJson["content"]["images"][shortCode.toStdString()];
auto content = event->content();
- auto body = event->content()["body"];
+ auto body = event->content()[u"body"_s];
if (!body.isUndefined()) {
sticker["body"] = body;
}
- auto url = event->content()["url"];
+ auto url = event->content()[u"url"_s];
if (!url.isUndefined()) {
sticker["url"] = url;
}
- auto info = event->content()["info"];
+ auto info = event->content()[u"info"_s];
if (!info.isUndefined()) {
sticker["info"] = info;
}
diff --git a/src/matrix-sticker.cpp b/src/matrix-sticker.cpp
--- a/src/matrix-sticker.cpp
+++ b/src/matrix-sticker.cpp
@@ -12,6 +12,7 @@
#include "qt-json.hpp"
#include "matrix-sticker.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
MatrixSticker::MatrixSticker(lager::reader<std::string> shortCode, lager::reader<Kazv::json> sticker, QObject *parent)
@@ -50,11 +51,11 @@
QJsonObject MatrixSticker::makeEventJson() const
{
return QJsonObject{
- {"type", "m.sticker"},
- {"content", QJsonObject{
- {"url", mxcUri()},
- {"body", body()},
- {"info", info()},
+ {u"type"_s, u"m.sticker"_s},
+ {u"content"_s, QJsonObject{
+ {u"url"_s, mxcUri()},
+ {u"body"_s, body()},
+ {u"info"_s, info()},
}},
};
}
diff --git a/src/qt-job.cpp b/src/qt-job.cpp
--- a/src/qt-job.cpp
+++ b/src/qt-job.cpp
@@ -28,7 +28,7 @@
auto query = job.requestQuery();
auto qQuery = QUrlQuery();
for (auto &&[k, v] : query) {
- qQuery.addQueryItem(QByteArray::fromStdString(k), QByteArray::fromStdString(v));
+ qQuery.addQueryItem(QString::fromStdString(k), QString::fromStdString(v));
}
auto url = QUrl(QString::fromStdString(job.url()));
diff --git a/src/shortcuts/shortcut-util.cpp b/src/shortcuts/shortcut-util.cpp
--- a/src/shortcuts/shortcut-util.cpp
+++ b/src/shortcuts/shortcut-util.cpp
@@ -8,6 +8,8 @@
#include "shortcut-util.hpp"
#include <QKeySequence>
+using namespace Qt::Literals::StringLiterals;
+
// https://stackoverflow.com/questions/64826271/how-to-use-qkeysequence-or-qkeysequenceedit-from-qml
static bool isKeyUnknown(int key)
{
@@ -40,7 +42,7 @@
QString modifierOnlyString = QKeySequence(Qt::Key_Underscore | modifiers).toString();
// Change "Ctrl+_" to "Ctrl+..."
- modifierOnlyString.replace("_", "...");
+ modifierOnlyString.replace('_'_L1, u"..."_s);
return modifierOnlyString;
}
}
diff --git a/src/tests/kazv-markdown-test.cpp b/src/tests/kazv-markdown-test.cpp
--- a/src/tests/kazv-markdown-test.cpp
+++ b/src/tests/kazv-markdown-test.cpp
@@ -15,6 +15,7 @@
#include "kazv-markdown.hpp"
#include "matrix-room.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
using namespace Kazv::Factory;
@@ -113,14 +114,14 @@
void KazvMarkdownTest::testMakeMentionsEvent()
{
auto replyToEvent = makeEvent(withEventKV(json::json_pointer("/sender"), "@foo:example.com"));
- auto e1 = makeTextMessageJson("@foo:example.com mew", "", "", Kazv::Event());
+ auto e1 = makeTextMessageJson(u"@foo:example.com mew"_s, u""_s, u""_s, Kazv::Event());
QVERIFY(e1["content"]["m.mentions"]["user_ids"] == json{"@foo:example.com"});
- auto e2 = makeTextMessageJson("@foo:example.com mew", "", QString::fromStdString(replyToEvent.id()), replyToEvent);
+ auto e2 = makeTextMessageJson(u"@foo:example.com mew"_s, u""_s, QString::fromStdString(replyToEvent.id()), replyToEvent);
QVERIFY(e2["content"]["m.mentions"]["user_ids"] == json{"@foo:example.com"});
- auto e3 = makeTextMessageJson("@bar:example.com mew", "", QString::fromStdString(replyToEvent.id()), replyToEvent);
+ auto e3 = makeTextMessageJson(u"@bar:example.com mew"_s, u""_s, QString::fromStdString(replyToEvent.id()), replyToEvent);
QVERIFY((e3["content"]["m.mentions"]["user_ids"] == json{"@bar:example.com", "@foo:example.com"}));
}
diff --git a/src/tests/matrix-event-test.cpp b/src/tests/matrix-event-test.cpp
--- a/src/tests/matrix-event-test.cpp
+++ b/src/tests/matrix-event-test.cpp
@@ -18,6 +18,7 @@
#include "test-model.hpp"
#include "test-utils.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
using namespace Kazv::Factory;
@@ -48,7 +49,7 @@
auto timeline = toUniquePtr(room->timeline());
auto event = toUniquePtr(timeline->at(3));
- QCOMPARE(event->eventId(), "$1");
+ QCOMPARE(event->eventId(), u"$1"_s);
auto history = toUniquePtr(event->history());
// three versions including the original one
QCOMPARE(history->count(), 3);
@@ -56,13 +57,13 @@
QCOMPARE(toUniquePtr(history->at(0))->underlyingEvent(), event->underlyingEvent());
auto v1 = toUniquePtr(history->at(1));
- QCOMPARE(v1->content()["body"], QStringLiteral("second"));
+ QCOMPARE(v1->content()[u"body"_s], QStringLiteral("second"));
QCOMPARE(v1->eventId(), QStringLiteral("$3"));
QCOMPARE(v1->underlyingEvent().originServerTs(), 1720751684800);
QCOMPARE(v1->relationType(), QStringLiteral("moe.kazv.mxc.some-rel"));
auto v2 = toUniquePtr(history->at(2));
- QCOMPARE(v2->content()["body"], QStringLiteral("third"));
+ QCOMPARE(v2->content()[u"body"_s], QStringLiteral("third"));
QCOMPARE(v2->eventId(), QStringLiteral("$4"));
QCOMPARE(v2->underlyingEvent().originServerTs(), 1720751684900);
QCOMPARE(v2->relationType(), QStringLiteral("moe.kazv.mxc.some-rel"));
@@ -92,7 +93,7 @@
auto timeline = toUniquePtr(room->timeline());
auto event = toUniquePtr(timeline->at(1));
- QCOMPARE(event->eventId(), "$0");
+ QCOMPARE(event->eventId(), u"$0"_s);
auto history = toUniquePtr(event->history());
// three versions including the original one
QCOMPARE(history->count(), 2);
@@ -101,7 +102,7 @@
auto v1 = toUniquePtr(history->at(1));
QCOMPARE(v1->sender(), QString::fromStdString(events[1].sender()));
- QCOMPARE(v1->content()["body"], QStringLiteral("second"));
+ QCOMPARE(v1->content()[u"body"_s], QStringLiteral("second"));
QCOMPARE(v1->eventId(), QStringLiteral("$1"));
QCOMPARE(v1->relationType(), QStringLiteral());
}
diff --git a/src/tests/matrix-link-test.cpp b/src/tests/matrix-link-test.cpp
--- a/src/tests/matrix-link-test.cpp
+++ b/src/tests/matrix-link-test.cpp
@@ -11,6 +11,8 @@
#include "matrix-link.hpp"
+using namespace Qt::Literals::StringLiterals;
+
class MatrixLinkTest : public QObject
{
Q_OBJECT
@@ -26,13 +28,13 @@
void MatrixLinkTest::testInvalidLink()
{
std::vector<QUrl> links = {
- QUrl("https://matrix.to/#"),
- QUrl("https://matrix.to/#/"),
- QUrl("https://matrix.to/#//"),
- QUrl("https://matrix.to/#///"),
- QUrl("http://matrix.to/#/%40alice%3Aexample.org"),
- QUrl("https://lol.lol/#/%40alice%3Aexample.org"),
- QUrl("https://matrix.to/#%40alice%3Aexample.org"),
+ QUrl(u"https://matrix.to/#"_s),
+ QUrl(u"https://matrix.to/#/"_s),
+ QUrl(u"https://matrix.to/#//"_s),
+ QUrl(u"https://matrix.to/#///"_s),
+ QUrl(u"http://matrix.to/#/%40alice%3Aexample.org"_s),
+ QUrl(u"https://lol.lol/#/%40alice%3Aexample.org"_s),
+ QUrl(u"https://matrix.to/#%40alice%3Aexample.org"_s),
};
for (auto link : links) {
MatrixLink ml(link);
@@ -43,29 +45,29 @@
void MatrixLinkTest::testUserLink()
{
std::vector<QUrl> links = {
- QUrl("https://matrix.to/#/%40alice%3Aexample.org"),
- QUrl("https://matrix.to/#/@alice%3Aexample.org"),
- QUrl("https://matrix.to/#/%40alice:example.org"),
- QUrl("https://matrix.to/#/@alice:example.org"),
+ QUrl(u"https://matrix.to/#/%40alice%3Aexample.org"_s),
+ QUrl(u"https://matrix.to/#/@alice%3Aexample.org"_s),
+ QUrl(u"https://matrix.to/#/%40alice:example.org"_s),
+ QUrl(u"https://matrix.to/#/@alice:example.org"_s),
};
for (auto link : links) {
MatrixLink ml(link);
QVERIFY(ml.isUser());
- QCOMPARE(ml.identifiers(), QStringList{"@alice:example.org"});
+ QCOMPARE(ml.identifiers(), QStringList{u"@alice:example.org"_s});
}
}
void MatrixLinkTest::testRoomLink()
{
std::vector<std::tuple<QUrl, QString>> links = {
- {QUrl("https://matrix.to/#/%23somewhere%3Aexample.org"), "#somewhere:example.org"},
- {QUrl("https://matrix.to/#/%23somewhere:example.org"), "#somewhere:example.org"},
- {QUrl("https://matrix.to/#/#somewhere%3Aexample.org"), "#somewhere:example.org"},
- {QUrl("https://matrix.to/#/#somewhere:example.org"), "#somewhere:example.org"},
- {QUrl("https://matrix.to/#/!somewhere%3Aexample.org?via=elsewhere.ca"), "!somewhere:example.org"},
- {QUrl("https://matrix.to/#/!somewhere:example.org?via=elsewhere.ca"), "!somewhere:example.org"},
- {QUrl("https://matrix.to/#/!somewhere%3Aexample.org"), "!somewhere:example.org"},
- {QUrl("https://matrix.to/#/!somewhere:example.org"), "!somewhere:example.org"},
+ {QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org"_s), u"#somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/%23somewhere:example.org"_s), u"#somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/#somewhere%3Aexample.org"_s), u"#somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/#somewhere:example.org"_s), u"#somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/!somewhere%3Aexample.org?via=elsewhere.ca"_s), u"!somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/!somewhere:example.org?via=elsewhere.ca"_s), u"!somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/!somewhere%3Aexample.org"_s), u"!somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/!somewhere:example.org"_s), u"!somewhere:example.org"_s},
};
for (auto [link, pointed] : links) {
MatrixLink ml(link);
@@ -77,27 +79,27 @@
void MatrixLinkTest::testEventLink()
{
std::vector<std::tuple<QUrl, QString>> links = {
- {QUrl("https://matrix.to/#/%23somewhere%3Aexample.org/%24event%3Aexample.org"), "#somewhere:example.org"},
- {QUrl("https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org"), "#somewhere:example.org"},
- {QUrl("https://matrix.to/#/!somewhere%3Aexample.org/%24event%3Aexample.org?via=elsewhere.ca"), "!somewhere:example.org"},
- {QUrl("https://matrix.to/#/!somewhere%3Aexample.org/$event:example.org?via=elsewhere.ca"), "!somewhere:example.org"},
+ {QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org/%24event%3Aexample.org"_s), u"#somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org"_s), u"#somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/!somewhere%3Aexample.org/%24event%3Aexample.org?via=elsewhere.ca"_s), u"!somewhere:example.org"_s},
+ {QUrl(u"https://matrix.to/#/!somewhere%3Aexample.org/$event:example.org?via=elsewhere.ca"_s), u"!somewhere:example.org"_s},
};
for (auto [link, pointed] : links) {
MatrixLink ml(link);
QVERIFY(ml.isRoom());
- QCOMPARE(ml.identifiers(), (QStringList{pointed, "$event:example.org"}));
+ QCOMPARE(ml.identifiers(), (QStringList{pointed, u"$event:example.org"_s}));
}
}
void MatrixLinkTest::testRoutingServers()
{
- QCOMPARE(MatrixLink(QUrl("https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org")).routingServers(), (QStringList{}));
+ QCOMPARE(MatrixLink(QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org"_s)).routingServers(), (QStringList{}));
- QCOMPARE(MatrixLink(QUrl("https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org?via=a.org")).routingServers(), (QStringList{"a.org"}));
+ QCOMPARE(MatrixLink(QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org?via=a.org"_s)).routingServers(), (QStringList{u"a.org"_s}));
- QCOMPARE(MatrixLink(QUrl("https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org?via=a.org&via=b.org")).routingServers(), (QStringList{"a.org", "b.org"}));
+ QCOMPARE(MatrixLink(QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org?via=a.org&via=b.org"_s)).routingServers(), (QStringList{u"a.org"_s, u"b.org"_s}));
- QCOMPARE(MatrixLink(QUrl("https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org?foo=bar&via=a.org&via=b.org")).routingServers(), (QStringList{"a.org", "b.org"}));
+ QCOMPARE(MatrixLink(QUrl(u"https://matrix.to/#/%23somewhere%3Aexample.org/%24event:example.org?foo=bar&via=a.org&via=b.org"_s)).routingServers(), (QStringList{u"a.org"_s, u"b.org"_s}));
}
QTEST_MAIN(MatrixLinkTest)
diff --git a/src/tests/matrix-promise-test.cpp b/src/tests/matrix-promise-test.cpp
--- a/src/tests/matrix-promise-test.cpp
+++ b/src/tests/matrix-promise-test.cpp
@@ -17,6 +17,7 @@
#include "matrix-promise.hpp"
#include "qt-promise-handler.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
class MatrixPromiseTest : public QObject
@@ -73,7 +74,7 @@
QCOMPARE(calledSpies[0]->first().at(0), true);
QCOMPARE(calledSpies[0]->first().at(1), QJsonValue(QJsonValue::Null));
- QCOMPARE(calledSpies[3]->first().at(0), QJsonValue(QJsonObject{{"error", "some"}, {"errorCode", "code"}}));
+ QCOMPARE(calledSpies[3]->first().at(0), QJsonValue(QJsonObject{{u"error"_s, u"some"_s}, {u"errorCode"_s, u"code"_s}}));
QCOMPARE(calledSpies[5]->first().at(0), QJsonValue(QJsonArray{0, 1, 2}));
}
diff --git a/src/tests/matrix-room-list-test.cpp b/src/tests/matrix-room-list-test.cpp
--- a/src/tests/matrix-room-list-test.cpp
+++ b/src/tests/matrix-room-list-test.cpp
@@ -20,6 +20,7 @@
#include "test-utils.hpp"
#include "factory.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
using namespace Kazv::Factory;
@@ -55,10 +56,10 @@
QCOMPARE(roomList->count(), 2);
- roomList->setTagId("m.favourite");
+ roomList->setTagId(u"m.favourite"_s);
QCOMPARE(roomList->count(), 1);
- roomList->setTagId("u.xxx");
+ roomList->setTagId(u"u.xxx"_s);
QCOMPARE(roomList->count(), 0);
}
@@ -177,29 +178,29 @@
std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)};
auto roomList = toUniquePtr(sdk->roomList());
- roomList->setfilter("some");
+ roomList->setfilter(u"some"_s);
QCOMPARE(roomList->count(), 2);
QCOMPARE(roomList->roomIds().contains(QString::fromStdString(room2.roomId)), true);
QCOMPARE(roomList->roomIds().contains(QString::fromStdString(room1.roomId)), true);
- roomList->setfilter("!some:example.org");
+ roomList->setfilter(u"!some:example.org"_s);
QCOMPARE(roomList->count(), 1);
QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId));
- roomList->setfilter("foo");
+ roomList->setfilter(u"foo"_s);
QCOMPARE(roomList->count(), 1);
QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId));
- roomList->setfilter("aaa");
+ roomList->setfilter(u"aaa"_s);
QCOMPARE(roomList->count(), 1);
QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId));
// By custom nickname of user (@foo:tusooa.xyz)
- roomList->setfilter("xxxx");
+ roomList->setfilter(u"xxxx"_s);
QCOMPARE(roomList->count(), 1);
QCOMPARE(roomList->roomIdAt(0), QString::fromStdString(room3.roomId));
@@ -225,8 +226,8 @@
QCOMPARE(roomList->count(), 3);
// Priority: Invite > Favourite
- QCOMPARE(roomList->roomIdAt(0), "!invite:tusooa.xyz");
- QCOMPARE(roomList->roomIdAt(1), "!favourite:tusooa.xyz");
+ QCOMPARE(roomList->roomIdAt(0), u"!invite:tusooa.xyz"_s);
+ QCOMPARE(roomList->roomIdAt(1), u"!favourite:tusooa.xyz"_s);
}
QTEST_MAIN(MatrixRoomListTest)
diff --git a/src/tests/matrix-room-member-list-model-test.cpp b/src/tests/matrix-room-member-list-model-test.cpp
--- a/src/tests/matrix-room-member-list-model-test.cpp
+++ b/src/tests/matrix-room-member-list-model-test.cpp
@@ -18,6 +18,7 @@
#include "test-model.hpp"
#include "test-utils.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
class MatrixRoomMemberListModelTest : public QObject
@@ -41,11 +42,11 @@
QCOMPARE(model.count(), 2);
auto first = toUniquePtr(model.at(0));
- QCOMPARE(first->name(), "user 1");
- QCOMPARE(first->userId(), "@t1:tusooa.xyz");
+ QCOMPARE(first->name(), u"user 1"_s);
+ QCOMPARE(first->userId(), u"@t1:tusooa.xyz"_s);
auto second = toUniquePtr(model.at(1));
- QCOMPARE(second->name(), QStringLiteral());
- QCOMPARE(second->userId(), "@t2:tusooa.xyz");
+ QVERIFY(second->name().isEmpty());
+ QCOMPARE(second->userId(), u"@t2:tusooa.xyz"_s);
}
@@ -61,28 +62,28 @@
QCOMPARE(model.count(), 2);
- model.setfilter(QString("@t"));
+ model.setfilter(u"@t"_s);
QCOMPARE(model.count(), 2);
{
- model.setfilter(QString("user 1"));
+ model.setfilter(u"user 1"_s);
QCOMPARE(model.count(), 1);
auto first = toUniquePtr(model.at(0));
- QCOMPARE(first->userId(), QString("@t1:tusooa.xyz"));
+ QCOMPARE(first->userId(), u"@t1:tusooa.xyz"_s);
}
{
- model.setfilter(QString("t2"));
+ model.setfilter(u"t2"_s);
QCOMPARE(model.count(), 1);
auto first = toUniquePtr(model.at(0));
- QCOMPARE(first->userId(), QString("@t2:tusooa.xyz"));
+ QCOMPARE(first->userId(), u"@t2:tusooa.xyz"_s);
}
{
- model.setfilter(QString("mewmew"));
+ model.setfilter(u"mewmew"_s);
QCOMPARE(model.count(), 1);
auto first = toUniquePtr(model.at(0));
- QCOMPARE(first->userId(), QString("@t1:tusooa.xyz"));
+ QCOMPARE(first->userId(), u"@t1:tusooa.xyz"_s);
}
}
diff --git a/src/tests/matrix-room-timeline-test.cpp b/src/tests/matrix-room-timeline-test.cpp
--- a/src/tests/matrix-room-timeline-test.cpp
+++ b/src/tests/matrix-room-timeline-test.cpp
@@ -23,6 +23,7 @@
#include "test-model.hpp"
#include "test-utils.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
using namespace Kazv::Factory;
@@ -42,7 +43,7 @@
auto model = makeTestModel();
std::unique_ptr<MatrixSdk> sdk{makeTestSdk(model)};
auto roomList = toUniquePtr(sdk->roomList());
- auto room = toUniquePtr(roomList->room("!foo:tusooa.xyz"));
+ auto room = toUniquePtr(roomList->room(u"!foo:tusooa.xyz"_s));
auto timeline = toUniquePtr(room->timeline());
QCOMPARE(timeline->count(), 2);
@@ -50,12 +51,12 @@
QCOMPARE(first->isSending(), true);
QCOMPARE(first->isLocalEcho(), true);
QCOMPARE(first->isFailed(), false);
- QCOMPARE(first->txnId(), "some-txn-id");
+ QCOMPARE(first->txnId(), u"some-txn-id"_s);
auto second = toUniquePtr(timeline->at(0));
QCOMPARE(second->isSending(), false);
QCOMPARE(second->isLocalEcho(), true);
QCOMPARE(second->isFailed(), true);
- QCOMPARE(second->txnId(), "some-other-txn-id");
+ QCOMPARE(second->txnId(), u"some-other-txn-id"_s);
}
void MatrixRoomTimelineTest::testReadReceipts()
@@ -73,20 +74,20 @@
auto timeline = toUniquePtr(room->timeline());
{
auto event = toUniquePtr(timeline->at(1));
- QCOMPARE(event->eventId(), "$1");
+ QCOMPARE(event->eventId(), u"$1"_s);
auto readers = toUniquePtr(event->readers());
QCOMPARE(readers->count(), 2);
auto reader1 = toUniquePtr(readers->at(0));
- QCOMPARE(reader1->userId(), "@a:example.com");
+ QCOMPARE(reader1->userId(), u"@a:example.com"_s);
QCOMPARE(reader1->timestamp(), 1234);
auto reader2 = toUniquePtr(readers->at(1));
- QCOMPARE(reader2->userId(), "@b:example.com");
+ QCOMPARE(reader2->userId(), u"@b:example.com"_s);
QCOMPARE(reader2->timestamp(), 5678);
}
{
auto event = toUniquePtr(timeline->at(0));
- QCOMPARE(event->eventId(), "$2");
+ QCOMPARE(event->eventId(), u"$2"_s);
auto readers = toUniquePtr(event->readers());
QCOMPARE(readers->count(), 0);
}
@@ -118,13 +119,13 @@
auto timeline = toUniquePtr(room->timeline());
auto event = toUniquePtr(timeline->at(7));
- QCOMPARE(event->eventId(), "$1");
+ QCOMPARE(event->eventId(), u"$1"_s);
// the content is taken from the newest valid edit
qDebug() << event->content();
- QCOMPARE(event->content(), (QJsonObject{{"body", "third"}}));
+ QCOMPARE(event->content(), (QJsonObject{{u"body"_s, u"third"_s}}));
// the relation is taken from the original content
- QCOMPARE(event->relationType(), "moe.kazv.mxc.some-rel");
- QCOMPARE(event->relatedEventId(), "$0");
+ QCOMPARE(event->relationType(), u"moe.kazv.mxc.some-rel"_s);
+ QCOMPARE(event->relatedEventId(), u"$0"_s);
QVERIFY(event->isEdited());
}
@@ -150,10 +151,10 @@
auto room = toUniquePtr(roomList->room(QString::fromStdString(r.roomId)));
auto timeline = toUniquePtr(room->timeline());
- QCOMPARE(timeline->indexOfEvent("$1"), 4);
- QCOMPARE(timeline->indexOfEvent("$2"), 3);
- QCOMPARE(timeline->indexOfEvent("$3"), 2);
- QCOMPARE(timeline->indexOfEvent("$4"), -1);
+ QCOMPARE(timeline->indexOfEvent(u"$1"_s), 4);
+ QCOMPARE(timeline->indexOfEvent(u"$2"_s), 3);
+ QCOMPARE(timeline->indexOfEvent(u"$3"_s), 2);
+ QCOMPARE(timeline->indexOfEvent(u"$4"_s), -1);
}
QTEST_MAIN(MatrixRoomTimelineTest)
diff --git a/src/tests/matrix-sdk-sessions-test.cpp b/src/tests/matrix-sdk-sessions-test.cpp
--- a/src/tests/matrix-sdk-sessions-test.cpp
+++ b/src/tests/matrix-sdk-sessions-test.cpp
@@ -17,6 +17,7 @@
#include "test-temp.hpp"
#include "matrix-sdk-sessions-test.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
namespace Fs = std::filesystem;
using StdPath = Fs::path;
@@ -100,7 +101,7 @@
createSession("@mew:example.com", "device4");
auto sdk = makeMatrixSdk();
- auto res = sdk->loadSession("@mew:example.com/device4");
+ auto res = sdk->loadSession(u"@mew:example.com/device4"_s);
QCOMPARE(res, MatrixSdk::SessionLoadSuccess);
QCOMPARE(sdk->userId(), QStringLiteral("@mew:example.com"));
QCOMPARE(sdk->deviceId(), QStringLiteral("device4"));
diff --git a/src/tests/matrix-sdk-test.cpp b/src/tests/matrix-sdk-test.cpp
--- a/src/tests/matrix-sdk-test.cpp
+++ b/src/tests/matrix-sdk-test.cpp
@@ -19,6 +19,7 @@
#include "test-model.hpp"
#include "test-utils.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
class MatrixSdkTest : public QObject
@@ -38,8 +39,8 @@
auto devices = toUniquePtr(sdk->devicesOfUser(QStringLiteral("@test1:test1.org")));
QVERIFY(devices->count() == 2);
auto dev = toUniquePtr(devices->at(0));
- QVERIFY(dev->deviceId() == "device1");
- QVERIFY(dev->trustLevel() == "unseen");
+ QVERIFY(dev->deviceId() == u"device1"_s);
+ QVERIFY(dev->trustLevel() == u"unseen"_s);
}
void MatrixSdkTest::testSetDeviceTrustLevel()
@@ -63,8 +64,8 @@
auto devices = toUniquePtr(sdk->devicesOfUser(QStringLiteral("@test1:test1.org")));
QVERIFY(devices->count() == 2);
auto dev = toUniquePtr(devices->at(0));
- QVERIFY(dev->deviceId() == "device1");
- QTRY_VERIFY(dev->trustLevel() == "verified"); // wait for the change to propagate to this thread
+ QVERIFY(dev->deviceId() == u"device1"_s);
+ QTRY_VERIFY(dev->trustLevel() == u"verified"_s); // wait for the change to propagate to this thread
}
QTEST_MAIN(MatrixSdkTest)
diff --git a/src/tests/matrix-sticker-pack-test.cpp b/src/tests/matrix-sticker-pack-test.cpp
--- a/src/tests/matrix-sticker-pack-test.cpp
+++ b/src/tests/matrix-sticker-pack-test.cpp
@@ -24,6 +24,7 @@
#include "matrix-event.hpp"
#include "matrix-sdk.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
using namespace Kazv::Factory;
@@ -82,11 +83,11 @@
QCOMPARE(sticker0->mxcUri(), QStringLiteral("mxc://example.org/blah"));
QCOMPARE(sticker0->info(), QJsonObject());
QCOMPARE(sticker0->makeEventJson(), (QJsonObject{
- {"type", "m.sticker"},
- {"content", QJsonObject{
- {"body", "myemote"},
- {"url", "mxc://example.org/blah"},
- {"info", QJsonObject()},
+ {u"type"_s, u"m.sticker"_s},
+ {u"content"_s, QJsonObject{
+ {u"body"_s, u"myemote"_s},
+ {u"url"_s, u"mxc://example.org/blah"_s},
+ {u"info"_s, QJsonObject()},
}},
}));
@@ -94,13 +95,13 @@
QCOMPARE(sticker1->shortCode(), QStringLiteral("mysticker"));
QCOMPARE(sticker1->body(), QStringLiteral("my sticker"));
QCOMPARE(sticker1->mxcUri(), QStringLiteral("mxc://example.org/sticker"));
- QCOMPARE(sticker1->info(), (QJsonObject{{"mimetype", "image/png"}}));
+ QCOMPARE(sticker1->info(), (QJsonObject{{u"mimetype"_s, u"image/png"_s}}));
QCOMPARE(sticker1->makeEventJson(), (QJsonObject{
- {"type", "m.sticker"},
- {"content", QJsonObject{
- {"body", "my sticker"},
- {"url", "mxc://example.org/sticker"},
- {"info", QJsonObject{{"mimetype", "image/png"}}},
+ {u"type"_s, u"m.sticker"_s},
+ {u"content"_s, QJsonObject{
+ {u"body"_s, u"my sticker"_s},
+ {u"url"_s, u"mxc://example.org/sticker"_s},
+ {u"info"_s, QJsonObject{{u"mimetype"_s, u"image/png"_s}}},
}},
}));
}
@@ -140,7 +141,7 @@
));
auto event = toUniquePtr(new MatrixEvent(eventCursor));
- auto newSource = stickerPack->addSticker("someotheremote", event.get()).template value<MatrixStickerPackSource>();
+ auto newSource = stickerPack->addSticker(u"someotheremote"_s, event.get()).template value<MatrixStickerPackSource>();
auto expected = sourceCursor.get().event.content().get();
expected["images"]["someotheremote"] = contentJson;
diff --git a/src/tests/matrix-user-given-attrs-map-test.cpp b/src/tests/matrix-user-given-attrs-map-test.cpp
--- a/src/tests/matrix-user-given-attrs-map-test.cpp
+++ b/src/tests/matrix-user-given-attrs-map-test.cpp
@@ -15,6 +15,7 @@
#include "test-utils.hpp"
#include "matrix-user-given-attrs-map.hpp"
+using namespace Qt::Literals::StringLiterals;
using namespace Kazv;
class MatrixUserGivenAttrsMapTest : public QObject
@@ -72,8 +73,8 @@
{
{
auto map = MatrixUserGivenAttrsMap(lager::make_constant(emptyEvent), FakeSetter());
- QCOMPARE(map.set("@a:example.com", QJsonValue()), json::object());
- QCOMPARE(map.set("@a:example.com", "k"), (json{{"@a:example.com", "k"}}));
+ QCOMPARE(map.set(u"@a:example.com"_s, QJsonValue()), json::object());
+ QCOMPARE(map.set(u"@a:example.com"_s, u"k"_s), (json{{"@a:example.com", "k"}}));
}
{
@@ -82,12 +83,12 @@
auto setter = FakeSetter{this, called, lastVal};
auto map = MatrixUserGivenAttrsMap(lager::make_constant(nicknameEvent), setter);
- QCOMPARE(map.set("@alice:example.com", QJsonValue()), (json{
+ QCOMPARE(map.set(u"@alice:example.com"_s, QJsonValue()), (json{
{"@bob:example.com", "Bobby"},
{"@eve:example.com", "My Lifelong Rival"},
}));
- QCOMPARE(map.set("@alice:example.com", "Something"), (json{
+ QCOMPARE(map.set(u"@alice:example.com"_s, u"Something"_s), (json{
{"@alice:example.com", "Something"},
{"@bob:example.com", "Bobby"},
{"@eve:example.com", "My Lifelong Rival"},
@@ -95,7 +96,7 @@
QCOMPARE(*called, 0);
- auto p = toUniquePtr(map.setAndUpload("@alice:example.com", "Something"));
+ auto p = toUniquePtr(map.setAndUpload(u"@alice:example.com"_s, u"Something"_s));
QCOMPARE(*called, 1);
QCOMPARE(*lastVal, (json{
{"@alice:example.com", "Something"},
diff --git a/src/tests/quick-tests/tst_ConfirmUploadPopup.qml b/src/tests/quick-tests/tst_ConfirmUploadPopup.qml
--- a/src/tests/quick-tests/tst_ConfirmUploadPopup.qml
+++ b/src/tests/quick-tests/tst_ConfirmUploadPopup.qml
@@ -15,7 +15,7 @@
Item {
id: item
- width: Kirigami.Units.gridUnit * 40
+ width: Kirigami.Units.gridUnit * 80
height: 600
property var l10n: Helpers.fluentMock
@@ -30,11 +30,7 @@
}
function isSheetOpen(sheet) {
- if (MK.KazvUtil.kfQtMajorVersion === 5) {
- return sheet.sheetOpen;
- } else {
- return sheet.opened;
- }
+ return sheet.opened;
}
TestCase {
@@ -96,11 +92,9 @@
function test_multiUploadCancelled() {
confirmUploadPopup.call(['file:///tmp/image.png', 'file:///tmp/a.txt']);
tryVerify(() => isSheetOpen(confirmUploadPopup));
- if (MK.KazvUtil.kfQtMajorVersion === 5) {
- confirmUploadPopup.contentItem.parent = item;
- }
tryVerify(() => findChild(confirmUploadPopup, 'imagePreview').visible);
- mouseClick(findChild(confirmUploadPopup, 'cancelButton'));
+ const button = findChild(confirmUploadPopup, 'cancelButton');
+ mouseClick(button);
tryVerify(() => !isSheetOpen(confirmUploadPopup));
verify(uploadRequestedSpy.count === 0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 10:05 PM (17 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39145
Default Alt Text
D144.1732341918.diff (45 KB)
Attached To
Mode
D144: Port away from legacy implicit conversions
Attached
Detach File
Event Timeline
Log In to Comment