diff options
Diffstat (limited to 'tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp')
-rw-r--r-- | tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp | 20 |
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(); } |