Fix tst_qquicktextedit::cursorRectangle_QTBUG_38947()
authorJ-P Nurmi <jpnurmi@gmail.com>
Sat, 17 May 2014 10:42:43 +0000 (12:42 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 19 May 2014 12:49:58 +0000 (14:49 +0200)
Fix the uninitialize variable and make sure the test creates
a window that has a sensible (200x200) size.

Change-Id: I02616ab3c832276921e84ae98b7ed926d8fc5f5e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Liang Qi <liang.qi@digia.com>
tests/auto/quick/qquicktextedit/data/qtbug-38947.qml
tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp

index 3c8254f4cedb80dcd7e6d1c12ef4ad2332dbde00..ebf8080e69000c2547be057877e3d75716592435 100644 (file)
@@ -1,11 +1,16 @@
 import QtQuick 2.0
 
-TextEdit {
-    text: "Hello\nWorld!"
-    selectByMouse: true
-    cursorDelegate: Rectangle {
-        width: 10
-        color: "transparent"
-        border.color: "red"
+Item {
+    height: 200
+    width: 200
+    TextEdit {
+        objectName: "textedit"
+        text: "Hello\nWorld!"
+        selectByMouse: true
+        cursorDelegate: Rectangle {
+            width: 10
+            color: "transparent"
+            border.color: "red"
+        }
     }
 }
index 32e4a99ef0d87764136375b71a31872b65fb8ff9..1ffd67cbf1c8b2eaccb43fd5bb0383cef129231f 100644 (file)
@@ -5267,7 +5267,7 @@ void tst_qquicktextedit::cursorRectangle_QTBUG_38947()
     window.show();
     window.requestActivate();
     QTest::qWaitForWindowExposed(&window);
-    QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(window.rootObject());
+    QQuickTextEdit *edit = window.rootObject()->findChild<QQuickTextEdit *>("textedit");
     QVERIFY(edit);
 
     QPoint from = edit->positionToRectangle(0).center().toPoint();
@@ -5276,7 +5276,7 @@ void tst_qquicktextedit::cursorRectangle_QTBUG_38947()
     QSignalSpy spy(edit, SIGNAL(cursorRectangleChanged()));
     QVERIFY(spy.isValid());
 
-    for (int i = i; i < edit->length() - 1; ++i) {
+    for (int i = 1; i < edit->length() - 1; ++i) {
         QRectF rect = edit->positionToRectangle(i);
         QTest::mouseMove(&window, rect.center().toPoint());
         QCOMPARE(edit->cursorRectangle(), rect);