summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativefocusscope
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-08-05 04:36:57 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-08-05 04:38:13 (GMT)
commiteb8c7d19c98d547f89caa1b5866fd2b5e43b32bf (patch)
tree56656466ea742db7741fc9987d88b67375193e9f /tests/auto/declarative/qdeclarativefocusscope
parent5a98d58c1ed78262c20b05aa178a92b4a1a097df (diff)
downloadQt-eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf.zip
Qt-eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf.tar.gz
Qt-eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf.tar.bz2
Make sure onFocusChanged is correctly emitted for items in a FocusScope.
Task-number: QTBUG-12649 Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativefocusscope')
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
index b0c9c03..b138f61 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();
};
/*
@@ -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"