diff options
Diffstat (limited to 'tests/auto/declarative')
6 files changed, 122 insertions, 5 deletions
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml b/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml new file mode 100644 index 0000000..07601c7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml @@ -0,0 +1,33 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + + FocusScope { + focus: true + Rectangle { + objectName: "item1" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + Rectangle { + objectName: "item2" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + } + + FocusScope { + Rectangle { + objectName: "item3" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + Rectangle { + objectName: "item4" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + } +} diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index b0c9c03..ec8f048 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -69,6 +69,7 @@ private slots: void textEdit(); void forceFocus(); void noParentFocus(); + void signalEmission(); }; /* @@ -335,7 +336,7 @@ void tst_qdeclarativefocusscope::noParentFocus() view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml")); QVERIFY(view->rootObject()); - QVERIFY(view->rootObject()->property("focus1") == true); + QVERIFY(view->rootObject()->property("focus1") == false); QVERIFY(view->rootObject()->property("focus2") == false); QVERIFY(view->rootObject()->property("focus3") == true); QVERIFY(view->rootObject()->property("focus4") == true); @@ -344,6 +345,61 @@ void tst_qdeclarativefocusscope::noParentFocus() delete view; } +void tst_qdeclarativefocusscope::signalEmission() +{ + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/signalEmission.qml")); + + QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1")); + QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2")); + QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3")); + QDeclarativeRectangle *item4 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item4")); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + QVERIFY(item4 != 0); + + view->show(); + qApp->setActiveWindow(view); + qApp->processEvents(); + +#ifdef Q_WS_X11 + // to be safe and avoid failing setFocus with window managers + qt_x11_wait_for_window_manager(view); +#endif + + QVariant blue(QColor("blue")); + QVariant red(QColor("red")); + + QVERIFY(view->hasFocus()); + QVERIFY(view->scene()->hasFocus()); + item1->setFocus(true); + QCOMPARE(item1->property("color"), red); + QCOMPARE(item2->property("color"), blue); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + item2->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + item3->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), red); + QCOMPARE(item4->property("color"), blue); + + item4->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), red); + + delete view; +} + QTEST_MAIN(tst_qdeclarativefocusscope) #include "tst_qdeclarativefocusscope.moc" diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index d5a911a..db1f191 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -585,7 +585,7 @@ void tst_qdeclarativeinstruction::dump() << "45\t\t48\tDEFER\t\t\t7" << "46\t\tNA\tDEFER\t\t\t7" << "47\t\t48\tSTORE_IMPORTED_SCRIPT\t2" - << "48\t\t50\tXXX UNKOWN INSTRUCTION\t1234" + << "48\t\t50\tXXX UNKNOWN INSTRUCTION\t1234" << "49\t\t51\tSTORE_VARIANT_INTEGER\t\t32\t11" << "50\t\t52\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" << "-------------------------------------------------------------------------------"; diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug3.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug3.qml new file mode 100644 index 0000000..54b5b68 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug3.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +Rectangle { + width: 300 + height: 300 + + Rectangle { + height: childrenRect.height + + Repeater { + model: 1 + Rectangle { } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index d76d360..25ca157 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -75,6 +75,7 @@ private slots: void childrenRect(); void childrenRectBug(); void childrenRectBug2(); + void childrenRectBug3(); void childrenProperty(); void resourcesProperty(); @@ -780,6 +781,17 @@ void tst_QDeclarativeItem::childrenRectBug2() delete canvas; } +// QTBUG-12722 +void tst_QDeclarativeItem::childrenRectBug3() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug3.qml")); + canvas->show(); + + //don't crash on delete + delete canvas; +} + template<typename T> T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 858c26d..10805b4 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -271,6 +271,9 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << ""; QTest::newRow("nested-set") << "{append({'foo':123});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << ""; + QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << ""; + QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << ""; + // XXX //QTest::newRow("nested-setprop") << "{append({'foo':123});setProperty(0,'foo',[{'x':123}]);get(0).foo.get(0).x}" << 123 << ""; } @@ -344,9 +347,7 @@ void tst_qdeclarativelistmodel::dynamic_worker() waitForWorker(item); QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString()); - if (QByteArray(QTest::currentDataTag()).startsWith("nested")) - QVERIFY(e.evaluate().toInt() != result); - else + if (!QByteArray(QTest::currentDataTag()).startsWith("nested")) QCOMPARE(e.evaluate().toInt(), result); } |