summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index add3c7b..375e801 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -43,6 +43,9 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <private/qdeclarativefontloader_p.h>
#include "../../../shared/util.h"
+#include "../shared/testhttpserver.h"
+
+#define SERVER_PORT 14445
class tst_qdeclarativefontloader : public QObject
@@ -57,16 +60,21 @@ private slots:
void localFont();
void failLocalFont();
void webFont();
+ void redirWebFont();
void failWebFont();
private slots:
private:
QDeclarativeEngine engine;
+ TestHTTPServer server;
};
-tst_qdeclarativefontloader::tst_qdeclarativefontloader()
+tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
+ server(SERVER_PORT)
{
+ server.serveDirectory(SRCDIR "/data");
+ Q_ASSERT(server.isValid());
}
void tst_qdeclarativefontloader::noFont()
@@ -126,21 +134,38 @@ void tst_qdeclarativefontloader::failLocalFont()
void tst_qdeclarativefontloader::webFont()
{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }";
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/tarzeau_ocr_a.ttf\" }";
+ QDeclarativeComponent component(&engine);
+
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::redirWebFont()
+{
+ server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
+
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/olddir/oldname.ttf\" }";
QDeclarativeComponent component(&engine);
+
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("Starburst"));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
}
void tst_qdeclarativefontloader::failWebFont()
{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.nokia.com/Starburst.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.nokia.com/Starburst.ttf\" ) ");
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/nonexist.ttf\" }";
+ QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://localhost:14445/nonexist.ttf\" ) ");
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());