1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
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: textinputelementtest
47 property string testtext: ""
50 id: textinputelementbackground
51 color: "green"; height: 50; width: parent.width *.8; border.color: "gray"; opacity: 0.7; radius: 5
52 anchors.centerIn: parent
55 font.pointSize: 12; width: parent.width; text: ""; horizontalAlignment: Text.AlignHCenter
56 anchors.centerIn: parent
57 Behavior on font.pointSize { NumberAnimation { duration: 1000 } }
58 Behavior on color { ColorAnimation { duration: 1000 } }
63 id: secondarybackground
64 color: "lightgray"; border.color: "gray"; opacity: 0.7; radius: 5; height: 50; width: parent.width *.8
65 anchors { top: textinputelementbackground.bottom; topMargin: 100; horizontalCenter: parent.horizontalCenter }
69 property string ignoretext: "Nothing to see here"
70 font.pointSize: 12; text: ""; opacity: text == ignoretext ? .3 : 1; horizontalAlignment: Text.AlignHCenter
71 anchors.centerIn: parent; width: parent.width
76 color: "lightgray"; height: 50; width: parent.width *.8; border.color: "gray"; opacity: 0; radius: 5
77 anchors.horizontalCenter: textinputelementbackground.horizontalCenter;
78 anchors.verticalCenter: textinputelementbackground.verticalCenter;
81 font.pointSize: 12; width: parent.width; text: ""; horizontalAlignment: Text.AlignHCenter
82 anchors.centerIn: parent
85 transitions: Transition {
86 AnchorAnimation { targets: shadowrect; duration: 1000 }
89 SequentialAnimation { id: copypaste
90 ScriptAction { script: { secondary.text = ""; shadowtext.text = textinputelement.selectedText; textinputelement.copy(); } }
91 NumberAnimation { target: shadowrect; property: "opacity"; to: 0.5; duration: 100 }
92 PauseAnimation { duration: 1000 }
93 ScriptAction { script: { secondary.paste(); } }
94 NumberAnimation { target: shadowrect; property: "opacity"; to: 0; duration: 100 }
95 NumberAnimation { target: shadowrect; property: "x"; to: textinputelementbackground.x; duration: 0 }
98 BugPanel { id: bugpanel }
100 SystemTestHelp { id: helpbubble; visible: statenum != 0
101 anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
105 State { name: "start"; when: statenum == 1
108 textinputelement.text = "Hello, my name is TextInput"
109 secondary.text = "Nothing to see here";
112 PropertyChanges { target: textinputelementtest
113 testtext: "This is a TextInput element. At present it should be saying hello.\n"+
114 "Next, it will select the TextInput portion of the displayed text" }
116 State { name: "highlight"; when: statenum == 2
117 StateChangeScript { script: textinputelement.select(18, 27); }
118 PropertyChanges { target: textinputelementtest
119 testtext: "TextInput should now be highlighted.\nNext, copy this to the other TextInput." }
121 State { name: "copypaste"; when: statenum == 3
122 PropertyChanges { target: copypaste; running: true }
123 AnchorChanges { target: shadowrect; anchors.verticalCenter: secondarybackground.verticalCenter }
124 PropertyChanges { target: textinputelementtest
125 testtext: "The second TextInput should now be showing the selected text of the top TextInput.\n"+
126 "Next, let's change the way the entered text is displayed." }
128 State { name: "passwordmode"; when: statenum == 4
129 StateChangeScript { script: textinputelement.deselect(); }
130 PropertyChanges { target: textinputelement; echoMode: TextInput.Password }
131 PropertyChanges { target: textinputelementtest
132 testtext: "The TextInput should now be showing asterisks (*) for every character in the top TextInput - all "+
133 textinputelement.text.length+" of them.\n"+
134 "Next, let's return to the start." }