From: Joona Petrell Date: Mon, 21 Nov 2011 14:50:06 +0000 (+0200) Subject: Fix failing openInputPanel autotests X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=3ef0ce6b794ed58d26ec6355cc13fd00f66c5176;p=konrad%2Fqtdeclarative.git Fix failing openInputPanel autotests Task-number: QTBUG-21946 Change-Id: I605aca3ba5b01414c9533ca9673f1b51917df755 Reviewed-by: Lars Knoll --- diff --git a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp index be058fc..9efb734 100644 --- a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp @@ -61,6 +61,8 @@ #include #include #include "../shared/util.h" +#include +#include #ifdef Q_OS_MAC #include @@ -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(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 77d5824..434c63a 100644 --- a/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp @@ -54,6 +54,8 @@ #include #include #include +#include +#include #ifdef Q_OS_MAC #include @@ -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(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