summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-03 23:12:19 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-03 23:12:19 (GMT)
commit7ca289fbbef4e8337124ce9e086b2c5b517ecbaa (patch)
treed8b765a5a158959b610a55c83cd2dffe066d6637 /tests/auto
parentd6d473534fdb08a417cc113368742c0ec011a97e (diff)
downloadQt-7ca289fbbef4e8337124ce9e086b2c5b517ecbaa.zip
Qt-7ca289fbbef4e8337124ce9e086b2c5b517ecbaa.tar.gz
Qt-7ca289fbbef4e8337124ce9e086b2c5b517ecbaa.tar.bz2
tests fixes
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp26
-rw-r--r--tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp47
2 files changed, 54 insertions, 19 deletions
diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
index 4bbc595..efc86cd 100644
--- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
+++ b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
@@ -52,12 +52,12 @@ public:
tst_qmlfontloader();
private slots:
- void nofont();
- void namedfont();
- void localfont();
- void faillocalfont();
- void webfont();
- void failwebfont();
+ void noFont();
+ void namedFont();
+ void localFont();
+ void failLocalFont();
+ void webFont();
+ void failWebFont();
private slots:
@@ -69,7 +69,7 @@ tst_qmlfontloader::tst_qmlfontloader()
{
}
-void tst_qmlfontloader::nofont()
+void tst_qmlfontloader::noFont()
{
QString componentStr = "import Qt 4.6\nFontLoader { }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
@@ -78,9 +78,11 @@ void tst_qmlfontloader::nofont()
QVERIFY(fontObject != 0);
QCOMPARE(fontObject->name(), QString(""));
QTRY_VERIFY(fontObject->status() == QmlFontLoader::Null);
+
+ delete fontObject;
}
-void tst_qmlfontloader::namedfont()
+void tst_qmlfontloader::namedFont()
{
QString componentStr = "import Qt 4.6\nFontLoader { name: \"Helvetica\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
@@ -91,7 +93,7 @@ void tst_qmlfontloader::namedfont()
QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
}
-void tst_qmlfontloader::localfont()
+void tst_qmlfontloader::localFont()
{
QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/Fontin-Bold.ttf\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
@@ -102,7 +104,7 @@ void tst_qmlfontloader::localfont()
QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
}
-void tst_qmlfontloader::faillocalfont()
+void tst_qmlfontloader::failLocalFont()
{
QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/dummy.ttf\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
@@ -113,7 +115,7 @@ void tst_qmlfontloader::faillocalfont()
QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
}
-void tst_qmlfontloader::webfont()
+void tst_qmlfontloader::webFont()
{
QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
@@ -124,7 +126,7 @@ void tst_qmlfontloader::webfont()
QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
}
-void tst_qmlfontloader::failwebfont()
+void tst_qmlfontloader::failWebFont()
{
QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
index d53de59..b9c12ee 100644
--- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
+++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
@@ -57,6 +57,7 @@ private slots:
void width();
void wrap();
void elide();
+ void textFormat();
// ### these tests may be trivial
void horizontalAlignment();
@@ -145,6 +146,9 @@ void tst_qmlgraphicstext::text()
QVERIFY(textObject != 0);
QCOMPARE(textObject->text(), QString(""));
+ QVERIFY(textObject->width() == 0);
+
+ delete textObject;
}
for (int i = 0; i < standard.size(); i++)
@@ -155,6 +159,7 @@ void tst_qmlgraphicstext::text()
QVERIFY(textObject != 0);
QCOMPARE(textObject->text(), standard.at(i));
+ QVERIFY(textObject->width() > 0);
}
for (int i = 0; i < richText.size(); i++)
@@ -166,6 +171,7 @@ void tst_qmlgraphicstext::text()
QVERIFY(textObject != 0);
QString expected = richText.at(i);
QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
+ QVERIFY(textObject->width() > 0);
}
}
@@ -176,6 +182,7 @@ void tst_qmlgraphicstext::width()
QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+ QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), 0.);
}
@@ -189,7 +196,9 @@ void tst_qmlgraphicstext::width()
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+ QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), qreal(metricWidth));
+ QVERIFY(textObject->textFormat() == QmlGraphicsText::PlainText);
}
for (int i = 0; i < richText.size(); i++)
@@ -204,7 +213,9 @@ void tst_qmlgraphicstext::width()
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+ QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), qreal(documentWidth));
+ QVERIFY(textObject->textFormat() == QmlGraphicsText::RichText);
}
}
@@ -217,6 +228,8 @@ void tst_qmlgraphicstext::wrap()
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
textHeight = textObject->height();
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrap() == true);
QCOMPARE(textObject->width(), 300.);
}
@@ -226,6 +239,7 @@ void tst_qmlgraphicstext::wrap()
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+ QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), 30.);
QVERIFY(textObject->height() > textHeight);
}
@@ -236,6 +250,7 @@ void tst_qmlgraphicstext::wrap()
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+ QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), 30.);
QVERIFY(textObject->height() > textHeight);
}
@@ -246,38 +261,56 @@ void tst_qmlgraphicstext::elide()
{
for (Qt::TextElideMode m = Qt::ElideLeft; m<=Qt::ElideNone; m=Qt::TextElideMode(int(m)+1)) {
const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
- QString elide = "elide: \""+QString(elidename[int(m)])+"\";";
+ QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
// XXX Poor coverage.
{
- QmlComponent textComponent(&engine, ("import Qt 4.6\nText { text: \"\"; "+elide+" width: 300 }").toLatin1(), QUrl("file://"));
+ QmlComponent textComponent(&engine, ("import Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->width(), 300.);
+ QCOMPARE(textObject->width(), 100.);
}
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "import Qt 4.6\nText { "+elide+" width: 300; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->width(), 300.);
+ QCOMPARE(textObject->width(), 100.);
}
// richtext - does nothing
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "import Qt 4.6\nText { "+elide+" width: 300; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->width(), 300.);
+ QCOMPARE(textObject->width(), 100.);
}
}
}
+void tst_qmlgraphicstext::textFormat()
+{
+ {
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl("file://"));
+ QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QmlGraphicsText::RichText);
+ }
+ {
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl("file://"));
+ QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QmlGraphicsText::PlainText);
+ }
+}
+
//the alignment tests may be trivial o.oa
void tst_qmlgraphicstext::horizontalAlignment()
{