summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextedit
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2011-03-01 02:51:27 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2011-03-01 07:40:23 (GMT)
commit88253db8a7d7910e1393b1948fb3747117538c92 (patch)
tree038cb2a758150312a6dfd1d4e6cd5f4bf548e215 /tests/auto/declarative/qdeclarativetextedit
parentd5c72c6fb75357061c5f9e0d0d2efdaff9140741 (diff)
downloadQt-88253db8a7d7910e1393b1948fb3747117538c92.zip
Qt-88253db8a7d7910e1393b1948fb3747117538c92.tar.gz
Qt-88253db8a7d7910e1393b1948fb3747117538c92.tar.bz2
Make sure horizontal QML editor text aligment always returns the actual alignment
Also, implicit empty text alignment now follows the Application's default layout direction traditionally set by the locale. Task-number: QTBUG-15880 Reviewed-by: Martin Jones Change-Id: I88340513d489290bafd393072786a19731097b77
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextedit')
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 87c2c60..eb02936 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -438,20 +438,47 @@ void tst_qdeclarativetextedit::hAlign_RightToLeft()
QVERIFY(textEdit != 0);
canvas->show();
+ // implicit alignment should follow the reading direction of RTL text
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight);
QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
- // "Right" align
+ // explicitly left aligned
+ textEdit->setHAlign(QDeclarativeTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
+
+ // explicitly right aligned
textEdit->setHAlign(QDeclarativeTextEdit::AlignRight);
QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
- // Center align
- // Note that position 0 is on the right-hand side
+ // explicitly center aligned
textEdit->setHAlign(QDeclarativeTextEdit::AlignHCenter);
QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignHCenter);
- QVERIFY(textEdit->positionToRectangle(0).x() - textEdit->width() < canvas->width()/2);
QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
+ // reseted alignment should go back to following the text reading direction
+ textEdit->resetHAlign();
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
+
+ // English text should be implicitly left aligned
+ textEdit->setText("Hello world!");
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
+
+ // empty text should implicitly follow the layout direction
+ QApplication::setLayoutDirection(Qt::RightToLeft);
+ textEdit->setText("");
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
+ textEdit->setHAlign(QDeclarativeTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
+
+ // set layout direction back to LTR to avoid affecting other autotests
+ QApplication::setLayoutDirection(Qt::LeftToRight);
+
delete canvas;
}