summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextinput
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/qdeclarativetextinput
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/qdeclarativetextinput')
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 7753f11..45f2cf7 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -914,17 +914,48 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
QVERIFY(textInputPrivate != 0);
QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
- // "Right" Align
- textInput->setHAlign(QDeclarativeTextInput::AlignRight);
+ // implicit alignment should follow the reading direction of RTL text
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+
+ // explicitly left aligned
+ textInput->setHAlign(QDeclarativeTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
- // Center Align
+ // explicitly right aligned
+ textInput->setHAlign(QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+
+ // explicitly center aligned
textInput->setHAlign(QDeclarativeTextInput::AlignHCenter);
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignHCenter);
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
QVERIFY(-textInputPrivate->hscroll + textInputPrivate->width() > canvas->width()/2);
+ // reseted alignment should go back to following the text reading direction
+ textInput->resetHAlign();
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+
+ // English text should be implicitly left aligned
+ textInput->setText("Hello world!");
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
+ QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
+
+ // empty text should implicitly follow the layout direction
+ QApplication::setLayoutDirection(Qt::RightToLeft);
+ textInput->setText("");
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+ textInput->setHAlign(QDeclarativeTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
+ QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
+
+ // set layout direction back to LTR to avoid affecting other autotests
+ QApplication::setLayoutDirection(Qt::LeftToRight);
+
delete canvas;
}