Fix autotests
authorAaron Kennedy <aaron.kennedy@nokia.com>
Wed, 22 Jun 2011 03:04:30 +0000 (13:04 +1000)
committerAaron Kennedy <aaron.kennedy@nokia.com>
Wed, 22 Jun 2011 03:04:56 +0000 (13:04 +1000)
tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp
tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp

index 8044b80..b5aaa00 100644 (file)
@@ -328,7 +328,6 @@ void tst_qdeclarativeimage::mirror()
             p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
             break;
         case QDeclarativeImage::PreserveAspectFit:
-            QEXPECT_FAIL("", "QTBUG-19538", Continue);
             p_e.drawPixmap(QRect(25, 0, width / (width/height), height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
             break;
         case QDeclarativeImage::PreserveAspectCrop:
index fda1640..1aa9a5d 100644 (file)
@@ -332,6 +332,7 @@ void tst_qdeclarativeinstruction::dump()
         i.storeScriptString.propertyIndex = 24;
         i.storeScriptString.value = 3;
         i.storeScriptString.scope = 1;
+        i.storeScriptString.bindingId = 3;
         data->addInstruction(i);
     }
 
@@ -535,7 +536,7 @@ void tst_qdeclarativeinstruction::dump()
         << "25\t\tSTORE_VARIANT_OBJECT\t22"
         << "26\t\tSTORE_INTERFACE\t\t23"
         << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\""
-        << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t0"
+        << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t3"
         << "29\t\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
         << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
         << "31\t\tSTORE_BINDING\t26\t3\t2"
index 40920e3..ea92607 100644 (file)
@@ -408,10 +408,7 @@ void tst_qsgtextedit::alignments()
     ob->setProperty("horizontalAlignment",hAlign);
     ob->setProperty("verticalAlignment",vAlign);
     QTRY_COMPARE(ob->property("running").toBool(),false);
-    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);
 
index 72d5288..7742725 100644 (file)
@@ -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();
     }