summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-03-17 15:45:38 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-03-18 22:34:13 +0100
commit180f78d12680f1954f9ea3f4b00200ecfa1a853e (patch)
treeabfb3c1c010ee777304c5bd5f36dc9255c3ca593 /tests/auto/widgets/widgets
parent2b9bc46670cd4d7e71d7ad157619552dd90a57a8 (diff)
QDial: use qRound to round
The calculation rounds early and often, which is intentional. Add unit test to make sure we don't regress. Fixes static analzyer report about incorrect rounding in c903a34347776fe3b89785faa35c446d. Address some outdated comments and documentation. The property is read only and calculated, so don't imply that it can be changed from its default value. Change-Id: If2dbd9890e533dfccda3eae4cbc96db4f1246f4d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qdial/tst_qdial.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
index 29aee1c397..86928414c8 100644
--- a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
+++ b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
@@ -42,6 +42,9 @@ private slots:
void valueChanged();
void sliderMoved();
void wrappingCheck();
+
+ void notchSize_data();
+ void notchSize();
};
// Testing get/set functions
@@ -194,5 +197,33 @@ void tst_QDial::wrappingCheck()
}
}
+/*
+ Verify that the notchSizes calculated don't change compared
+ to Qt 5.15 results for dial sizes at the edge values of the
+ algorithm.
+*/
+void tst_QDial::notchSize_data()
+{
+ QTest::addColumn<int>("diameter");
+ QTest::addColumn<int>("notchSize");
+
+ QTest::newRow("data0") << 50 << 4;
+ QTest::newRow("data1") << 80 << 4;
+ QTest::newRow("data2") << 95 << 4;
+ QTest::newRow("data3") << 110 << 4;
+ QTest::newRow("data4") << 152 << 2;
+ QTest::newRow("data5") << 210 << 2;
+ QTest::newRow("data6") << 228 << 1;
+}
+
+void tst_QDial::notchSize()
+{
+ QFETCH(int, diameter);
+ QFETCH(int, notchSize);
+ QDial dial;
+ dial.setFixedSize(QSize(diameter, diameter));
+ QCOMPARE(dial.notchSize(), notchSize);
+}
+
QTEST_MAIN(tst_QDial)
#include "tst_qdial.moc"