summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextinput
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2011-03-07 03:10:08 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2011-03-07 05:20:12 (GMT)
commit27e4302b7f45f22180693d26747f419177c81e27 (patch)
tree5d25d8460e785cd6ac3db10d2516ebd1667bf7ae /tests/auto/declarative/qdeclarativetextinput
parent7872985cc2eb21ae9283aa8e6779f490b500dff0 (diff)
downloadQt-27e4302b7f45f22180693d26747f419177c81e27.zip
Qt-27e4302b7f45f22180693d26747f419177c81e27.tar.gz
Qt-27e4302b7f45f22180693d26747f419177c81e27.tar.bz2
Reverse horizontal alignment of QML editors when the layout mirroring is enabled
Task-number: QTBUG-15880 Reviewed-by: Martin Jones Change-Id: Ie9cebd7bc6d40f5f555bfd83ddc3a24a55c6cb4d
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextinput')
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 666bbc8..bcae3fc 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -1050,20 +1050,24 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
// implicit alignment should follow the reading direction of RTL text
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
// explicitly left aligned
textInput->setHAlign(QDeclarativeTextInput::AlignLeft);
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
// explicitly right aligned
textInput->setHAlign(QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
// explicitly center aligned
textInput->setHAlign(QDeclarativeTextInput::AlignHCenter);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignHCenter);
QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
QVERIFY(-textInputPrivate->hscroll + textInputPrivate->width() > canvas->width()/2);
@@ -1071,8 +1075,34 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
// reseted alignment should go back to following the text reading direction
textInput->resetHAlign();
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+ // mirror the text item
+ QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+
+ // explicitly right aligned behaves as left aligned
+ textInput->setHAlign(QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), QDeclarativeTextInput::AlignLeft);
+ QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
+
+ // mirrored explicitly left aligned behaves as right aligned
+ textInput->setHAlign(QDeclarativeTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);
+ QCOMPARE(textInput->effectiveHAlign(), QDeclarativeTextInput::AlignRight);
+ QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
+
+ // disable mirroring
+ QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(false);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ textInput->resetHAlign();
+
// English text should be implicitly left aligned
textInput->setText("Hello world!");
QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft);