diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/slider/rounder.qml | 75 | ||||
-rw-r--r-- | tests/auto/controls/data/tableview/table_buttondelegate.qml | 5 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 19 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 27 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tableview.qml | 5 | ||||
-rw-r--r-- | tests/auto/extras/data/tst_circulartickmarklabel.qml | 9 | ||||
-rw-r--r-- | tests/auto/extras/data/tst_tumbler.qml | 6 |
7 files changed, 143 insertions, 3 deletions
diff --git a/tests/auto/controls/data/slider/rounder.qml b/tests/auto/controls/data/slider/rounder.qml new file mode 100644 index 00000000..b7191892 --- /dev/null +++ b/tests/auto/controls/data/slider/rounder.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +/* Rounding errors in the value at end of range are elusive. + * They're sensitive to fine details in hard-to-anticipate ways. + */ +Item { + visible: true + /* Sensitive to slider width */ + width: 800 + height: 400 + + /* Let test know value and where to click */ + property int waist: slider.y + slider.height / 2 + property alias value: slider.value + + Slider { + id: slider + width: parent.width + + /* Sensitive to value range. */ + minimumValue: 0 + maximumValue: 100 + + style: SliderStyle { + /* Sensitive to handle size. */ + handle: Rectangle { + implicitHeight: 26 + implicitWidth: 26 + color: "salmon" + } + } + } +} diff --git a/tests/auto/controls/data/tableview/table_buttondelegate.qml b/tests/auto/controls/data/tableview/table_buttondelegate.qml index 3f1be964..3c347b36 100644 --- a/tests/auto/controls/data/tableview/table_buttondelegate.qml +++ b/tests/auto/controls/data/tableview/table_buttondelegate.qml @@ -55,15 +55,16 @@ TableView { onClicked: ++clickCount TableViewColumn { + id: column width: 100 } rowDelegate: Item { height: 40 - width: parent.width + width: column.width } itemDelegate: Button { height: 40 - width: parent.width + width: column.width text: styleData.value activeFocusOnPress: true onClicked: ++table.buttonClickCount diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index da8c79f8..cecc3928 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -682,6 +682,25 @@ TestCase { return index } + function test_emptyTextItem() { + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.2 ; ComboBox { }', testCase, ''); + comboBox.model = [ + "1", + "", + "3" + ] + compare(comboBox.currentIndex, 0) + compare(comboBox.currentText, "1") + comboBox.currentIndex = 1 + compare(comboBox.currentIndex, 1) + compare(comboBox.currentText, "") + comboBox.currentIndex = 2 + compare(comboBox.currentIndex, 2) + compare(comboBox.currentText, "3") + compare(comboBox.find(""), 1) + comboBox.destroy() + } + function test_minusOneIndexResetsSelection_QTBUG_35794() { var qmlObjects = ['import QtQuick.Controls 1.2 ; ComboBox { model: ["A", "B", "C"] }', 'import QtQuick.Controls 1.2 ; ComboBox { editable: true; model: ["A", "B", "C"] }'] diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 305605f6..1589f2ab 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -330,5 +330,32 @@ Item { control.destroy() } + + function test_dragRounding() { + // Regression test: ends of range should be exact, not 99.99999999 &c. + var component = Qt.createComponent("slider/rounder.qml") + compare(component.status, Component.Ready) + var control = component.createObject(container) + + // Does moving to maximum (100) actually reach it ? + mousePress(control, 0, control.waist) + mouseMove(control, control.width, control.waist) + mouseRelease(control, control.width, control.waist) + // Equality checks are dodgy with floats, but this should still be exact: + verify(control.value == 100) + // Neither of the following caught the bug, with value 100 -1.421e-14 + // compare(control.value, 100) + // fuzzyCompare(control.value, 100, 1e-16) + + // Now check it all works going the other way, too: + mousePress(control, control.width, control.waist) + mouseMove(control, 0, control.waist) + mouseRelease(control, 0, control.waist) + verify(control.value == 0) + + // Tidy up. + control.destroy() + component.destroy() + } } } diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index a01df56f..8a821661 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -91,7 +91,10 @@ TestCase { model: 10; \n\ }', testCase, '') wait(50); - verify(table.__viewTopMargin > 0) + testCase.visible = true // ### FIXME Why do I need this at all? + verify(table.visible) + verify(table.__listView.headerItem.visible) + verify(table.__listView.headerItem.height > 0) table.destroy() } diff --git a/tests/auto/extras/data/tst_circulartickmarklabel.qml b/tests/auto/extras/data/tst_circulartickmarklabel.qml index 2d1841e0..60d7ff9e 100644 --- a/tests/auto/extras/data/tst_circulartickmarklabel.qml +++ b/tests/auto/extras/data/tst_circulartickmarklabel.qml @@ -314,6 +314,15 @@ TestCase { compare(label.__panel.tickmarkValueFromMinorIndex(((label.tickmarkCount - 1) * label.minorTickmarkCount) - 1), 98); } + function test_labelText() { + for (var i = 0; i < label.labelCount; ++i) { + var labelDelegateLoader = findChild(label, "labelDelegateLoader" + i); + verify(labelDelegateLoader); + compare(labelDelegateLoader.styleData.index, i); + compare(labelDelegateLoader.styleData.value, i * label.labelStepSize); + } + } + function test_invalidValues() { // Shouldn't produce warnings. label.labelStepSize = 0; diff --git a/tests/auto/extras/data/tst_tumbler.qml b/tests/auto/extras/data/tst_tumbler.qml index 9f3ecc2f..c0c20532 100644 --- a/tests/auto/extras/data/tst_tumbler.qml +++ b/tests/auto/extras/data/tst_tumbler.qml @@ -150,6 +150,12 @@ Item { tumbler.setCurrentIndexAt(0, 1); tryCompare(tumbler.__viewAt(0), "offset", 4); compare(tumbler.currentIndexAt(0), 1); + + tumbler.setCurrentIndexAt(0, 0); + waitForRendering(tumbler); + tumbler.setCurrentIndexAt(0, tumbler.getColumn(0).model.count-1, 1000); + tryCompare(tumbler.__viewAt(0), "offset", 1); + compare(tumbler.currentIndexAt(0), tumbler.getColumn(0).model.count-1); } function test_visible() { |