diff options
Diffstat (limited to 'tests/auto/declarative')
31 files changed, 444 insertions, 192 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml new file mode 100644 index 0000000..804559c --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + color: "blue" + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 5c2c145..174967b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -80,6 +80,7 @@ private slots: void startup(); void groupedPropertyCrash(); void runningTrue(); + void sameValue(); }; void tst_qdeclarativebehaviors::simpleBehavior() @@ -384,6 +385,33 @@ void tst_qdeclarativebehaviors::runningTrue() QTRY_VERIFY(runningSpy.count() > 0); } +//QTBUG-12295 +void tst_qdeclarativebehaviors::sameValue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *target = rect->findChild<QDeclarativeRectangle*>("myRect"); + QVERIFY(target); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); + QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + //this is the main point of the test -- the behavior needs to be triggered again + //even though we set 0 twice in a row. + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); +} + QTEST_MAIN(tst_qdeclarativebehaviors) #include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml index 6c39f20..42b50cf 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml @@ -4,11 +4,11 @@ Rectangle { id: root width:300; height:400 - property bool focus1: root.wantsFocus - property bool focus2: item1.wantsFocus - property bool focus3: fs1.wantsFocus - property bool focus4: fs2.wantsFocus - property bool focus5: theItem.wantsFocus + property bool focus1: root.activeFocus + property bool focus2: item1.activeFocus + property bool focus3: fs1.activeFocus + property bool focus4: fs2.activeFocus + property bool focus5: theItem.activeFocus Item { id: item1 diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml index af9c420..9144854 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml @@ -15,28 +15,28 @@ Rectangle { height: 120; width: 420 color: "transparent" - border.width: 5; border.color: firstScope.wantsFocus?"blue":"black" + border.width: 5; border.color: firstScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } Rectangle { id: item2; objectName: "item2" x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -50,32 +50,32 @@ Rectangle { y: 160; height: 120; width: 420 color: "transparent" - border.width: 5; border.color: secondScope.wantsFocus?"blue":"black" + border.width: 5; border.color: secondScope.activeFocus?"blue":"black" Rectangle { id: item4; objectName: "item4" x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } Rectangle { id: item5; objectName: "item5" x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } } } Keys.onDigit4Pressed: item4.focus = true - Keys.onDigit5Pressed: item5.forceFocus() + Keys.onDigit5Pressed: item5.forceActiveFocus() } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml index aa43ba8..55be103 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml @@ -20,21 +20,21 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.debug("Top Left"); KeyNavigation.right: item2 focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } @@ -43,13 +43,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -63,14 +63,14 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml index 216277e..5ed701d 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml @@ -10,27 +10,27 @@ Rectangle { FocusScope { y: 100 focus: true; objectName: "item1" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item2" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item3" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item4" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item5" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } } } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml index 2ac0d18..c6d112f 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml @@ -13,7 +13,7 @@ Rectangle { ListElement { name: "4" } ListElement { name: "5" } ListElement { name: "6" } - ListElement { name: "6" } + ListElement { name: "7" } ListElement { name: "8" } ListElement { name: "9" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml index 8862b39..3c6d3bd 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml @@ -19,21 +19,21 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Error - Top Left"); KeyNavigation.right: item2 focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } @@ -42,13 +42,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Error - Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -62,14 +62,14 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Error - Bottom Left"); KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml index cdb5164..4417d5f 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml @@ -20,13 +20,13 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: item1.wantsFocus?"blue":"black" + border.color: item1.activeFocus?"blue":"black" } TextEdit { @@ -47,13 +47,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onReturnPressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -66,7 +66,7 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: item3.wantsFocus?"blue":"black" + border.color: item3.activeFocus?"blue":"black" } TextEdit { diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 2559087..b0c9c03 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -118,22 +118,22 @@ void tst_qdeclarativefocusscope::basic() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == true); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); delete view; } @@ -166,16 +166,11 @@ void tst_qdeclarativefocusscope::nested() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item1->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->wantsFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == true); - QVERIFY(item3->hasFocus() == false); - QVERIFY(item4->wantsFocus() == true); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->wantsFocus() == true); - QVERIFY(item5->hasFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == true); + QVERIFY(item5->hasActiveFocus() == true); delete view; } @@ -204,22 +199,22 @@ void tst_qdeclarativefocusscope::noFocus() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); delete view; } @@ -249,32 +244,32 @@ void tst_qdeclarativefocusscope::textEdit() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == true); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); delete view; } @@ -308,28 +303,28 @@ void tst_qdeclarativefocusscope::forceFocus() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == false); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_4); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == false); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_5); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == true); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == true); delete view; } diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 38fd458..b8d2828 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -136,6 +136,7 @@ void tst_qdeclarativeimage::imageSource_data() QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << ""; + QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << ""; QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true << false << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; @@ -155,6 +156,7 @@ void tst_qdeclarativeimage::imageSource() if (remote) { QVERIFY(server.isValid()); server.serveDirectory(SRCDIR "/data"); + server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); } if (!error.isEmpty()) diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index ffb2105..d76d360 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -371,7 +371,7 @@ void tst_QDeclarativeItem::keyNavigation() QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // right QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); @@ -380,7 +380,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // down key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); @@ -389,7 +389,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // left key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); @@ -398,7 +398,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // up key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); @@ -407,7 +407,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // tab key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); @@ -416,7 +416,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // backtab key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); @@ -425,7 +425,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); delete canvas; } @@ -618,21 +618,21 @@ void tst_QDeclarativeItem::mouseFocus() QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "declarativeItem"); QVERIFY(item); - QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); + QSignalSpy focusSpy(item, SIGNAL(activeFocusChanged(bool))); QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); QApplication::processEvents(); QCOMPARE(focusSpy.count(), 1); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // make sure focusable graphics widget underneath does not steal focus QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); QApplication::processEvents(); QCOMPARE(focusSpy.count(), 1); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); item->setFocus(false); - QVERIFY(!item->hasFocus()); + QVERIFY(!item->hasActiveFocus()); QCOMPARE(focusSpy.count(), 2); item->setFocus(true); QCOMPARE(focusSpy.count(), 3); @@ -664,7 +664,8 @@ void tst_QDeclarativeItem::propertyChanges() QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); - QSignalSpy wantsFocusSpy(parentItem, SIGNAL(wantsFocusChanged(bool))); + QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); + QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged())); item->setParentItem(parentItem); item->setWidth(100.0); @@ -677,6 +678,10 @@ void tst_QDeclarativeItem::propertyChanges() QList<QVariant> parentArguments = parentSpy.first(); QVERIFY(parentArguments.count() == 1); QCOMPARE(item->parentItem(), qvariant_cast<QDeclarativeItem *>(parentArguments.at(0))); + QCOMPARE(childrenChangedSpy.count(),1); + + item->setParentItem(parentItem); + QCOMPARE(childrenChangedSpy.count(),1); QCOMPARE(item->width(), 100.0); QCOMPARE(widthSpy.count(),1); @@ -696,14 +701,14 @@ void tst_QDeclarativeItem::propertyChanges() QVERIFY(childrenRectArguments.count() == 1); QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); - QCOMPARE(item->hasFocus(), true); + QCOMPARE(item->hasActiveFocus(), true); QCOMPARE(focusSpy.count(),1); QList<QVariant> focusArguments = focusSpy.first(); QVERIFY(focusArguments.count() == 1); QCOMPARE(focusArguments.at(0).toBool(), true); + QCOMPARE(parentItem->hasActiveFocus(), false); QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(parentItem->wantsFocus(), false); QCOMPARE(wantsFocusSpy.count(),0); delete canvas; diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 5a10372..c9bb467 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -137,6 +137,17 @@ void tst_QDeclarativeMouseArea::dragProperties() QCOMPARE(yminSpy.count(),1); QCOMPARE(ymaxSpy.count(),1); + // filterChildren + QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged())); + + drag->setFilterChildren(true); + + QVERIFY(drag->filterChildren()); + QCOMPARE(filterChildrenSpy.count(), 1); + + drag->setFilterChildren(true); + QCOMPARE(filterChildrenSpy.count(), 1); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index 8956205..ff6f224 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml @@ -6,6 +6,7 @@ Rectangle { property int currentB: -1 property real delegateWidth: 60 property real delegateHeight: 20 + property real delegateScale: 1.0 width: 240 height: 320 color: "#ffffff" @@ -17,6 +18,7 @@ Rectangle { objectName: "wrapper" height: root.delegateHeight width: root.delegateWidth + scale: root.delegateScale color: PathView.isCurrentItem ? "lightsteelblue" : "white" border.color: "black" Text { diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index bf1e13a..fdbb16d 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -451,11 +451,19 @@ void tst_QDeclarativePathView::pathMoved() QCOMPARE(firstItem->pos() + offset, start); // Change delegate size + pathview->setOffset(0.1); + pathview->setOffset(0.0); canvas->rootObject()->setProperty("delegateWidth", 30); QCOMPARE(firstItem->width(), 30.0); offset.setX(firstItem->width()/2); QTRY_COMPARE(firstItem->pos() + offset, start); + // Change delegate scale + pathview->setOffset(0.1); + pathview->setOffset(0.0); + canvas->rootObject()->setProperty("delegateScale", 1.2); + QTRY_COMPARE(firstItem->pos() + offset, start); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml index e8dd8cc..4810736 100644 --- a/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml +++ b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml @@ -4,21 +4,27 @@ import Qt 4.7 Rectangle { + id: root color: "lightgray" width: 240 height: 320 + property variant itemModel: itemModel1 function checkProperties() { testObject.error = false; - if (testObject.useModel && view.model != itemModel) { + if (testObject.useModel && view.model != root.itemModel) { console.log("model property incorrect"); testObject.error = true; } } + function switchModel() { + root.itemModel = itemModel2 + } + VisualItemModel { - id: itemModel - objectName: "itemModel" + id: itemModel1 + objectName: "itemModel1" Rectangle { objectName: "item1" height: 50; width: 100; color: "#FFFEF0" @@ -36,12 +42,27 @@ Rectangle { } } + VisualItemModel { + id: itemModel2 + objectName: "itemModel2" + Rectangle { + objectName: "item4" + height: 50; width: 100; color: "#FFFEF0" + Text { objectName: "text4"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item5" + height: 50; width: 100; color: "#F0FFF7" + Text { objectName: "text5"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + } + Column { objectName: "container" Repeater { id: view objectName: "repeater" - model: testObject.useModel ? itemModel : 0 + model: testObject.useModel ? root.itemModel : 0 } } } diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 7299a43..623b3d7 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -361,6 +361,15 @@ void tst_QDeclarativeRepeater::itemModel() QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3"); QVERIFY(container->childItems().at(3) == repeater); + QMetaObject::invokeMethod(canvas->rootObject(), "switchModel"); + QCOMPARE(container->childItems().count(), 3); + QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4"); + QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5"); + QVERIFY(container->childItems().at(2) == repeater); + + testObject->setUseModel(false); + QCOMPARE(container->childItems().count(), 1); + delete testObject; delete canvas; } diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml new file mode 100644 index 0000000..e6b6020 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml @@ -0,0 +1,37 @@ +import Qt 4.7 +Rectangle { + id: container + color: "red" + height: 200 + width: 200 + Column { + id: column + objectName: "column" + anchors.left: container.right + anchors.bottom: container.bottom + + Rectangle { + id: rectangle + color: "blue" + height: 100 + width: 200 + } + Rectangle { + color: "blue" + height: 100 + width: 200 + } + } + states: State { + name: "reanchored" + AnchorChanges { + target: column + anchors.left: undefined + anchors.right: container.right + } + PropertyChanges { + target: rectangle + opacity: 0 + } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml index 807eec9..8f9a7f2 100644 --- a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml +++ b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml @@ -5,6 +5,6 @@ Rectangle { color: "red" states: State { name: "blue" - PropertyChanges { target: myRectangle; colr: "blue"; wantsFocus: true } + PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true } } } diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 639b2f3..3b6a420 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -121,6 +121,7 @@ private slots: void anchorChanges4(); void anchorChanges5(); void anchorChangesCrash(); + void anchorRewindBug(); void script(); void restoreEntryValues(); void explicitChanges(); @@ -807,6 +808,40 @@ void tst_qdeclarativestates::anchorChangesCrash() delete rect; } +// QTBUG-12273 +void tst_qdeclarativestates::anchorRewindBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItem * column = rect->findChild<QDeclarativeItem*>("column"); + + QVERIFY(column != 0); + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 100.0); + + QDeclarativeItemPrivate::get(rect)->setState(""); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + + delete rect; +} + void tst_qdeclarativestates::script() { QDeclarativeEngine engine; @@ -887,7 +922,7 @@ void tst_qdeclarativestates::propertyErrors() QCOMPARE(rect->color(),QColor("red")); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\""); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); QDeclarativeItemPrivate::get(rect)->setState("blue"); } diff --git a/tests/auto/declarative/qdeclarativetext/data/rotated.qml b/tests/auto/declarative/qdeclarativetext/data/rotated.qml new file mode 100644 index 0000000..01eec44 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/rotated.qml @@ -0,0 +1,18 @@ +import Qt 4.7 + +Rectangle { + width : 200 + height : 100 + + Text { + objectName: "text" + x: 20 + y: 20 + height : 20 + width : 80 + text : "Something" + rotation : 30 + transformOrigin : Item.TopLeft + } +} + diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 80198eb..658f381 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -97,6 +97,8 @@ private slots: void clickLink(); + void QTBUG_12291(); + private: QStringList standard; QStringList richText; @@ -246,6 +248,7 @@ void tst_qdeclarativetext::width() QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); QVERIFY(textObject != 0); + QVERIFY(textObject->boundingRect().width() > 0); QCOMPARE(textObject->width(), qreal(metricWidth)); QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format } @@ -847,22 +850,22 @@ void tst_qdeclarativetext::letterSpacing() QCOMPARE(textObject->font().letterSpacing(), 0.0); } { - QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: -50 }"; + QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: -2 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), -50.); + QCOMPARE(textObject->font().letterSpacing(), -2.); } { - QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: 200 }"; + QString componentStr = "import Qt 4.7\nText { text: \"Hello world!\"; font.letterSpacing: 3 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create()); QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), 200.); + QCOMPARE(textObject->font().letterSpacing(), 3.); } } @@ -897,6 +900,23 @@ void tst_qdeclarativetext::wordSpacing() } } +void tst_qdeclarativetext::QTBUG_12291() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/rotated.qml"); + + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QObject *ob = canvas->rootObject(); + QVERIFY(ob != 0); + + QDeclarativeText *text = ob->findChild<QDeclarativeText*>("text"); + QVERIFY(text); + QVERIFY(text->boundingRect().isValid()); +} + class EventSender : public QGraphicsItem { public: diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 4783bc7..57a5e29 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -115,6 +115,7 @@ private slots: void navigation(); void readOnly(); void copyAndPaste(); + void textInput(); void openInputPanelOnClick(); void openInputPanelOnFocus(); void geometrySignals(); @@ -604,7 +605,7 @@ void tst_qdeclarativetextedit::persistentSelection() void tst_qdeclarativetextedit::focusOnPress() { { - QString componentStr = "import Qt 4.7\nTextEdit { focusOnPress: true; text: \"Hello World\" }"; + QString componentStr = "import Qt 4.7\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); @@ -613,7 +614,7 @@ void tst_qdeclarativetextedit::focusOnPress() } { - QString componentStr = "import Qt 4.7\nTextEdit { focusOnPress: false; text: \"Hello World\" }"; + QString componentStr = "import Qt 4.7\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); @@ -840,15 +841,15 @@ void tst_qdeclarativetextedit::navigation() QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); } void tst_qdeclarativetextedit::copyAndPaste() { @@ -882,6 +883,12 @@ void tst_qdeclarativetextedit::copyAndPaste() { QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); QCOMPARE(textEdit->text().length(), 24); + // QTBUG-12339 + // test that document and internal text attribute are in sync + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(textEdit); + QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri); + QCOMPARE(textEdit->text(), editPrivate->text); + // select word textEdit->setCursorPosition(0); textEdit->selectWord(); @@ -908,7 +915,7 @@ void tst_qdeclarativetextedit::readOnly() QDeclarativeTextEdit *edit = qobject_cast<QDeclarativeTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(edit != 0); - QTRY_VERIFY(edit->hasFocus() == true); + QTRY_VERIFY(edit->hasActiveFocus() == true); QVERIFY(edit->isReadOnly() == true); QString initial = edit->text(); for(int k=Qt::Key_0; k<=Qt::Key_Z; k++) @@ -961,6 +968,33 @@ public: bool closeInputPanelReceived; }; +void tst_qdeclarativetextedit::textInput() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QDeclarativeTextEdit edit; + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); + QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri); + edit.setPos(0, 0); + scene.addItem(&edit); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + edit.setFocus(true); + QVERIFY(edit.hasActiveFocus() == true); + + // test that input method event is committed + QInputMethodEvent event; + event.setCommitString( "Hello world!", 0, 0); + QApplication::sendEvent(&view, &event); + QCOMPARE(edit.text(), QString("Hello world!")); + + // QTBUG-12339 + // test that document and internal text attribute are in sync + QCOMPARE(editPrivate->text, QString("Hello world!")); +} + void tst_qdeclarativetextedit::openInputPanelOnClick() { QGraphicsScene scene; @@ -968,7 +1002,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextEdit edit; - QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); scene.addItem(&edit); @@ -1016,7 +1050,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextEdit edit; - QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); scene.addItem(&edit); @@ -1038,7 +1072,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() // focus on press, input panel on focus QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); - QVERIFY(edit.hasFocus()); + QVERIFY(edit.hasActiveFocus()); QCOMPARE(ic.openInputPanelReceived, true); ic.openInputPanelReceived = false; @@ -1048,7 +1082,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() ic.openInputPanelReceived = false; // if already focused, input panel can be opened on press - QVERIFY(edit.hasFocus()); + QVERIFY(edit.hasActiveFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); @@ -1076,7 +1110,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); // no automatic input panel events should - // be sent if focusOnPress is false + // be sent if activeFocusOnPress is false edit.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); edit.setFocusOnPress(false); @@ -1103,7 +1137,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; - // set focusOnPress back to true + // set activeFocusOnPress back to true edit.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); edit.setFocusOnPress(true); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index a48bc39..6e15a4a 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -494,7 +494,7 @@ void tst_qdeclarativetextinput::maxLength() } textinputObject->setText(""); - QTRY_VERIFY(textinputObject->hasFocus() == true); + QTRY_VERIFY(textinputObject->hasActiveFocus() == true); for(int i=0; i<20; i++){ QCOMPARE(textinputObject->text().length(), qMin(i,10)); //simulateKey(canvas, Qt::Key_A); @@ -515,7 +515,7 @@ void tst_qdeclarativetextinput::masks() QVERIFY(canvas->rootObject() != 0); QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); QVERIFY(textinputObject != 0); - QTRY_VERIFY(textinputObject->hasFocus() == true); + QTRY_VERIFY(textinputObject->hasActiveFocus() == true); QVERIFY(textinputObject->text().length() == 0); QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; ")); for(int i=0; i<10; i++){ @@ -544,7 +544,7 @@ void tst_qdeclarativetextinput::validators() QDeclarativeTextInput *intInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput"))); QVERIFY(intInput); intInput->setFocus(true); - QTRY_VERIFY(intInput->hasFocus()); + QTRY_VERIFY(intInput->hasActiveFocus()); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); QCOMPARE(intInput->text(), QLatin1String("1")); @@ -565,7 +565,7 @@ void tst_qdeclarativetextinput::validators() QDeclarativeTextInput *dblInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput"))); QTRY_VERIFY(dblInput); dblInput->setFocus(true); - QVERIFY(dblInput->hasFocus() == true); + QVERIFY(dblInput->hasActiveFocus() == true); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); QCOMPARE(dblInput->text(), QLatin1String("1")); @@ -594,7 +594,7 @@ void tst_qdeclarativetextinput::validators() QDeclarativeTextInput *strInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput"))); QTRY_VERIFY(strInput); strInput->setFocus(true); - QVERIFY(strInput->hasFocus() == true); + QVERIFY(strInput->hasActiveFocus() == true); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); QCOMPARE(strInput->text(), QLatin1String("")); @@ -642,7 +642,7 @@ void tst_qdeclarativetextinput::inputMethods() QVERIFY(canvas->rootObject() != 0); input->setFocus(true); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); // test that input method event is committed QInputMethodEvent event; event.setCommitString( "My ", -12, 0); @@ -669,11 +669,11 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(input != 0); input->setCursorPosition(0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); //QT-2944: If text is selected, ensure we deselect upon cursor motion input->setCursorPosition(input->text().length()); input->select(0,input->text().length()); @@ -681,11 +681,11 @@ void tst_qdeclarativetextinput::navigation() simulateKey(canvas, Qt::Key_Right); QVERIFY(input->selectionStart() == input->selectionEnd()); QVERIFY(input->selectionStart() == input->text().length()); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). input->setCursorPosition(2); @@ -784,7 +784,7 @@ void tst_qdeclarativetextinput::readOnly() QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); QVERIFY(input->isReadOnly() == true); QString initial = input->text(); for(int k=Qt::Key_0; k<=Qt::Key_Z; k++) @@ -802,13 +802,16 @@ void tst_qdeclarativetextinput::echoMode() QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml"); canvas->show(); canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); QVERIFY(canvas->rootObject() != 0); QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); QString initial = input->text(); Qt::InputMethodHints ref; QCOMPARE(initial, QLatin1String("ABCDefgh")); @@ -849,6 +852,7 @@ void tst_qdeclarativetextinput::echoMode() QCOMPARE(input->text(), QLatin1String("a")); QCOMPARE(input->displayText(), QLatin1String("a")); input->setFocus(false); + QVERIFY(input->hasActiveFocus() == false); QCOMPARE(input->displayText(), QLatin1String("Q")); } @@ -901,7 +905,7 @@ void tst_qdeclarativetextinput::openInputPanelOnClick() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextInput input; - QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); scene.addItem(&input); @@ -948,7 +952,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextInput input; - QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); scene.addItem(&input); @@ -970,7 +974,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() // focus on press, input panel on focus QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); - QVERIFY(input.hasFocus()); + QVERIFY(input.hasActiveFocus()); QCOMPARE(ic.openInputPanelReceived, true); ic.openInputPanelReceived = false; @@ -980,7 +984,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() ic.openInputPanelReceived = false; // if already focused, input panel can be opened on press - QVERIFY(input.hasFocus()); + QVERIFY(input.hasActiveFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); @@ -1008,7 +1012,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); // no automatic input panel events should - // be sent if focusOnPress is false + // be sent if activeFocusOnPress is false input.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); input.setFocusOnPress(false); @@ -1035,7 +1039,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; - // set focusOnPress back to true + // set activeFocusOnPress back to true input.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); input.setFocusOnPress(true); diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index b08da0f..de8d222 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -152,16 +152,16 @@ void tst_QDeclarativeViewer::loading() TEST_INITIAL_SIZES(viewer); - viewer->resize(QSize(400, 500)); + viewer->resize(QSize(250, 350)); qApp->processEvents(); // window resized - QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); - QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); + QTRY_COMPARE(rootItem->width(), 250.0); + QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(400, 500)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); + QCOMPARE(viewer->size(), QSize(250, 350)); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->reload(); @@ -177,16 +177,16 @@ void tst_QDeclarativeViewer::loading() QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->size(), viewer->sizeHint()); - viewer->resize(QSize(400, 500)); + viewer->resize(QSize(250, 350)); qApp->processEvents(); // window resized again - QTRY_COMPARE(rootItem->width(), 400.0); - QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer)); - QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer))); + QTRY_COMPARE(rootItem->width(), 250.0); + QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); + QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(400, 500)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); + QCOMPARE(viewer->size(), QSize(250, 350)); QCOMPARE(viewer->size(), viewer->sizeHint()); viewer->open(SRCDIR "/data/orientation.qml"); diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml index f5198c9..d030222 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml @@ -11,6 +11,9 @@ ListView { width: 100 color: model.modelData.color Text { objectName: "name"; text: name } + Text { objectName: "section"; text: parent.ListView.section } } } + section.property: "name" + section.criteria: ViewSection.FullString } diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 43d4d06..e0f32ea 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -179,6 +179,9 @@ void tst_qdeclarativevisualdatamodel::objectListModel() QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 0); QCOMPARE(name->text(), QString("Item 1")); + QDeclarativeText *section = findItem<QDeclarativeText>(contentItem, "section", 0); + QCOMPARE(section->text(), QString("Item 1")); + dataList[0]->setProperty("name", QLatin1String("Changed")); QCOMPARE(name->text(), QString("Changed")); } diff --git a/tests/auto/declarative/qmlvisual/focusscope/test.qml b/tests/auto/declarative/qmlvisual/focusscope/test.qml index d83bad4..24b4b99 100644 --- a/tests/auto/declarative/qmlvisual/focusscope/test.qml +++ b/tests/auto/declarative/qmlvisual/focusscope/test.qml @@ -19,14 +19,14 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1 x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Top Left"); KeyNavigation.right: item2 focus: true @@ -42,7 +42,7 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Top Right"); @@ -62,7 +62,7 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: myScope diff --git a/tests/auto/declarative/qmlvisual/focusscope/test2.qml b/tests/auto/declarative/qmlvisual/focusscope/test2.qml index 7a6ed83..19c8bed 100644 --- a/tests/auto/declarative/qmlvisual/focusscope/test2.qml +++ b/tests/auto/declarative/qmlvisual/focusscope/test2.qml @@ -10,27 +10,27 @@ Rectangle { FocusScope { y: 100 focus: true - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } } } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml index 73dd4d7..e268a60 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml @@ -34,10 +34,10 @@ Rectangle { text: s.text; font.underline: true; font.overline: true; font.strikeout: true } Text { - text: s.text; font.letterSpacing: 200 + text: s.text; font.letterSpacing: 2 } Text { - text: s.text; font.underline: true; font.letterSpacing: 200; font.capitalization: "AllUppercase"; color: "blue" + text: s.text; font.underline: true; font.letterSpacing: 2; font.capitalization: "AllUppercase"; color: "blue" } Text { text: s.text; font.overline: true; font.wordSpacing: 25; font.capitalization: "Capitalize"; color: "green" diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml index b41b93a..a883b9c 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml @@ -34,10 +34,10 @@ Rectangle { text: s.text; font.underline: true; font.overline: true; font.strikeout: true } Text { - text: s.text; font.letterSpacing: 200 + text: s.text; font.letterSpacing: 2 } Text { - text: s.text; font.underline: true; font.letterSpacing: 200; font.capitalization: "AllUppercase"; color: "blue" + text: s.text; font.underline: true; font.letterSpacing: 2; font.capitalization: "AllUppercase"; color: "blue" } Text { text: s.text; font.overline: true; font.wordSpacing: 25; font.capitalization: "Capitalize"; color: "green" |