From 82de61470c0e43e228bdb3b3f1afc84afc6bbdc8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 4 Jul 2018 16:02:06 +0200 Subject: Texteditor tests --- framework/qml/tests/tst_texteditor.qml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/framework/qml/tests/tst_texteditor.qml b/framework/qml/tests/tst_texteditor.qml index e4813a0d..f80afe66 100644 --- a/framework/qml/tests/tst_texteditor.qml +++ b/framework/qml/tests/tst_texteditor.qml @@ -28,17 +28,18 @@ TestCase { height: 400 name: "TextEditor" - Kube.TextEditor { - id: editor - initialText: "Foobar\nBarBar" - htmlEnabled: false + Component { + id: editorComponent + Kube.TextEditor {} } function test_1initialText() { + var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: false}) compare(editor.text, editor.initialText) } - function test_2htmlConversion() { + function test_2plainToHtmlConversion() { + var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: false}) editor.htmlEnabled = true verify(editor.text.indexOf("") !== -1) //It's converted into two paragraphs, so we can't check as a single string @@ -46,5 +47,27 @@ TestCase { verify(editor.text.indexOf("BarBar") !== -1) editor.htmlEnabled = false compare(editor.text, editor.initialText) + + editor.htmlEnabled = true + verify(editor.text.indexOf("") !== -1) + } + + function test_3htmlToPlainConversion() { + var editor = createTemporaryObject(editorComponent, testCase, {initialText: "

test

", htmlEnabled: true}) + editor.htmlEnabled = false + compare(editor.text, "test") + + editor.htmlEnabled = true + verify(editor.text.indexOf("") !== -1) + } + + function test_4detectPlain() { + var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: true}) + compare(editor.htmlEnabled, false) + } + + function test_5detectHtml() { + var editor = createTemporaryObject(editorComponent, testCase, {initialText: "

test

", htmlEnabled: false}) + compare(editor.htmlEnabled, true) } } -- cgit v1.2.3