1 /****************************************************************************
3 ** Copyright (C) 2012 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: intvalidatorelementtest
47 property string testtext: ""
49 IntValidator { id: intvalidatorelement; top: 30; bottom: -50 //top: 20; bottom: -50
50 //Behavior on top { NumberAnimation { duration: 1000 } }
54 id: intvalidatorelementbackground
55 color: intvalidatorelementinput.acceptableInput ? "green" : "red"
56 height: 50; width: parent.width *.8; border.color: "gray"; opacity: 0.7; radius: 5
57 anchors.centerIn: parent
60 id: intvalidatorelementinput
61 font.pointSize: 12; width: parent.width; text: "0"; horizontalAlignment: Text.AlignHCenter; validator: intvalidatorelement
62 anchors.centerIn: parent
63 Behavior on font.pointSize { NumberAnimation { duration: 1000 } }
64 Behavior on color { ColorAnimation { duration: 1000 } }
69 anchors.top: intvalidatorelementbackground.bottom; anchors.topMargin: 50; anchors.horizontalCenter: parent.horizontalCenter
70 text: "Top: " + intvalidatorelement.top + " Bottom: " + intvalidatorelement.bottom
73 SystemTestHelp { id: helpbubble; visible: statenum != 0
74 anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
76 BugPanel { id: bugpanel }
79 State { name: "start"; when: statenum == 1
80 PropertyChanges { target: intvalidatorelementinput; text: "0" }
81 PropertyChanges { target: intvalidatorelementtest
82 testtext: "This is a TextInput element using an IntValidator for input masking. At present it should be indicating 0.\n"+
83 "Next, let's attempt to enter a number smaller than the lowest allowable value: -80" }
85 State { name: "lowerthan"; when: statenum == 2
86 PropertyChanges { target: intvalidatorelementinput; text: "-80" }
87 PropertyChanges { target: intvalidatorelementtest
88 testtext: "The TextInput background should be showing red - input is not acceptable.\n"+
89 "Next, let's enter a value equal to the lowest allowable value: -50." }
91 State { name: "equaltobottom"; when: statenum == 3
92 PropertyChanges { target: intvalidatorelementinput; text: "-50" }
93 PropertyChanges { target: intvalidatorelementtest
94 testtext: "The TextInput background should be showing green - input is acceptable.\n"+
95 "Next, let's attempt to enter a number greater than the highest allowable value: 35" }
97 State { name: "greaterthan"; when: statenum == 4
98 PropertyChanges { target: intvalidatorelementinput; text: "35" }
99 PropertyChanges { target: intvalidatorelementtest
100 testtext: "The TextInput background should be showing red - input is not acceptable.\n"+
101 "Next, let's change the value of top to be greater than the entered number." }
103 State { name: "increasedtop"; when: statenum == 5
104 PropertyChanges { target: intvalidatorelementinput; text: "35" }
105 PropertyChanges { target: intvalidatorelement; top: 35 }
106 PropertyChanges { target: intvalidatorelementtest
107 testtext: "The highest value should have increased to 35, thus making the number valid and turning the input background green.\n"+
108 "Next, let's change the value of bottom to be greater than the entered number." }
109 PropertyChanges { target: bugpanel; bugnumber: "19956" }
111 State { name: "increasedbottom"; when: statenum == 6
112 PropertyChanges { target: intvalidatorelementinput; text: "35" }
113 PropertyChanges { target: intvalidatorelement; top: 35; bottom: 36 }
114 PropertyChanges { target: intvalidatorelementtest
115 testtext: "The lowest value should have increased to 36, thus making the validator invalid and turning the input background red.\n"+
116 "Press advance to restart the test." }