1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the test suite of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:BSD$
9
** You may use this file under the terms of the BSD license as follows:
11
** "Redistribution and use in source and binary forms, with or without
12
** modification, are permitted provided that the following conditions are
14
** * Redistributions of source code must retain the above copyright
15
** notice, this list of conditions and the following disclaimer.
16
** * Redistributions in binary form must reproduce the above copyright
17
** notice, this list of conditions and the following disclaimer in
18
** the documentation and/or other materials provided with the
20
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21
** of its contributors may be used to endorse or promote products derived
22
** from this software without specific prior written permission.
25
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39
****************************************************************************/
56
font.family: "Courier"
78
text: "The quick brown fox jumped over the lazy dog"
85
property string styledtextvalue: "Line 1<br>Line 2<br>Line 3"
86
text: "Line 1\nLine 2\nLine 3"
87
textFormat: Text.PlainText
94
function test_empty() {
95
compare(emptyText.text, "")
98
function test_family() {
99
compare(txtfamily.font.family, "Courier")
100
txtfamily.font.family = "Helvetica";
101
compare(txtfamily.font.family, "Helvetica")
104
function test_color() {
105
compare(txtcolor.color, "#ff0000")
106
txtcolor.color = "blue";
107
compare(txtcolor.color, "#0000ff")
110
function test_textentry() {
111
txtentry.focus = true;
112
compare(txtentry.text, "")
118
keyClick(Qt.Key_Space)
124
compare(txtentry.text, "hello world")
127
function test_functions() {
128
compare(txtfunctions.getText(4,9), "quick")
129
txtfunctions.select(4,9);
130
compare(txtfunctions.selectedText, "quick")
131
txtfunctions.deselect();
132
compare(txtfunctions.selectedText, "")
133
txtfunctions.select(4,9);
135
compare(txtfunctions.text, "The brown fox jumped over the lazy dog")
136
txtfunctions.text = "Qt";
137
txtfunctions.insert(txtfunctions.text.length, " ")
138
compare(txtfunctions.text, "Qt ");
139
txtfunctions.cursorPosition = txtfunctions.text.length;
140
txtfunctions.paste();
141
compare(txtfunctions.text, "Qt quick");
142
txtfunctions.cursorPosition = txtfunctions.text.length;
143
txtfunctions.selectWord();
144
compare(txtfunctions.selectedText, "quick")
146
txtfunctions.selectAll();
147
compare(txtfunctions.selectedText, "Qt quick")
148
txtfunctions.deselect();
149
compare(txtfunctions.selectedText, "")
150
txtfunctions.paste();
151
compare(txtfunctions.text, "Qt quickquick");
154
function test_linecounts() {
155
compare(txtlines.lineCount, 3)
156
txtlines.text = txtlines.styledtextvalue;
157
compare(txtlines.text, "Line 1<br>Line 2<br>Line 3")
158
tryCompare(txtlines.lineCount, 1)
159
txtlines.textFormat = Text.StyledText;
160
tryCompare(txtlines.lineCount, 3)
161
txtlines.textFormat = Text.RichText;
162
tryCompare(txtlines.lineCount, 3)