aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextinput
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-07-09 16:33:21 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-11 12:36:02 +0200
commite89a17af703250f06002e16fd00e9ed407769fc4 (patch)
tree9c4980881faaf1b7d99b3d9ac39d8cf1ad5d8d06 /tests/auto/quick/qquicktextinput
parentbcf3afa90f371b7ea0d32285d6065046e9296f52 (diff)
Add tests for instantiating cursor delegates in the Loading state.
Components created by QML are usually (always?) ready when assigned to n property, but it possible for an externally supplied component to still be loading, as in the test and the code handles it. Change-Id: I2058e3479e2e711b52af2a0128e6e4c4c3ff7504 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
-rw-r--r--tests/auto/quick/qquicktextinput/data/RemoteCursor.qml5
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTestRemote.qml12
-rw-r--r--tests/auto/quick/qquicktextinput/qquicktextinput.pro5
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp37
4 files changed, 58 insertions, 1 deletions
diff --git a/tests/auto/quick/qquicktextinput/data/RemoteCursor.qml b/tests/auto/quick/qquicktextinput/data/RemoteCursor.qml
new file mode 100644
index 0000000000..7f459f5cc4
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/data/RemoteCursor.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Rectangle {
+ objectName: "cursorInstance"
+}
diff --git a/tests/auto/quick/qquicktextinput/data/cursorTestRemote.qml b/tests/auto/quick/qquicktextinput/data/cursorTestRemote.qml
new file mode 100644
index 0000000000..8ae872a714
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/data/cursorTestRemote.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Rectangle { width: 300; height: 300; color: "white"
+ TextInput {
+ text: "Hello world!"
+ id: textInputObject;
+ objectName: "textInputObject"
+ width: 300; height: 300
+ wrapMode: TextInput.Wrap
+ cursorDelegate: contextDelegate
+ }
+}
diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
index 13b087eef5..76cb177c3d 100644
--- a/tests/auto/quick/qquicktextinput/qquicktextinput.pro
+++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
@@ -2,7 +2,10 @@ CONFIG += testcase
TARGET = tst_qquicktextinput
macx:CONFIG -= app_bundle
-SOURCES += tst_qquicktextinput.cpp
+SOURCES += tst_qquicktextinput.cpp \
+ ../../shared/testhttpserver.cpp
+
+HEADERS += ../../shared/testhttpserver.h
include (../../shared/util.pri)
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 4261fafec4..46267673a8 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -41,6 +41,7 @@
#include <qtest.h>
#include <QtTest/QSignalSpy>
#include "../../shared/util.h"
+#include "../../shared/testhttpserver.h"
#include <private/qinputmethod_p.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlexpression.h>
@@ -62,6 +63,9 @@
#include "qplatformdefs.h"
#include "../../shared/platforminputcontext.h"
+#define SERVER_PORT 14460
+#define SERVER_ADDR "http://localhost:14460"
+
Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
Q_DECLARE_METATYPE(QQuickTextInput::EchoMode)
Q_DECLARE_METATYPE(Qt::Key)
@@ -142,6 +146,7 @@ private slots:
void passwordCharacter();
void cursorDelegate_data();
void cursorDelegate();
+ void remoteCursorDelegate();
void cursorVisible();
void cursorRectangle_data();
void cursorRectangle();
@@ -2603,6 +2608,38 @@ void tst_qquicktextinput::cursorDelegate()
QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
}
+void tst_qquicktextinput::remoteCursorDelegate()
+{
+ TestHTTPServer server(SERVER_PORT);
+ server.serveDirectory(dataDirectory());
+
+ QQuickView view;
+
+ QQmlComponent component(view.engine(), QUrl(SERVER_ADDR "/RemoteCursor.qml"));
+
+ view.rootContext()->setContextProperty("contextDelegate", &component);
+ view.setSource(testFileUrl("cursorTestRemote.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+
+ // Delegate is created on demand, and so won't be available immediately. Focus in or
+ // setCursorVisible(true) will trigger creation.
+ QTRY_VERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
+ QVERIFY(!textInputObject->isCursorVisible());
+
+ textInputObject->setFocus(true);
+ QVERIFY(textInputObject->isCursorVisible());
+
+ QCOMPARE(component.status(), QQmlComponent::Loading);
+ QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
+
+ // Wait for component to load.
+ QTRY_COMPARE(component.status(), QQmlComponent::Ready);
+ QVERIFY(textInputObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
void tst_qquicktextinput::cursorVisible()
{
QQuickTextInput input;