aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qsgtextinput
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-22 13:04:30 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-22 13:04:56 +1000
commit6938289ce3e1e29cc81f0e007390e0b5f6ef1a43 (patch)
tree34c3741dfb6add08bae47c341d830bb8db99c0b1 /tests/auto/declarative/qsgtextinput
parent9dd181877888c2842d3254bea9d217f4c6a45273 (diff)
Fix autotests
Diffstat (limited to 'tests/auto/declarative/qsgtextinput')
-rw-r--r--tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
index 72d5288824..77427253a6 100644
--- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
+++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp
@@ -1037,12 +1037,7 @@ void tst_qsgtextinput::horizontalAlignment()
QObject *ob = canvas.rootObject();
QVERIFY(ob != 0);
ob->setProperty("horizontalAlignment",hAlign);
- QImage actual(canvas.width(), canvas.height(), QImage::Format_RGB32);
- actual.fill(qRgb(255,255,255));
- {
- QPainter p(&actual);
- canvas.render(&p);
- }
+ QImage actual = canvas.grabFrameBuffer();
expectfile = createExpectedFileIfNotFound(expectfile, actual);
@@ -1736,7 +1731,7 @@ void tst_qsgtextinput::cursorRectangle()
// Check the cursor rectangle remains within the input bounding rect when auto scrolling.
QVERIFY(r.left() < input.boundingRect().width());
- QVERIFY(r.right() >= input.width());
+ QVERIFY(r.right() >= input.width() - error);
for (int i = 6; i < text.length(); ++i) {
input.setCursorPosition(i);
@@ -2221,18 +2216,25 @@ void tst_qsgtextinput::preeditAutoScroll()
QCOMPARE(input->positionAt(0), 0);
QCOMPARE(input->positionAt(input->width()), 5);
+ // some tolerance for different fonts.
+#ifdef Q_OS_LINUX
+ const int error = 2;
+#else
+ const int error = 5;
+#endif
+
// test if the preedit is larger than the text input that the
// character preceding the cursor is still visible.
qreal x = input->positionToRectangle(0).x();
for (int i = 0; i < 3; ++i) {
ic.sendPreeditText(preeditText, i + 1);
- QVERIFY(input->cursorRectangle().right() >= fm.width(preeditText.at(i)));
+ QVERIFY(input->cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input->positionToRectangle(0).x() < x);
x = input->positionToRectangle(0).x();
}
for (int i = 1; i >= 0; --i) {
ic.sendPreeditText(preeditText, i + 1);
- QVERIFY(input->cursorRectangle().right() >= fm.width(preeditText.at(i)));
+ QVERIFY(input->cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
QVERIFY(input->positionToRectangle(0).x() > x);
x = input->positionToRectangle(0).x();
}