diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-07-24 15:54:28 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-30 07:18:57 +0200 |
commit | 33027ec13451ad078d655d55d474a0f281ee8f9e (patch) | |
tree | cd109a0a1d5f59a0a5c5d3d4adc9b0ef89a55487 /tests/auto/quick/qquicktext | |
parent | 59c13497ef6e2e48bcb277bfc9562f3d962e6d19 (diff) |
Add tests for Text(*) default property values and notifiers.
Change-Id: I64bfe285ab4ddad53a4d323ca93b15ea0426ed51
Reviewed-by: Damian Jansen <damian.jansen@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicktext')
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 99 |
1 files changed, 96 insertions, 3 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index e6368c010e..deaaa1315f 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -102,6 +102,7 @@ private slots: void style(); void color(); void smooth(); + void renderType(); // QQuickFontValueType void weight(); @@ -437,6 +438,29 @@ void tst_qquicktext::wrap() delete textObject; } + + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Text {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickText *textObject = qobject_cast<QQuickText *>(object.data()); + QVERIFY(textObject); + + QSignalSpy spy(textObject, SIGNAL(wrapModeChanged())); + + QCOMPARE(textObject->wrapMode(), QQuickText::NoWrap); + + textObject->setWrapMode(QQuickText::Wrap); + QCOMPARE(textObject->wrapMode(), QQuickText::Wrap); + QCOMPARE(spy.count(), 1); + + textObject->setWrapMode(QQuickText::Wrap); + QCOMPARE(spy.count(), 1); + + textObject->setWrapMode(QQuickText::NoWrap); + QCOMPARE(textObject->wrapMode(), QQuickText::NoWrap); + QCOMPARE(spy.count(), 2); + } } void tst_qquicktext::elide() @@ -640,6 +664,29 @@ void tst_qquicktext::textFormat() delete textObject; } + + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Text {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickText *text = qobject_cast<QQuickText *>(object.data()); + QVERIFY(text); + + QSignalSpy spy(text, SIGNAL(textFormatChanged(TextFormat))); + + QCOMPARE(text->textFormat(), QQuickText::AutoText); + + text->setTextFormat(QQuickText::StyledText); + QCOMPARE(text->textFormat(), QQuickText::StyledText); + QCOMPARE(spy.count(), 1); + + text->setTextFormat(QQuickText::StyledText); + QCOMPARE(spy.count(), 1); + + text->setTextFormat(QQuickText::AutoText); + QCOMPARE(text->textFormat(), QQuickText::AutoText); + QCOMPARE(spy.count(), 2); + } } @@ -1077,6 +1124,31 @@ void tst_qquicktext::color() QCOMPARE(textObject->color(), QColor("black")); QCOMPARE(textObject->linkColor(), QColor("blue")); + QSignalSpy colorSpy(textObject, SIGNAL(colorChanged())); + QSignalSpy linkColorSpy(textObject, SIGNAL(linkColorChanged())); + + textObject->setColor(QColor("white")); + QCOMPARE(textObject->color(), QColor("white")); + QCOMPARE(colorSpy.count(), 1); + + textObject->setLinkColor(QColor("black")); + QCOMPARE(textObject->linkColor(), QColor("black")); + QCOMPARE(linkColorSpy.count(), 1); + + textObject->setColor(QColor("white")); + QCOMPARE(colorSpy.count(), 1); + + textObject->setLinkColor(QColor("black")); + QCOMPARE(linkColorSpy.count(), 1); + + textObject->setColor(QColor("black")); + QCOMPARE(textObject->color(), QColor("black")); + QCOMPARE(colorSpy.count(), 2); + + textObject->setLinkColor(QColor("blue")); + QCOMPARE(textObject->linkColor(), QColor("blue")); + QCOMPARE(linkColorSpy.count(), 2); + delete textObject; } @@ -1239,6 +1311,30 @@ void tst_qquicktext::smooth() } } +void tst_qquicktext::renderType() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n Text {}", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickText *text = qobject_cast<QQuickText *>(object.data()); + QVERIFY(text); + + QSignalSpy spy(text, SIGNAL(renderTypeChanged())); + + QCOMPARE(text->renderType(), QQuickText::QtRendering); + + text->setRenderType(QQuickText::NativeRendering); + QCOMPARE(text->renderType(), QQuickText::NativeRendering); + QCOMPARE(spy.count(), 1); + + text->setRenderType(QQuickText::NativeRendering); + QCOMPARE(spy.count(), 1); + + text->setRenderType(QQuickText::QtRendering); + QCOMPARE(text->renderType(), QQuickText::QtRendering); + QCOMPARE(spy.count(), 2); +} + void tst_qquicktext::weight() { { @@ -1437,9 +1533,6 @@ void tst_qquicktext::wordSpacing() } } - - - class EventSender : public QQuickItem { public: |