1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** 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.horizontalCenter: parent.horizontalCenter
58 anchors.bottom: parent.bottom
59 anchors.bottomMargin: 15
62 id: intvalidatorelementinput
63 font.pointSize: 12; width: parent.width; text: "0"; horizontalAlignment: Text.AlignHCenter; validator: intvalidatorelement
64 anchors.centerIn: parent
65 Behavior on font.pointSize { NumberAnimation { duration: 1000 } }
66 Behavior on color { ColorAnimation { duration: 1000 } }
71 anchors.top: intvalidatorelementbackground.bottom; anchors.topMargin: 50; anchors.horizontalCenter: parent.horizontalCenter
72 text: "Top: " + intvalidatorelement.top + " Bottom: " + intvalidatorelement.bottom
75 SystemTestHelp { id: helpbubble; visible: statenum != 0
76 anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
78 BugPanel { id: bugpanel }
81 State { name: "start"; when: statenum == 1
82 PropertyChanges { target: intvalidatorelementinput; text: "0" }
83 PropertyChanges { target: intvalidatorelementtest
84 testtext: "This is a TextInput element using an IntValidator for input masking. At present it should be indicating 0.\n"+
85 "Next, let's attempt to enter a number smaller than the lowest allowable value: -80" }
87 State { name: "lowerthan"; when: statenum == 2
88 PropertyChanges { target: intvalidatorelementinput; text: "-80" }
89 PropertyChanges { target: intvalidatorelementtest
90 testtext: "The TextInput background should be showing red - input is not acceptable.\n"+
91 "Next, let's enter a value equal to the lowest allowable value: -50." }
93 State { name: "equaltobottom"; when: statenum == 3
94 PropertyChanges { target: intvalidatorelementinput; text: "-50" }
95 PropertyChanges { target: intvalidatorelementtest
96 testtext: "The TextInput background should be showing green - input is acceptable.\n"+
97 "Next, let's attempt to enter a number greater than the highest allowable value: 35" }
99 State { name: "greaterthan"; when: statenum == 4
100 PropertyChanges { target: intvalidatorelementinput; text: "35" }
101 PropertyChanges { target: intvalidatorelementtest
102 testtext: "The TextInput background should be showing red - input is not acceptable.\n"+
103 "Next, let's change the value of top to be greater than the entered number." }
105 State { name: "increasedtop"; when: statenum == 5
106 PropertyChanges { target: intvalidatorelementinput; text: "35" }
107 PropertyChanges { target: intvalidatorelement; top: 35 }
108 PropertyChanges { target: intvalidatorelementtest
109 testtext: "The highest value should have increased to 35, thus making the number valid and turning the input background green.\n"+
110 "Next, let's change the value of bottom to be greater than the entered number." }
111 PropertyChanges { target: bugpanel; bugnumber: "19956" }
113 State { name: "increasedbottom"; when: statenum == 6
114 PropertyChanges { target: intvalidatorelementinput; text: "35" }
115 PropertyChanges { target: intvalidatorelement; top: 35; bottom: 36 }
116 PropertyChanges { target: intvalidatorelementtest
117 testtext: "The lowest value should have increased to 36, thus making the validator invalid and turning the input background red.\n"+
118 "Press advance to restart the test." }