summaryrefslogtreecommitdiff
path: root/tests/auto/declarative/qdeclarativetextinput
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-08-22 11:31:22 +1000
committerMichael Brasser <michael.brasser@nokia.com>2011-08-23 11:57:46 +1000
commit2c198b3ace2fb09ed0eaa45aec6ce2c96a45aafb (patch)
treef506f57915d6c3813a20f4215f626de9a02dd9e4 /tests/auto/declarative/qdeclarativetextinput
parentb98e9e69dd8ba33d5f01b9518d95b63b86c4b443 (diff)
downloadqt4-tools-2c198b3ace2fb09ed0eaa45aec6ce2c96a45aafb.tar.gz
Fix left alignment of native RTL pre-edit text.
If there is no committed text in a TextInput or TextEdit determine if the pre-edit text is right to left before falling back to the global keyboard settings. Change-Id: I7e5568e936341602b8faf7be120f9a770c115f48 Task-number: QMLNG-72 Reviewed-by: Michael Brasser
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextinput')
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml1
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp13
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml
index b11535e50b..7f27bbe5cb 100644
--- a/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml
@@ -18,6 +18,7 @@ Rectangle {
objectName: "text"
anchors.fill: parent
text: top.text
+ focus: true
}
}
}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 280f952204..7f3b8a2ec7 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -1198,6 +1198,8 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
QVERIFY(textInput != 0);
canvas->show();
+ const QString rtlText = textInput->text();
+
QDeclarativeTextInputPrivate *textInputPrivate = QDeclarativeTextInputPrivate::get(textInput);
QVERIFY(textInputPrivate != 0);
QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
@@ -1262,6 +1264,17 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ // If there is no commited text, the preedit text should determine the alignment.
+ textInput->setText(QString());
+ { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
+
#ifndef Q_OS_MAC // QTBUG-18040
// empty text with implicit alignment follows the system locale-based
// keyboard input direction from QApplication::keyboardInputDirection