summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-08-11 11:50:37 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-08-11 11:50:37 (GMT)
commitc6ed32dc7e9c8a566f376d1baa7e616a1019f9af (patch)
tree95ce43172963aa266630d8836ccb6b23dde78991 /tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
parent9986c3f0c0681c7ea8bc8e5cfea5662880db6654 (diff)
parent5fa15620d09df1164cc28aa9b1e646a61f87e909 (diff)
downloadQt-c6ed32dc7e9c8a566f376d1baa7e616a1019f9af.zip
Qt-c6ed32dc7e9c8a566f376d1baa7e616a1019f9af.tar.gz
Qt-c6ed32dc7e9c8a566f376d1baa7e616a1019f9af.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp58
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"