diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-03-18 04:55:34 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-03-23 05:00:09 (GMT) |
commit | fad4cdb70323a2c1925c31917ce2b6cff62748b0 (patch) | |
tree | 42eb46b2a45f792391475ca5528b851f0ee38a8b /tests/auto/declarative | |
parent | ccf9a964f55ce6b7404f2b2fbd9345697d37bea3 (diff) | |
download | Qt-fad4cdb70323a2c1925c31917ce2b6cff62748b0.zip Qt-fad4cdb70323a2c1925c31917ce2b6cff62748b0.tar.gz Qt-fad4cdb70323a2c1925c31917ce2b6cff62748b0.tar.bz2 |
Changing the alignment property should trigger a repaint.
Just clear the cache when the property changes.
Task-number:QTBUG-8155
Reviewed-by:Yann Bodson
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 8b513e8..e623df6 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -72,6 +72,7 @@ private slots: void readOnly(); void sendRequestSoftwareInputPanelEvent(); + void setHAlignClearCache(); private: void simulateKey(QDeclarativeView *, int key); @@ -651,6 +652,38 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.softwareInputPanelEventReceived, true); } +class MyTextInput : public QDeclarativeTextInput +{ +public: + MyTextInput(QDeclarativeItem *parent = 0) : QDeclarativeTextInput(parent) + { + nbPaint = 0; + } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + nbPaint++; + QDeclarativeTextInput::paint(painter, option, widget); + } + int nbPaint; +}; + +void tst_qdeclarativetextinput::setHAlignClearCache() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + MyTextInput input; + input.setText("Hello world"); + scene.addItem(&input); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QCOMPARE(input.nbPaint, 1); + input.setHAlign(QDeclarativeTextInput::AlignRight); + QApplication::processEvents(); + //Changing the alignment should trigger a repaint + QCOMPARE(input.nbPaint, 2); +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" |