diff options
Diffstat (limited to 'tests/auto')
86 files changed, 2048 insertions, 356 deletions
diff --git a/tests/auto/compiler/tst_compiler.cpp b/tests/auto/compiler/tst_compiler.cpp index 368620d..90eb357 100644 --- a/tests/auto/compiler/tst_compiler.cpp +++ b/tests/auto/compiler/tst_compiler.cpp @@ -640,7 +640,7 @@ static inline double qt_inf() #endif union { uchar c[8]; double d; } returnValue; - qMemCopy(returnValue.c, bytes, sizeof(returnValue.c)); + memcpy(returnValue.c, bytes, sizeof(returnValue.c)); return returnValue.d; } 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" diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index 0fc99f3..c94272c 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -113,6 +113,7 @@ SUBDIRS=\ qmdisubwindow \ qmessagebox \ qmetaobject \ + qmimedata \ qmouseevent_modal \ qmovie \ qnetworkaccessmanager_and_qprogressdialog \ diff --git a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp index 048ea35..4b3ce18 100644 --- a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp +++ b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp @@ -128,10 +128,10 @@ const struct Example examples[] = { {"mainwindows/menus Example", "mainwindows/menus", "menus", 10, -1}, {"mainwindows/recentfiles Example", "mainwindows/recentfiles", "recentfiles", 10, -1}, {"mainwindows/sdi Example", "mainwindows/sdi", "sdi", 10, -1}, - {"multitouch/dials Example", "multitouch/dials", "dials", 10, -1}, - {"multitouch/fingerpaint Example", "multitouch/fingerpaint", "fingerpaint", 10, -1}, - {"multitouch/knobs Example", "multitouch/knobs", "knobs", 10, -1}, - {"multitouch/pinchzoom Example", "multitouch/pinchzoom", "pinchzoom", 10, -1}, + {"touch/dials Example", "touch/dials", "dials", 10, -1}, + {"touch/fingerpaint Example", "touch/fingerpaint", "fingerpaint", 10, -1}, + {"touch/knobs Example", "touch/knobs", "knobs", 10, -1}, + {"touch/pinchzoom Example", "touch/pinchzoom", "pinchzoom", 10, -1}, {"opengl/2dpainting Example", "opengl/2dpainting", "2dpainting", 10, -1}, {"opengl/grabber Example", "opengl/grabber", "grabber", 10, -1}, {"opengl/hellogl Example", "opengl/hellogl", "hellogl", 10, -1}, diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 0765bfc..f58f932 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -275,3 +275,30 @@ void bogosity() // no spaces here. test collateral damage from ignoring equal sign Class::member=QObject::tr("just QObject"); } + + + +namespace Internal { + +class Message : public QObject +{ + Q_OBJECT +public: + Message(QObject *parent = 0); +}; + +} // The temporary closing of the namespace triggers the problem + +namespace Internal { + +static inline QString message1() +{ + return Message::tr("message1"); // Had no namespace +} + +static inline QString message2() +{ + return Message::tr("message2"); // Already had namespace +} + +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 208191d..7ac318e 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -120,6 +120,19 @@ backslashed \ stuff.</source> </message> </context> <context> + <name>Internal::Message</name> + <message> + <location filename="main.cpp" line="296"/> + <source>message1</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="301"/> + <source>message2</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>KÃ¥ntekst</name> <message utf8="true"> <location filename="finddialog.cpp" line="180"/> diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 994057b..2f98521 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -204,9 +204,8 @@ void tst_MediaObject::testPlayFromResource() #ifdef Q_OS_SYMBIAN QSKIP("Not implemented yet.", SkipAll); #else - QFile file(MEDIA_FILEPATH); MediaObject media; - media.setCurrentSource(&file); + media.setCurrentSource(QString(MEDIA_FILEPATH)); QVERIFY(media.state() != Phonon::ErrorState); if (media.state() != Phonon::StoppedState) QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 19f3677..d3a7e03 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -491,6 +491,7 @@ private slots: void typenameWithUnsigned(); void warnOnVirtualSignal(); void QTBUG5590_dummyProperty(); + void QTBUG12260_defaultTemplate(); signals: void sigWithUnsignedArg(unsigned foo); void sigWithSignedArg(signed foo); @@ -1340,6 +1341,27 @@ signals: void testSignal(TestTemplate2<const int, const short*>); }; +class QTBUG12260_defaultTemplate_Object : public QObject +{ Q_OBJECT +public slots: +#if !(defined(Q_CC_GNU) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) || defined(Q_MOC_RUN) + void doSomething(QHash<QString, QVariant> values = QHash<QString, QVariant>() ) { Q_UNUSED(values); } +#else + // we want to test the previous function, but gcc < 4.4 seemed to have a bug similar to the one moc has. + typedef QHash<QString, QVariant> WorkaroundGCCBug; + void doSomething(QHash<QString, QVariant> values = WorkaroundGCCBug() ) { Q_UNUSED(values); } +#endif + + void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); } +}; + + +void tst_Moc::QTBUG12260_defaultTemplate() +{ + QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomething(QHash<QString,QVariant>)") != -1); + QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1); +} + QTEST_APPLESS_MAIN(tst_Moc) #include "tst_moc.moc" diff --git a/tests/auto/network.pro b/tests/auto/network.pro index 4f205fe..31c754c 100644 --- a/tests/auto/network.pro +++ b/tests/auto/network.pro @@ -7,6 +7,7 @@ SUBDIRS=\ networkselftest \ qabstractnetworkcache \ qabstractsocket \ + qauthenticator \ qeventloop \ qftp \ qhostaddress \ @@ -35,7 +36,8 @@ SUBDIRS=\ qsslkey \ qsslsocket \ -contains(QT_CONFIG, private_tests): SUBDIRS -= \ +!contains(QT_CONFIG, private_tests): SUBDIRS -= \ + qauthenticator \ qhttpnetworkconnection \ qhttpnetworkreply \ qnativesocketengine \ diff --git a/tests/auto/qauthenticator/qauthenticator.pro b/tests/auto/qauthenticator/qauthenticator.pro new file mode 100644 index 0000000..05f83bc --- /dev/null +++ b/tests/auto/qauthenticator/qauthenticator.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +requires(contains(QT_CONFIG,private_tests)) +QT = core network +SOURCES += tst_qauthenticator.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/qauthenticator/tst_qauthenticator.cpp b/tests/auto/qauthenticator/tst_qauthenticator.cpp new file mode 100644 index 0000000..37d6774 --- /dev/null +++ b/tests/auto/qauthenticator/tst_qauthenticator.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtCore/QString> +#include <QtTest/QtTest> +#include <QtCore/QCoreApplication> +#include <QtNetwork/QAuthenticator> + +#include <private/qauthenticator_p.h> + +class tst_QAuthenticator : public QObject +{ + Q_OBJECT + +public: + tst_QAuthenticator(); + +private Q_SLOTS: + void basicAuth(); + void basicAuth_data(); + + void ntlmAuth_data(); + void ntlmAuth(); +}; + +tst_QAuthenticator::tst_QAuthenticator() +{ +} + +void tst_QAuthenticator::basicAuth_data() +{ + QTest::addColumn<QString>("data"); + QTest::addColumn<QString>("realm"); + QTest::addColumn<QString>("user"); + QTest::addColumn<QString>("password"); + QTest::addColumn<QByteArray>("expectedReply"); + + QTest::newRow("just-user") << "" << "" << "foo" << "" << QByteArray("foo:").toBase64(); + QTest::newRow("user-password") << "" << "" << "foo" << "bar" << QByteArray("foo:bar").toBase64(); + QTest::newRow("user-password-realm") << "realm=\"secure area\"" << "secure area" << "foo" << "bar" << QByteArray("foo:bar").toBase64(); +} + +void tst_QAuthenticator::basicAuth() +{ + QFETCH(QString, data); + QFETCH(QString, realm); + QFETCH(QString, user); + QFETCH(QString, password); + QFETCH(QByteArray, expectedReply); + + QAuthenticator auth; + auth.detach(); + QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth); + QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + + QList<QPair<QByteArray, QByteArray> > headers; + headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); + priv->parseHttpResponse(headers, /*isProxy = */ false); + + QCOMPARE(auth.realm(), realm); + QCOMPARE(auth.option("realm").toString(), realm); + + auth.setUser(user); + auth.setPassword(password); + + QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + + QCOMPARE(priv->calculateResponse("GET", "/").constData(), ("Basic " + expectedReply).constData()); +} + +void tst_QAuthenticator::ntlmAuth_data() +{ + QTest::addColumn<QString>("data"); + QTest::addColumn<QString>("realm"); + + QTest::newRow("no-realm") << "TlRMTVNTUAACAAAAHAAcADAAAAAFAoEATFZ3OLRQADIAAAAAAAAAAJYAlgBMAAAAUQBUAC0AVABFAFMAVAAtAEQATwBNAEEASQBOAAIAHABRAFQALQBUAEUAUwBUAC0ARABPAE0AQQBJAE4AAQAcAFEAVAAtAFQARQBTAFQALQBTAEUAUgBWAEUAUgAEABYAcQB0AC0AdABlAHMAdAAtAG4AZQB0AAMANABxAHQALQB0AGUAcwB0AC0AcwBlAHIAdgBlAHIALgBxAHQALQB0AGUAcwB0AC0AbgBlAHQAAAAAAA==" << ""; + QTest::newRow("with-realm") << "TlRMTVNTUAACAAAADAAMADgAAAAFAoECWCZkccFFAzwAAAAAAAAAAL4AvgBEAAAABQLODgAAAA9NAEcARABOAE8ASwACAAwATQBHAEQATgBPAEsAAQAcAE4ATwBLAC0AQQBNAFMAUwBTAEYARQAtADAAMQAEACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQADAD4AbgBvAGsALQBhAG0AcwBzAHMAZgBlAC0AMAAxAC4AbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAFACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAAAAAA" << "NOE"; +} + +void tst_QAuthenticator::ntlmAuth() +{ + QFETCH(QString, data); + QFETCH(QString, realm); + + QAuthenticator auth; + auth.detach(); + QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth); + QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + + QList<QPair<QByteArray, QByteArray> > headers; + + // NTLM phase 1: negotiate + // This phase of NTLM contains no information, other than what we're willing to negotiate + // Current implementation uses flags: + // NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET + headers << qMakePair<QByteArray, QByteArray>("WWW-Authenticate", "NTLM"); + priv->parseHttpResponse(headers, /*isProxy = */ false); + QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABQIAAAAAAAAAAAAAAAAAAAAAAAA="); + + // NTLM phase 2: challenge + headers.clear(); + headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8()); + priv->parseHttpResponse(headers, /*isProxy = */ false); + + QEXPECT_FAIL("with-realm", "NTLM authentication code doesn't extract the realm", Continue); + QCOMPARE(auth.realm(), realm); + + auth.setUser("unimportant"); + auth.setPassword("unimportant"); + + QVERIFY(!priv->calculateResponse("GET", "/").isEmpty()); +} + +QTEST_MAIN(tst_QAuthenticator); + +#include "tst_qauthenticator.moc" diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 0900b35..1a82a4c 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -961,14 +961,26 @@ void tst_QDateTime::currentDateTime() upperBound.setTime_t(buf2); upperBound = upperBound.addSecs(1); - QVERIFY(lowerBound < upperBound); - - QVERIFY(lowerBound <= dt1); - QVERIFY(dt1 < upperBound); - QVERIFY(lowerBound <= dt2); - QVERIFY(dt2 < upperBound); - QVERIFY(lowerBound <= dt3); - QVERIFY(dt3 < upperBound); + QString details = QString("\n" + "lowerBound: %1\n" + "dt1: %2\n" + "dt2: %3\n" + "dt3: %4\n" + "upperBound: %5\n") + .arg(lowerBound.toTime_t()) + .arg(dt1.toTime_t()) + .arg(dt2.toTime_t()) + .arg(dt3.toTime_t()) + .arg(upperBound.toTime_t()); + + QVERIFY2(lowerBound < upperBound, qPrintable(details)); + + QVERIFY2(lowerBound <= dt1, qPrintable(details)); + QVERIFY2(dt1 < upperBound, qPrintable(details)); + QVERIFY2(lowerBound <= dt2, qPrintable(details)); + QVERIFY2(dt2 < upperBound, qPrintable(details)); + QVERIFY2(lowerBound <= dt3, qPrintable(details)); + QVERIFY2(dt3 < upperBound, qPrintable(details)); QVERIFY(dt1.timeSpec() == Qt::LocalTime); QVERIFY(dt2.timeSpec() == Qt::LocalTime); @@ -1000,14 +1012,26 @@ void tst_QDateTime::currentDateTimeUtc() upperBound.setTime_t(buf2); upperBound = upperBound.addSecs(1); - QVERIFY(lowerBound < upperBound); - - QVERIFY(lowerBound <= dt1); - QVERIFY(dt1 < upperBound); - QVERIFY(lowerBound <= dt2); - QVERIFY(dt2 < upperBound); - QVERIFY(lowerBound <= dt3); - QVERIFY(dt3 < upperBound); + QString details = QString("\n" + "lowerBound: %1\n" + "dt1: %2\n" + "dt2: %3\n" + "dt3: %4\n" + "upperBound: %5\n") + .arg(lowerBound.toTime_t()) + .arg(dt1.toTime_t()) + .arg(dt2.toTime_t()) + .arg(dt3.toTime_t()) + .arg(upperBound.toTime_t()); + + QVERIFY2(lowerBound < upperBound, qPrintable(details)); + + QVERIFY2(lowerBound <= dt1, qPrintable(details)); + QVERIFY2(dt1 < upperBound, qPrintable(details)); + QVERIFY2(lowerBound <= dt2, qPrintable(details)); + QVERIFY2(dt2 < upperBound, qPrintable(details)); + QVERIFY2(lowerBound <= dt3, qPrintable(details)); + QVERIFY2(dt3 < upperBound, qPrintable(details)); QVERIFY(dt1.timeSpec() == Qt::UTC); QVERIFY(dt2.timeSpec() == Qt::LocalTime); diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index d8ff2d3..a870e47 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -70,18 +70,34 @@ class MyObject: public QObject " <arg direction=\"in\" type=\"v\" name=\"ping\" />\n" " <arg direction=\"out\" type=\"v\" name=\"ping\" />\n" " </method>\n" +" <method name=\"ping_invokable\" >\n" +" <arg direction=\"in\" type=\"v\" name=\"ping_invokable\" />\n" +" <arg direction=\"out\" type=\"v\" name=\"ping_invokable\" />\n" +" </method>\n" " <method name=\"ping\" >\n" " <arg direction=\"in\" type=\"v\" name=\"ping1\" />\n" " <arg direction=\"in\" type=\"v\" name=\"ping2\" />\n" " <arg direction=\"out\" type=\"v\" name=\"pong1\" />\n" " <arg direction=\"out\" type=\"v\" name=\"pong2\" />\n" " </method>\n" +" <method name=\"ping_invokable\" >\n" +" <arg direction=\"in\" type=\"v\" name=\"ping1_invokable\" />\n" +" <arg direction=\"in\" type=\"v\" name=\"ping2_invokable\" />\n" +" <arg direction=\"out\" type=\"v\" name=\"pong1_invokable\" />\n" +" <arg direction=\"out\" type=\"v\" name=\"pong2_invokable\" />\n" +" </method>\n" " <method name=\"ping\" >\n" " <arg direction=\"in\" type=\"ai\" name=\"ping\" />\n" " <arg direction=\"out\" type=\"ai\" name=\"ping\" />\n" " <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList<int>\"/>\n" " <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList<int>\"/>\n" " </method>\n" +" <method name=\"ping_invokable\" >\n" +" <arg direction=\"in\" type=\"ai\" name=\"ping_invokable\" />\n" +" <arg direction=\"out\" type=\"ai\" name=\"ping_invokable\" />\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList<int>\"/>\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList<int>\"/>\n" +" </method>\n" " </interface>\n" "") Q_PROPERTY(int prop1 READ prop1 WRITE setProp1) @@ -120,6 +136,20 @@ public: m_complexProp = value; } + Q_INVOKABLE void ping_invokable(QDBusMessage msg) + { + QDBusConnection sender = QDBusConnection::sender(); + if (!sender.isConnected()) + exit(1); + + ++callCount; + callArgs = msg.arguments(); + + msg.setDelayedReply(true); + if (!sender.send(msg.createReply(callArgs))) + exit(1); + } + public slots: void ping(QDBusMessage msg) @@ -220,6 +250,7 @@ void tst_QDBusInterface::initTestCase() con.registerObject("/", &obj, QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSlots + | QDBusConnection::ExportAllInvokables | QDBusConnection::ExportChildObjects); } @@ -283,7 +314,7 @@ void tst_QDBusInterface::introspect() const QMetaObject *mo = iface.metaObject(); - QCOMPARE(mo->methodCount() - mo->methodOffset(), 4); + QCOMPARE(mo->methodCount() - mo->methodOffset(), 7); QVERIFY(mo->indexOfSignal(TEST_SIGNAL_NAME "(QString)") != -1); QCOMPARE(mo->propertyCount() - mo->propertyOffset(), 2); @@ -298,6 +329,8 @@ void tst_QDBusInterface::callMethod() TEST_INTERFACE_NAME); MyObject::callCount = 0; + + // call a SLOT method QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo"))); QCOMPARE(MyObject::callCount, 1); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -315,6 +348,25 @@ void tst_QDBusInterface::callMethod() dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().type(), QVariant::String); QCOMPARE(dv.variant().toString(), QString("foo")); + + // call an INVOKABLE method + reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar"))); + QCOMPARE(MyObject::callCount, 2); + QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), QString("bar")); + + // verify reply + QCOMPARE(reply.arguments().count(), 1); + v = reply.arguments().at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), QString("bar")); } void tst_QDBusInterface::invokeMethod() @@ -323,8 +375,9 @@ void tst_QDBusInterface::invokeMethod() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; + + // make the SLOT call without a return type QDBusVariant arg("foo"); QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_ARG(QDBusVariant, arg))); QCOMPARE(MyObject::callCount, 1); @@ -335,6 +388,18 @@ void tst_QDBusInterface::invokeMethod() QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().type(), QVariant::String); QCOMPARE(dv.variant().toString(), QString("foo")); + + // make the INVOKABLE call without a return type + QDBusVariant arg2("bar"); + QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_ARG(QDBusVariant, arg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), QString("bar")); } void tst_QDBusInterface::invokeMethodWithReturn() @@ -343,10 +408,11 @@ void tst_QDBusInterface::invokeMethodWithReturn() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; - QDBusVariant arg("foo"); QDBusVariant retArg; + + // make the SLOT call without a return type + QDBusVariant arg("foo"); QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg))); QCOMPARE(MyObject::callCount, 1); @@ -359,6 +425,21 @@ void tst_QDBusInterface::invokeMethodWithReturn() // verify that we got the reply as expected QCOMPARE(retArg.variant(), arg.variant()); + + // make the INVOKABLE call without a return type + QDBusVariant arg2("bar"); + QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg2.variant().toString()); + + // verify that we got the reply as expected + QCOMPARE(retArg.variant(), arg2.variant()); } void tst_QDBusInterface::invokeMethodWithMultiReturn() @@ -367,10 +448,11 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; - QDBusVariant arg("foo"), arg2("bar"); QDBusVariant retArg, retArg2; + + // make the SLOT call without a return type + QDBusVariant arg("foo"), arg2("bar"); QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg), @@ -393,6 +475,31 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn() // verify that we got the replies as expected QCOMPARE(retArg.variant(), arg.variant()); QCOMPARE(retArg2.variant(), arg2.variant()); + + // make the INVOKABLE call without a return type + QDBusVariant arg3("hello"), arg4("world"); + QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", + Q_RETURN_ARG(QDBusVariant, retArg), + Q_ARG(QDBusVariant, arg3), + Q_ARG(QDBusVariant, arg4), + Q_ARG(QDBusVariant&, retArg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 2); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg3.variant().toString()); + + v = MyObject::callArgs.at(1); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg4.variant().toString()); + + // verify that we got the replies as expected + QCOMPARE(retArg.variant(), arg3.variant()); + QCOMPARE(retArg2.variant(), arg4.variant()); } void tst_QDBusInterface::invokeMethodWithComplexReturn() @@ -401,10 +508,11 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; - QList<int> arg = QList<int>() << 42 << -47; QList<int> retArg; + + // make the SLOT call without a return type + QList<int> arg = QList<int>() << 42 << -47; QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg))); QCOMPARE(MyObject::callCount, 1); @@ -416,6 +524,20 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn() // verify that we got the reply as expected QCOMPARE(retArg, arg); + + // make the INVOKABLE call without a return type + QList<int> arg2 = QList<int>() << 24 << -74; + QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); + QCOMPARE(qdbus_cast<QList<int> >(v), arg2); + + // verify that we got the reply as expected + QCOMPARE(retArg, arg2); } void tst_QDBusInterface::signal() diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 9a96130..ed4ecb4 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -140,6 +140,7 @@ private slots: void QTBUG4419_lineEditSelectAll(); void QTBUG6558_showDirsOnly(); void QTBUG4842_selectFilterWithHideNameFilterDetails(); + void dontShowCompleterOnRoot(); private: QByteArray userSettings; @@ -1194,5 +1195,26 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() } +void tst_QFileDialog2::dontShowCompleterOnRoot() +{ + QNonNativeFileDialog fd(0, "TestFileDialog"); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.show(); + + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); + QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); + + fd.setDirectory(""); + QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QTRY_VERIFY(lineEdit->text().isEmpty()); + + //The gatherer thread will then return the result + QApplication::processEvents(); + + QTRY_VERIFY(lineEdit->completer()->popup()->isHidden()); +} + QTEST_MAIN(tst_QFileDialog2) #include "tst_qfiledialog2.moc" diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 4387553..a074f4b 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1120,7 +1120,7 @@ void tst_QFileInfo::isHidden_data() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QVERIFY(QDir("./hidden-directory").exists() || QDir().mkdir("./hidden-directory")); - QVERIFY(SetFileAttributesW((wchar_t*)QString("./hidden-directory").utf16(),FILE_ATTRIBUTE_HIDDEN)); + QVERIFY(SetFileAttributesW(reinterpret_cast<LPCWSTR>(QString("./hidden-directory").utf16()),FILE_ATTRIBUTE_HIDDEN)); QTest::newRow("C:/path/to/hidden-directory") << QDir::currentPath() + QString::fromLatin1("/hidden-directory") << true; QTest::newRow("C:/path/to/hidden-directory/.") << QDir::currentPath() + QString::fromLatin1("/hidden-directory/.") << true; #endif diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index d6a6e9c..085ca54 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -2246,5 +2246,30 @@ void tst_QGL::textureCleanup() #endif } -QTEST_MAIN(tst_QGL) +class tst_QGLDummy : public QObject +{ +Q_OBJECT + +public: + tst_QGLDummy() {} + +private slots: + void qglSkipTests() { + QSKIP("QGL not supported on this system.", SkipAll); + } +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QTEST_DISABLE_KEYPAD_NAVIGATION \ + QGLWidget glWidget; + if (!glWidget.isValid()) { + tst_QGLDummy tc; + return QTest::qExec(&tc, argc, argv); + } + tst_QGL tc; + return QTest::qExec(&tc, argc, argv); +} + #include "tst_qgl.moc" diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 49f110e..49a76fa 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -161,6 +161,7 @@ private slots: void draw(); void update(); void boundingRect(); + void clippedBoundingRect(); void deviceRect(); void pixmap(); @@ -282,6 +283,20 @@ void tst_QGraphicsEffectSource::boundingRect() QTRY_COMPARE(effect->source()->boundingRect(), itemBoundingRect); } +void tst_QGraphicsEffectSource::clippedBoundingRect() +{ + QRectF itemBoundingRect = item->boundingRect(); + item->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QGraphicsRectItem *child = new QGraphicsRectItem(-1000, -1000, 2000, 2000); + child->setBrush(Qt::red); + child->setParentItem(item); + + effect->storeDeviceDependentStuff = true; + effect->source()->update(); + QTRY_COMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); +} + void tst_QGraphicsEffectSource::deviceRect() { effect->storeDeviceDependentStuff = true; diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index b9a5c66..d1d6860 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -105,6 +105,7 @@ private slots: void geometries_data(); void geometries(); void avoidRecursionInInsertItem(); + void styleInfoLeak(); void task236367_maxSizeHint(); }; @@ -2196,6 +2197,12 @@ void tst_QGraphicsGridLayout::avoidRecursionInInsertItem() QCOMPARE(layout->count(), 0); } +void tst_QGraphicsGridLayout::styleInfoLeak() +{ + QGraphicsGridLayout grid; + grid.horizontalSpacing(); +} + void tst_QGraphicsGridLayout::task236367_maxSizeHint() { QGraphicsWidget *widget = new QGraphicsWidget; diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index c26e5d4..6107fa1 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -102,6 +102,7 @@ private slots: void layoutDirection(); void removeLayout(); void avoidRecursionInInsertItem(); + void styleInfoLeak(); // Task specific tests void task218400_insertStretchCrash(); @@ -1443,6 +1444,12 @@ void tst_QGraphicsLinearLayout::avoidRecursionInInsertItem() QCOMPARE(layout->count(), 0); } +void tst_QGraphicsLinearLayout::styleInfoLeak() +{ + QGraphicsLinearLayout layout; + layout.spacing(); +} + void tst_QGraphicsLinearLayout::task218400_insertStretchCrash() { QGraphicsScene *scene = new QGraphicsScene; diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index 6396e44..dba8a64 100644 --- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -224,7 +224,18 @@ void tst_QGraphicsSceneIndex::connectedToSceneRectChanged() { class MyScene : public QGraphicsScene - { public: using QGraphicsScene::receivers; }; + { + public: +#ifdef Q_CC_RVCT + //using keyword doesn't change visibility to public in RVCT2.2 compiler + inline int receivers(const char* signal) const + { + return QGraphicsScene::receivers(signal); + } +#else + using QGraphicsScene::receivers; +#endif + }; MyScene scene; // Uses QGraphicsSceneBspTreeIndex by default. QCOMPARE(scene.receivers(SIGNAL(sceneRectChanged(const QRectF&))), 1); diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index b8df7f6..1cce687 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -219,6 +219,7 @@ private slots: void update2_data(); void update2(); void update_ancestorClipsChildrenToShape(); + void update_ancestorClipsChildrenToShape2(); void inputMethodSensitivity(); void inputContextReset(); void indirectPainting(); @@ -3815,6 +3816,78 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape() #endif } +void tst_QGraphicsView::update_ancestorClipsChildrenToShape2() +{ + QGraphicsScene scene(-150, -150, 300, 300); + + /* + Add two rects: + + +------------------+ + | child | + | +--------------+ | + | | parent | | + | | | | + | | | | + | | | | + | +--------------+ | + +------------------+ + + ... where the parent has no contents and clips the child to shape. + */ + QApplication::processEvents(); // Get rid of pending update. + + QGraphicsRectItem *parent = static_cast<QGraphicsRectItem *>(scene.addRect(-50, -50, 100, 100)); + parent->setBrush(QColor(0, 0, 255, 125)); + parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + parent->setFlag(QGraphicsItem::ItemHasNoContents); + + QGraphicsRectItem *child = static_cast<QGraphicsRectItem *>(scene.addRect(-100, -100, 200, 200)); + child->setBrush(QColor(255, 0, 0, 125)); + child->setParentItem(parent); + + CustomView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.painted); + + view.lastUpdateRegions.clear(); + view.painted = false; + + // Call child->update() and make sure the updated area is within its parent's clip. + QRectF expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect()); + expected &= parent->deviceTransform(view.viewportTransform()).mapRect(parent->boundingRect()); + + child->update(); + QTRY_VERIFY(view.painted); + +#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions + QTRY_VERIFY(view.painted); + QCOMPARE(view.lastUpdateRegions.size(), 1); + QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect())); +#endif + + QTest::qWait(50); + + view.lastUpdateRegions.clear(); + view.painted = false; + + // Invalidate the parent's geometry and trigger an update. + // The update area should be clipped to the parent's bounding rect for 'normal' items, + // but in this case the item has no contents (ItemHasNoContents) and its geometry + // is invalidated, which means we cannot clip the child update. So, the expected + // area is exactly the same as the child's bounding rect (adjusted for antialiasing). + parent->setRect(parent->rect().adjusted(-10, -10, -10, -10)); + expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect()); + expected.adjust(-2, -2, 2, 2); // Antialiasing + +#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions + QTRY_VERIFY(view.painted); + QCOMPARE(view.lastUpdateRegions.size(), 1); + QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect())); +#endif +} + class FocusItem : public QGraphicsRectItem { public: diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index f6cd4e3..da0a0bb 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -193,6 +193,7 @@ private slots: void QTBUG6058_reset(); void QTBUG7833_sectionClicked(); void QTBUG8650_crashOnInsertSections(); + void QTBUG12268_hiddenMovedSectionSorting(); protected: QHeaderView *view; @@ -2071,5 +2072,25 @@ void tst_QHeaderView::QTBUG8650_crashOnInsertSections() model.insertColumn(0, items); } +void tst_QHeaderView::QTBUG12268_hiddenMovedSectionSorting() +{ + QTableView view; + QStandardItemModel *model = new QStandardItemModel(4,3, &view); + for (int i = 0; i< model->rowCount(); ++i) + for (int j = 0; j< model->columnCount(); ++j) + model->setData(model->index(i,j), QString("item [%1,%2]").arg(i).arg(j)); + view.setModel(model); + view.horizontalHeader()->setMovable(true); + view.setSortingEnabled(true); + view.sortByColumn(1, Qt::AscendingOrder); + view.horizontalHeader()->moveSection(0,2); + view.setColumnHidden(1, true); + view.show(); + QTest::qWaitForWindowShown(&view); + QCOMPARE(view.horizontalHeader()->hiddenSectionCount(), 1); + QTest::mouseClick(view.horizontalHeader()->viewport(), Qt::LeftButton); + QCOMPARE(view.horizontalHeader()->hiddenSectionCount(), 1); +} + QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 4219920..517c1816 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -83,6 +83,8 @@ private slots: void convertToFormat_data(); void convertToFormat(); + void convertToFormatRgb888ToRGB32(); + void createAlphaMask_data(); void createAlphaMask(); #ifndef QT_NO_IMAGE_HEURISTIC_MASK @@ -799,6 +801,26 @@ void tst_QImage::convertToFormat() QFile::remove(QLatin1String("expected2.xpm")); } +void tst_QImage::convertToFormatRgb888ToRGB32() +{ + // 545 so width % 4 != 0. This ensure there is padding at the end of the scanlines + const int height = 545; + const int width = 545; + QImage source(width, height, QImage::Format_RGB888); + for (int y = 0; y < height; ++y) { + uchar *srcPixels = source.scanLine(y); + for (int x = 0; x < width * 3; ++x) + srcPixels[x] = x; + } + + QImage rgb32Image = source.convertToFormat(QImage::Format_RGB888); + QCOMPARE(rgb32Image.format(), QImage::Format_RGB888); + for (int x = 0; x < width; ++x) { + for (int y = 0; y < height; ++y) + QCOMPARE(rgb32Image.pixel(x, y), source.pixel(x, y)); + } +} + void tst_QImage::createAlphaMask_data() { QTest::addColumn<int>("x"); diff --git a/tests/auto/qimagereader/images/pngwithcompressedtext.png b/tests/auto/qimagereader/images/pngwithcompressedtext.png Binary files differdeleted file mode 100644 index 01b2270..0000000 --- a/tests/auto/qimagereader/images/pngwithcompressedtext.png +++ /dev/null diff --git a/tests/auto/qimagereader/images/pngwithtext.png b/tests/auto/qimagereader/images/pngwithtext.png Binary files differdeleted file mode 100644 index 5d93799..0000000 --- a/tests/auto/qimagereader/images/pngwithtext.png +++ /dev/null diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index 278427b..1acc82f 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -38,8 +38,6 @@ <file>images/noclearcode.bmp</file> <file>images/noclearcode.gif</file> <file>images/nontransparent.xpm</file> - <file>images/pngwithcompressedtext.png</file> - <file>images/pngwithtext.png</file> <file>images/runners.ppm</file> <file>images/teapot.ppm</file> <file>images/test.ppm</file> diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index fe2a719..5b30b04 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -123,9 +123,6 @@ private slots: void supportsAnimation_data(); void supportsAnimation(); - void description_data(); - void description(); - void readFromResources_data(); void readFromResources(); @@ -315,7 +312,24 @@ void tst_QImageReader::jpegRgbCmyk() QImage image1(prefix + QLatin1String("YCbCr_cmyk.jpg")); QImage image2(prefix + QLatin1String("YCbCr_cmyk.png")); - QCOMPARE(image1, image2); + // first, do some obvious tests + QCOMPARE(image1.height(), image2.height()); + QCOMPARE(image1.width(), image2.width()); + QCOMPARE(image1.format(), image2.format()); + QCOMPARE(image1.format(), QImage::Format_RGB32); + + // compare all the pixels with a slack of 3. This ignores rounding errors in libjpeg/libpng + for (int h = 0; h < image1.height(); ++h) { + const uchar *s1 = image1.constScanLine(h); + const uchar *s2 = image2.constScanLine(h); + for (int w = 0; w < image1.width() * 4; ++w) { + if (*s1 != *s2) { + QVERIFY2(qAbs(*s1 - *s2) <= 3, qPrintable(QString("images differ in line %1, col %2 (image1: %3, image2: %4)").arg(h).arg(w).arg(*s1, 0, 16).arg(*s2, 0, 16))); + } + s1++; + s2++; + } + } } void tst_QImageReader::setScaledSize_data() @@ -1236,53 +1250,6 @@ void tst_QImageReader::devicePosition() } -void tst_QImageReader::description_data() -{ - QTest::addColumn<QString>("fileName"); - QTest::addColumn<QStringMap>("description"); - - QMap<QString, QString> willem; - willem["Title"] = "PngSuite"; - willem["Author"] = "Willem A.J. van Schaik (gwillem@ntuvax.ntu.ac.sg)"; - willem["Copyright"] = "Copyright Willem van Schaik, Singapore 1995"; - willem["Description"] = "A compilation of a set of images created to test the " - "various color-types of the PNG format. Included are " - "black&white, color, paletted, with alpha channel, with " - "transparency formats. All bit-depths allowed according " - "to the spec are present."; - willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\"."; - willem["Disclaimer"] = "Freeware."; - - QTest::newRow("PNG") << QString("pngwithtext.png") << willem; - QTest::newRow("PNG Compressed") << QString("pngwithcompressedtext.png") << willem; -} - -void tst_QImageReader::description() -{ - QFETCH(QString, fileName); - QFETCH(QStringMap, description); - - // Sanity check - QVERIFY(!QImage(prefix + fileName).isNull()); - - QImageReader reader(prefix + fileName); - - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); - QCOMPARE(reader.textKeys(), QStringList(description.keys())); - - QImage image = reader.read(); - QVERIFY(!image.isNull()); - - foreach (QString key, description.keys()) - QCOMPARE(image.text(key), description.value(key)); - QCOMPARE(image.textKeys(), QStringList(description.keys())); - - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); - QCOMPARE(reader.textKeys(), QStringList(description.keys())); -} - void tst_QImageReader::readFromResources_data() { QTest::addColumn<QString>("fileName"); @@ -1388,12 +1355,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("image.png") << QString("image.png") << QByteArray("png") << QSize(22, 22) << QString(""); - QTest::newRow("pngwithcompressedtext.png") << QString("pngwithcompressedtext.png") - << QByteArray("png") << QSize(32, 32) - << QString(""); - QTest::newRow("pngwithtext.png") << QString("pngwithtext.png") - << QByteArray("png") << QSize(32, 32) - << QString(""); QTest::newRow("kollada.png") << QString("kollada.png") << QByteArray("png") << QSize(436, 160) << QString(""); diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index c4860c3..c6ec715 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -93,9 +93,6 @@ private slots: void largeTiff(); #endif - void setDescription_data(); - void setDescription(); - void writeToInvalidDevice(); void supportsOption_data(); @@ -420,41 +417,6 @@ void tst_QImageWriter::readWriteNonDestructive() QCOMPARE(image, image2); } -void tst_QImageWriter::setDescription_data() -{ - QTest::addColumn<QString>("fileName"); - QTest::addColumn<QStringMap>("description"); - - QMap<QString, QString> willem; - willem["Title"] = "PngSuite"; - willem["Author"] = "Willem A.J. van Schaik (willem@schaik.com)"; - willem["Copyright"] = "Copyright Willem van Schaik, Singapore 1995-96"; - willem["Description"] = "A compilation of a set of images created to test the " - "various color-types of the PNG format. Included are " - "black&white, color, paletted, with alpha channel, with " - "transparency formats. All bit-depths allowed according " - "to the spec are present."; - willem["Software"] = "Created on a NeXTstation color using \"pnmtopng\"."; - willem["Disclaimer"] = "Freeware."; - - QTest::newRow("PNG") << prefix + QString("gen-pngwithtext.png") << willem; -} - -void tst_QImageWriter::setDescription() -{ - QFETCH(QString, fileName); - QFETCH(QStringMap, description); - - QImageWriter writer(fileName, "png"); - foreach (QString key, description.keys()) - writer.setText(key, description.value(key)); - QVERIFY(writer.write(QImage(prefix + "kollada.png"))); - - QImageReader reader(fileName); - foreach (QString key, description.keys()) - QCOMPARE(reader.text(key), description.value(key)); -} - void tst_QImageWriter::writeToInvalidDevice() { QLatin1String fileName("/these/directories/do/not/exist/001.png"); diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 356e2f8..7048754 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -72,6 +72,7 @@ private slots: void read_QByteArray(); void unget(); void peek(); + void peekAndRead(); void getch(); void putch(); @@ -354,6 +355,31 @@ void tst_QIODevice::peek() QFile::remove("peektestfile"); } +void tst_QIODevice::peekAndRead() +{ + QByteArray originalData; + for (int i=0;i<1000;i++) + originalData += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QBuffer buffer; + QFile::remove("peektestfile"); + QFile file("peektestfile"); + + for (int i = 0; i < 2; ++i) { + QByteArray readData; + QIODevice *device = i ? (QIODevice *)&file : (QIODevice *)&buffer; + device->open(QBuffer::ReadWrite); + device->write(originalData); + device->seek(0); + while (!device->atEnd()) { + char peekIn[26]; + device->peek(peekIn, 26); + readData += device->read(26); + } + QCOMPARE(readData, originalData); + } + QFile::remove("peektestfile"); +} + void tst_QIODevice::getch() { #ifdef QT3_SUPPORT diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index b34e559..717b32d 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -66,7 +66,6 @@ #include <qspinbox.h> #include <qdebug.h> - //TESTED_CLASS= //TESTED_FILES= @@ -275,6 +274,7 @@ private slots: void taskQTBUG_7902_contextMenuCrash(); #endif void taskQTBUG_7395_readOnlyShortcut(); + void QTBUG697_paletteCurrentColorGroup(); #ifdef QT3_SUPPORT void validateAndSet_data(); @@ -3714,5 +3714,32 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() QCOMPARE(spy.count(), 1); } +void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() +{ +#ifndef Q_WS_X11 + QSKIP("Only tested on X11", SkipAll); +#endif + QLineEdit le; + le.setText(" "); + QPalette p = le.palette(); + p.setBrush(QPalette::Active, QPalette::Highlight, Qt::green); + p.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::red); + le.setPalette(p); + + le.show(); + QApplication::setActiveWindow(&le); + QTest::qWaitForWindowShown(&le); + le.setFocus(); + QTRY_VERIFY(le.hasFocus()); + le.selectAll(); + + QImage img(le.size(),QImage::Format_ARGB32 ); + le.render(&img); + QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::green).rgb()); + QApplication::setActiveWindow(0); + le.render(&img); + QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb()); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" diff --git a/tests/auto/qmake/testdata/simple_app/build/README b/tests/auto/qmake/testdata/simple_app/build/README new file mode 100644 index 0000000..acfd9d9 --- /dev/null +++ b/tests/auto/qmake/testdata/simple_app/build/README @@ -0,0 +1 @@ +Here to ensure build/ exists, used by the simple_app_shadowbuild2 test. diff --git a/tests/auto/qmake/testdata/simple_app/simple_app.pro b/tests/auto/qmake/testdata/simple_app/simple_app.pro index f496d5b..a8c4ad6 100644 --- a/tests/auto/qmake/testdata/simple_app/simple_app.pro +++ b/tests/auto/qmake/testdata/simple_app/simple_app.pro @@ -3,6 +3,7 @@ CONFIG += qt warn_on HEADERS = test_file.h SOURCES = test_file.cpp \ main.cpp +RESOURCES = test.qrc TARGET = simple_app DESTDIR = ./ diff --git a/tests/auto/qmake/testdata/simple_app/test.qrc b/tests/auto/qmake/testdata/simple_app/test.qrc new file mode 100644 index 0000000..decde3d --- /dev/null +++ b/tests/auto/qmake/testdata/simple_app/test.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>test.qrc</file> + </qresource> +</RCC> diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 03054e7..5efe714 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -65,6 +65,7 @@ public slots: private slots: void simple_app(); void simple_app_shadowbuild(); + void simple_app_shadowbuild2(); void simple_lib(); void simple_dll(); void subdirs(); @@ -163,6 +164,21 @@ void tst_qmake::simple_app_shadowbuild() QVERIFY( test_compiler.removeMakefile( buildDir ) ); } +void tst_qmake::simple_app_shadowbuild2() +{ + QString workDir = base_path + "/testdata/simple_app"; + QString buildDir = base_path + "/testdata/simple_app/build"; + + QVERIFY( test_compiler.qmake( workDir, "simple_app", buildDir )); + QVERIFY( test_compiler.make( buildDir )); + QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); + QVERIFY( test_compiler.makeClean( buildDir )); + QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean + QVERIFY( test_compiler.makeDistClean( buildDir )); + QVERIFY( !test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean + QVERIFY( test_compiler.removeMakefile( buildDir ) ); +} + void tst_qmake::simple_dll() { QString workDir = base_path + "/testdata/simple_dll"; diff --git a/tests/auto/qmimedata/qmimedata.pro b/tests/auto/qmimedata/qmimedata.pro new file mode 100644 index 0000000..13fbe65 --- /dev/null +++ b/tests/auto/qmimedata/qmimedata.pro @@ -0,0 +1,4 @@ +load(qttest_p4) +SOURCES += tst_qmimedata.cpp + + diff --git a/tests/auto/qmimedata/tst_qmimedata.cpp b/tests/auto/qmimedata/tst_qmimedata.cpp new file mode 100644 index 0000000..be7a654 --- /dev/null +++ b/tests/auto/qmimedata/tst_qmimedata.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> + +#include <QMimeData> + +class tst_QMimeData : public QObject +{ + Q_OBJECT +public: + tst_QMimeData() + { + } + +private slots: + void clear() const; + void colorData() const; + void data() const; + void formats() const; + void hasColor() const; + void hasFormat() const; + void hasHtml() const; + void hasImage() const; + // hasText() covered by setText() + // hasUrls() covered by setUrls() + // html() covered by setHtml() + void imageData() const; + void removeFormat() const; + // setColorData() covered by hasColor() + // setData() covered in a few different tests + void setHtml() const; + // setImageData() covered in a few tests + void setText() const; + void setUrls() const; + // text() covered in setText() + // urls() covered by setUrls() +}; + +void tst_QMimeData::clear() const +{ + QMimeData mimeData; + + // set, clear, verify empty + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasText()); + mimeData.clear(); + QVERIFY(mimeData.hasText() == false); + + // repopulate, verify not empty + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasText()); +} + +void tst_QMimeData::colorData() const +{ + QMimeData mimeData; + QColor red = Qt::red; + QColor blue = Qt::blue; + + // set, verify + mimeData.setColorData(red); + QVERIFY(mimeData.hasColor()); + QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), red); + + // change, verify + mimeData.setColorData(Qt::blue); + QVERIFY(mimeData.hasColor()); + QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), blue); +} + +void tst_QMimeData::data() const +{ + QMimeData mimeData; + + // set text, verify + mimeData.setData("text/plain", "pirates"); + QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); + QVERIFY(mimeData.data("text/html").length() == 0); + + // html time + mimeData.setData("text/html", "ninjas"); + QCOMPARE(mimeData.data("text/html"), QByteArray("ninjas")); + QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); // make sure text not damaged + QCOMPARE(mimeData.data("text/html"), mimeData.html().toLatin1()); +} + +void tst_QMimeData::formats() const +{ + QMimeData mimeData; + + // set text, verify + mimeData.setData("text/plain", "pirates"); + QCOMPARE(mimeData.formats(), QStringList() << "text/plain"); + + // set html, verify + mimeData.setData("text/html", "ninjas"); + QCOMPARE(mimeData.formats(), QStringList() << "text/plain" << "text/html"); + + // clear, verify + mimeData.clear(); + QCOMPARE(mimeData.formats(), QStringList()); + + // set an odd format, verify + mimeData.setData("foo/bar", "somevalue"); + QCOMPARE(mimeData.formats(), QStringList() << "foo/bar"); +} + +void tst_QMimeData::hasColor() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasColor() == false); + + // set, verify + mimeData.setColorData(QColor(Qt::red)); + QVERIFY(mimeData.hasColor()); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasColor() == false); + + // set something else, verify + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasColor() == false); +} + +void tst_QMimeData::hasFormat() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasFormat("text/plain") == false); + + // add, verify + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasFormat("text/plain")); + QVERIFY(mimeData.hasFormat("text/html") == false); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(mimeData.hasFormat("text/html") == false); +} + +void tst_QMimeData::hasHtml() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasHtml() == false); + + // add plain, verify false + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasHtml() == false); + + // add html, verify + mimeData.setData("text/html", "ninjas"); + QVERIFY(mimeData.hasHtml()); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasHtml() == false); + + // readd, verify + mimeData.setData("text/html", "ninjas"); + QVERIFY(mimeData.hasHtml()); +} + +void tst_QMimeData::hasImage() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasImage() == false); + + // add text, verify false + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasImage() == false); + + // add image + mimeData.setImageData(QImage()); + QVERIFY(mimeData.hasImage()); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasImage() == false); +} + +void tst_QMimeData::imageData() const +{ + QMimeData mimeData; + + // initial state + QCOMPARE(mimeData.imageData(), QVariant()); + + // set, test + mimeData.setImageData(QImage()); + QVERIFY(mimeData.hasImage()); + QCOMPARE(mimeData.imageData(), QVariant(QImage())); + + // clear, verify + mimeData.clear(); + QCOMPARE(mimeData.imageData(), QVariant()); +} + +void tst_QMimeData::removeFormat() const +{ + QMimeData mimeData; + + // add, verify + mimeData.setData("text/plain", "pirates"); + QVERIFY(mimeData.hasFormat("text/plain")); + + // add another, verify + mimeData.setData("text/html", "ninjas"); + QVERIFY(mimeData.hasFormat("text/html")); + + // remove, verify + mimeData.removeFormat("text/plain"); + QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(mimeData.hasFormat("text/html")); + + // remove, verify + mimeData.removeFormat("text/html"); + QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(mimeData.hasFormat("text/html") == false); +} + +void tst_QMimeData::setHtml() const +{ + QMimeData mimeData; + + // initial state + QVERIFY(mimeData.hasHtml() == false); + + // add html, verify + mimeData.setHtml("ninjas"); + QVERIFY(mimeData.hasHtml()); + QCOMPARE(mimeData.html(), QLatin1String("ninjas")); + + // reset html + mimeData.setHtml("pirates"); + QVERIFY(mimeData.hasHtml()); + QCOMPARE(mimeData.html(), QLatin1String("pirates")); +} + +void tst_QMimeData::setText() const +{ + QMimeData mimeData; + + // verify initial state + QCOMPARE(mimeData.text(), QLatin1String("")); + QVERIFY(mimeData.hasText() == false); + + // set, verify + mimeData.setText("pirates"); + QVERIFY(mimeData.hasText()); + QCOMPARE(mimeData.text(), QLatin1String("pirates")); + QCOMPARE(mimeData.text().toLatin1(), mimeData.data("text/plain")); + + // reset, verify + mimeData.setText("ninjas"); + QVERIFY(mimeData.hasText()); + QCOMPARE(mimeData.text(), QLatin1String("ninjas")); + QCOMPARE(mimeData.text().toLatin1(), mimeData.data("text/plain")); + + // clear, verify + mimeData.clear(); + QCOMPARE(mimeData.text(), QLatin1String("")); + QVERIFY(mimeData.hasText() == false); +} + +void tst_QMimeData::setUrls() const +{ + QMimeData mimeData; + QList<QUrl> shortUrlList; + QList<QUrl> longUrlList; + + // set up + shortUrlList += QUrl("http://qt.nokia.com"); + longUrlList = shortUrlList; + longUrlList += QUrl("http://www.google.com"); + + // verify initial state + QVERIFY(mimeData.hasUrls() == false); + + // set a few, verify + mimeData.setUrls(shortUrlList); + QCOMPARE(mimeData.urls(), shortUrlList); + + // change them, verify + mimeData.setUrls(longUrlList); + QCOMPARE(mimeData.urls(), longUrlList); + + // clear, verify + mimeData.clear(); + QVERIFY(mimeData.hasUrls() == false); +} + + +QTEST_MAIN(tst_QMimeData) +#include "tst_qmimedata.moc" diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 24f6e52..3388cd5 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -88,7 +88,7 @@ private slots: void sessionStop(); void roamingErrorCodes(); - + void sessionProperties_data(); void sessionProperties(); @@ -918,6 +918,10 @@ void tst_QNetworkSession::sessionOpenCloseStop() session.waitForOpened(); #endif + // Wait until the configuration is uptodate as well, it may be signaled 'connected' + // bit later than the session + QTRY_VERIFY(configuration.state() == QNetworkConfiguration::Active); + if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); if (!errorSpy.isEmpty()) { @@ -1131,8 +1135,9 @@ void tst_QNetworkSession::sessionOpenCloseStop() roamedSuccessfully = true; } else if (state == QNetworkSession::Closing) { QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session.state() == QNetworkSession::Connected); - roamedSuccessfully = true; + QTRY_VERIFY(session.state() == QNetworkSession::Connected || + session.state() == QNetworkSession::Disconnected); + roamedSuccessfully = false; } else if (state == QNetworkSession::Disconnected) { QTRY_VERIFY(!errorSpy.isEmpty()); QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 27ee6e7..f358681 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -4176,14 +4176,18 @@ void tst_QPainter::inactivePainter() p.setWorldTransform(QTransform().scale(0.5, 0.5), true); } -bool testCompositionMode(int src, int dst, int expected, QPainter::CompositionMode op) +bool testCompositionMode(int src, int dst, int expected, QPainter::CompositionMode op, qreal opacity = 1.0) { - QImage actual(1, 1, QImage::Format_ARGB32_Premultiplied); + // The test image needs to be large enough to test SIMD code + const QSize imageSize(100, 100); + + QImage actual(imageSize, QImage::Format_ARGB32_Premultiplied); actual.fill(QColor(dst, dst, dst).rgb()); QPainter p(&actual); p.setCompositionMode(op); - p.fillRect(0, 0, 1, 1, QColor(src, src, src)); + p.setOpacity(opacity); + p.fillRect(QRect(QPoint(), imageSize), QColor(src, src, src)); p.end(); if (qRed(actual.pixel(0, 0)) != expected) { @@ -4191,7 +4195,9 @@ bool testCompositionMode(int src, int dst, int expected, QPainter::CompositionMo src, dst, qRed(actual.pixel(0, 0)), expected); return false; } else { - return true; + QImage refImage(imageSize, QImage::Format_ARGB32_Premultiplied); + refImage.fill(QColor(expected, expected, expected).rgb()); + return actual == refImage; } } @@ -4206,6 +4212,16 @@ void tst_QPainter::extendedBlendModes() QVERIFY(testCompositionMode( 0, 255, 255, QPainter::CompositionMode_Plus)); QVERIFY(testCompositionMode(128, 128, 255, QPainter::CompositionMode_Plus)); + QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(127, 128, 165, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(127, 0, 37, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode( 0, 127, 127, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(255, 0, 75, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode( 0, 255, 255, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(128, 128, 166, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(186, 200, 255, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_Multiply)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Multiply)); QVERIFY(testCompositionMode(127, 255, 127, QPainter::CompositionMode_Multiply)); diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index c3ee192..ff8258f 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -12,14 +12,16 @@ wince*|symbian: { icons.sources = convertFromToHICON/* icons.path = convertFromToHICON - DEPLOYMENT += task31722_0 task31722_1 icons - DEPLOYMENT_PLUGIN += qico + loadFromData.sources = loadFromData/* + loadFromData.path = loadFromData + + DEPLOYMENT += task31722_0 task31722_1 icons loadFromData } wince*: { DEFINES += SRCDIR=\\\".\\\" + DEPLOYMENT_PLUGIN += qico } else:symbian { - DEPLOYMENT_PLUGIN += qmng LIBS += -lfbscli.dll -lbitgdi.dll -lgdi.dll contains(QT_CONFIG, openvg) { LIBS += $$QMAKE_LIBS_OPENVG diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 6ebe0aa..81fb749 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -4297,6 +4297,35 @@ void tst_QScriptEngine::reentrancy() QScriptEngine eng; QCOMPARE(eng.evaluate("Array()").toString(), QString()); } + + { + QScriptEngine eng1; + QScriptEngine eng2; + { + QScriptValue d1 = eng1.newDate(0); + QScriptValue d2 = eng2.newDate(0); + QCOMPARE(d1.toDateTime(), d2.toDateTime()); + QCOMPARE(d2.toDateTime(), d1.toDateTime()); + } + { + QScriptValue r1 = eng1.newRegExp("foo", "gim"); + QScriptValue r2 = eng2.newRegExp("foo", "gim"); + QCOMPARE(r1.toRegExp(), r2.toRegExp()); + QCOMPARE(r2.toRegExp(), r1.toRegExp()); + } + { + QScriptValue o1 = eng1.newQObject(this); + QScriptValue o2 = eng2.newQObject(this); + QCOMPARE(o1.toQObject(), o2.toQObject()); + QCOMPARE(o2.toQObject(), o1.toQObject()); + } + { + QScriptValue mo1 = eng1.newQMetaObject(&staticMetaObject); + QScriptValue mo2 = eng2.newQMetaObject(&staticMetaObject); + QCOMPARE(mo1.toQMetaObject(), mo2.toQMetaObject()); + QCOMPARE(mo2.toQMetaObject(), mo1.toQMetaObject()); + } + } } void tst_QScriptEngine:: incDecNonObjectProperty() diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index a0f10dd..c30a636 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -97,6 +97,7 @@ private slots: void functionEntryAndExit_objectCall(); void positionChange_1(); void positionChange_2(); + void positionChange_3(); void exceptionThrowAndCatch(); void eventOrder_assigment(); void eventOrder_functionDefinition(); @@ -116,6 +117,8 @@ private slots: void evaluateProgram_SyntaxError(); void evaluateNullProgram(); void QTBUG6108(); + void backtraces_data(); + void backtraces(); private: double m_testProperty; @@ -1623,6 +1626,56 @@ void tst_QScriptEngineAgent::positionChange_2() delete spy; } +void tst_QScriptEngineAgent::positionChange_3() +{ + QScriptEngine eng; + eng.evaluate("function some_function1(a) {\n a++; \n return a + 12; } \n some_function1(42);", "function1.qs", 12); + QScriptValue some_function2 = eng.evaluate("(function (b) {\n b--; \n return b + 11; })", "function2.qs", 21); + some_function2.call(QScriptValue(), QScriptValueList() << 2 ); + + // Test that the agent work, even if installed after the function has been evaluated. + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnorePositionChange)); + { + spy->clear(); + QScriptValue v = eng.evaluate("some_function1(15)"); + QCOMPARE(v.toInt32(), (15+1+12)); + QCOMPARE(spy->count(), 3); + + // some_function1() + QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(0).scriptId != -1); + QCOMPARE(spy->at(0).lineNumber, 1); + + // a++ + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(1).scriptId != spy->at(0).scriptId); + QCOMPARE(spy->at(1).lineNumber, 13); + // return a + 12 + QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(2).scriptId == spy->at(1).scriptId); + QCOMPARE(spy->at(2).lineNumber, 14); + } + + { + spy->clear(); + QScriptValue v = some_function2.call(QScriptValue(), QScriptValueList() << 89 ); + QCOMPARE(v.toInt32(), (89-1+11)); + QCOMPARE(spy->count(), 2); + + // b-- + QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(0).scriptId != -1); + QCOMPARE(spy->at(0).lineNumber, 22); + // return b + 11 + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(1).scriptId == spy->at(0).scriptId); + QCOMPARE(spy->at(1).lineNumber, 23); + } + + QVERIFY(!eng.hasUncaughtException()); +} + + void tst_QScriptEngineAgent::exceptionThrowAndCatch() { QScriptEngine eng; @@ -2379,5 +2432,86 @@ void tst_QScriptEngineAgent::QTBUG6108() QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId); } +class BacktraceSpy : public QScriptEngineAgent +{ +public: + BacktraceSpy(QScriptEngine *engine, const QStringList &expectedbacktrace, int breakpoint) + : QScriptEngineAgent(engine), expectedbacktrace(expectedbacktrace), breakpoint(breakpoint), ok(false) {} + + QStringList expectedbacktrace; + int breakpoint; + bool ok; + +protected: + + void exceptionThrow(qint64 , const QScriptValue &, bool) + { check(); } + + void positionChange(qint64 , int lineNumber, int ) + { + if (lineNumber == breakpoint) + check(); + } + +private: + void check() + { + QCOMPARE(engine()->currentContext()->backtrace(), expectedbacktrace); + ok = true; + } +}; + + +void tst_QScriptEngineAgent::backtraces_data() +{ + QTest::addColumn<QString>("code"); + QTest::addColumn<int>("breakpoint"); + QTest::addColumn<QStringList>("expectedbacktrace"); + + { + QString source( + "function foo() {\n" + " var a = 5\n" + "}\n" + "foo('hello', { })\n" + "var r = 0;"); + + QStringList expected; + expected + << "foo('hello', [object Object]) at filename.js:2" + << "<global>() at filename.js:4"; + QTest::newRow("simple breakpoint") << source << 2 << expected; + } + + { + QString source( + "function foo() {\n" + " error = err\n" //this must throw + "}\n" + "foo('hello', { })\n" + "var r = 0;"); + + QStringList expected; + expected + << "foo('hello', [object Object]) at filename.js:2" + << "<global>() at filename.js:4"; + QTest::newRow("throw because of error") << source << -100 << expected; + } +} + +void tst_QScriptEngineAgent::backtraces() +{ + QFETCH(QString, code); + QFETCH(int, breakpoint); + QFETCH(QStringList, expectedbacktrace); + + QScriptEngine eng; + BacktraceSpy *spy = new BacktraceSpy(&eng, expectedbacktrace, breakpoint); + eng.setAgent(spy); + QLatin1String filename("filename.js"); + eng.evaluate(code, filename); + QVERIFY(spy->ok); +} + QTEST_MAIN(tst_QScriptEngineAgent) #include "tst_qscriptengineagent.moc" diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 1d8706c..18480cc 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2123,6 +2123,10 @@ void tst_QScriptValue::getSetProperty() QVERIFY(object.property(foo).strictlyEquals(num)); QVERIFY(object.property("foo").strictlyEquals(num)); QVERIFY(object.propertyFlags(foo) == 0); + + // Setting index property on non-Array + object.setProperty(13, num); + QVERIFY(object.property(13).equals(num)); } void tst_QScriptValue::arrayElementGetterSetter() diff --git a/tests/auto/qscrollbar/tst_qscrollbar.cpp b/tests/auto/qscrollbar/tst_qscrollbar.cpp index 735b2dd..16d5b42 100644 --- a/tests/auto/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/qscrollbar/tst_qscrollbar.cpp @@ -130,7 +130,7 @@ void tst_QScrollBar::task_209492() QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, 0); QApplication::sendEvent(verticalScrollBar, &mousePressEvent); - QTest::qWait(50); + QTest::qWait(1); QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, 0); QApplication::sendEvent(verticalScrollBar, &mouseReleaseEvent); diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 4e23cb1..6b4904f 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -95,6 +95,8 @@ private slots: void creating(); void creatingQObject(); void mixTrackingPointerCode(); + void reentrancyWhileDestructing(); + void threadStressTest_data(); void threadStressTest(); void map(); @@ -1870,6 +1872,60 @@ void tst_QSharedPointer::invalidConstructs() } } +namespace QTBUG11730 { + struct IB + { + virtual ~IB() {} + }; + + struct IA + { + virtual QSharedPointer<IB> getB() = 0; + }; + + struct B: public IB + { + IA *m_a; + B(IA *a_a) :m_a(a_a) + { } + ~B() + { + QSharedPointer<IB> b = m_a->getB(); + } + }; + + struct A: public IA + { + QSharedPointer<IB> b; + + virtual QSharedPointer<IB> getB() + { + return b; + } + + A() + { + b = QSharedPointer<IB>(new B(this)); + } + + ~A() + { + b.clear(); + } + }; +} + +void tst_QSharedPointer::reentrancyWhileDestructing() +{ + // this bug is about recursing back into QSharedPointer::clear() + // from inside it + // that is, the destructor of the object being deleted recurses + // into the same QSharedPointer object. + // First reported as QTBUG-11730 + QTBUG11730::A obj; +} + + QTEST_MAIN(tst_QSharedPointer) #include "tst_qsharedpointer.moc" diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 0cf638b..0c12974 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -55,6 +55,7 @@ #include <QAuthenticator> #include "private/qhostinfo_p.h" +#include "private/qsslsocket_openssl_p.h" #include "../network-settings.h" @@ -163,6 +164,7 @@ private slots: void setDefaultCiphers(); void supportedCiphers(); void systemCaCertificates(); + void wildcardCertificateNames(); void wildcard(); void setEmptyKey(); void spontaneousWrite(); @@ -1063,6 +1065,28 @@ void tst_QSslSocket::systemCaCertificates() QCOMPARE(certs, QSslSocket::defaultCaCertificates()); } +void tst_QSslSocket::wildcardCertificateNames() +{ + // Passing CN matches + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("www.example.com"), QString("www.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("www.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx*.example.com"), QString("xxxwww.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("foo.example.com")), true ); + + // Failing CN matches + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx.example.com"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.*.com"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("baa.foo.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("baa.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.com"), QString("example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*fail.com"), QString("example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example.")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString(""), QString("www")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www")), false ); +} + void tst_QSslSocket::wildcard() { QSKIP("TODO: solve wildcard problem", SkipAll); diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index 106fd8c..02e2921 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -85,6 +85,7 @@ private slots: void testFillInheritance(); void testStopOffsetOpacity(); void testUseElement(); + void smallFont(); #ifndef QT_NO_COMPRESS void testGzLoading(); @@ -1342,5 +1343,28 @@ void tst_QSvgRenderer::testUseElement() } } +void tst_QSvgRenderer::smallFont() +{ + static const char *svgs[] = { "<svg width=\"50px\" height=\"50px\"><text x=\"10\" y=\"10\" font-size=\"0\">Hello world</text></svg>", + "<svg width=\"50px\" height=\"50px\"><text x=\"10\" y=\"10\" font-size=\"0.5\">Hello world</text></svg>" + }; + const int COUNT = sizeof(svgs) / sizeof(svgs[0]); + QImage images[COUNT]; + QPainter p; + + for (int i = 0; i < COUNT; ++i) { + QByteArray data(svgs[i]); + if (i == 0) + QTest::ignoreMessage(QtWarningMsg, "QFont::setPointSizeF: Point size <= 0 (0.000000), must be greater than 0"); + QSvgRenderer renderer(data); + images[i] = QImage(50, 50, QImage::Format_ARGB32_Premultiplied); + images[i].fill(-1); + p.begin(&images[i]); + renderer.render(&p); + p.end(); + } + QVERIFY(images[0] != images[1]); +} + QTEST_MAIN(tst_QSvgRenderer) #include "tst_qsvgrenderer.moc" diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 31cae40..e3b2ca5 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -275,7 +275,7 @@ void tst_QTcpSocket::initTestCase_data() QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; -// QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm) << false; + QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm) << false; #ifndef QT_NO_OPENSSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; @@ -284,7 +284,7 @@ void tst_QTcpSocket::initTestCase_data() QTest::newRow("WithHttpProxy SSL") << true << int(HttpProxy) << true; QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; -// QTest::newRow("WithHttpProxyNtlmAuth SSL") << true << int(HttpProxy | AuthNtlm) << true; + QTest::newRow("WithHttpProxyNtlmAuth SSL") << true << int(HttpProxy | AuthNtlm) << true; #endif } diff --git a/tests/auto/qtexttable/tst_qtexttable.cpp b/tests/auto/qtexttable/tst_qtexttable.cpp index 2e6007e..a811b85 100644 --- a/tests/auto/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/qtexttable/tst_qtexttable.cpp @@ -48,9 +48,14 @@ #include <qtexttable.h> #include <qdebug.h> #include <qtextcursor.h> +#include <qtextdocument.h> +#include <qtextedit.h> //TESTED_FILES= +typedef QList<int> IntList; +Q_DECLARE_METATYPE(IntList) + QT_FORWARD_DECLARE_CLASS(QTextDocument) class tst_QTextTable : public QObject @@ -78,6 +83,7 @@ private slots: void insertRows(); void deleteInTable(); void mergeCells(); + void mergeAndInsert(); void splitCells(); void blocksForTableShouldHaveEmptyFormat(); void removeTableByRemoveRows(); @@ -93,6 +99,9 @@ private slots: void removeColumns3(); void removeColumns4(); void removeColumns5(); + void removeColumnsInTableWithMergedRows(); + void QTBUG11282_insertBeforeMergedEnding_data(); + void QTBUG11282_insertBeforeMergedEnding(); private: QTextTable *create2x2Table(); @@ -586,6 +595,16 @@ void tst_QTextTable::mergeCells() QVERIFY(table->cellAt(0, 1) == table->cellAt(1, 1)); } +void tst_QTextTable::mergeAndInsert() +{ + QTextTable *table = cursor.insertTable(4,3); + table->mergeCells(0,1,3,2); + table->mergeCells(3,0,1,3); + //Don't crash ! + table->insertColumns(1,2); + QCOMPARE(table->columns(), 5); +} + void tst_QTextTable::splitCells() { QTextTable *table = create4x4Table(); @@ -931,5 +950,55 @@ void tst_QTextTable::removeColumns5() QCOMPARE(table->cellAt(3, 2).firstPosition(), 11); } +void tst_QTextTable::removeColumnsInTableWithMergedRows() +{ + QTextTable *table = cursor.insertTable(3, 4); + table->mergeCells(0, 0, 1, 4); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 4); + + table->removeColumns(0, table->columns() - 1); + + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 1); +} + +void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding_data() +{ + QTest::addColumn<int>("rows"); + QTest::addColumn<int>("columns"); + QTest::addColumn<QList<int> >("merge"); + QTest::addColumn<QList<int> >("insert"); + + QTest::newRow("2x3, merge two, insert one") << 2 << 3 << (QList<int>() << 1 << 2 << 2) + << (QList<int>() << 1 << 1) ; + QTest::newRow("3x4, merge three, insert one") << 3 << 4 << (QList<int>() << 1 << 3 << 3) + << (QList<int>() << 1 << 1) ; + QTest::newRow("4x3, merge two, insert two") << 4 << 3 << (QList<int>() << 1 << 4 << 2) + << (QList<int>() << 1 << 2) ; + QTest::newRow("4x4, merge middle two, insert one") << 4 << 4 << (QList<int>() << 1 << 4 << 2) + << (QList<int>() << 1 << 1) ; +} + +void tst_QTextTable::QTBUG11282_insertBeforeMergedEnding() +{ + QFETCH(int, rows); + QFETCH(int, columns); + QFETCH(QList<int>, merge); + QFETCH(QList<int>, insert); + QTextTable *table = cursor.insertTable(rows, columns); + QTextEdit *textEdit = new QTextEdit; + textEdit->setDocument(doc); + textEdit->show(); + QTest::qWaitForWindowShown(textEdit); + table->mergeCells(0,merge.at(0), merge.at(1), merge.at(2)); + //Don't crash ! + table->insertColumns(insert.at(0), insert.at(1)); + //Check that the final size is what we expected + QCOMPARE(table->rows(), rows); + QCOMPARE(table->columns(), columns + insert.at(1)); + delete textEdit; +} + QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" diff --git a/tests/auto/quuid/quuid.pro b/tests/auto/quuid/quuid.pro index f7608fa..25e2456 100644 --- a/tests/auto/quuid/quuid.pro +++ b/tests/auto/quuid/quuid.pro @@ -1,3 +1,6 @@ -load(qttest_p4) -QT = core -SOURCES += tst_quuid.cpp +TEMPLATE = subdirs + +SUBDIRS = testProcessUniqueness + +SUBDIRS += test + diff --git a/tests/auto/quuid/test/test.pro b/tests/auto/quuid/test/test.pro new file mode 100644 index 0000000..123aa50 --- /dev/null +++ b/tests/auto/quuid/test/test.pro @@ -0,0 +1,29 @@ +load(qttest_p4) + +QT = core +SOURCES += ../tst_quuid.cpp +TARGET = tst_quuid + +CONFIG(debug_and_release_target) { + CONFIG(debug, debug|release) { + DESTDIR = ../debug + } else { + DESTDIR = ../release + } +} else { + DESTDIR = .. +} + +wince* { + addFile_processUniqueness.sources = $$OUT_PWD/../testProcessUniqueness/testProcessUniqueness.exe + addFile_processUniqueness.path = testProcessUniqueness + + DEPLOYMENT += addFile_processUniqueness +} + +symbian { + binDep.sources = testProcessUniqueness.exe + binDep.path = \\sys\\bin + + DEPLOYMENT += binDep +} diff --git a/tests/auto/quuid/testProcessUniqueness/main.cpp b/tests/auto/quuid/testProcessUniqueness/main.cpp new file mode 100644 index 0000000..4d33c84 --- /dev/null +++ b/tests/auto/quuid/testProcessUniqueness/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <stdio.h> +#include <QUuid> + +// This is a testcase for QTBUG-11213 +int main(int argc, char **argv) +{ + Q_UNUSED(argc) + Q_UNUSED(argv) + + // First, break QUuid. + qrand(); + + // Now print a few uuids. + printf("%s", qPrintable(QUuid::createUuid().toString())); + printf("%s", qPrintable(QUuid::createUuid().toString())); + printf("%s", qPrintable(QUuid::createUuid().toString())); + + // Done + return 0; +} + diff --git a/tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro b/tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro new file mode 100644 index 0000000..88df1a2 --- /dev/null +++ b/tests/auto/quuid/testProcessUniqueness/testProcessUniqueness.pro @@ -0,0 +1,8 @@ +SOURCES = main.cpp +CONFIG += console + +DESTDIR = ./ + +# no install rule for application used by test +INSTALLS = + diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 47f356a..409d8cf 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -73,6 +73,7 @@ private slots: void versions(); void threadUniqueness(); + void processUniqueness(); public: // Variables @@ -196,5 +197,33 @@ void tst_QUuid::threadUniqueness() qDeleteAll(threads); } +void tst_QUuid::processUniqueness() +{ + QProcess process; + QString processOneOutput; + QString processTwoOutput; + + // Start it once +#ifdef Q_OS_MAC + process.start("testProcessUniqueness/testProcessUniqueness.app"); +#else + process.start("testProcessUniqueness/testProcessUniqueness"); +#endif + QVERIFY(process.waitForFinished()); + processOneOutput = process.readAllStandardOutput(); + + // Start it twice +#ifdef Q_OS_MAC + process.start("testProcessUniqueness/testProcessUniqueness.app"); +#else + process.start("testProcessUniqueness/testProcessUniqueness"); +#endif + QVERIFY(process.waitForFinished()); + processTwoOutput = process.readAllStandardOutput(); + + // They should be *different*! + QVERIFY(processOneOutput != processTwoOutput); +} + QTEST_MAIN(tst_QUuid) #include "tst_quuid.moc" diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 2d559c8..f722f89 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -397,6 +397,9 @@ private slots: void childAt(); #ifdef Q_WS_MAC void childAt_unifiedToolBar(); +#ifdef QT_MAC_USE_COCOA + void taskQTBUG_11373(); +#endif // QT_MAC_USE_COCOA #endif private: @@ -9691,7 +9694,6 @@ void tst_QWidget::destroyBackingStoreWhenHidden() // Native child widget should once again share parent's backing store QVERIFY(0 != backingStore(parent)); - QEXPECT_FAIL("", "QTBUG-10643", Continue); QVERIFY(0 == backingStore(child)); } @@ -9740,7 +9742,7 @@ void tst_QWidget::destroyBackingStoreWhenHidden() QVERIFY(0 != backingStore(child)); // Parent is obscured, therefore its backing store should be destroyed - QEXPECT_FAIL("", "QTBUG-10643", Continue); + QEXPECT_FAIL("", "QTBUG-12406", Continue); QVERIFY(0 == backingStore(parent)); // Disable full screen @@ -9754,7 +9756,6 @@ void tst_QWidget::destroyBackingStoreWhenHidden() // Native child widget should once again share parent's backing store QVERIFY(0 != backingStore(parent)); - QEXPECT_FAIL("", "QTBUG-10643", Continue); QVERIFY(0 == backingStore(child)); } } @@ -10435,6 +10436,26 @@ void tst_QWidget::childAt_unifiedToolBar() QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast<QWidget *>(toolBar)); QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label)); } + +#ifdef QT_MAC_USE_COCOA +void tst_QWidget::taskQTBUG_11373() +{ + QMainWindow * myWindow = new QMainWindow(); + QWidget * center = new QWidget(); + myWindow -> setCentralWidget(center); + QWidget * drawer = new QWidget(myWindow, Qt::Drawer); + drawer -> hide(); + QCOMPARE(drawer->isVisible(), false); + myWindow -> show(); + myWindow -> raise(); + // The drawer shouldn't be visible now. + QCOMPARE(drawer->isVisible(), false); + myWindow -> setWindowState(Qt::WindowFullScreen); + myWindow -> setWindowState(Qt::WindowNoState); + // The drawer should still not be visible, since we haven't shown it. + QCOMPARE(drawer->isVisible(), false); +} +#endif // QT_MAC_USE_COCOA #endif QTEST_MAIN(tst_QWidget) diff --git a/tests/auto/qxmlquery/qxmlquery.pro b/tests/auto/qxmlquery/qxmlquery.pro index ae73488..044b7ce 100644 --- a/tests/auto/qxmlquery/qxmlquery.pro +++ b/tests/auto/qxmlquery/qxmlquery.pro @@ -23,7 +23,12 @@ wince*|symbian: { addFiles.path = . patternistFiles.sources = ../xmlpatterns/queries - patternistFiles.path = ../xmlpatterns + symbian: { + #../xmlpatterns resolves to an illegal path for deployment + patternistFiles.path = xmlpatterns + } else { + patternistFiles.path = ../xmlpatterns + } DEPLOYMENT += addFiles patternistFiles } diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index 6fd9b93..2187aeb 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -67,6 +67,9 @@ #if defined(Q_OS_SYMBIAN) #define SRCDIR "" +#define XMLPATTERNSDIR "xmlpatterns" +#else +#define XMLPATTERNSDIR SRCDIR "../xmlpatterns" #endif /*! @@ -264,7 +267,7 @@ void tst_QXmlQuery::checkBaseURI(const QUrl &baseURI, const QString &candidate) QVERIFY(QDir(baseURI.toLocalFile()).relativeFilePath(QFileInfo(candidate).canonicalFilePath()).startsWith("../")); } -const char *const tst_QXmlQuery::queriesDirectory = SRCDIR "../xmlpatterns/queries/"; +const char *const tst_QXmlQuery::queriesDirectory = XMLPATTERNSDIR "/queries/"; QStringList tst_QXmlQuery::queries() { @@ -857,7 +860,7 @@ void tst_QXmlQuery::bindVariableXSLTSuccess() const stylesheet.bindVariable(QLatin1String("paramSelectWithTypeIntBoundWithBindVariableRequired"), QVariant(QLatin1String("param5"))); - stylesheet.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl")))); + stylesheet.setQuery(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/parameters.xsl")))); QVERIFY(stylesheet.isValid()); @@ -1798,11 +1801,11 @@ void tst_QXmlQuery::setFocusQUrl() const { QXmlQuery query(QXmlQuery::XSLT20); - const TestURIResolver resolver(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + const TestURIResolver resolver(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); query.setUriResolver(&resolver); QVERIFY(query.setFocus(QUrl(QLatin1String("arbitraryURI")))); - query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl")))); + query.setQuery(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/copyWholeDocument.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -2997,7 +3000,7 @@ void tst_QXmlQuery::setInitialTemplateNameQXmlName() const QCOMPARE(query.initialTemplateName(), name); - query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl")))); + query.setQuery(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/namedTemplate.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -3059,7 +3062,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure fn:doc() picks up the right QNetworkAccessManager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")))); + QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/queries/simpleDocument.xml")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3075,7 +3078,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure setQuery() is using the right network manager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq")))); + QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/queries/concat.xq")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3133,9 +3136,9 @@ void tst_QXmlQuery::multipleDocsAndFocus() const /* We use string concatenation, since variable bindings might disturb what * we're testing. */ query.setQuery(QLatin1String("string(doc('") + - inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")) + + inputFile(QLatin1String(XMLPATTERNSDIR "/queries/simpleDocument.xml")) + QLatin1String("'))")); - query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QStringList result; @@ -3159,11 +3162,11 @@ void tst_QXmlQuery::multipleEvaluationsWithDifferentFocus() const QXmlQuery query; QStringList result; - query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QVERIFY(query.evaluateTo(&result)); - query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/stylesheets/documentElement.xml")))); QVERIFY(query.evaluateTo(&result)); } |