1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 id: texteditelementtest
47 property string testtext: ""
48 property string wraptext: "Set this property to wrap the text to the TextEdit item's width. The text will only wrap if an explicit width has been set."
51 id: texteditelementbackground
52 color: "green"; height: 150; width: parent.width *.8; border.color: "gray"; opacity: 0.7; radius: 5; clip: true
53 anchors.centerIn: parent
57 font.pointSize: 12; width: parent.width; text: ""; horizontalAlignment: Text.AlignLeft
58 anchors.centerIn: parent
59 Behavior on font.pointSize { NumberAnimation { duration: 1000 } }
60 Behavior on color { ColorAnimation { duration: 1000 } }
65 id: secondarybackground
66 color: "lightgray"; border.color: "gray"; opacity: 0.7; radius: 5; height: 150; width: parent.width *.8
67 anchors { top: texteditelementbackground.bottom; topMargin: 50; horizontalCenter: parent.horizontalCenter }
71 property string ignoretext: "Nothing to see here"
72 font.pointSize: 12; width: parent.width; text: ""; opacity: text == ignoretext ? .3 : 1; horizontalAlignment: Text.AlignLeft
73 anchors.centerIn: parent
78 color: "lightgray"; height: 50; width: parent.width *.8; border.color: "gray"; opacity: 0; radius: 5
79 anchors.horizontalCenter: texteditelementbackground.horizontalCenter;
80 anchors.verticalCenter: texteditelementbackground.verticalCenter;
84 font.pointSize: 12; width: parent.width; text: ""; horizontalAlignment: Text.AlignLeft
85 anchors.centerIn: parent
88 transitions: Transition {
89 AnchorAnimation { targets: shadowrect; duration: 1000 }
92 SequentialAnimation { id: copypaste
93 ScriptAction { script: { secondary.text = ""; shadowtext.text = texteditelement.selectedText; texteditelement.copy(); } }
94 NumberAnimation { target: shadowrect; property: "opacity"; to: 0.5; duration: 100 }
95 PauseAnimation { duration: 1000 }
96 ScriptAction { script: { secondary.paste(); } }
97 NumberAnimation { target: shadowrect; property: "opacity"; to: 0; duration: 100 }
98 NumberAnimation { target: shadowrect; property: "x"; to: texteditelementbackground.x; duration: 0 }
101 SystemTestHelp { id: helpbubble; visible: statenum != 0
102 anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
104 BugPanel { id: bugpanel }
107 State { name: "start"; when: statenum == 1
110 texteditelement.text = "Hello, my name is TextEdit"
111 secondary.text = "Nothing to see here";
114 PropertyChanges { target: texteditelementtest
115 testtext: "This is a TextEdit element. At present it should be saying hello.\n"+
116 "Next, the TextEdit portion of the displayed text will be selected" }
118 State { name: "highlight"; when: statenum == 2
119 StateChangeScript { script: texteditelement.select(18, 26); }
120 PropertyChanges { target: texteditelementtest
121 testtext: "TextEdit should now be highlighted.\nNext, it will be copied this to the other TextEdit." }
123 State { name: "copypaste"; when: statenum == 3
124 PropertyChanges { target: copypaste; running: true }
125 AnchorChanges { target: shadowrect; anchors.verticalCenter: secondarybackground.verticalCenter }
126 PropertyChanges { target: texteditelementtest
127 testtext: "The second TextEdit should now be showing the selected text of the top TextEdit.\n"+
128 "Next, a larger amount of text will be entered." }
130 State { name: "largetextnowrap"; when: statenum == 4
131 PropertyChanges { target: texteditelement; text: wraptext }
132 PropertyChanges { target: texteditelementtest
133 testtext: "The TextEdit should now be showing a line of text, chopped off by the edge of the rectangle.\n"+
134 "Next, the TextEdit will set wrapping to fix that." }
136 State { name: "largetextwrap"; when: statenum == 5
137 PropertyChanges { target: texteditelement; text: wraptext; wrapMode: TextEdit.WordWrap }
138 PropertyChanges { target: texteditelementtest
139 testtext: "The TextEdit should now be showing a block of text.\n"+
140 "Advance to restart the test." }