From 69d6a95a4c12bacb700f3d7ccc9188d3cc22c8ae Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 4 Nov 2009 14:34:22 +1000 Subject: more autotests --- .../declarative/animations/color-animation.qml | 5 +- .../qmlgraphicstext/tst_qmlgraphicstext.cpp | 257 ++++++++++++++++++--- 2 files changed, 226 insertions(+), 36 deletions(-) diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml index edb0659..54608c7 100644 --- a/examples/declarative/animations/color-animation.qml +++ b/examples/declarative/animations/color-animation.qml @@ -31,10 +31,7 @@ Item { Item { width: parent.width; height: 2 * parent.height transformOrigin: Item.Center - rotation: SequentialAnimation { - running: true; repeat: true - NumberAnimation { from: 0; to: 360; duration: 10000 } - } + rotation: NumberAnimation { from: 0; to: 360; duration: 10000; running: true; repeat: true } Image { source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter transformOrigin: Item.Center; rotation: -3 * parent.rotation diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp index 1a90575..3e86cab 100644 --- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp +++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include class tst_qmlgraphicstext : public QObject @@ -67,6 +68,15 @@ private slots: void color(); void smooth(); + // QmlFontValueType + void weight(); + void underline(); + void overline(); + void strikeout(); + void capitalization(); + void letterSpacing(); + void wordSpacing(); + private: QStringList standard; QStringList richText; @@ -88,54 +98,54 @@ private: tst_qmlgraphicstext::tst_qmlgraphicstext() { standard << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox\n jumped over the lazy dog"; + << "the quick brown fox\n jumped over the lazy dog"; richText << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox
jumped over the lazy dog
"; + << "the quick brown fox
jumped over the lazy dog
"; horizontalAlignmentmentStrings << "AlignLeft" - << "AlignRight" - << "AlignHCenter"; + << "AlignRight" + << "AlignHCenter"; verticalAlignmentmentStrings << "AlignTop" - << "AlignBottom" - << "AlignVCenter"; + << "AlignBottom" + << "AlignVCenter"; horizontalAlignmentments << Qt::AlignLeft - << Qt::AlignRight - << Qt::AlignHCenter; + << Qt::AlignRight + << Qt::AlignHCenter; verticalAlignmentments << Qt::AlignTop - << Qt::AlignBottom - << Qt::AlignVCenter; + << Qt::AlignBottom + << Qt::AlignVCenter; styleStrings << "Normal" - << "Outline" - << "Raised" - << "Sunken"; + << "Outline" + << "Raised" + << "Sunken"; styles << QmlGraphicsText::Normal - << QmlGraphicsText::Outline - << QmlGraphicsText::Raised - << QmlGraphicsText::Sunken; + << QmlGraphicsText::Outline + << QmlGraphicsText::Raised + << QmlGraphicsText::Sunken; colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; - // - // need a different test to do alpha channel test - // << "#AA0011DD" - // << "#00F16B11"; - // + << "antiquewhite" + << "aqua" + << "darkkhaki" + << "darkolivegreen" + << "dimgray" + << "palevioletred" + << "lightsteelblue" + << "#000000" + << "#AAAAAA" + << "#FFFFFF" + << "#2AC05F"; + // + // need a different test to do alpha channel test + // << "#AA0011DD" + // << "#00F16B11"; + // } void tst_qmlgraphicstext::text() @@ -353,6 +363,8 @@ void tst_qmlgraphicstext::verticalAlignment() QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); } } @@ -365,6 +377,7 @@ void tst_qmlgraphicstext::verticalAlignment() QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + QVERIFY(textObject != 0); QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); } } @@ -528,6 +541,186 @@ void tst_qmlgraphicstext::smooth() } } +void tst_qmlgraphicstext::weight() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Normal); + } + { + QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Bold); + } +} + +void tst_qmlgraphicstext::underline() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().underline(), false); + } + { + QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().underline(), true); + } +} + +void tst_qmlgraphicstext::overline() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().overline(), false); + } + { + QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().overline(), true); + } +} + +void tst_qmlgraphicstext::strikeout() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().strikeOut(), false); + } + { + QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().strikeOut(), true); + } +} + +void tst_qmlgraphicstext::capitalization() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::MixedCase); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllUppercase); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllLowercase); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::SmallCaps); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::Capitalize); + } +} + +void tst_qmlgraphicstext::letterSpacing() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), 0.0); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), -50.); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), 200.); + } +} + +void tst_qmlgraphicstext::wordSpacing() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), 0.0); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), -50.); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), 200.); + } +} + QTEST_MAIN(tst_qmlgraphicstext) #include "tst_qmlgraphicstext.moc" -- cgit v0.12