summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-07 15:18:16 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-07 15:18:16 +0100
commitcdf13ce286b14273e1e29c5bb02cbc880f31b786 (patch)
tree10733cb3fb35647b19cfd15ab158f56b1cb550e1 /tests/auto/other
parent21d607c81af0cd285e9bb3869ac3cd18358f1c8f (diff)
parenta8321f21fb82714771b4717c99dd475f2c74649e (diff)
Merge branch 'stable' into dev
Conflicts: tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp Change-Id: I6b8d505fc22f052c307ca27f58f7d16f98965f47
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/modeltest/modeltest.cpp2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp37
2 files changed, 25 insertions, 14 deletions
diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp
index 17f164b638..27b1e5aa95 100644
--- a/tests/auto/other/modeltest/modeltest.cpp
+++ b/tests/auto/other/modeltest/modeltest.cpp
@@ -46,8 +46,6 @@
#include <QtTest/QtTest>
-Q_DECLARE_METATYPE ( QModelIndex )
-
/*!
Connect to all of the models signals. Whenever anything happens recheck everything.
*/
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 9302828196..3da8c4612c 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -184,7 +184,8 @@ static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *c
do { \
if (!errorAt && !(cond)) { \
errorAt = __LINE__; \
- qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \
+ qWarning("level: %d, role: %d (%s)", treelevel, iface->role(), #cond); \
+ break; \
} \
} while (0)
@@ -195,13 +196,10 @@ static int verifyHierarchy(QAccessibleInterface *iface)
QAIPtr middleChild;
QAIPtr if2;
++treelevel;
- int middle = iface->childCount()/2 + 1;
- if (iface->childCount() >= 2) {
- middleChild = QAIPtr(iface->child(middle - 1));
- }
for (int i = 0; i < iface->childCount() && !errorAt; ++i) {
if2 = QAIPtr(iface->child(i));
EXPECT(if2 != 0);
+ EXPECT(iface->indexOfChild(if2.data()) == i);
// navigate Ancestor
QAIPtr parent(if2->parent());
EXPECT(iface->object() == parent->object());
@@ -1534,7 +1532,7 @@ static QRect characterRect(const QTextEdit &edit, int offset)
QPointF layoutPosition = layout->position();
int relativeOffset = offset - block.position();
QTextLine line = layout->lineForTextPosition(relativeOffset);
- QFontMetrics fm(edit.font());
+ QFontMetrics fm(edit.currentFont());
QChar ch = edit.document()->characterAt(offset);
int w = fm.width(ch);
int h = fm.height();
@@ -1546,6 +1544,21 @@ static QRect characterRect(const QTextEdit &edit, int offset)
return r;
}
+/* The rects does not have to be exactly the same. They may be slightly different due to
+ different ways of calculating them. By having an acceptable delta, this should also
+ make the test a bit more resilient against any future changes in the behavior of
+ characterRect().
+*/
+static bool fuzzyRectCompare(const QRect &a, const QRect &b)
+{
+ static const int MAX_ACCEPTABLE_DELTA = 1;
+ const QMargins delta(a.left() - b.left(), a.top() - b.top(),
+ a.right() - b.right(), a.bottom() - b.bottom());
+
+ return qAbs(delta.left()) <= MAX_ACCEPTABLE_DELTA && qAbs(delta.top()) <= MAX_ACCEPTABLE_DELTA
+ && qAbs(delta.right()) <= MAX_ACCEPTABLE_DELTA && qAbs(delta.bottom()) <= MAX_ACCEPTABLE_DELTA;
+}
+
void tst_QAccessibility::textEditTest()
{
for (int pass = 0; pass < 2; ++pass) {
@@ -1561,7 +1574,7 @@ void tst_QAccessibility::textEditTest()
QFont font("Helvetica");
font.setPointSizeF(12.5);
font.setWordSpacing(1.1);
- edit.setFont(font);
+ edit.setCurrentFont(font);
}
edit.show();
@@ -1575,23 +1588,23 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(startOffset, 13);
QCOMPARE(endOffset, 31);
QCOMPARE(iface->textInterface()->characterCount(), 48);
- QFontMetrics fm(edit.font());
+ QFontMetrics fm(edit.currentFont());
QCOMPARE(iface->textInterface()->characterRect(0).size(), QSize(fm.width("h"), fm.height()));
QCOMPARE(iface->textInterface()->characterRect(5).size(), QSize(fm.width(" "), fm.height()));
QCOMPARE(iface->textInterface()->characterRect(6).size(), QSize(fm.width("w"), fm.height()));
int offset = 10;
QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("d"));
- QCOMPARE(iface->textInterface()->characterRect(offset), characterRect(edit, offset));
+ QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
offset = 13;
QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("H"));
- QCOMPARE(iface->textInterface()->characterRect(offset), characterRect(edit, offset));
+ QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
offset = 21;
QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("y"));
- QCOMPARE(iface->textInterface()->characterRect(offset), characterRect(edit, offset));
+ QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
offset = 32;
QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("I"));
- QCOMPARE(iface->textInterface()->characterRect(offset), characterRect(edit, offset));
+ QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
QTestAccessibility::clearEvents();