From 32d11f2d679b811c9af349fe9f0b0b29d4f598c0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 13 Oct 2015 17:53:33 +0200 Subject: Avoid real-rounding glitches near ends of a slider's range. Floating point doesn't quite reliably satisfy certain standard identities of arithmetic ... Task-number: QTBUG-42358 Change-Id: I7417feedbfc1fd6f59510e0ee6d07d98ff7ddc46 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/slider/rounder.qml | 75 +++++++++++++++++++++++++++++ tests/auto/controls/data/tst_slider.qml | 27 +++++++++++ 2 files changed, 102 insertions(+) create mode 100644 tests/auto/controls/data/slider/rounder.qml (limited to 'tests') 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_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() + } } } -- cgit v1.2.1 From 34767778f6409f414add562eaad0eac11d88149d Mon Sep 17 00:00:00 2001 From: Karim Pinter Date: Thu, 15 Oct 2015 15:39:05 +0000 Subject: Adding animation interval for tumbler Extending the Tumblers setCurrentIndexAt method with timeinterval, which is set to the animation so while it changes it can move slower then default. Task-number: QTBUG-48680 Change-Id: Ic8e76c604bad928ae7b11cfbea76c11d5d295f80 Reviewed-by: Mitch Curtis --- tests/auto/extras/data/tst_tumbler.qml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') 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() { -- cgit v1.2.1 From d3dbbe4781c4a7137ada0324e6ec5b14fed5c859 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 22 Oct 2015 18:44:20 +0300 Subject: Allow ComboBox to select items with empty text ComboBox checks selected text like a boolean value. This check is unnecessary and prevents from item with empty text could be selected. [ChangeLog][ComboBox] ComboBox is now able to select items with empty text. Task-number: QTBUG-42127 Change-Id: Ifaa0598d17c85cee099c88f4e03092137ba17c70 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_combobox.qml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') 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"] }'] -- cgit v1.2.1 From b2492f31fd55b7b7335154464c1c12a6895f5a23 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 29 Oct 2015 14:00:29 +0100 Subject: BasicTableView: Use ListView's overlay header for the table header Previoulsy we manually positioned the table header over the table contents, which required some manual tweakings. Since 5.4, ListView support overlay headers that we can use them to clean our code in BasicTableView. There is, however, a small issue on Mac where the vertical scrollbar (specially in non-transient mode) is displayed below the table header. Since the header can't span beyond the ListView boundaries, we need to account for the vertical scrollbar width in the ListView's content width. This patch also updates the Desktop style to set the transientScrollBars property and some small tweaks to the Base style. Change-Id: I4433d0703328f23eadb0ae4563fbef5bba0168db Task-number: QTBUG-34344 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tableview/table_buttondelegate.qml | 5 +++-- tests/auto/controls/data/tst_tableview.qml | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'tests') 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_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() } -- cgit v1.2.1 From a68b58a35aeafad279236d31c28acda02baff5cf Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 4 Nov 2015 11:26:56 +0100 Subject: Fix CircularGauge's tickmark labels all being set 0 We were relying on model.get() to somehow reevaluate after we'd updated properties of model items, which somehow worked until 4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e. The correct approach is to do the same thing as we do for styleData.index: rely on the model properties that are exposed to the delegate, which do get updated. Change-Id: I529ab7dcc142187fc185b11658dc5e1496b6d6db Task-number: QTBUG-48839 Reviewed-by: J-P Nurmi --- tests/auto/extras/data/tst_circulartickmarklabel.qml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') 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; -- cgit v1.2.1