From 19cdd020abc9effb50b4251fa688e32420b55d30 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 9 Nov 2011 15:09:12 +1000 Subject: [PATCH] Fix expected failure in TextEdit hAlign_RightToLeft test. Send events to the input item instead of the canvas. And apply the fix from 4.8 for the tested condition which somehow wasn't applied when the test itself was. Change-Id: I0f5bfe8fc13fc426b395fa8ef87cb5549789a92e Reviewed-by: Martin Jones --- src/declarative/items/qquicktextedit.cpp | 10 +++++++++- .../qquicktextedit/tst_qquicktextedit.cpp | 9 ++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/declarative/items/qquicktextedit.cpp b/src/declarative/items/qquicktextedit.cpp index 6d66ed9..18d2cb8 100644 --- a/src/declarative/items/qquicktextedit.cpp +++ b/src/declarative/items/qquicktextedit.cpp @@ -550,7 +550,15 @@ bool QQuickTextEditPrivate::determineHorizontalAlignment() { Q_Q(QQuickTextEdit); if (hAlignImplicit && q->isComponentComplete()) { - bool alignToRight = text.isEmpty() ? QGuiApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText; + bool alignToRight; + if (text.isEmpty()) { + const QString preeditText = control->textCursor().block().layout()->preeditAreaText(); + alignToRight = preeditText.isEmpty() + ? QGuiApplication::keyboardInputDirection() == Qt::RightToLeft + : preeditText.isRightToLeft(); + } else { + alignToRight = rightToLeftText; + } return setHAlign(alignToRight ? QQuickTextEdit::AlignRight : QQuickTextEdit::AlignLeft); } return false; diff --git a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp index a23fc76..edb3eb3 100644 --- a/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/declarative/qquicktextedit/tst_qquicktextedit.cpp @@ -572,12 +572,15 @@ void tst_qquicktextedit::hAlign_RightToLeft() QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); textEdit->setText(QString()); - { QInputMethodEvent ev(rtlText, QList()); QGuiApplication::sendEvent(&canvas, &ev); } - QEXPECT_FAIL("", "QTBUG-21691", Abort); + { QInputMethodEvent ev(rtlText, QList()); QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &ev); } QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - { QInputMethodEvent ev("Hello world!", QList()); QGuiApplication::sendEvent(&canvas, &ev); } + { QInputMethodEvent ev("Hello world!", QList()); QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &ev); } QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be + // redundant as an actual input method may take care of it. + { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &ev); } + #ifndef Q_OS_MAC // QTBUG-18040 // empty text with implicit alignment follows the system locale-based // keyboard input direction from QGuiApplication::keyboardInputDirection -- 1.7.2.5