diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
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" |