Fix failing openInputPanel autotests
authorJoona Petrell <joona.t.petrell@nokia.com>
Mon, 21 Nov 2011 14:50:06 +0000 (16:50 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 22 Nov 2011 02:30:34 +0000 (03:30 +0100)
Task-number: QTBUG-21946
Change-Id: I605aca3ba5b01414c9533ca9673f1b51917df755
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp
tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp

index be058fc..9efb734 100644 (file)
@@ -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()
index 77d5824..434c63a 100644 (file)
@@ -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