aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-09-10 12:35:31 +0200
committerLars Knoll <lars.knoll@theqtcompany.com>2015-09-14 12:04:32 +0000
commitea89d156afaf7d22c069e92a1666be584f01d5ac (patch)
treef5751f3458c0a105b7e8a25d4f7d3b0e712f5b26 /tests
parent3713120cc8b7f8a95aa670d759b8f9ed3b72425a (diff)
Fix autotests
Commit 35793cea28c4bd1d6d8fbae884d9ae3c19745c61 caused changes to font metrics on Mac when running our autotests. This change adjust auto tests to pass again after the change. Fix QQuickText::fontSizeMode autotests. The calculations are font dependent, and with small differences in the fonts between different OSes it's difficult to find values that work everywhere. Also fix the baseline calculations for some items that were using the wrong fonts (exchanging empty and non empty calculations). Fix language dependent differences on metrics calculations in tst_qquicktextinput. Change-Id: I7d0c7c79c8c62a4619b2f0e95ef53660b7feb782 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquicktext/data/fontSizeMode.qml4
-rw-r--r--tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml2
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp10
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp6
4 files changed, 12 insertions, 10 deletions
diff --git a/tests/auto/quick/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
index 84f7ce8d50..48e7c7b6d0 100644
--- a/tests/auto/quick/qquicktext/data/fontSizeMode.qml
+++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
@@ -13,10 +13,10 @@ Item {
id: myText
objectName: "myText"
width: 250
- height: 41
+ height: 35
minimumPointSize: 8
minimumPixelSize: 8
- font.pixelSize: 30
+ font.pixelSize: 25
font.family: "Helvetica"
}
}
diff --git a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
index 9c9318d3cc..45255691fb 100644
--- a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
+++ b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
Rectangle {
- width: 200
+ width: 220
height: 100
Text {
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index c1f10f9788..6042c08891 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -913,7 +913,7 @@ void tst_qquicktext::hAlignImplicitWidth()
// Try to check whether alignment works by checking the number of black
// pixels in the thirds of the grabbed image.
- const int windowWidth = 200;
+ const int windowWidth = 220;
const int textWidth = qCeil(text->implicitWidth());
QVERIFY2(textWidth < windowWidth, "System font too large.");
const int sectionWidth = textWidth / 3;
@@ -3756,8 +3756,8 @@ void tst_qquicktext::baselineOffset_data()
<< "<b>hello world</b>"
<< "<b>hello<br/>world</b>"
<< QByteArray("height: 200")
- << &expectedBaselineTop
- << &expectedBaselineBold;
+ << &expectedBaselineBold
+ << &expectedBaselineTop;
QTest::newRow("richText")
<< "<b>hello world</b>"
@@ -3852,8 +3852,8 @@ void tst_qquicktext::baselineOffset_data()
<< "<b>hello world</b>"
<< "<b>hello<br/>world</b>"
<< QByteArray("height: 200; topPadding: 10; bottomPadding: 20")
- << &expectedBaselineTop
- << &expectedBaselineBold;
+ << &expectedBaselineBold
+ << &expectedBaselineTop;
QTest::newRow("richText with padding")
<< "<b>hello world</b>"
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 079f73ae34..85123c6f92 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -3092,14 +3092,16 @@ void tst_qquicktextinput::cursorRectangle()
} else {
QCOMPARE(r.left(), input.width());
}
- QVERIFY(r.top() >= line.height() - 1);
+ // we can't be exact here, as the space character can have a different ascent/descent from the arabic chars
+ // this then leads to different line heights between the wrapped and non wrapped texts
+ QVERIFY(r.top() >= line.height() - 5);
COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(11), r);
for (int i = wrapPosition + 1; i < text.length(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
- QVERIFY(r.top() >= line.height() - 1);
+ QVERIFY(r.top() >= line.height() - 5);
COMPARE_INPUT_METHOD_QUERY(QRectF, (&input), Qt::ImCursorRectangle, toRectF, r);
QCOMPARE(input.positionToRectangle(i), r);
}