summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-04 16:02:06 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-05 00:24:00 +0200
commit82de61470c0e43e228bdb3b3f1afc84afc6bbdc8 (patch)
tree9abab0a1ff686ac5436d92cf5b516d5e953339e4 /framework
parent7787aab8214820197f09a79c8f49f1ba039981e9 (diff)
downloadkube-82de61470c0e43e228bdb3b3f1afc84afc6bbdc8.tar.gz
kube-82de61470c0e43e228bdb3b3f1afc84afc6bbdc8.zip
Texteditor tests
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/tests/tst_texteditor.qml33
1 files 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 {
28 height: 400 28 height: 400
29 name: "TextEditor" 29 name: "TextEditor"
30 30
31 Kube.TextEditor { 31 Component {
32 id: editor 32 id: editorComponent
33 initialText: "Foobar\nBarBar" 33 Kube.TextEditor {}
34 htmlEnabled: false
35 } 34 }
36 35
37 function test_1initialText() { 36 function test_1initialText() {
37 var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: false})
38 compare(editor.text, editor.initialText) 38 compare(editor.text, editor.initialText)
39 } 39 }
40 40
41 function test_2htmlConversion() { 41 function test_2plainToHtmlConversion() {
42 var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: false})
42 editor.htmlEnabled = true 43 editor.htmlEnabled = true
43 verify(editor.text.indexOf("<html>") !== -1) 44 verify(editor.text.indexOf("<html>") !== -1)
44 //It's converted into two paragraphs, so we can't check as a single string 45 //It's converted into two paragraphs, so we can't check as a single string
@@ -46,5 +47,27 @@ TestCase {
46 verify(editor.text.indexOf("BarBar") !== -1) 47 verify(editor.text.indexOf("BarBar") !== -1)
47 editor.htmlEnabled = false 48 editor.htmlEnabled = false
48 compare(editor.text, editor.initialText) 49 compare(editor.text, editor.initialText)
50
51 editor.htmlEnabled = true
52 verify(editor.text.indexOf("<html>") !== -1)
53 }
54
55 function test_3htmlToPlainConversion() {
56 var editor = createTemporaryObject(editorComponent, testCase, {initialText: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\" font-family:'Noto Sans'; font-size:9pt; font-weight:400; font-style:normal;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">test</p></body></html>", htmlEnabled: true})
57 editor.htmlEnabled = false
58 compare(editor.text, "test")
59
60 editor.htmlEnabled = true
61 verify(editor.text.indexOf("<html>") !== -1)
62 }
63
64 function test_4detectPlain() {
65 var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: true})
66 compare(editor.htmlEnabled, false)
67 }
68
69 function test_5detectHtml() {
70 var editor = createTemporaryObject(editorComponent, testCase, {initialText: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\" font-family:'Noto Sans'; font-size:9pt; font-weight:400; font-style:normal;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">test</p></body></html>", htmlEnabled: false})
71 compare(editor.htmlEnabled, true)
49 } 72 }
50} 73}