diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-28 09:32:26 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-28 09:32:26 +0100 |
commit | 2e48d16e4a230069884ac0585ae111037f4171fb (patch) | |
tree | d31d2dbc2be10d203721387955f2cdde451e5b95 /tests | |
parent | 4cfdab4a3317b09dab9c4000b6a004d2ea0560c1 (diff) | |
parent | d3dbbe4781c4a7137ada0324e6ec5b14fed5c859 (diff) | |
download | qtquickcontrols-2e48d16e4a230069884ac0585ae111037f4171fb.tar.gz |
Merge remote-tracking branch 'origin/5.5' into 5.6
Change-Id: I7177ee6f1dc74d7f0d2ac9a3aedcc8d7a00cee41
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/slider/rounder.qml | 75 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 19 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 27 |
3 files changed, 121 insertions, 0 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/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() + } } } |