summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlengine.cpp9
-rw-r--r--src/declarative/qml/qmlengine_p.h4
-rw-r--r--tests/auto/declarative/qfxtextinput/data/navigation.qml23
-rw-r--r--tests/auto/declarative/qfxtextinput/qfxtextinput.pro6
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp78
5 files changed, 108 insertions, 12 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index d2d0590..9a5efdb 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -107,7 +107,7 @@ QScriptValue desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
}
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
-: rootContext(0), currentBindContext(0), currentExpression(0),
+: rootContext(0), currentExpression(0),
isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0),
nodeListClass(0), namedNodeMapClass(0), scriptEngine(this), rootComponent(0),
networkAccessManager(0), typeManager(e), uniqueId(1)
@@ -199,13 +199,6 @@ void QmlEnginePrivate::init()
}
}
-QmlContext *QmlEnginePrivate::setCurrentBindContext(QmlContext *c)
-{
- QmlContext *old = currentBindContext;
- currentBindContext = c;
- return old;
-}
-
QmlEnginePrivate::CapturedProperty::CapturedProperty(const QmlMetaProperty &p)
: object(p.object()), coreIndex(p.coreIndex()), notifyIndex(p.property().notifySignalIndex())
{
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index b3c6279..b595e7c 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -114,7 +114,6 @@ public:
QPODVector<CapturedProperty> capturedProperties;
QmlContext *rootContext;
- QmlContext *currentBindContext; // ### Remove me
QmlExpression *currentExpression;
bool isDebugging;
#ifdef QT_SCRIPTTOOLS_LIB
@@ -128,9 +127,6 @@ public:
QScriptClass *nodeListClass;
QScriptClass *namedNodeMapClass;
- QmlContext *setCurrentBindContext(QmlContext *);
- QStack<QmlContext *> activeContexts; // ### Remove me
-
struct QmlScriptEngine : public QScriptEngine
{
QmlScriptEngine(QmlEnginePrivate *priv)
diff --git a/tests/auto/declarative/qfxtextinput/data/navigation.qml b/tests/auto/declarative/qfxtextinput/data/navigation.qml
new file mode 100644
index 0000000..c1a6162
--- /dev/null
+++ b/tests/auto/declarative/qfxtextinput/data/navigation.qml
@@ -0,0 +1,23 @@
+import Qt 4.6
+
+Rectangle {
+ property var myInput: Input
+
+ width: 800; height: 600; color: "blue"
+
+ Item {
+ id: FirstItem
+ KeyNavigation.right: Input
+ }
+
+ TextInput { id: Input; focus: true;
+ KeyNavigation.left: FirstItem
+ KeyNavigation.right: LastItem
+ KeyNavigation.up: FirstItem
+ KeyNavigation.down: LastItem
+ }
+ Item {
+ id: LastItem
+ KeyNavigation.left: Input
+ }
+}
diff --git a/tests/auto/declarative/qfxtextinput/qfxtextinput.pro b/tests/auto/declarative/qfxtextinput/qfxtextinput.pro
new file mode 100644
index 0000000..396e66d
--- /dev/null
+++ b/tests/auto/declarative/qfxtextinput/qfxtextinput.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+SOURCES += tst_qfxtextinput.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
new file mode 100644
index 0000000..852a868
--- /dev/null
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -0,0 +1,78 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QFile>
+#include <QtDeclarative/qfxview.h>
+#include <qfxtextinput.h>
+#include <QDebug>
+
+class tst_qfxtextinput : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qfxtextinput();
+
+private slots:
+ void navigation();
+
+private:
+ void simulateKey(QFxView *, int key);
+ QFxView *createView(const QString &filename);
+
+ QmlEngine engine;
+};
+
+tst_qfxtextinput::tst_qfxtextinput()
+{
+}
+
+/*
+TextInput element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+*/
+void tst_qfxtextinput::navigation()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QVERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == true);
+}
+
+void tst_qfxtextinput::simulateKey(QFxView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QApplication::sendEvent(view, &press);
+ QApplication::sendEvent(view, &release);
+}
+
+QFxView *tst_qfxtextinput::createView(const QString &filename)
+{
+ QFxView *canvas = new QFxView(0);
+
+ QFile file(filename);
+ file.open(QFile::ReadOnly);
+ QString xml = file.readAll();
+ canvas->setQml(xml, filename);
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_qfxtextinput)
+
+#include "tst_qfxtextinput.moc"