Warning, /pim/kube/framework/qml/tests/tst_texteditor.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright 2017 Christian Mollekopf <mollekopf@kolabsystems.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU Library General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 import QtQuick 2.7
0021 import QtTest 1.0
0022 import org.kube.framework 1.0 as Kube
0023 
0024 
0025 TestCase {
0026     id: testCase
0027     width: 400
0028     height: 400
0029     name: "TextEditor"
0030 
0031     Component {
0032         id: editorComponent
0033         Kube.TextEditor {}
0034     }
0035 
0036     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>"
0037     property string plainText: "Foobar\nBarBar"
0038 
0039     function test_1initialText() {
0040         var editor = createTemporaryObject(editorComponent, testCase, {initialText: plainText})
0041         compare(editor.text, editor.initialText)
0042     }
0043 
0044     function test_3htmlToPlainConversion() {
0045         var editor = createTemporaryObject(editorComponent, testCase, {initialText: htmlText})
0046         editor.clearFormatting()
0047         compare(editor.text, plainText)
0048     }
0049 
0050     function test_4detectPlain() {
0051         var editor = createTemporaryObject(editorComponent, testCase, {initialText: plainText})
0052         compare(editor.htmlEnabled, false)
0053     }
0054 
0055     function test_5detectHtml() {
0056         var editor = createTemporaryObject(editorComponent, testCase, {initialText: htmlText})
0057         compare(editor.htmlEnabled, true)
0058     }
0059 }