summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/declarative.pro1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp16
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp11
-rw-r--r--src/imports/multimedia/multimedia.pro2
-rw-r--r--src/imports/particles/particles.pro2
-rw-r--r--src/imports/webkit/webkit.pro2
-rw-r--r--src/imports/widgets/widgets.pro2
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test.qml (renamed from examples/declarative/focusscope/test.qml)11
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test2.qml (renamed from examples/declarative/focusscope/test2.qml)11
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test3.qml (renamed from examples/declarative/focusscope/test3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test4.qml (renamed from examples/declarative/focusscope/test4.qml)9
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test5.qml (renamed from examples/declarative/focusscope/test5.qml)9
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro6
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp278
15 files changed, 330 insertions, 31 deletions
diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro
index bddfbee..0f58738 100644
--- a/examples/declarative/declarative.pro
+++ b/examples/declarative/declarative.pro
@@ -21,7 +21,6 @@ sources.files = \
effects \
fillmode \
focus \
- focusscope \
fonts \
gridview \
layouts \
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 29490e3..05e13a7 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1510,11 +1510,19 @@ QDeclarativeAnchors *QDeclarativeItem::anchors()
void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
{
- QGraphicsObject *i = qobject_cast<QGraphicsObject *>(o);
- if (i) {
- i->setParentItem(static_cast<QDeclarativeItem *>(prop->object));
+ if (!o)
+ return;
+
+ QDeclarativeItem *that = static_cast<QDeclarativeItem *>(prop->object);
+
+ // This test is measurably (albeit only slightly) faster than qobject_cast<>()
+ const QMetaObject *mo = o->metaObject();
+ while (mo && mo != &QGraphicsObject::staticMetaObject) mo = mo->d.superdata;
+
+ if (mo) {
+ QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(o))->setParentItemHelper(that, 0, 0);
} else {
- o->setParent(static_cast<QDeclarativeItem *>(prop->object));
+ o->setParent(that);
}
}
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index abac086..bb742ee 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1463,13 +1463,14 @@ public:
QDeclarativeDirComponents importExtension(const QString &absoluteFilePath, const QString &uri, QDeclarativeEngine *engine) {
QFile file(absoluteFilePath);
- QString dir = QFileInfo(file).path();
QString filecontent;
if (file.open(QFile::ReadOnly)) {
filecontent = QString::fromUtf8(file.readAll());
if (qmlImportTrace())
qDebug() << "QDeclarativeEngine::add: loaded" << absoluteFilePath;
}
+ QDir dir = QFileInfo(file).dir();
+
QDeclarativeDirParser qmldirParser;
qmldirParser.setSource(filecontent);
qmldirParser.parse();
@@ -1479,9 +1480,13 @@ public:
foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser.plugins()) {
- QDir pluginDir(dir + QDir::separator() + plugin.path);
- if (dir.startsWith(QLatin1Char(':')))
+
+ QDir pluginDir = dir.absoluteFilePath(plugin.path);
+
+ // hack for resources, should probably go away
+ if (absoluteFilePath.startsWith(QLatin1Char(':')))
pluginDir = QDir(QCoreApplication::applicationDirPath());
+
QString resolvedFilePath =
QDeclarativeEnginePrivate::get(engine)
->resolvePlugin(pluginDir,
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index 8792e2b..78618fc 100644
--- a/src/imports/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -20,7 +20,7 @@ SOURCES += \
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
+qmldir.files += $$PWD/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro
index 53d9c24..a46db8c 100644
--- a/src/imports/particles/particles.pro
+++ b/src/imports/particles/particles.pro
@@ -14,7 +14,7 @@ HEADERS += \
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
+qmldir.files += $$PWD/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro
index a11f87f..7463a7f 100644
--- a/src/imports/webkit/webkit.pro
+++ b/src/imports/webkit/webkit.pro
@@ -11,7 +11,7 @@ HEADERS += qdeclarativewebview_p.h \
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
+qmldir.files += $$PWD/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro
index bf2576d..cccd8b4 100644
--- a/src/imports/widgets/widgets.pro
+++ b/src/imports/widgets/widgets.pro
@@ -15,7 +15,7 @@ HEADERS += \
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
+qmldir.files += $$PWD/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index bebc54e..2d88058 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -23,6 +23,7 @@ SUBDIRS += \
qdeclarativeborderimage \ # Cover
qdeclarativeflickable \ # Cover
qdeclarativeflipable \ # Cover
+ qdeclarativefocusscope \ # Cover
qdeclarativegridview \ # Cover
qdeclarativeitem \ # Cover
qdeclarativelistview \ # Cover
diff --git a/examples/declarative/focusscope/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
index e4332e7..647e5bf 100644
--- a/examples/declarative/focusscope/test.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
@@ -14,20 +14,21 @@ Rectangle {
Keys.onDigit9Pressed: console.log("Error - FocusScope")
Rectangle {
+ objectName: "item0"
height: 120
width: 420
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ //border.color: myScope.wantsFocus?"blue":"black"
Rectangle {
- id: item1
+ id: item1; objectName: "item1"
x: 10; y: 10
width: 100; height: 100; color: "green"
border.width: 5
border.color: wantsFocus?"blue":"black"
- Keys.onDigit9Pressed: console.log("Top Left");
+ Keys.onDigit9Pressed: console.debug("Top Left");
KeyNavigation.right: item2
focus: true
@@ -38,7 +39,7 @@ Rectangle {
}
Rectangle {
- id: item2
+ id: item2; objectName: "item2"
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
@@ -58,7 +59,7 @@ Rectangle {
Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" }
Rectangle {
- id: item3
+ id: item3; objectName: "item3"
x: 10; y: 300
width: 100; height: 100; color: "green"
border.width: 5
diff --git a/examples/declarative/focusscope/test2.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
index 5b6971a..277fda4 100644
--- a/examples/declarative/focusscope/test2.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
@@ -9,32 +9,31 @@ Rectangle {
FocusScope {
y: 100
- focus: true
+ focus: true; objectName: "item1"
Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
FocusScope {
y: 100
- focus: true
+ focus: true; objectName: "item2"
Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
FocusScope {
y: 100
- focus: true
+ focus: true; objectName: "item3"
Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
FocusScope {
y: 100
- focus: true
+ focus: true; objectName: "item4"
Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
FocusScope {
y: 100
- focus: true
+ focus: true; objectName: "item5"
Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
}
}
}
}
}
-
}
diff --git a/examples/declarative/focusscope/test3.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
index 9344d07..9344d07 100644
--- a/examples/declarative/focusscope/test3.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
diff --git a/examples/declarative/focusscope/test4.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
index cc96df9..d8bd390 100644
--- a/examples/declarative/focusscope/test4.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
@@ -13,15 +13,16 @@ Rectangle {
Keys.onDigit9Pressed: console.log("Error - FocusScope")
Rectangle {
+ objectName: "item0"
height: 120
width: 420
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ //border.color: myScope.wantsFocus?"blue":"black"
Rectangle {
- id: item1
+ id: item1; objectName: "item1"
x: 10; y: 10
width: 100; height: 100; color: "green"
border.width: 5
@@ -37,7 +38,7 @@ Rectangle {
}
Rectangle {
- id: item2
+ id: item2; objectName: "item2"
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
@@ -57,7 +58,7 @@ Rectangle {
Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." }
Rectangle {
- id: item3
+ id: item3; objectName: "item3"
x: 10; y: 300
width: 100; height: 100; color: "green"
border.width: 5
diff --git a/examples/declarative/focusscope/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
index da98350..0b75ec4 100644
--- a/examples/declarative/focusscope/test5.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
@@ -14,12 +14,13 @@ Rectangle {
Keys.onReturnPressed: console.log("Error - FocusScope")
Rectangle {
+ objectName: "item0"
height: 120
width: 420
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ //border.color: myScope.wantsFocus?"blue":"black"
Rectangle {
x: 10; y: 10
@@ -29,7 +30,7 @@ Rectangle {
}
TextEdit {
- id: item1
+ id: item1; objectName: "item1"
x: 20; y: 20
width: 90; height: 90
color: "white"
@@ -42,7 +43,7 @@ Rectangle {
}
Rectangle {
- id: item2
+ id: item2; objectName: "item2"
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
@@ -69,7 +70,7 @@ Rectangle {
}
TextEdit {
- id: item3
+ id: item3; objectName: "item3"
x: 20; y: 310
width: 90; height: 90
color: "white"
diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
new file mode 100644
index 0000000..4d7a9b3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativefocusscope.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
new file mode 100644
index 0000000..1bd8331
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** 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 <qtest.h>
+#include <QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetextedit_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativefocusscope_p.h>
+
+
+class tst_qdeclarativefocusscope : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativefocusscope() {}
+
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id);
+
+private slots:
+ void basic();
+ void nested();
+ void noFocus();
+ void textEdit();
+};
+
+/*
+ Find an item with the specified id.
+*/
+template<typename T>
+T *tst_qdeclarativefocusscope::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ QList<QGraphicsItem *> children = parent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(children.at(i)->toGraphicsObject());
+ if (item) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ return static_cast<T*>(item);
+ }
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+ }
+ return 0;
+}
+
+void tst_qdeclarativefocusscope::basic()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml"));
+
+ QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 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
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == true);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == true);
+
+ delete view;
+}
+
+void tst_qdeclarativefocusscope::nested()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test2.qml"));
+
+ QDeclarativeFocusScope *item1 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeFocusScope *item2 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeFocusScope *item3 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item3"));
+ QDeclarativeFocusScope *item4 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item4"));
+ QDeclarativeFocusScope *item5 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item5"));
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+ QVERIFY(item5 != 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
+
+ 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);
+ delete view;
+}
+
+void tst_qdeclarativefocusscope::noFocus()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test4.qml"));
+
+ QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 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
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ delete view;
+}
+
+void tst_qdeclarativefocusscope::textEdit()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml"));
+
+ QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeTextEdit *item1 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeTextEdit *item3 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 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
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == 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);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == true);
+
+ delete view;
+}
+
+QTEST_MAIN(tst_qdeclarativefocusscope)
+
+#include "tst_qdeclarativefocusscope.moc"