diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2013-02-20 17:38:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-21 16:59:55 +0100 |
commit | 6ea1b2b1f26d266b88b091ddece0cdaad5d3accc (patch) | |
tree | 38b488f646b7070b0bc8ef1edae7281f8a24e1e3 /tests/auto/controls | |
parent | e8a53a5a3a4b3d8069e69eba7f96e1f0b47699b6 (diff) | |
download | qtquickcontrols-6ea1b2b1f26d266b88b091ddece0cdaad5d3accc.tar.gz |
Rename QtDesktop to QtQuick.Controls
Change-Id: Icc61dbfc74cc2a303b9847e7d2c7ace4a9002046
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/controls')
38 files changed, 3374 insertions, 0 deletions
diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro new file mode 100644 index 00000000..20ee603a --- /dev/null +++ b/tests/auto/controls/controls.pro @@ -0,0 +1,41 @@ +TEMPLATE = app +TARGET = tst_controls + +IMPORTPATH = $$OUT_PWD/../testplugin + +QT += widgets + +CONFIG += qmltestcase + +INCLUDEPATH += $$PWD/../../shared +SOURCES += $$PWD/tst_controls.cpp + +TESTDATA = $$PWD/data/* + +OTHER_FILES += \ + $$PWD/data/tst_button.qml \ + $$PWD/data/tst_shortcuts.qml \ + $$PWD/data/tst_spinbox.qml \ + $$PWD/data/tst_tableview.qml \ + $$PWD/data/tst_rangemodel.qml \ + $$PWD/data/tst_scrollarea.qml \ + $$PWD/data/tst_menu.qml \ + $$PWD/data/tst_textfield.qml \ + $$PWD/data/tst_textarea.qml \ + $$PWD/data/tst_applicationwindow.qml \ + $$PWD/data/tst_combobox.qml \ + $$PWD/data/tst_progressbar.qml \ + $$PWD/data/tst_radiobutton.qml \ + $$PWD/data/tst_label.qml \ + $$PWD/data/tst_page.qml \ + $$PWD/data/tst_menubar.qml \ + $$PWD/data/tst_slider.qml \ + $$PWD/data/tst_statusbar.qml \ + $$PWD/data/tst_tab.qml \ + $$PWD/data/tst_tabframe.qml \ + $$PWD/data/tst_tableviewcolumn.qml \ + $$PWD/data/tst_toolbar.qml \ + $$PWD/data/tst_toolbutton.qml \ + $$PWD/data/tst_checkbox.qml + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/controls/data/rangemodel/rangemodel.qml b/tests/auto/controls/data/rangemodel/rangemodel.qml new file mode 100644 index 00000000..661e1672 --- /dev/null +++ b/tests/auto/controls/data/rangemodel/rangemodel.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls.Private 1.0 + +RangeModel { + minimumValue: 0 + maximumValue: 100 + positionAtMinimum: 0 + positionAtMaximum: 100 + value: 40 + inverted: false + stepSize: 2 +} diff --git a/tests/auto/controls/data/shortcut/shortcuts.qml b/tests/auto/controls/data/shortcut/shortcuts.qml new file mode 100644 index 00000000..e550aece --- /dev/null +++ b/tests/auto/controls/data/shortcut/shortcuts.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 + +Rectangle { + width: 300 + height: 300 + id: rect + + Text { + id: text + text: "hello" + anchors.centerIn: parent + } + + Action { + shortcut: "a" + onTriggered: text.text = "a pressed" + } + + Action { + shortcut: "b" + onTriggered: text.text = "b pressed" + } + + Action { + shortcut: "ctrl+c" + onTriggered: text.text = "ctrl c pressed" + } + + Action { + shortcut: "d" + onTriggered: text.text = "d pressed" + } + + Action { + shortcut: "alt+d" + onTriggered: text.text = "alt d pressed" + } + + Action { + shortcut: "shift+d" + onTriggered: text.text = "shift d pressed 1" + } + Action { + shortcut: "shift+d" + onTriggered: text.text = "shift d pressed 2" + } + + Action { + mnemonic: "&test" + onTriggered: text.text = "alt t pressed" + } +} diff --git a/tests/auto/controls/data/tableview/table1_qobjectmodel.qml b/tests/auto/controls/data/tableview/table1_qobjectmodel.qml new file mode 100644 index 00000000..b1dd83d3 --- /dev/null +++ b/tests/auto/controls/data/tableview/table1_qobjectmodel.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 +import QtQuickControlsTests 1.0 + +TableView { + model: TestObject {} + height: 70 + TableViewColumn { + role: "value" + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table2_qabstractitemmodel.qml b/tests/auto/controls/data/tableview/table2_qabstractitemmodel.qml new file mode 100644 index 00000000..4487f6c1 --- /dev/null +++ b/tests/auto/controls/data/tableview/table2_qabstractitemmodel.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 +import QtQuickControlsTests 1.0 + +TableView { + model: TestItemModel {} + height: 70 + TableViewColumn { + role: "test" + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table3_qobjectlist.qml b/tests/auto/controls/data/tableview/table3_qobjectlist.qml new file mode 100644 index 00000000..8cb13ccc --- /dev/null +++ b/tests/auto/controls/data/tableview/table3_qobjectlist.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 +import QtQuickControlsTests 1.0 + +TableView { + model: model_qobjectlist + height: 70 + TableViewColumn { + role: "value" + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table4_qstringlist.qml b/tests/auto/controls/data/tableview/table4_qstringlist.qml new file mode 100644 index 00000000..6501dec5 --- /dev/null +++ b/tests/auto/controls/data/tableview/table4_qstringlist.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 +import QtQuickControlsTests 1.0 + +TableView { + model: model_qstringlist + height: 70 + TableViewColumn { + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table5_listmodel.qml b/tests/auto/controls/data/tableview/table5_listmodel.qml new file mode 100644 index 00000000..05d948bc --- /dev/null +++ b/tests/auto/controls/data/tableview/table5_listmodel.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 + +TableView { + + model: ListModel { + ListElement { value: "A" } + ListElement { value: "B" } + ListElement { value: "C" } + } // qml + height: 70 + TableViewColumn { + role: "value" + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table6_countmodel.qml b/tests/auto/controls/data/tableview/table6_countmodel.qml new file mode 100644 index 00000000..d5599b44 --- /dev/null +++ b/tests/auto/controls/data/tableview/table6_countmodel.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 + +TableView { + model: 3 // qml + height: 70 + TableViewColumn { + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table7_arraymodel.qml b/tests/auto/controls/data/tableview/table7_arraymodel.qml new file mode 100644 index 00000000..700f3635 --- /dev/null +++ b/tests/auto/controls/data/tableview/table7_arraymodel.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 + +TableView { + model: ["A", "B", "C"] // qml + height: 70 + TableViewColumn { + width: 100 + } +} diff --git a/tests/auto/controls/data/tableview/table8_itemmodel.qml b/tests/auto/controls/data/tableview/table8_itemmodel.qml new file mode 100644 index 00000000..774bb408 --- /dev/null +++ b/tests/auto/controls/data/tableview/table8_itemmodel.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtQuick.Controls 1.0 + +TableView { + model: Item { x: 10 }// qml + height: 70 + TableViewColumn { + role: "x" + width: 100 + } +} diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml new file mode 100644 index 00000000..d1ec6582 --- /dev/null +++ b/tests/auto/controls/data/tst_applicationwindow.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_ApplicationWindow" + when:windowShown + width:400 + height:400 + + function test_window() { + var tmp = Qt.createQmlObject('import QtQuick.Controls 1.0; ApplicationWindow {id: window}', testCase, ''); + tmp.statusBar = Qt.createQmlObject('import QtQuick.Controls 1.0; StatusBar {}', testCase, ''); + tmp.toolBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolBar {}', testCase, ''); + verify(tmp.statusBar !== undefined) + verify(tmp.toolBar !== undefined) + } +} diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml new file mode 100644 index 00000000..757bc64b --- /dev/null +++ b/tests/auto/controls/data/tst_button.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_Button" + when:windowShown + width:400 + height:400 + + function test_defaultbutton() { + var tmp = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button1}', testCase, ''); + compare(tmp.defaultbutton, false); + } + + function test_text() { + var tmp1 = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button2_1}', testCase, ''); + compare(tmp1.text, ""); + tmp1.text = "Hello"; + compare(tmp1.text, "Hello"); + + var tmp2 = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button2_2; text: "Hello"}', testCase, ''); + compare(tmp2.text, "Hello"); + } +} diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml new file mode 100644 index 00000000..449439ef --- /dev/null +++ b/tests/auto/controls/data/tst_checkbox.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +Item { + id: container + + TestCase { + id: testCase + name: "Tests_CheckBox" + when: windowShown + width: 50 + height: 50 + + property var checkBox + + SignalSpy { + id: signalSpy + } + + function init() { + checkBox = Qt.createQmlObject("import QtQuick.Controls 1.0; CheckBox { }", container, ""); + } + + function cleanup() { + signalSpy.clear(); + } + + function test_defaultConstructed() { + compare(checkBox.checked, false); + compare(checkBox.checkedState, Qt.Unchecked); + compare(checkBox.partiallyCheckedEnabled, false); + compare(checkBox.text, ""); + } + + function test_text() { + compare(checkBox.text, ""); + + checkBox.text = "Check me!"; + compare(checkBox.text, "Check me!"); + } + + function test_checked() { + compare(checkBox.checked, false); + compare(checkBox.checkedState, Qt.Unchecked); + compare(checkBox.partiallyCheckedEnabled, false); + + checkBox.checked = true; + compare(checkBox.checked, true); + compare(checkBox.checkedState, Qt.Checked); + compare(checkBox.partiallyCheckedEnabled, false); + + checkBox.checkedState = Qt.Unchecked; + compare(checkBox.checked, false); + compare(checkBox.checkedState, Qt.Unchecked); + compare(checkBox.partiallyCheckedEnabled, false); + + checkBox.checkedState = Qt.Checked; + compare(checkBox.checked, true); + compare(checkBox.checkedState, Qt.Checked); + compare(checkBox.partiallyCheckedEnabled, false); + + checkBox.checkedState = Qt.PartiallyChecked; + compare(checkBox.checked, false); + compare(checkBox.checkedState, Qt.PartiallyChecked); + compare(checkBox.partiallyCheckedEnabled, true); + } + + function test_clicked() { + signalSpy.signalName = "clicked" + signalSpy.target = checkBox; + compare(signalSpy.count, 0); + mouseClick(checkBox, checkBox.x + 1, checkBox.y + 1, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(checkBox.checked, true); + compare(checkBox.checkedState, Qt.Checked); + + // Clicking outside should do nothing. + mouseClick(checkBox, checkBox.x - 1, checkBox.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(checkBox.checked, true); + + mouseClick(checkBox, checkBox.x, checkBox.y - 1, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(checkBox.checked, true); + + mouseClick(checkBox, checkBox.x - 1, checkBox.y - 1, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(checkBox.checked, true); + } + + function test_keyPressed() { + checkBox.forceActiveFocus(); + + signalSpy.signalName = "clicked"; + signalSpy.target = checkBox; + compare(signalSpy.count, 0); + + // Try cycling through checked and unchecked. + var expectedStates = [Qt.Checked, Qt.Unchecked]; + expectedStates = expectedStates.concat(expectedStates, expectedStates, expectedStates); + for (var i = 0; i < expectedStates.length; ++i) { + keyPress(Qt.Key_Space); + keyRelease(Qt.Key_Space); + compare(signalSpy.count, i + 1); + compare(checkBox.checkedState, expectedStates[i]); + compare(checkBox.checked, checkBox.checkedState === Qt.Checked); + } + + // Try cycling through all three states. + checkBox.partiallyCheckedEnabled = true; + compare(checkBox.checkedState, Qt.Unchecked); + compare(checkBox.checked, false); + + signalSpy.clear(); + expectedStates = [Qt.Checked, Qt.PartiallyChecked, Qt.Unchecked]; + expectedStates = expectedStates.concat(expectedStates, expectedStates, expectedStates); + for (i = 0; i < expectedStates.length; ++i) { + keyPress(Qt.Key_Space); + keyRelease(Qt.Key_Space); + compare(signalSpy.count, i + 1); + compare(checkBox.checkedState, expectedStates[i]); + } + } + + function test_exclusiveGroup() { + var root = Qt.createQmlObject("import QtQuick 2.0; import QtQuick.Controls 1.0; \n" + + "Row { \n" + + " property alias checkBox1: checkBox1 \n" + + " property alias checkBox2: checkBox2 \n" + + " property alias group: group \n" + + " ExclusiveGroup { id: group } \n" + + " CheckBox { id: checkBox1; checked: true; exclusiveGroup: group } \n" + + " CheckBox { id: checkBox2; exclusiveGroup: group } \n" + + "}", container, ""); + + compare(root.checkBox1.exclusiveGroup, root.group); + compare(root.checkBox2.exclusiveGroup, root.group); + compare(root.checkBox1.checked, true); + compare(root.checkBox2.checked, false); + + root.forceActiveFocus(); + + signalSpy.target = root.checkBox2; + signalSpy.signalName = "clicked"; + compare(signalSpy.count, 0); + + mouseClick(root.checkBox2, root.checkBox2.x, root.checkBox2.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(root.checkBox1.checked, false); + compare(root.checkBox2.checked, true); + + signalSpy.clear(); + signalSpy.target = root.checkBox1; + signalSpy.signalName = "clicked"; + compare(signalSpy.count, 0); + + mouseClick(root.checkBox1, root.checkBox1.x, root.checkBox1.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(root.checkBox1.checked, true); + compare(root.checkBox2.checked, false); + } + } +} diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml new file mode 100644 index 00000000..08a8c488 --- /dev/null +++ b/tests/auto/controls/data/tst_combobox.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_ComboBox" + when:windowShown + width:400 + height:400 + + property var model + function init() { + model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", testCase, '') + model.append({ text: "Banana", color: "Yellow" }) + model.append({ text: "Apple", color: "Green" }) + model.append({ text: "Coconut", color: "Brown" }) + } + + function test_keyupdown() { + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox {}', testCase, ''); + comboBox.model = model + + compare(comboBox.selectedIndex, 0) + + comboBox.forceActiveFocus() + + keyPress(Qt.Key_Down) + compare(comboBox.selectedIndex, 1) + keyPress(Qt.Key_Down) + compare(comboBox.selectedIndex, 2) + keyPress(Qt.Key_Up) + compare(comboBox.selectedIndex, 1) + } + + function test_textrole() { + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox {}', testCase, ''); + comboBox.model = model + comboBox.textRole = "text" + compare(comboBox.selectedIndex, 0) + expectFail('', "QTCOMPONENTS-1301") + compare(comboBox.selectedText, "Banana") + } +} diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml new file mode 100644 index 00000000..1a83a4a5 --- /dev/null +++ b/tests/auto/controls/data/tst_label.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_Label" + when:windowShown + width:400 + height:400 + + function test_createLabel() { + var label = Qt.createQmlObject('import QtQuick.Controls 1.0; Label {}', testCase, ''); + } +} diff --git a/tests/auto/controls/data/tst_menu.qml b/tests/auto/controls/data/tst_menu.qml new file mode 100644 index 00000000..6dadfb08 --- /dev/null +++ b/tests/auto/controls/data/tst_menu.qml @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 +import QtQuick.Controls 1.0 + +TestCase { + id: testcase + name: "Tests_Menu" + when: windowShown + width: 300; height: 300 + + property var menuItemsText: [ "apple", "banana", "clementine", "dragon fruit" ] + + property var menu + property var menuItem + + SignalSpy { + id: menuSpy + target: testcase.menu + signalName: "selectedIndexChanged" + } + + SignalSpy { + id: menuItemSpy + target: testcase.menuItem + signalName: "triggered" + } + + Component { + id: creationComponent + Menu { + MenuItem { text: "apple" } + MenuItem { text: "banana" } + MenuItem { text: "clementine" } + MenuItem { text: "dragon fruit" } + } + } + + function init() { + menu = creationComponent.createObject(testcase) + } + + function cleanup() { + menuSpy.clear() + menuItemSpy.clear() + menu.destroy() + } + + function test_creation() { + compare(menu.menuItems.length, testcase.menuItemsText.length) + for (var i = 0; i < menu.menuItems.length; i++) + compare(menu.menuItems[i].text, testcase.menuItemsText[i]) + } + + Component { + id: modelCreationComponent + // TODO Update when model patch is in + // Menu { MenuItemRepeater { model: testcase.menuItemsText MenuItem { text: modelData } } + ContextMenu { model: testcase.menuItemsText } + } + + function test_modelCreation() { + var menu = modelCreationComponent.createObject(testcase) + compare(menu.menuItems.length, testcase.menuItemsText.length) + for (var i = 0; i < menu.menuItems.length; i++) + compare(menu.menuItems[i].text, testcase.menuItemsText[i]) + menu.destroy() + } + + function test_trigger() { + menuItem = menu.menuItems[2] + menuItem.trigger() + + compare(menuItemSpy.count, 1) + expectFail('', "MenuItem.trigger() won't always update selectedIndex") + compare(menuSpy.count, 1) + compare(menu.selectedIndex, 2) + } + + function test_check() { + for (var i = 0; i < menu.menuItems.length; i++) + menu.menuItems[i].checkable = true + + menuItem = menu.menuItems[2] + compare(menuItem.checkable, true) + compare(menuItem.checked, false) + menuItem.trigger() + + for (i = 0; i < menu.menuItems.length; i++) + compare(menu.menuItems[i].checked, i === 2) + + menuItem = menu.menuItems[3] + compare(menuItem.checkable, true) + compare(menuItem.checked, false) + menuItem.trigger() + + for (i = 0; i < menu.menuItems.length; i++) + compare(menu.menuItems[i].checked, i === 2 || i === 3) + + compare(menuItemSpy.count, 2) + expectFail('', "MenuItem.trigger() won't always update selectedIndex") + compare(menuSpy.count, 2) + compare(menu.selectedIndex, 3) + } + + ExclusiveGroup { id: eg } + + function test_exclusive() { + for (var i = 0; i < menu.menuItems.length; i++) { + menu.menuItems[i].checkable = true + menu.menuItems[i].exclusiveGroup = eg + } + + menuItem = menu.menuItems[2] + compare(menuItem.checkable, true) + compare(menuItem.checked, false) + menuItem.trigger() + + for (i = 0; i < menu.menuItems.length; i++) + compare(menu.menuItems[i].checked, i === 2) + + menuItem = menu.menuItems[3] + compare(menuItem.checkable, true) + compare(menuItem.checked, false) + menuItem.trigger() + + for (i = 0; i < menu.menuItems.length; i++) + compare(menu.menuItems[i].checked, i === 3) + + compare(menuItemSpy.count, 2) + expectFail('', "MenuItem.trigger() won't always update selectedIndex") + compare(menuSpy.count, 2) + compare(menu.selectedIndex, 3) + } + + function test_selectedIndex() { + for (var i = 0; i < menu.menuItems.length; i++) + menu.menuItems[i].checkable = true + + menu.selectedIndex = 3 + compare(menu.selectedIndex, 3) + verify(menu.menuItems[menu.selectedIndex].checked) + } +} diff --git a/tests/auto/controls/data/tst_menubar.qml b/tests/auto/controls/data/tst_menubar.qml new file mode 100644 index 00000000..f6c04bd4 --- /dev/null +++ b/tests/auto/controls/data/tst_menubar.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_MenuBar" + when:windowShown + width:400 + height:400 + + function test_createMenuBar() { + var menuBar = Qt.createQmlObject('import QtQuick.Controls 1.0; MenuBar {}', testCase, ''); + } +} diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml new file mode 100644 index 00000000..0e5ce78e --- /dev/null +++ b/tests/auto/controls/data/tst_page.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_Page" + when:windowShown + width:400 + height:400 + + function test_createPage() { + var page = Qt.createQmlObject('import QtQuick.Controls 1.0; Page {}', testCase, ''); + } + + +} diff --git a/tests/auto/controls/data/tst_pagestack.qml b/tests/auto/controls/data/tst_pagestack.qml new file mode 100644 index 00000000..14068c72 --- /dev/null +++ b/tests/auto/controls/data/tst_pagestack.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 +import QtQuick.Controls 1.0 + +TestCase { + id: testCase + name: "Tests_PageStack" + when: windowShown + width: 400 + height: 400 + + Item { id: anItem } + Component { + id: pageComponent + Page {} + } + + Component { + id: stackComponent + PageStack {} + } + + function test_splitterrow() { + var component = stackComponent + var stack = component.createObject(testCase); + verify (stack !== null, "pagestack created is null") + verify (stack.depth === 0) + stack.push(anItem) + verify (stack.depth === 1) + stack.push(anItem) + verify (stack.depth === 2) + stack.pop() + verify (stack.depth === 1) + stack.push(pageComponent) + verify (stack.depth === 2) + } +} diff --git a/tests/auto/controls/data/tst_progressbar.qml b/tests/auto/controls/data/tst_progressbar.qml new file mode 100644 index 00000000..56b2ad0e --- /dev/null +++ b/tests/auto/controls/data/tst_progressbar.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_ProgressBar" + when:windowShown + width:400 + height:400 + + function test_minimumvalue() { + var progressBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {}', testCase, ''); + + progressBar.minimumValue = 5 + progressBar.maximumValue = 10 + progressBar.value = 2 + compare(progressBar.minimumValue, 5) + compare(progressBar.value, 5) + + progressBar.minimumValue = 7 + compare(progressBar.value, 7) + } + + function test_maximumvalue() { + var progressBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {}', testCase, ''); + + progressBar.minimumValue = 5 + progressBar.maximumValue = 10 + progressBar.value = 15 + compare(progressBar.maximumValue, 10) + compare(progressBar.value, 10) + + progressBar.maximumValue = 8 + compare(progressBar.value, 8) + } + + function test_invalidMinMax() { + var progressBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {}', testCase, ''); + + // minimumValue has priority over maximum if they are inconsistent + + progressBar.minimumValue = 10 + progressBar.maximumValue = 10 + compare(progressBar.value, progressBar.minimumValue) + + progressBar.value = 17 + compare(progressBar.value, progressBar.minimumValue) + + progressBar.maximumValue = 5 + compare(progressBar.value, progressBar.minimumValue) + + progressBar.value = 12 + compare(progressBar.value, progressBar.minimumValue) + + var progressBar2 = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {minimumValue: 10; maximumValue: 4; value: 5}', testCase, ''); + compare(progressBar.value, progressBar.minimumValue) + } +} diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml new file mode 100644 index 00000000..1ad1b032 --- /dev/null +++ b/tests/auto/controls/data/tst_radiobutton.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +Item { + id: container + + TestCase { + id: testCase + name: "Tests_RadioButton" + when: windowShown + width: 400 + height: 400 + + property var radioButton + + SignalSpy { + id: signalSpy + } + + function init() { + radioButton = Qt.createQmlObject('import QtQuick.Controls 1.0; RadioButton {}', container, ''); + } + + function cleanup() { + signalSpy.clear(); + } + + function test_createRadioButton() { + compare(radioButton.checked, false); + compare(radioButton.text, ""); + } + + function test_defaultConstructed() { + compare(radioButton.checked, false); + compare(radioButton.text, ""); + } + + function test_text() { + compare(radioButton.text, ""); + + radioButton.text = "Check me!"; + compare(radioButton.text, "Check me!"); + } + + function test_checked() { + compare(radioButton.checked, false); + + radioButton.checked = true; + compare(radioButton.checked, true); + + radioButton.checked = false; + compare(radioButton.checked, false); + } + + function test_clicked() { + signalSpy.signalName = "clicked" + signalSpy.target = radioButton; + compare(signalSpy.count, 0); + mouseClick(radioButton, radioButton.x, radioButton.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(radioButton.checked, true); + + // Clicking outside should do nothing. + mouseClick(radioButton, radioButton.x - 1, radioButton.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(radioButton.checked, true); + + mouseClick(radioButton, radioButton.x, radioButton.y - 1, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(radioButton.checked, true); + + mouseClick(radioButton, radioButton.x - 1, radioButton.y - 1, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(radioButton.checked, true); + } + + function test_keyPressed() { + radioButton.forceActiveFocus(); + + signalSpy.signalName = "clicked"; + signalSpy.target = radioButton; + compare(signalSpy.count, 0); + + // Try cycling through checked and unchecked. + var expectedStates = [true, false]; + expectedStates = expectedStates.concat(expectedStates, expectedStates, expectedStates); + for (var i = 0; i < expectedStates.length; ++i) { + keyPress(Qt.Key_Space); + keyRelease(Qt.Key_Space); + compare(signalSpy.count, i + 1); + compare(radioButton.checked, expectedStates[i]); + } + } + + function test_exclusiveGroup() { + var root = Qt.createQmlObject("import QtQuick 2.0; import QtQuick.Controls 1.0; \n" + + "Row { \n" + + " property alias radioButton1: radioButton1 \n" + + " property alias radioButton2: radioButton2 \n" + + " property alias group: group \n" + + " ExclusiveGroup { id: group } \n" + + " RadioButton { id: radioButton1; checked: true; exclusiveGroup: group } \n" + + " RadioButton { id: radioButton2; exclusiveGroup: group } \n" + + "}", container, ""); + + compare(root.radioButton1.exclusiveGroup, root.group); + compare(root.radioButton2.exclusiveGroup, root.group); + compare(root.radioButton1.checked, true); + compare(root.radioButton2.checked, false); + + root.forceActiveFocus(); + + signalSpy.target = root.radioButton2; + signalSpy.signalName = "clicked"; + compare(signalSpy.count, 0); + + mouseClick(root.radioButton2, root.radioButton2.x, root.radioButton2.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(root.radioButton1.checked, false); + compare(root.radioButton2.checked, true); + + signalSpy.clear(); + signalSpy.target = root.radioButton1; + signalSpy.signalName = "clicked"; + compare(signalSpy.count, 0); + + mouseClick(root.radioButton1, root.radioButton1.x, root.radioButton1.y, Qt.LeftButton); + compare(signalSpy.count, 1); + compare(root.radioButton1.checked, true); + compare(root.radioButton2.checked, false); + } + } +} diff --git a/tests/auto/controls/data/tst_rangemodel.qml b/tests/auto/controls/data/tst_rangemodel.qml new file mode 100644 index 00000000..259c884c --- /dev/null +++ b/tests/auto/controls/data/tst_rangemodel.qml @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_RangeModel" + when: windowShown + width:400 + height:400 + + property var range + + SignalSpy { + id: spy + target: range + } + + function init() { + if (range !== undefined) + range.destroy() + var component = Qt.createComponent("rangemodel/rangemodel.qml"); + compare(component.status, Component.Ready) + range = component.createObject(testCase); + verify(range !== null, "created object is null") + } + + function cleanup() { + spy.clear() + } + + function test_setminimumvalue() { + spy.signalName = "minimumChanged" + compare(spy.count, 0) + compare(range.minimumValue, 0) + range.minimumValue = 15 + compare(spy.count, 1) + compare(range.minimumValue, 15) + } + + function test_setmaximumvalue() { + spy.signalName = "maximumChanged" + compare(spy.count, 0) + compare(range.maximumValue, 100) + range.maximumValue = 35 + compare(spy.count, 1) + compare(range.maximumValue, 35) + } + + function test_setpositionatminimum() { + spy.signalName = "positionAtMinimumChanged" + compare(spy.count, 0) + compare(range.positionAtMinimum, 0) + range.positionAtMinimum = 15 + compare(spy.count, 1) + compare(range.positionAtMinimum, 15) + } + + function test_setpositionatmaximum() { + spy.signalName = "positionAtMaximumChanged" + compare(spy.count, 0) + compare(range.positionAtMaximum, 100) + range.positionAtMaximum = 35 + compare(spy.count, 1) + compare(range.positionAtMaximum, 35) + } + + function test_setvalue_data() { + return [ + { tag: "in range", value: 20, expected: 20 }, + { tag: "below min", value: 5, expected: 10 }, + { tag: "above max", value: 110, expected: 100 }, + ] + } + + function test_setvalue(data) { + spy.signalName = "valueChanged" + compare(spy.count, 0) + range.minimumValue = 10 + compare(range.minimumValue, 10) + compare(range.maximumValue, 100) + range.value = data.value + compare(spy.count, 1) + compare(range.value, data.expected) + } + + function test_setinverted_data() { + return [ + { tag: "inverted false", value: false, posAtMin: 0, posAtMax: 100, expected: false }, + { tag: "inverted true", value: true, posAtMin: 100, posAtMax: 0, expected: true }, + ] + } + + function test_setinverted(data) { + spy.signalName = "invertedChanged" + compare(spy.count, 0) + range.inverted = data.value + if (range.inverted === true) + compare(spy.count, 1) + compare(range.inverted, data.expected ) + compare(range.positionForValue(0), data.posAtMin) + compare(range.positionForValue(100), data.posAtMax) + compare(range.valueForPosition(data.posAtMin), 0) + compare(range.valueForPosition(data.posAtMax), 100) + } + + function test_setstepsize() { + spy.signalName = "stepSizeChanged" + compare(spy.count, 0) + compare(range.stepSize, 2) + range.stepSize = 3 + compare(spy.count, 1) + compare(range.stepSize, 3) + } + + function test_setposition() { + spy.signalName = "positionChanged" + compare(spy.count, 0) + compare(range.position, 40) + range.position = 50 + compare(spy.count, 1) + compare(range.position, 50) + compare(range.valueForPosition(range.position), 50) + range.positionAtMaximum = 200 + compare(spy.count, 2) + compare(range.position, 100) + } +} diff --git a/tests/auto/controls/data/tst_scrollarea.qml b/tests/auto/controls/data/tst_scrollarea.qml new file mode 100644 index 00000000..a2c1ed1f --- /dev/null +++ b/tests/auto/controls/data/tst_scrollarea.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 +import QtQuick.Controls 1.0 + +TestCase { + id: testCase + name: "Tests_ScrollArea" + when:windowShown + width:400 + height:400 + + + TextArea { id: textArea } + + Item { id: bigItem } + + Component { + id: scrollAreaComponent + ScrollArea { } + } + + function test_scroll() { + var component = scrollAreaComponent + var scrollArea = component.createObject(testCase); + verify(scrollArea !== null, "table created is null") + + scrollArea.contentItem = bigItem + scrollArea.visible = true + verify(scrollArea.flickableItem, "flickableItem should not be null") + verify(scrollArea.flickableItem !== scrollArea.contentItem) + verify(scrollArea.flickableItem.contentHeight === 0, "ContentHeight not set") + + bigItem.height = 222 + bigItem.width = 333 + + verify(scrollArea.flickableItem.contentHeight === 222, "ContentHeight not set") + verify(scrollArea.flickableItem.contentWidth === 333, "ContentHeight not set") + + scrollArea.flickableItem.contentY = 200 + verify(scrollArea.flickableItem.contentY === 200, "ContentY not set") + + scrollArea.flickableItem.contentX = 300 + verify(scrollArea.flickableItem.contentX === 300, "ContentX not set") + } + + function test_viewport() { + var component = scrollAreaComponent + var scrollArea = component.createObject(testCase); + verify(scrollArea !== null, "table created is null") + + scrollArea.forceActiveFocus(); + verify(scrollArea.viewport, "Viewport not defined") + verify(!scrollArea.contentItem, "contentItem should be null") + verify(!scrollArea.flickableItem, "flickableItem should be null") + verify(!scrollArea.frame, "Frame should be false") + + scrollArea.contentItem = textArea + verify(scrollArea.viewport, "Viewport should be defined") + verify(scrollArea.contentItem, "contentItem should not be null") + verify(scrollArea.flickableItem, "flickableItem should not be null") + verify(scrollArea.flickableItem.contentHeight === textArea.height, "Content height not set") + + var prevViewportWidth = scrollArea.viewport.width + scrollArea.frame = true + verify(scrollArea.frame, "Frame should be true") + verify(scrollArea.viewport.width < prevViewportWidth, "Viewport should be smaller with frame") + } +} diff --git a/tests/auto/controls/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml new file mode 100644 index 00000000..344fc327 --- /dev/null +++ b/tests/auto/controls/data/tst_shortcuts.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Private 1.0 + +TestCase { + id: testCase + name: "Tests_Shortcut" + when: windowShown + width: 400 + height: 400 + + property var rootObject + + // Style item to find out if we are on mac + StyleItem { + id: styleItem + } + + function initTestCase() { + var component = Qt.createComponent("shortcut/shortcuts.qml"); + compare(component.status, Component.Ready) + rootObject = component.createObject(testCase); + verify(rootObject !== null, "created object is null") + rootObject.forceActiveFocus(); + } + + function test_shortcut_data() { + return [ + { key: Qt.Key_A, modifier: Qt.NoModifier, expected: "a pressed" }, + { key: Qt.Key_B, modifier: Qt.NoModifier, expected: "b pressed" }, + { key: Qt.Key_C, modifier: Qt.NoModifier, expected: "no key press" }, + { key: Qt.Key_C, modifier: Qt.ControlModifier, expected: "ctrl c pressed" }, + { key: Qt.Key_D, modifier: Qt.NoModifier, expected: "d pressed" }, + { key: Qt.Key_D, modifier: Qt.ControlModifier, expected: "no key press" }, + // shift d is not triggered because it is overloaded + { key: Qt.Key_D, modifier: Qt.ShiftModifier, expected: "no key press" }, + { key: Qt.Key_D, modifier: Qt.AltModifier, expected: "alt d pressed" }, + { key: Qt.Key_T, modifier: Qt.NoModifier, expected: "no key press" }, + // on mac we don't have mnemonics + { key: Qt.Key_T, modifier: Qt.AltModifier, expected: styleItem.style === "mac" ? "no key press" : "alt t pressed" }, + ] + } + + function test_shortcut(data) { + + verify(rootObject != undefined); + var text = rootObject.children[0]; + text.text = "no key press"; + + keyPress(data.key, data.modifier); + + verify(text != undefined); + compare(text.text, data.expected.toString()); + + } +} + + + diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml new file mode 100644 index 00000000..70dc3d92 --- /dev/null +++ b/tests/auto/controls/data/tst_slider.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_Slider" + when:windowShown + width:400 + height:400 + + function test_minimumvalue() { + var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {}', testCase, ''); + + slider.minimumValue = 5 + slider.maximumValue = 10 + slider.value = 2 + compare(slider.minimumValue, 5) + compare(slider.value, 5) + } + + function test_maximumvalue() { + var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {}', testCase, ''); + + slider.minimumValue = 5 + slider.maximumValue = 10 + slider.value = 15 + compare(slider.maximumValue, 10) + compare(slider.value, 10) + } +} diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml new file mode 100644 index 00000000..fe482308 --- /dev/null +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -0,0 +1,304 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +Item { + id: container + width: 300; height: 300 + + TestCase { + id: testcase + name: "Tests_SpinBox" + when: windowShown + + property int arrowMargin: 4 // the mouse areas for the up/down arrows have margins + property point mainCoord: "0,0" + property point upCoord: "0,0" + property point downCoord: "0,0" + + function test_increment_key() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {maximumValue: 50}', container, '') + spinbox.forceActiveFocus() + + compare(spinbox.maximumValue, 50) + spinbox.value = spinbox.maximumValue - 3 + keyPress(Qt.Key_Up) + compare(spinbox.value, spinbox.maximumValue - 2) + keyPress(Qt.Key_Up) + keyPress(Qt.Key_Up) + compare(spinbox.value, spinbox.maximumValue) + keyPress(Qt.Key_Up) + compare(spinbox.value, spinbox.maximumValue) + } + + function test_decrement_key() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {minimumValue: 10}', container, '') + spinbox.forceActiveFocus() + + compare(spinbox.minimumValue, 10) + spinbox.value = spinbox.minimumValue + 3 + keyPress(Qt.Key_Down) + compare(spinbox.value, spinbox.minimumValue + 2) + keyPress(Qt.Key_Down) + keyPress(Qt.Key_Down) + compare(spinbox.value, spinbox.minimumValue) + keyPress(Qt.Key_Down) + compare(spinbox.value, spinbox.minimumValue) + } + + function test_increment_mouse() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {maximumValue: 50}', container, '') + spinbox.forceActiveFocus() + setCoordinates(spinbox) + + spinbox.value = spinbox.maximumValue - 3 + mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton) + compare(spinbox.value, spinbox.maximumValue - 2) + mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton) + mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton) + compare(spinbox.value, spinbox.maximumValue) + mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton) + compare(spinbox.value, spinbox.maximumValue) + } + + function test_decrement_mouse() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {minimumValue: 10}', container, '') + spinbox.forceActiveFocus() + setCoordinates(spinbox) + + spinbox.value = spinbox.minimumValue + 3 + mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton) + compare(spinbox.value, spinbox.minimumValue + 2) + mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton) + mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton) + compare(spinbox.value, spinbox.minimumValue) + mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton) + compare(spinbox.value, spinbox.minimumValue) + } + + function test_move_mouse() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + spinbox.forceActiveFocus() + setCoordinates(spinbox) + + mouseMove(spinbox, mainCoord.x, mainCoord.y) + compare(spinbox.__containsMouse, true) + compare(spinbox.__upHovered, false) + compare(spinbox.__downHovered, false) + + mouseMove(spinbox.parent, upCoord.x, upCoord.y) + compare(spinbox.__upHovered, true) + compare(spinbox.__downHovered, false) + + mouseMove(spinbox, downCoord.x, downCoord.y) + compare(spinbox.__upHovered, false) + compare(spinbox.__downHovered, true) + + mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) + compare(spinbox.__containsMouse, false) + compare(spinbox.__upHovered, false) + compare(spinbox.__downHovered, false) + } + + function test_maxvalue() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + spinbox.value = spinbox.maximumValue + 1 + compare(spinbox.value, spinbox.maximumValue) + + spinbox.maximumValue = 0; + spinbox.minimumValue = 0; + spinbox.value = 10; + compare(spinbox.value, 0) + + spinbox.maximumValue = 5; + spinbox.minimumValue = 0; + spinbox.value = 10; + compare(spinbox.value, 5) + } + + function test_minvalue() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + spinbox.value = spinbox.minimumValue - 1 + compare(spinbox.value, spinbox.minimumValue) + + spinbox.maximumValue = 0; + spinbox.minimumValue = 6; + spinbox.value = 3; + compare(spinbox.value, 6) + + spinbox.maximumValue = 10; + spinbox.minimumValue = 6; + spinbox.value = 0; + compare(spinbox.value, 6) + } + + function test_nanvalue() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + // It is not possible to set a string to the spinbox value. + // Nan is a valid number though + spinbox.value = NaN + compare(spinbox.value, NaN) + compare(spinbox.__text, "nan") + } + + function test_decimals() { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + + spinbox.decimals = 0 + spinbox.value = 1.00001 + compare(spinbox.value, 1) + compare(spinbox.__text, "1") + + spinbox.decimals = 1 + spinbox.value = 1.00001 + compare(spinbox.value, 1) + compare(spinbox.__text, "1.0") + spinbox.value = 1.1 + compare(spinbox.value, 1.1) + compare(spinbox.__text, "1.1") + + spinbox.decimals = 5 + spinbox.value = 1.00001 + compare(spinbox.value, 1.00001) + compare(spinbox.__text, "1.00001") + + spinbox.decimals = 6 + compare(spinbox.value, 1.00001) + compare(spinbox.__text, "1.000010") + } + + function test_stepsize() + { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + spinbox.forceActiveFocus() + + spinbox.stepSize = 2 + spinbox.value = 10 + + compare(spinbox.value, 10) + + keyPress(Qt.Key_Up) + compare(spinbox.value, 10 + spinbox.stepSize) + + var previousValue = spinbox.value + keyPress(Qt.Key_Down) + compare(spinbox.value, previousValue - spinbox.stepSize) + } + + function test_negativeStepSize() + { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + spinbox.forceActiveFocus() + + spinbox.minimumValue = -50 + spinbox.maximumValue = 50 + + spinbox.stepSize = -2 + spinbox.value = 5 + + compare(spinbox.value, 5) + + keyPress(Qt.Key_Up) + compare(spinbox.value, 5 + spinbox.stepSize) + + var previousValue = spinbox.value + keyPress(Qt.Key_Down) + compare(spinbox.value, previousValue - spinbox.stepSize) + + // test on the edges + + spinbox.value = -49 + keyPress(Qt.Key_Up) + compare(spinbox.value, spinbox.minimumValue) + + spinbox.value = 49 + keyPress(Qt.Key_Down) + compare(spinbox.value, spinbox.maximumValue) + } + + function test_ImplicitSize() // Verify if we correctly grow and shrink depending on contents + { + var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '') + spinbox.forceActiveFocus() + spinbox.minimumValue = -50 + spinbox.maximumValue = 50 + + var oldSize = spinbox.implicitWidth + spinbox.maximumValue = 5000 + verify(oldSize < spinbox.implicitWidth) + oldSize = spinbox.implicitWidth + spinbox.maximumValue = 50 + verify(oldSize > spinbox.implicitWidth) + + oldSize = spinbox.implicitWidth + spinbox.minimumValue = -5000 + verify(oldSize < spinbox.implicitWidth) + + spinbox.minimumValue = -50 + oldSize = spinbox.implicitWidth + spinbox.minimumValue = -5000 + verify(oldSize < spinbox.implicitWidth) + + spinbox.minimumValue = -50 + oldSize = spinbox.implicitWidth + spinbox.minimumValue = -5000 + verify(oldSize < spinbox.implicitWidth) + + spinbox.minimumValue = -50 + spinbox.decimals = 0 + oldSize = spinbox.implicitWidth + spinbox.decimals = 4 + verify(oldSize < spinbox.implicitWidth) + } + + function setCoordinates(item) + { + mainCoord.x = item.x + 1 + mainCoord.y = item.y + 1 + upCoord.x = item.x + item.width - arrowMargin + upCoord.y = item.y + arrowMargin + downCoord.x = upCoord.x + downCoord.y = item.y + item.height - arrowMargin + } + } +} + diff --git a/tests/auto/controls/data/tst_splitter.qml b/tests/auto/controls/data/tst_splitter.qml new file mode 100644 index 00000000..a4a50f50 --- /dev/null +++ b/tests/auto/controls/data/tst_splitter.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 +import QtQuick.Controls 1.0 + +TestCase { + id: testCase + name: "Tests_Splitter" + when: windowShown + width: 400 + height: 400 + + + Component { + id: splitterRow + Splitter { Item {} Item {} } + } + + function test_splitter() { + var component = splitterRow + var splitter = component.createObject(testCase); + verify (splitter !== null, "splitterrow created is null") + verify (splitter.orientation === Qt.Horizontal) + verify (splitter.__items.length === 2) + } + +} diff --git a/tests/auto/controls/data/tst_statusbar.qml b/tests/auto/controls/data/tst_statusbar.qml new file mode 100644 index 00000000..4eb9bd82 --- /dev/null +++ b/tests/auto/controls/data/tst_statusbar.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_StatusBar" + when:windowShown + width:400 + height:400 + + function test_createStatusBar() { + var statusBar = Qt.createQmlObject('import QtQuick.Controls 1.0; StatusBar {}', testCase, ''); + } +} + diff --git a/tests/auto/controls/data/tst_tab.qml b/tests/auto/controls/data/tst_tab.qml new file mode 100644 index 00000000..c20b2ea2 --- /dev/null +++ b/tests/auto/controls/data/tst_tab.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_Tab" + when:windowShown + width:400 + height:400 + + function test_createTab() { + var tab = Qt.createQmlObject('import QtQuick.Controls 1.0; Tab {}', testCase, ''); + } +} + diff --git a/tests/auto/controls/data/tst_tabframe.qml b/tests/auto/controls/data/tst_tabframe.qml new file mode 100644 index 00000000..4c6d7992 --- /dev/null +++ b/tests/auto/controls/data/tst_tabframe.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_TabFrame" + when:windowShown + width:400 + height:400 + + function test_createTabFrame() { + var tabFrame = Qt.createQmlObject('import QtQuick.Controls 1.0; TabFrame {}', testCase, ''); + } + + function test_repeater() { + var tabFrame = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; TabFrame { Repeater { model: 3; Tab { } } }', testCase, ''); + compare(tabFrame.count, 3) + } +} + diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml new file mode 100644 index 00000000..bf7c9bb4 --- /dev/null +++ b/tests/auto/controls/data/tst_tableview.qml @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 +import QtQuick.Controls 1.0 +import QtQuickControlsTests 1.0 + +TestCase { + id: testCase + name: "Tests_TableView" + when:windowShown + width:400 + height:400 + + function test_usingqmlmodel_data() { + return [ + {tag: "listmodel", a: "tableview/table5_listmodel.qml", expected: "A"}, + {tag: "countmodel", a: "tableview/table6_countmodel.qml", expected: 0}, + {tag: "arraymodel", a: "tableview/table7_arraymodel.qml", expected: "A"}, + {tag: "itemmodel", a: "tableview/table8_itemmodel.qml", expected: 10}, + ] + } + + function test_usingqmlmodel(data) { + + var component = Qt.createComponent(data.a) + compare(component.status, Component.Ready) + var table = component.createObject(testCase); + verify(table !== null, "table created is null") + table.forceActiveFocus(); + + verify(table.currentItem !== undefined, "No current item found") + var label = findAChild(table.currentItem, "label") + verify(label !== undefined) + compare(label.text, data.expected.toString()); + } + + function test_usingcppqobjectmodel() { + + var component = Qt.createComponent("tableview/table1_qobjectmodel.qml") + compare(component.status, Component.Ready) + var table = component.createObject(testCase); + verify(table !== null, "table created is null") + table.forceActiveFocus(); + + // read data from the model directly + var valuefrommodel = table.model.value; + verify(valuefrommodel !== undefined, "The model has no defined value") + + verify(table.currentItem !== undefined, "No current item found") + var label = findAChild(table.currentItem, "label") + verify(label !== undefined) + compare(label.text, valuefrommodel.toString()); + } + + function test_usingcppqabstractitemmodel() { + + var component = Qt.createComponent("tableview/table2_qabstractitemmodel.qml") + compare(component.status, Component.Ready) + var table = component.createObject(testCase); + verify(table !== null, "table created is null") + table.forceActiveFocus(); + + // to go to next row (this model has 10 rows) + table.__incrementCurrentIndex() + + // read data from the model directly + var valuefrommodel = table.model.dataAt(table.currentIndex) + verify(valuefrommodel !== undefined, "The model has no defined value") + + verify(table.currentItem !== undefined, "No current item found") + var label = findAChild(table.currentItem, "label") + verify(label !== undefined) + compare(label.text, valuefrommodel.toString()) + } + + function test_usingcpplistmodel_data() { + return [ + {tag: "qobjectlistmodel", a: "tableview/table3_qobjectlist.qml", expected: 1}, + {tag: "qstringlistmodel", a: "tableview/table4_qstringlist.qml", expected: "B"}, + ] + } + + function test_usingcpplistmodel(data) { + + var component = Qt.createComponent(data.a) + compare(component.status, Component.Ready) + var table = component.createObject(testCase); + verify(table !== null, "table created is null") + table.forceActiveFocus(); + + // to go to next row (this model has 3 rows, read the second row) + table.__incrementCurrentIndex() + + verify(table.currentItem !== undefined, "No current item found") + var label = findAChild(table.currentItem, "label") + verify(label !== undefined) + compare(label.text, data.expected.toString()); + } + + // In TableView, drawn text = table.currentItem.children[1].children[1].itemAt(0).children[0].children[0].text + + function findAChild(item, name) + { + if (item.count === undefined) { + var i = 0 + while (item.children[i] !== undefined) { + var child = item.children[i] + if (child.objectName === name) + return child + else { + var found = findAChild(child, name) + if (found !== undefined) + return found + } + i++ + } + + } else { // item with count => columns + for (var j = 0; j < item.count ; j++) { + var tempitem = item.itemAt(j) + if (tempitem.objectName === name) + return tempitem + var found = findAChild(tempitem, name) + if (found !== undefined) + return found + } + } + return undefined // no matching child found + } +} diff --git a/tests/auto/controls/data/tst_tableviewcolumn.qml b/tests/auto/controls/data/tst_tableviewcolumn.qml new file mode 100644 index 00000000..a7a75759 --- /dev/null +++ b/tests/auto/controls/data/tst_tableviewcolumn.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_TableViewColumn" + when:windowShown + width:400 + height:400 + + function test_createTableViewColumn() { + var tableViewColumn = Qt.createQmlObject('import QtQuick.Controls 1.0; TableViewColumn {}', testCase, ''); + } +} + diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml new file mode 100644 index 00000000..105f19c7 --- /dev/null +++ b/tests/auto/controls/data/tst_textarea.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_TextArea" + when: windowShown + width: 400 + height: 400 + + function test_append() { + var textarea = Qt.createQmlObject('import QtQuick.Controls 1.0; TextArea {}', testCase, '') + + compare(textarea.text, "") + + textarea.append("my") + compare(textarea.text, "my") + + textarea.append("name"); + compare(textarea.text, "my\nname") + } +} diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml new file mode 100644 index 00000000..1f051e74 --- /dev/null +++ b/tests/auto/controls/data/tst_textfield.qml @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_TextField" + when: windowShown + width: 400 + height: 400 + + function test_text() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + + compare(textfield.text, "") + textfield.text = "hello world" + compare(textfield.text, "hello world") + } + + function test_maximumLength() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + + textfield.text = "hello world" + textfield.maximumLength = 5 + compare(textfield.text, "hello") + } + + function test_length() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + + textfield.text = "hello world" + compare(textfield.length, 11) + } + + + function test_readonly() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + compare(textfield.readOnly, false) + textfield.text = "hello" + textfield.readOnly = true + keyPress(Qt.Key_9) + compare(textfield.text,"hello") + } + + function test_inputMask() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + // +/- not required, 1 digit required, 1 aphabetic character required and 2 digits not required + textfield.inputMask = "#9A00" + + keyPress(Qt.Key_Minus) + compare(textfield.text,"-") + compare(textfield.acceptableInput, false) + + keyPress(Qt.Key_9) + compare(textfield.text,"-9") + compare(textfield.acceptableInput, false) + + keyPress(Qt.Key_B) + compare(textfield.text,"-9b") + compare(textfield.acceptableInput, true) + + keyPress(Qt.Key_1) + compare(textfield.text,"-9b1") + compare(textfield.acceptableInput, true) + + keyPress(Qt.Key_1) + compare(textfield.text,"-9b11") + compare(textfield.acceptableInput, true) + + keyPress(Qt.Key_Backspace) + keyPress(Qt.Key_Backspace) + keyPress(Qt.Key_Backspace) + compare(textfield.text,"-9") + compare(textfield.acceptableInput, false) + + keyPress(Qt.Key_3) + compare(textfield.acceptableInput, false) + compare(textfield.text,"-93") + } + + function test_validator() { + var textfield = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; TextField {validator: RegExpValidator { regExp: /(red|blue|green)?/; }}', testCase, '') + + textfield.text = "blu" + compare(textfield.acceptableInput, false) + + textfield.text = "blue" + compare(textfield.acceptableInput, true) + + textfield.text = "bluee" + compare(textfield.acceptableInput, false) + } + + function test_selectAll() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.selectAll(); + + keyPress(Qt.Key_Delete) + compare(textfield.text, "") + } + + function test_select() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.select(5, 8); + + compare(textfield.selectionEnd, 8) + compare(textfield.selectionStart, 5) + compare(textfield.selectedText, "is ") + keyPress(Qt.Key_Delete) + compare(textfield.text, "this my text") + } + + function test_cursorPosition() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + compare(textfield.cursorPosition, 0) + keyPress(Qt.Key_M) + compare(textfield.cursorPosition, 1) + keyPress(Qt.Key_Y) + compare(textfield.cursorPosition, 2) + + textfield.cursorPosition = 1 + keyPress(Qt.Key_A) + compare(textfield.text, "may") + } + + function test_selectWord() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.selectWord(); + compare(textfield.selectedText, "text") + textfield.cursorPosition = 2 + textfield.selectWord(); + compare(textfield.selectedText, "this") + } + + function copy() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.text = "this is my text" + textfield.select(0, 5) + textfield.copy() + } + + function test_getText() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + var gettext = textfield.getText(0, 4) + compare(gettext, "this") + } + + function test_insert() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.insert(8, "not ") + compare(textfield.text, "this is not my text") + } + + function test_deselect() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.selectWord(); + textfield.deselect() + compare(textfield.selectedText, "") + } + + function test_undo() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.insert(8, "not ") + compare(textfield.canUndo, true) + textfield.undo() + compare(textfield.text, "this is my text") + } + + function test_redo() { + var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '') + textfield.forceActiveFocus() + + textfield.text = "this is my text" + textfield.insert(8, "not ") + textfield.undo() + compare(textfield.canRedo, true) + textfield.redo() + compare(textfield.text, "this is not my text") + } +} diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml new file mode 100644 index 00000000..9c125604 --- /dev/null +++ b/tests/auto/controls/data/tst_toolbar.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_ToolBar" + when:windowShown + width:400 + height:400 + + function test_createToolBar() { + var toolBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolBar {}', testCase, ''); + } +} + diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml new file mode 100644 index 00000000..61c3d308 --- /dev/null +++ b/tests/auto/controls/data/tst_toolbutton.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Components project. +** +** $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.0 +import QtTest 1.0 + +TestCase { + id: testCase + name: "Tests_ToolButton" + when:windowShown + width:400 + height:400 + + function test_createToolButton() { + var toolButton = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolButton {}', testCase, ''); + } +} + diff --git a/tests/auto/controls/tst_controls.cpp b/tests/auto/controls/tst_controls.cpp new file mode 100644 index 00000000..e63c01b0 --- /dev/null +++ b/tests/auto/controls/tst_controls.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtQuickTest/quicktest.h> +#include "qt_quick_controls_quicktest.h" +QT_QUICK_CONTROLS_TEST_MAIN(qtquickcontrols) |