diff options
author | axis <qt-info@nokia.com> | 2009-04-07 14:28:57 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-05-04 13:24:07 (GMT) |
commit | 0bc0c1c9b09cda459dbfdc16cb4089297160ce85 (patch) | |
tree | 9b619fc14285c3fd1b7dd7598c7f4b4301cc7f33 /tests/auto/qinputcontext | |
parent | 8d08c42c6a5478e8890d59f58483f4eff3d286ca (diff) | |
download | Qt-0bc0c1c9b09cda459dbfdc16cb4089297160ce85.zip Qt-0bc0c1c9b09cda459dbfdc16cb4089297160ce85.tar.gz Qt-0bc0c1c9b09cda459dbfdc16cb4089297160ce85.tar.bz2 |
Implemented RequestSoftwareInputPanel events in QLineEdit.
AutoTest: Included
RevBy: denis
Diffstat (limited to 'tests/auto/qinputcontext')
-rw-r--r-- | tests/auto/qinputcontext/tst_qinputcontext.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 08bf614..5fdd931 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -45,6 +45,7 @@ #include <qinputcontext.h> #include <qlineedit.h> #include <qplaintextedit.h> +#include <qlayout.h> class tst_QInputContext : public QObject { @@ -62,6 +63,7 @@ public slots: private slots: void maximumTextLength(); void filterMouseEvents(); + void requestSoftwareInputPanel(); }; void tst_QInputContext::maximumTextLength() @@ -82,7 +84,7 @@ void tst_QInputContext::maximumTextLength() class QFilterInputContext : public QInputContext { public: - QFilterInputContext() : successful(false) {} + QFilterInputContext() : lastType(QEvent::None) {} ~QFilterInputContext() {} QString identifierName() { return QString(); } @@ -94,26 +96,65 @@ public: bool filterEvent( const QEvent *event ) { - successful = event->type() == QEvent::MouseButtonRelease; + lastType = event->type(); + return false; } public: - bool successful; + QEvent::Type lastType; }; void tst_QInputContext::filterMouseEvents() { QLineEdit le; le.show(); + QApplication::setActiveWindow(&le); QFilterInputContext *ic = new QFilterInputContext; le.setInputContext(ic); QTest::mouseClick(&le, Qt::LeftButton); - QVERIFY(ic->successful); + QCOMPARE(ic->lastType, QEvent::MouseButtonRelease); le.setInputContext(0); } +void tst_QInputContext::requestSoftwareInputPanel() +{ + QWidget w; + QLayout *layout = new QVBoxLayout; + QLineEdit *le1, *le2; + le1 = new QLineEdit; + le2 = new QLineEdit; + layout->addWidget(le1); + layout->addWidget(le2); + w.setLayout(layout); + + QFilterInputContext *ic1, *ic2; + ic1 = new QFilterInputContext; + ic2 = new QFilterInputContext; + le1->setInputContext(ic1); + le2->setInputContext(ic2); + + w.show(); + QApplication::setActiveWindow(&w); + + // Testing single click panel activation. + QApplication::setTwoClicksToRequestSIP(false); + QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QCOMPARE(ic2->lastType, QEvent::RequestSoftwareInputPanel); + + // Testing double click panel activation. + QApplication::setTwoClicksToRequestSIP(true); + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastType != QEvent::RequestSoftwareInputPanel); + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QCOMPARE(ic1->lastType, QEvent::RequestSoftwareInputPanel); + + // Testing right mouse button + QTest::mouseClick(le1, Qt::RightButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastType != QEvent::RequestSoftwareInputPanel); +} + QTEST_MAIN(tst_QInputContext) #include "tst_qinputcontext.moc" |