summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlfontloader
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-03 12:14:36 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-03 12:14:36 (GMT)
commitd6d473534fdb08a417cc113368742c0ec011a97e (patch)
tree43e021181618d2dc08983a5fc8f03ff5f527cc68 /tests/auto/declarative/qmlfontloader
parentfeeb75edbbe0912f1719cf405be5927da6890d47 (diff)
downloadQt-d6d473534fdb08a417cc113368742c0ec011a97e.zip
Qt-d6d473534fdb08a417cc113368742c0ec011a97e.tar.gz
Qt-d6d473534fdb08a417cc113368742c0ec011a97e.tar.bz2
more qmlfontloader tests
Diffstat (limited to 'tests/auto/declarative/qmlfontloader')
-rw-r--r--tests/auto/declarative/qmlfontloader/data/dummy.ttf0
-rw-r--r--tests/auto/declarative/qmlfontloader/qmlfontloader.pro3
-rw-r--r--tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp32
3 files changed, 33 insertions, 2 deletions
diff --git a/tests/auto/declarative/qmlfontloader/data/dummy.ttf b/tests/auto/declarative/qmlfontloader/data/dummy.ttf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmlfontloader/data/dummy.ttf
diff --git a/tests/auto/declarative/qmlfontloader/qmlfontloader.pro b/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
index 0ecfde0..bc89639 100644
--- a/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
+++ b/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
@@ -3,3 +3,6 @@ contains(QT_CONFIG,declarative): QT += declarative gui
macx:CONFIG -= app_bundle
SOURCES += tst_qmlfontloader.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
index 464ae5d..4bbc595 100644
--- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
+++ b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
@@ -55,7 +55,9 @@ private slots:
void nofont();
void namedfont();
void localfont();
+ void faillocalfont();
void webfont();
+ void failwebfont();
private slots:
@@ -75,6 +77,7 @@ void tst_qmlfontloader::nofont()
QVERIFY(fontObject != 0);
QCOMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QmlFontLoader::Null);
}
void tst_qmlfontloader::namedfont()
@@ -85,16 +88,29 @@ void tst_qmlfontloader::namedfont()
QVERIFY(fontObject != 0);
QCOMPARE(fontObject->name(), QString("Helvetica"));
+ QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
}
void tst_qmlfontloader::localfont()
{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"data/Fontin-Bold.ttf\" }";
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/Fontin-Bold.ttf\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->name(), QString("Fontin"));
+ QTRY_COMPARE(fontObject->name(), QString("Fontin"));
+ QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
+}
+
+void tst_qmlfontloader::faillocalfont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/dummy.ttf\" }";
+ QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
+ QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
}
void tst_qmlfontloader::webfont()
@@ -105,6 +121,18 @@ void tst_qmlfontloader::webfont()
QVERIFY(fontObject != 0);
QTRY_COMPARE(fontObject->name(), QString("Starburst"));
+ QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
+}
+
+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://"));
+ QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
}
QTEST_MAIN(tst_qmlfontloader)