summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 3afdc0a12a..b882055888 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -64,6 +64,9 @@
#include <qproxystyle.h>
#include <qfont.h>
+#include "../../../shared/platforminputcontext.h"
+#include <private/qinputmethod_p.h>
+
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
@@ -80,6 +83,8 @@ public:
tst_QComboBox() {}
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void getSetCheck();
void ensureReturnIsIgnored();
void setEditable();
@@ -162,6 +167,10 @@ private slots:
void task_QTBUG_39088_inputMethodHints();
void task_QTBUG_49831_scrollerNotActivated();
void task_QTBUG_56693_itemFontFromModel();
+ void inputMethodUpdate();
+
+private:
+ PlatformInputContext m_platformInputContext;
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -207,6 +216,18 @@ protected:
QRegion visualRegionForSelection(const QItemSelection &) const { return QRegion(); }
};
+void tst_QComboBox::initTestCase()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &m_platformInputContext;
+}
+
+void tst_QComboBox::cleanupTestCase()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
// Testing get/set functions
void tst_QComboBox::getSetCheck()
{
@@ -3324,5 +3345,59 @@ void tst_QComboBox::task_QTBUG_56693_itemFontFromModel()
box.hidePopup();
}
+void tst_QComboBox::inputMethodUpdate()
+{
+ TestWidget topLevel;
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QComboBox *testWidget = topLevel.comboBox();
+ // make sure we have no lineedit
+ QVERIFY(!testWidget->lineEdit());
+ // test setEditable(true)
+ testWidget->setEditable(true);
+ QVERIFY(testWidget->lineEdit());
+
+ testWidget->activateWindow();
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+ QTRY_COMPARE(qApp->focusObject(), testWidget);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("preedit text", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant());
+ QInputMethodEvent event("preedit text", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event("", attributes);
+ event.setCommitString("preedit text");
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+ QCOMPARE(testWidget->lineEdit()->text(), QString("preedit text"));
+
+ m_platformInputContext.m_updateCallCount = 0;
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(testWidget, &event);
+ }
+ QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"