diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-31 13:46:48 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-31 13:46:48 +0200 |
commit | 69c2e873e74727526cf197ab4a06b368a1d820ec (patch) | |
tree | 94ff7659ca6bb8e9e26ad1418d24bdd26ccc93af /framework/qml/tests | |
parent | ab2b00093e1a40fc8dabd2c95b4bbd576e88e953 (diff) | |
download | kube-69c2e873e74727526cf197ab4a06b368a1d820ec.tar.gz kube-69c2e873e74727526cf197ab4a06b368a1d820ec.zip |
Fixed texteditor test
Diffstat (limited to 'framework/qml/tests')
-rw-r--r-- | framework/qml/tests/tst_texteditor.qml | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/framework/qml/tests/tst_texteditor.qml b/framework/qml/tests/tst_texteditor.qml index f80afe66..544270e5 100644 --- a/framework/qml/tests/tst_texteditor.qml +++ b/framework/qml/tests/tst_texteditor.qml | |||
@@ -33,41 +33,27 @@ TestCase { | |||
33 | Kube.TextEditor {} | 33 | Kube.TextEditor {} |
34 | } | 34 | } |
35 | 35 | ||
36 | function test_1initialText() { | 36 | property string htmlText: "<!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;\"><b>Foobar</b><br>BarBar</p></body></html>" |
37 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: false}) | 37 | property string plainText: "Foobar\nBarBar" |
38 | compare(editor.text, editor.initialText) | ||
39 | } | ||
40 | 38 | ||
41 | function test_2plainToHtmlConversion() { | 39 | function test_1initialText() { |
42 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: false}) | 40 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: plainText}) |
43 | editor.htmlEnabled = true | ||
44 | verify(editor.text.indexOf("<html>") !== -1) | ||
45 | //It's converted into two paragraphs, so we can't check as a single string | ||
46 | verify(editor.text.indexOf("Foobar") !== -1) | ||
47 | verify(editor.text.indexOf("BarBar") !== -1) | ||
48 | editor.htmlEnabled = false | ||
49 | compare(editor.text, editor.initialText) | 41 | compare(editor.text, editor.initialText) |
50 | |||
51 | editor.htmlEnabled = true | ||
52 | verify(editor.text.indexOf("<html>") !== -1) | ||
53 | } | 42 | } |
54 | 43 | ||
55 | function test_3htmlToPlainConversion() { | 44 | 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}) | 45 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: htmlText}) |
57 | editor.htmlEnabled = false | 46 | editor.clearFormatting() |
58 | compare(editor.text, "test") | 47 | compare(editor.text, plainText) |
59 | |||
60 | editor.htmlEnabled = true | ||
61 | verify(editor.text.indexOf("<html>") !== -1) | ||
62 | } | 48 | } |
63 | 49 | ||
64 | function test_4detectPlain() { | 50 | function test_4detectPlain() { |
65 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: "Foobar\nBarBar", htmlEnabled: true}) | 51 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: plainText}) |
66 | compare(editor.htmlEnabled, false) | 52 | compare(editor.htmlEnabled, false) |
67 | } | 53 | } |
68 | 54 | ||
69 | function test_5detectHtml() { | 55 | 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}) | 56 | var editor = createTemporaryObject(editorComponent, testCase, {initialText: htmlText}) |
71 | compare(editor.htmlEnabled, true) | 57 | compare(editor.htmlEnabled, true) |
72 | } | 58 | } |
73 | } | 59 | } |