aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2011-11-21 16:50:06 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-22 03:30:34 +0100
commit3ef0ce6b794ed58d26ec6355cc13fd00f66c5176 (patch)
tree980c2d2d1e3a5e5b652756670b720b7b966531fe /tests
parent9132f67d469aaff722ba2b447932dd0d636817ce (diff)
Fix failing openInputPanel autotests
Task-number: QTBUG-21946 Change-Id: I605aca3ba5b01414c9533ca9673f1b51917df755 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp31
-rw-r--r--tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp30
2 files changed, 59 insertions, 2 deletions
diff --git a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
index be058fc838..9efb73409a 100644
--- a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
@@ -61,6 +61,8 @@
#include <QMimeData>
#include <private/qtextcontrol_p.h>
#include "../shared/util.h"
+#include <qplatforminputcontext_qpa.h>
+#include <private/qinputpanel_p.h>
#ifdef Q_OS_MAC
#include <Carbon/Carbon.h>
@@ -1993,8 +1995,33 @@ void tst_qquicktextedit::textInput()
QCOMPARE(editPrivate->text, QString("Hello world!"));
}
+class PlatformInputContext : public QPlatformInputContext
+{
+public:
+ PlatformInputContext() : m_visible(false) {}
+
+ virtual void showInputPanel()
+ {
+ m_visible = true;
+ }
+ virtual void hideInputPanel()
+ {
+ m_visible = false;
+ }
+ virtual bool isInputPanelVisible() const
+ {
+ return m_visible;
+ }
+
+ bool m_visible;
+};
+
void tst_qquicktextedit::openInputPanel()
{
+ PlatformInputContext platformInputContext;
+ QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
+ inputPanelPrivate->testContext = &platformInputContext;
+
QQuickView view(QUrl::fromLocalFile(TESTDATA("openInputPanel.qml")));
view.show();
view.requestActivateWindow();
@@ -2009,7 +2036,7 @@ void tst_qquicktextedit::openInputPanel()
QVERIFY(!edit->hasActiveFocus());
qDebug() << &edit << qApp->inputPanel()->inputItem();
QCOMPARE(qApp->inputPanel()->inputItem(), static_cast<QObject*>(0));
- QEXPECT_FAIL("", "QTBUG-21946", Abort);
+
QCOMPARE(qApp->inputPanel()->visible(), false);
// input panel should open on focus
@@ -2079,6 +2106,8 @@ void tst_qquicktextedit::openInputPanel()
// input panel should close when closeSoftwareInputPanel is called
edit->closeSoftwareInputPanel();
QCOMPARE(qApp->inputPanel()->visible(), false);
+
+ inputPanelPrivate->testContext = 0;
}
void tst_qquicktextedit::geometrySignals()
diff --git a/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp
index 77d5824a51..434c63a779 100644
--- a/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp
@@ -54,6 +54,8 @@
#include <QInputContext>
#include <QtOpenGL/QGLShaderProgram>
#include <math.h>
+#include <qplatforminputcontext_qpa.h>
+#include <private/qinputpanel_p.h>
#ifdef Q_OS_MAC
#include <Carbon/Carbon.h>
@@ -2149,8 +2151,33 @@ void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
QGuiApplication::sendEvent(view, &release);
}
+class PlatformInputContext : public QPlatformInputContext
+{
+public:
+ PlatformInputContext() : m_visible(false) {}
+
+ virtual void showInputPanel()
+ {
+ m_visible = true;
+ }
+ virtual void hideInputPanel()
+ {
+ m_visible = false;
+ }
+ virtual bool isInputPanelVisible() const
+ {
+ return m_visible;
+ }
+
+ bool m_visible;
+};
+
void tst_qquicktextinput::openInputPanel()
{
+ PlatformInputContext platformInputContext;
+ QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
+ inputPanelPrivate->testContext = &platformInputContext;
+
QQuickView view(QUrl::fromLocalFile(TESTDATA("openInputPanel.qml")));
view.show();
view.requestActivateWindow();
@@ -2165,7 +2192,6 @@ void tst_qquicktextinput::openInputPanel()
QVERIFY(!input->hasActiveFocus());
qDebug() << &input << qApp->inputPanel()->inputItem();
QCOMPARE(qApp->inputPanel()->inputItem(), static_cast<QObject*>(0));
- QEXPECT_FAIL("", "QTBUG-21946", Abort);
QCOMPARE(qApp->inputPanel()->visible(), false);
// input panel should open on focus
@@ -2235,6 +2261,8 @@ void tst_qquicktextinput::openInputPanel()
// input panel should close when closeSoftwareInputPanel is called
input->closeSoftwareInputPanel();
QCOMPARE(qApp->inputPanel()->visible(), false);
+
+ inputPanelPrivate->testContext = 0;
}
class MyTextInput : public QQuickTextInput