summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp47
-rw-r--r--tests/auto/gui/image/qimagewriter/images/App.icobin0 -> 318 bytes
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp3
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp156
4 files changed, 53 insertions, 153 deletions
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index ac9dadee47..2dbb078ae0 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -50,6 +50,8 @@ private slots:
void nextImageDelay();
void pngCompression_data();
void pngCompression();
+ void write_data();
+ void write();
private:
QString m_IconPath;
@@ -296,6 +298,51 @@ void tst_QIcoImageFormat::pngCompression()
QCOMPARE(image.height(), height);
}
+void tst_QIcoImageFormat::write_data()
+{
+ QTest::addColumn<QSize>("inSize");
+ QTest::addColumn<QSize>("outSize");
+
+ QTest::newRow("64x64") << QSize(64, 64) << QSize(64, 64);
+ QTest::newRow("128x200") << QSize(128, 200) << QSize(128, 200);
+ QTest::newRow("256x256") << QSize(256, 256) << QSize(256, 256);
+ QTest::newRow("400x400") << QSize(400, 400) << QSize(256, 256);
+}
+
+void tst_QIcoImageFormat::write()
+{
+ QFETCH(QSize, inSize);
+ QFETCH(QSize, outSize);
+
+ QImage inImg;
+ {
+ QImageReader reader(m_IconPath + "/valid/Qt.ico");
+ reader.jumpToImage(4);
+ reader.setScaledSize(inSize);
+ inImg = reader.read();
+ QVERIFY(!inImg.isNull());
+ QCOMPARE(inImg.size(), inSize);
+ }
+
+ QBuffer buf;
+ {
+ buf.open(QIODevice::WriteOnly);
+ QImageWriter writer(&buf, "ico");
+ QVERIFY(writer.write(inImg));
+ buf.close();
+ }
+ {
+ buf.open(QIODevice::ReadOnly);
+ QImageReader reader(&buf);
+ QVERIFY(reader.canRead());
+ QCOMPARE(reader.format(), QByteArray("ico"));
+ QImage outImg = reader.read();
+ QVERIFY(!outImg.isNull());
+ QCOMPARE(outImg.size(), outSize);
+ buf.close();
+ }
+}
+
QTEST_MAIN(tst_QIcoImageFormat)
#include "tst_qicoimageformat.moc"
diff --git a/tests/auto/gui/image/qimagewriter/images/App.ico b/tests/auto/gui/image/qimagewriter/images/App.ico
new file mode 100644
index 0000000000..03b80a68f8
--- /dev/null
+++ b/tests/auto/gui/image/qimagewriter/images/App.ico
Binary files differ
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index f48fab4f0a..9e747f8b11 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -179,6 +179,7 @@ void tst_QImageWriter::writeImage_data()
QTest::newRow("PBM: ship63") << QString("ship63.pbm") << true << QByteArray("pbm");
QTest::newRow("XBM: gnus") << QString("gnus.xbm") << false << QByteArray("xbm");
QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg");
+ QTest::newRow("ICO: App") << QString("App.ico") << true << QByteArray("ico");
}
void tst_QImageWriter::writeImage()
@@ -240,7 +241,7 @@ void tst_QImageWriter::writeImage2_data()
QTest::addColumn<QImage>("image");
const QStringList formats = QStringList() << "bmp" << "xpm" << "png"
- << "ppm"; //<< "jpeg";
+ << "ppm" << "ico"; //<< "jpeg";
QImage image0(70, 70, QImage::Format_ARGB32);
image0.fill(QColor(Qt::red).rgb());
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 188c35c14c..894b197968 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -110,158 +110,10 @@ void tst_QFont::exactMatch()
// Check if a non-existing font hasn't an exact match
font = QFont( "BogusFont", 33 );
QVERIFY( !font.exactMatch() );
-
-#ifdef Q_OS_WIN
- QSKIP("Exact matching on windows misses a lot because of the sample chars");
-#endif
-
-
- if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) {
- QVERIFY(QFont("sans").exactMatch());
- QVERIFY(QFont("sans-serif").exactMatch());
- QVERIFY(QFont("serif").exactMatch());
- QVERIFY(QFont("monospace").exactMatch());
- }
-
- QSKIP("This test is bogus on Unix with support for font aliases in fontconfig");
-
- QFontDatabase fdb;
-
- QList<QFontDatabase::WritingSystem> systems = fdb.writingSystems();
- for (int system = 0; system < systems.count(); ++system) {
- QStringList families = fdb.families(systems[system]);
- if (families.isEmpty())
- return;
-
- QStringList::ConstIterator f_it, f_end = families.end();
- for (f_it = families.begin(); f_it != f_end; ++f_it) {
- const QString &family = *f_it;
- if (family.contains('['))
- continue;
-
- QStringList styles = fdb.styles(family);
- QVERIFY(!styles.isEmpty());
- QStringList::ConstIterator s_it, s_end = styles.end();
- for (s_it = styles.begin(); s_it != s_end; ++s_it) {
- const QString &style = *s_it;
-
- if (fdb.isSmoothlyScalable(family, style)) {
- // smoothly scalable font... don't need to load every pointsize
- font = fdb.font(family, style, 12);
- QFontInfo fontinfo(font);
-
- if (! fontinfo.exactMatch()) {
- // Unfortunately, this can fail, since
- // QFontDatabase does not fill in all font
- // properties. Check to make sure that the
- // test didn't fail for obvious reasons
-
- if (fontinfo.family().isEmpty()
- && fontinfo.pointSize() == 0) {
- // this is a box rendering engine... this can happen from
- // time to time, especially on X11 with iso10646-1 or
- // unknown font encodings
- continue;
- }
-
-#ifdef Q_OS_WIN
- if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) {
- /* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s",
- font.family().latin1(), fontinfo.family().latin1());
- */
- } else
-#endif
- {
- if (!(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty())) {
- qDebug("Test about to fail for font: %s, fontinfo: %s",
- font.family().toLatin1().constData(),
- fontinfo.family().toLatin1().constData());
- }
- QVERIFY(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty());
- }
- if (font.pointSize() != -1) {
- QCOMPARE(font.pointSize(), fontinfo.pointSize());
- } else {
- QCOMPARE(font.pixelSize(), fontinfo.pixelSize());
- }
- QCOMPARE(font.italic(), fontinfo.italic());
- if (font.weight() != fontinfo.weight()) {
- qDebug("font is %s", font.toString().toLatin1().constData());
- }
- QCOMPARE(font.weight(), fontinfo.weight());
- } else {
- font.setFixedPitch(!fontinfo.fixedPitch());
- QFontInfo fontinfo1(font);
- QVERIFY( !fontinfo1.exactMatch() );
-
- font.setFixedPitch(fontinfo.fixedPitch());
- QFontInfo fontinfo2(font);
- QVERIFY( fontinfo2.exactMatch() );
- }
- }
-#if 0
- // ############## can only work if we have float point sizes in QFD
- else {
- QList<int> sizes = fdb.pointSizes(family, style);
- QVERIFY(!sizes.isEmpty());
- QList<int>::ConstIterator z_it, z_end = sizes.end();
- for (z_it = sizes.begin(); z_it != z_end; ++z_it) {
- const int size = *z_it;
-
- // Initialize the font, and check if it is an exact match
- font = fdb.font(family, style, size);
- QFontInfo fontinfo(font, (QFont::Script) script);
-
- if (! fontinfo.exactMatch()) {
- // Unfortunately, this can fail, since
- // QFontDatabase does not fill in all font
- // properties. Check to make sure that the
- // test didn't fail for obvious reasons
-
- if (fontinfo.family().isEmpty()
- && fontinfo.pointSize() == 0) {
- // this is a box rendering engine... this can happen from
- // time to time, especially on X11 with iso10646-1 or
- // unknown font encodings
- continue;
- }
-
- // no need to skip MS-fonts here it seems
- if (!(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty())) {
- qDebug("Test about to fail for font: %s, fontinfo: %s",
- font.family().latin1(), fontinfo.family().latin1());
- }
- QVERIFY(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty());
- if (font.pointSize() != -1) {
- QCOMPARE(font.pointSize(), fontinfo.pointSize());
- } else {
- QCOMPARE(font.pixelSize(), fontinfo.pixelSize());
- }
- QCOMPARE(font.italic(), fontinfo.italic());
- QCOMPARE(font.weight(), fontinfo.weight());
- } else {
- font.setFixedPitch(!fontinfo.fixedPitch());
- QFontInfo fontinfo1(font, (QFont::Script) script);
- QVERIFY( !fontinfo1.exactMatch() );
-
- font.setFixedPitch(fontinfo.fixedPitch());
- QFontInfo fontinfo2(font, (QFont::Script) script);
- QVERIFY( fontinfo2.exactMatch() );
- }
- }
- }
-#endif
- }
- }
- }
+ QVERIFY(!QFont("sans").exactMatch());
+ QVERIFY(!QFont("sans-serif").exactMatch());
+ QVERIFY(!QFont("serif").exactMatch());
+ QVERIFY(!QFont("monospace").exactMatch());
}
void tst_QFont::italicOblique()