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: regexpvalidatorelementtest
47 property string testtext: ""
48 property variant regexp: /[a-z]{3}/
50 RegExpValidator { id: regexpvalidatorelement; regExp: regexp }
53 id: regexpvalidatorelementbackground
54 color: regexpvalidatorelementinput.acceptableInput ? "green" : "red"; height: 50; width: parent.width *.8
55 border.color: "gray"; opacity: 0.7; radius: 5
56 anchors.centerIn: parent
59 id: regexpvalidatorelementinput
60 font.pointSize: 12; width: parent.width; text: "0"; horizontalAlignment: Text.AlignHCenter; validator: regexpvalidatorelement
61 anchors.centerIn: parent
62 Behavior on font.pointSize { NumberAnimation { duration: 1000 } }
63 Behavior on color { ColorAnimation { duration: 1000 } }
68 anchors.top: regexpvalidatorelementbackground.bottom; anchors.topMargin: 50; anchors.horizontalCenter: parent.horizontalCenter
69 text: "Regular Expression: " + regexp
72 SystemTestHelp { id: helpbubble; visible: statenum != 0
73 anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
75 BugPanel { id: bugpanel }
78 State { name: "start"; when: statenum == 1
79 PropertyChanges { target: regexpvalidatorelementinput; text: "abc" }
80 PropertyChanges { target: regexpvalidatorelementtest
81 testtext: "This is a TextInput element using an RegExpValidator for input masking. At present it should be indicating abc.\n"+
82 "The regExp value will only match to a value that has three alpha characters\n"+
83 "Next, let's attempt to enter text that does not match the regular expression: 123" }
85 State { name: "notmatch"; when: statenum == 2
86 PropertyChanges { target: regexpvalidatorelementinput; text: "123" }
87 PropertyChanges { target: regexpvalidatorelementtest
88 testtext: "The TextInput background should be showing red - input is not acceptable.\n"+
89 "Next, let's enter a word with not enough characters to match: aa." }
91 State { name: "notenough"; when: statenum == 3
92 PropertyChanges { target: regexpvalidatorelementinput; text: "aa" }
93 PropertyChanges { target: regexpvalidatorelementtest
94 testtext: "The TextInput background should be showing red - input is not acceptable.\n"+
95 "Next, let's attempt to enter a word with too many characters to match: abcd" }
97 State { name: "toomany"; when: statenum == 4
98 PropertyChanges { target: regexpvalidatorelementinput; text: "abcd" }
99 PropertyChanges { target: regexpvalidatorelementtest
100 testtext: "The TextInput background should still be showing red - input is not acceptable.\n"+
101 "Next, let's change the regex to accept the new value." }
103 State { name: "changedregex"; when: statenum == 5
104 PropertyChanges { target: regexpvalidatorelementinput; text: "abcd" }
105 PropertyChanges { target: regexpvalidatorelementtest; regexp: /[a-z]{4}/
106 testtext: "The regular expression should have changed to match four characters, "+
107 "thus making the text valid and turning the input background green.\n"+
108 "Press advance to restart the test." }
109 PropertyChanges { target: bugpanel; bugnumber: "19956" }