diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/combobox/cb_keys.qml | 62 | ||||
-rw-r--r-- | tests/auto/controls/data/spinbox/sb_keys.qml | 63 | ||||
-rw-r--r-- | tests/auto/controls/data/textarea/ta_keys.qml | 62 | ||||
-rw-r--r-- | tests/auto/controls/data/textfield/tf_keys.qml | 62 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 32 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 32 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_textarea.qml | 32 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_textfield.qml | 32 |
8 files changed, 377 insertions, 0 deletions
diff --git a/tests/auto/controls/data/combobox/cb_keys.qml b/tests/auto/controls/data/combobox/cb_keys.qml new file mode 100644 index 00000000..0e75fddb --- /dev/null +++ b/tests/auto/controls/data/combobox/cb_keys.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +Row { + width: 100 + height: 50 + spacing: 10 + + property alias control1: _control1 + ComboBox { + id: _control1 + editable: true + property bool gotit: false + Keys.onPressed: { + if ((!gotit) && (event.key === Qt.Key_B)) { + gotit = true; + event.accepted = true; + return; + } + } + } +} diff --git a/tests/auto/controls/data/spinbox/sb_keys.qml b/tests/auto/controls/data/spinbox/sb_keys.qml new file mode 100644 index 00000000..39671835 --- /dev/null +++ b/tests/auto/controls/data/spinbox/sb_keys.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +Row { + width: 100 + height: 50 + spacing: 10 + + property alias control1: _control1 + SpinBox { + id: _control1 + value: 9 + property bool gotit: false + Keys.onPressed: { + if ((!gotit) && (event.key === Qt.Key_B)) { + gotit = true; + value = value - 2; + event.accepted = true; + return; + } + } + } +} diff --git a/tests/auto/controls/data/textarea/ta_keys.qml b/tests/auto/controls/data/textarea/ta_keys.qml new file mode 100644 index 00000000..e810bbc9 --- /dev/null +++ b/tests/auto/controls/data/textarea/ta_keys.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +Row { + width: 100 + height: 50 + spacing: 10 + + property alias control1: _control1 + TextArea { + id: _control1 + text: "" + property bool gotit: false + Keys.onPressed: { + if ((!gotit) && (event.key === Qt.Key_B)) { + gotit = true; + event.accepted = true; + return; + } + } + } +} diff --git a/tests/auto/controls/data/textfield/tf_keys.qml b/tests/auto/controls/data/textfield/tf_keys.qml new file mode 100644 index 00000000..4124651d --- /dev/null +++ b/tests/auto/controls/data/textfield/tf_keys.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +Row { + width: 100 + height: 50 + spacing: 10 + + property alias control1: _control1 + TextField { + id: _control1 + text: "" + property bool gotit: false + Keys.onPressed: { + if ((!gotit) && (event.key === Qt.Key_B)) { + gotit = true; + event.accepted = true; + return; + } + } + } +} diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 6758c982..4d5117fb 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -697,5 +697,37 @@ TestCase { comboBox.destroy() } } + + function test_keys() { + var component = Qt.createComponent("combobox/cb_keys.qml") + compare(component.status, Component.Ready) + var test = component.createObject(container); + verify(test !== null, "test control created is null") + var control1 = test.control1 + verify(control1 !== null) + + control1.forceActiveFocus() + verify(control1.activeFocus) + + verify(control1.gotit === false) + verify(control1.editText === "0") + + keyPress(Qt.Key_A) + verify(control1.activeFocus) + verify(control1.gotit === false) + verify(control1.editText === "0a") + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.editText === "0a") + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.editText === "0ab") + + test.destroy() + } } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 260fc0c1..4a01c6c2 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -645,6 +645,38 @@ Item { spinbox.destroy() } + + function test_keys() { + var component = Qt.createComponent("spinbox/sb_keys.qml") + compare(component.status, Component.Ready) + var test = component.createObject(container); + verify(test !== null, "test control created is null") + var control1 = test.control1 + verify(control1 !== null) + + control1.forceActiveFocus() + verify(control1.activeFocus) + + verify(control1.gotit === false) + verify(control1.value === 9) + + keyPress(Qt.Key_A) + verify(control1.activeFocus) + verify(control1.gotit === false) + verify(control1.value === 9) + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.value === 7) + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.value === 7) + + test.destroy() + } } } diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index 5d0778f1..31239bef 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -155,5 +155,37 @@ TestCase { verify(!control.control3.activeFocus) control.destroy() } + + function test_keys() { + var component = Qt.createComponent("textarea/ta_keys.qml") + compare(component.status, Component.Ready) + var test = component.createObject(container); + verify(test !== null, "test control created is null") + var control1 = test.control1 + verify(control1 !== null) + + control1.forceActiveFocus() + verify(control1.activeFocus) + + verify(control1.gotit === false) + verify(control1.text === "") + + keyPress(Qt.Key_A) + verify(control1.activeFocus) + verify(control1.gotit === false) + verify(control1.text === "a") + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.text === "a") + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.text === "ab") + + test.destroy() + } } } diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index a526d1f0..c8f59b7f 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -396,5 +396,37 @@ TestCase { test.destroy() } + + function test_keys() { + var component = Qt.createComponent("textfield/tf_keys.qml") + compare(component.status, Component.Ready) + var test = component.createObject(container); + verify(test !== null, "test control created is null") + var control1 = test.control1 + verify(control1 !== null) + + control1.forceActiveFocus() + verify(control1.activeFocus) + + verify(control1.gotit === false) + verify(control1.text === "") + + keyPress(Qt.Key_A) + verify(control1.activeFocus) + verify(control1.gotit === false) + verify(control1.text === "a") + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.text === "a") + + keyPress(Qt.Key_B) + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control1.text === "ab") + + test.destroy() + } } } |