diff options
Diffstat (limited to 'framework/qml/tests/tst_texteditor.qml')
-rw-r--r-- | framework/qml/tests/tst_texteditor.qml | 33 |
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 | } |