summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-01-31 22:25:09 +0200
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-02-17 17:09:50 +0000
commitb07f71a53f0dad132169e6d007b7305857400e99 (patch)
tree6a483eefb79b4f12b0653db56e488149e1765c29 /tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
parent07745d7bfbf6c8d83e0243150d8ce934675dea87 (diff)
Widgets: Update micro focus in QLineEdit and friends
QLineEdit, QAbstractSpinBox and QComboBox did not notify micro focus changes to the input context. In particular, the updates were missed during pre-edit stage. This change adds the missing bindings to QWidget::updateMicroFocus(). Change-Id: I9a7fff962f46dbabd8fb02836c206bace115793b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
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"