diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-07-07 04:05:29 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-07-07 04:05:29 (GMT) |
commit | be19c343000ffc7099474663c66a13226fa5253c (patch) | |
tree | 84e8c75fbdeab23475bba7cbad75764598d7c23d /tests | |
parent | 98bfc8b8db811eb902290dbe87660ce799a44c27 (diff) | |
download | Qt-be19c343000ffc7099474663c66a13226fa5253c.zip Qt-be19c343000ffc7099474663c66a13226fa5253c.tar.gz Qt-be19c343000ffc7099474663c66a13226fa5253c.tar.bz2 |
More generated images in anticipation of QT-3574
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 28 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 45 |
2 files changed, 45 insertions, 28 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 2025504..6e4aa22 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -64,6 +64,23 @@ #define SRCDIR "." #endif +QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +{ + // XXX This will be replaced by some clever persistent platform image store. + QString persistent_dir = SRCDIR "/data"; + QString arch = "unknown-architecture"; // QTest needs to help with this. + + QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; + + if (!QFile::exists(expectfile)) { + actual.save(expectfile); + qWarning() << "created" << expectfile; + } + + return expectfile; +} + + class tst_qdeclarativetextedit : public QObject { @@ -345,16 +362,7 @@ void tst_qdeclarativetextedit::alignments() QPainter p(&actual); canvas->render(&p); - // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = SRCDIR "/data"; - QString arch = "unknown-architecture"; // QTest needs to help with this. - - expectfile = persistent_dir + QDir::separator() + expectfile + "-" + arch + ".png"; - - if (!QFile::exists(expectfile)) { - actual.save(expectfile); - qWarning() << "created" << expectfile; - } + expectfile = createExpectedFileIfNotFound(expectfile, actual); QImage expect(expectfile); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 5354f42..16d9ac7 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -47,6 +47,7 @@ #include <private/qdeclarativetextinput_p.h> #include <private/qdeclarativetextinput_p_p.h> #include <QDebug> +#include <QDir> #include <QStyle> #include <QInputContext> #include <private/qapplication_p.h> @@ -56,6 +57,22 @@ #define SRCDIR "." #endif +QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +{ + // XXX This will be replaced by some clever persistent platform image store. + QString persistent_dir = SRCDIR "/data"; + QString arch = "unknown-architecture"; // QTest needs to help with this. + + QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; + + if (!QFile::exists(expectfile)) { + actual.save(expectfile); + qWarning() << "created" << expectfile; + } + + return expectfile; +} + class tst_qdeclarativetextinput : public QObject { @@ -381,9 +398,9 @@ void tst_qdeclarativetextinput::horizontalAlignment_data() QTest::addColumn<int>("hAlign"); QTest::addColumn<QString>("expectfile"); - QTest::newRow("L") << int(Qt::AlignLeft) << SRCDIR "/data/halign_left.png"; - QTest::newRow("R") << int(Qt::AlignRight) << SRCDIR "/data/halign_right.png"; - QTest::newRow("C") << int(Qt::AlignHCenter) << SRCDIR "/data/halign_center.png"; + QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left"; + QTest::newRow("R") << int(Qt::AlignRight) << "halign_right"; + QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center"; } void tst_qdeclarativetextinput::horizontalAlignment() @@ -391,13 +408,6 @@ void tst_qdeclarativetextinput::horizontalAlignment() QFETCH(int, hAlign); QFETCH(QString, expectfile); -#ifdef Q_WS_X11 - // Font-specific, but not likely platform-specific, so only test on one platform - QFont fn; - fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*"); - QApplication::setFont(fn); -#endif - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment.qml"); canvas->show(); @@ -409,17 +419,16 @@ void tst_qdeclarativetextinput::horizontalAlignment() ob->setProperty("horizontalAlignment",hAlign); QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); actual.fill(qRgb(255,255,255)); - QPainter p(&actual); - canvas->render(&p); + { + QPainter p(&actual); + canvas->render(&p); + } + + expectfile = createExpectedFileIfNotFound(expectfile, actual); QImage expect(expectfile); -#ifdef Q_WS_X11 - // Font-specific, but not likely platform-specific, so only test on one platform - if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") { - QCOMPARE(actual,expect); - } -#endif + QCOMPARE(actual,expect); } void tst_qdeclarativetextinput::positionAt() |