StatusQ: Redundant TextUtils removed
This commit is contained in:
parent
9f9dcefcf8
commit
417ad03ce1
|
@ -112,7 +112,6 @@ add_test(NAME DirectoryFilesWatcherTest COMMAND DirectoryFilesWatcherTest)
|
|||
|
||||
add_executable(QmlTests
|
||||
qmlTests/main.cpp
|
||||
qmlTests/src/TextUtils.cpp qmlTests/src/TextUtils.h
|
||||
${TEST_QML_FILES})
|
||||
|
||||
add_dependencies(QmlTests StatusQ)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include <QQmlEngine>
|
||||
#include <QtQuickTest>
|
||||
|
||||
#include "src/TextUtils.h"
|
||||
|
||||
class Setup : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -27,8 +25,6 @@ public slots:
|
|||
for (const auto& path : additionalImportPaths)
|
||||
engine->addImportPath(path);
|
||||
|
||||
qmlRegisterSingletonType<TextUtils>("TextUtils", 1, 0, "TextUtils", &TextUtils::qmlInstance);
|
||||
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#include "TextUtils.h"
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
TextUtils::TextUtils(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QObject *TextUtils::qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine)
|
||||
Q_UNUSED(scriptEngine)
|
||||
|
||||
static TextUtils instance;
|
||||
QQmlEngine::setObjectOwnership(&instance, QQmlEngine::CppOwnership);
|
||||
|
||||
return &instance;
|
||||
}
|
||||
|
||||
QString TextUtils::htmlToPlainText(const QString &html) {
|
||||
return QTextDocumentFragment::fromHtml( html ).toPlainText();
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
class QQmlEngine;
|
||||
class QJSEngine;
|
||||
|
||||
class TextUtils : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(TextUtils)
|
||||
public:
|
||||
static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine);
|
||||
|
||||
Q_INVOKABLE QString htmlToPlainText(const QString& html);
|
||||
|
||||
private:
|
||||
TextUtils(QObject *parent = nullptr);
|
||||
};
|
|
@ -4,6 +4,7 @@ import QtQml 2.14
|
|||
import QtTest 1.0
|
||||
|
||||
import StatusQ 0.1 // https://github.com/status-im/status-desktop/issues/10218
|
||||
import StatusQ.Core.Utils 0.1 as SQUtils
|
||||
|
||||
import utils 1.0
|
||||
import shared.status 1.0
|
||||
|
@ -11,8 +12,6 @@ import shared.stores 1.0 as SharedStores
|
|||
|
||||
import AppLayouts.Chat.stores 1.0 as ChatStores
|
||||
|
||||
import TextUtils 1.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
width: 600
|
||||
|
@ -601,7 +600,7 @@ Item {
|
|||
keyClick(Qt.Key_Left)
|
||||
compare(controlUnderTest.textInput.getText(0, controlUnderTest.textInput.length), "Hello @JohnDoe !")
|
||||
|
||||
var plainTextWithPubKey = TextUtils.htmlToPlainText(controlUnderTest.getTextWithPublicKeys())
|
||||
var plainTextWithPubKey = SQUtils.StringUtils.plainText(controlUnderTest.getTextWithPublicKeys())
|
||||
compare(plainTextWithPubKey, "Hello @0x0JohnDoe !")
|
||||
|
||||
controlUnderTest.textInput.cursorPosition = 15
|
||||
|
@ -609,7 +608,7 @@ Item {
|
|||
compare(controlUnderTest.textInput.getText(0, controlUnderTest.textInput.length), "Hello @JohnDoe!")
|
||||
|
||||
keyClick(Qt.Key_S)
|
||||
plainTextWithPubKey = TextUtils.htmlToPlainText(controlUnderTest.getTextWithPublicKeys())
|
||||
plainTextWithPubKey = SQUtils.StringUtils.plainText(controlUnderTest.getTextWithPublicKeys())
|
||||
compare(plainTextWithPubKey, "Hello @0x0JohnDoe s!")
|
||||
}
|
||||
|
||||
|
@ -633,7 +632,7 @@ Item {
|
|||
compare(controlUnderTest.textInput.getText(0, controlUnderTest.textInput.length),
|
||||
"Hels")
|
||||
|
||||
const plainTextWithPubKey = TextUtils.htmlToPlainText(controlUnderTest.getTextWithPublicKeys())
|
||||
const plainTextWithPubKey = SQUtils.StringUtils.plainText(controlUnderTest.getTextWithPublicKeys())
|
||||
compare(plainTextWithPubKey,
|
||||
"Hels")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue