diff options
Diffstat (limited to 'tests/auto/gui/text/qrawfont')
-rw-r--r-- | tests/auto/gui/text/qrawfont/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/gui/text/qrawfont/CMakeLists.txt | 30 | ||||
-rw-r--r-- | tests/auto/gui/text/qrawfont/qrawfont.pro | 10 | ||||
-rw-r--r-- | tests/auto/gui/text/qrawfont/testdata.qrc | 7 | ||||
-rw-r--r-- | tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 105 |
5 files changed, 65 insertions, 89 deletions
diff --git a/tests/auto/gui/text/qrawfont/BLACKLIST b/tests/auto/gui/text/qrawfont/BLACKLIST deleted file mode 100644 index 44b3d7d481..0000000000 --- a/tests/auto/gui/text/qrawfont/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -# QTBUG-85364 -windows-10 gcc cmake diff --git a/tests/auto/gui/text/qrawfont/CMakeLists.txt b/tests/auto/gui/text/qrawfont/CMakeLists.txt index f51d4ec13d..d2a318a2a3 100644 --- a/tests/auto/gui/text/qrawfont/CMakeLists.txt +++ b/tests/auto/gui/text/qrawfont/CMakeLists.txt @@ -1,17 +1,15 @@ -# Generated from qrawfont.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qrawfont Test: ##################################################################### -qt_add_test(tst_qrawfont - SOURCES - tst_qrawfont.cpp - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::Gui - Qt::GuiPrivate -) +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qrawfont LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() # Resources: set_source_files_properties("../../../shared/resources/testfont.ttf" @@ -23,10 +21,14 @@ set(testdata_resource_files "testfont_os2_v1.ttf" ) -qt_add_resource(tst_qrawfont "testdata" - PREFIX - "/" - FILES - ${testdata_resource_files} +qt_internal_add_test(tst_qrawfont + SOURCES + tst_qrawfont.cpp + LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + TESTDATA ${testdata_resource_files} + BUILTIN_TESTDATA ) diff --git a/tests/auto/gui/text/qrawfont/qrawfont.pro b/tests/auto/gui/text/qrawfont/qrawfont.pro deleted file mode 100644 index 47e760e1da..0000000000 --- a/tests/auto/gui/text/qrawfont/qrawfont.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qrawfont - -QT = core core-private gui gui-private testlib - -SOURCES += \ - tst_qrawfont.cpp - -RESOURCES += \ - testdata.qrc diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc deleted file mode 100644 index c7ac9641d1..0000000000 --- a/tests/auto/gui/text/qrawfont/testdata.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>testfont_bold_italic.ttf</file> - <file>testfont_os2_v1.ttf</file> - <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file> - </qresource> -</RCC> diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 8ed9ad6a9a..5ec2536718 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -1,32 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QTest> #include <QtGui/QFontDatabase> #include <qrawfont.h> @@ -121,8 +96,7 @@ void tst_QRawFont::initTestCase() if (testFont.isEmpty() || testFontBoldItalic.isEmpty()) QFAIL("qrawfont unittest font files not found!"); - QFontDatabase database; - if (database.families().count() == 0) + if (QFontDatabase::families().size() == 0) QSKIP("No fonts available!!!"); } @@ -389,8 +363,7 @@ void tst_QRawFont::advances() void tst_QRawFont::textLayout() { - QFontDatabase fontDatabase; - int id = fontDatabase.addApplicationFont(testFont); + int id = QFontDatabase::addApplicationFont(testFont); QVERIFY(id >= 0); QString familyName = QString::fromLatin1("QtBidiTestFont"); @@ -420,18 +393,18 @@ void tst_QRawFont::textLayout() QCOMPARE(glyphs.glyphIndexes(), expectedGlyphIndices); - QVERIFY(fontDatabase.removeApplicationFont(id)); + QVERIFY(QFontDatabase::removeApplicationFont(id)); } void tst_QRawFont::fontTable_data() { - QTest::addColumn<QByteArray>("tagName"); + QTest::addColumn<QFont::Tag>("tag"); QTest::addColumn<QFont::HintingPreference>("hintingPreference"); QTest::addColumn<int>("offset"); QTest::addColumn<quint32>("expectedValue"); QTest::newRow("Head table, magic number, default hinting") - << QByteArray("head") + << QFont::Tag("head") << QFont::PreferDefaultHinting << 12 << (QSysInfo::ByteOrder == QSysInfo::BigEndian @@ -439,7 +412,7 @@ void tst_QRawFont::fontTable_data() : 0xF53C0F5F); QTest::newRow("Head table, magic number, no hinting") - << QByteArray("head") + << QFont::Tag("head") << QFont::PreferNoHinting << 12 << (QSysInfo::ByteOrder == QSysInfo::BigEndian @@ -447,7 +420,7 @@ void tst_QRawFont::fontTable_data() : 0xF53C0F5F); QTest::newRow("Head table, magic number, vertical hinting") - << QByteArray("head") + << QFont::Tag("head") << QFont::PreferVerticalHinting << 12 << (QSysInfo::ByteOrder == QSysInfo::BigEndian @@ -455,7 +428,7 @@ void tst_QRawFont::fontTable_data() : 0xF53C0F5F); QTest::newRow("Head table, magic number, full hinting") - << QByteArray("head") + << QFont::Tag("head") << QFont::PreferFullHinting << 12 << (QSysInfo::ByteOrder == QSysInfo::BigEndian @@ -465,7 +438,7 @@ void tst_QRawFont::fontTable_data() void tst_QRawFont::fontTable() { - QFETCH(QByteArray, tagName); + QFETCH(QFont::Tag, tag); QFETCH(QFont::HintingPreference, hintingPreference); QFETCH(int, offset); QFETCH(quint32, expectedValue); @@ -473,11 +446,13 @@ void tst_QRawFont::fontTable() QRawFont font(testFont, 10, hintingPreference); QVERIFY(font.isValid()); - QByteArray table = font.fontTable(tagName); + QByteArray table = font.fontTable(tag); QVERIFY(!table.isEmpty()); const quint32 *value = reinterpret_cast<const quint32 *>(table.constData() + offset); QCOMPARE(*value, expectedValue); + + QCOMPARE(font.fontTable(tag.toString()), table); } typedef QList<QFontDatabase::WritingSystem> WritingSystemList; @@ -517,7 +492,7 @@ void tst_QRawFont::supportedWritingSystems_data() void tst_QRawFont::supportedWritingSystems() { QFETCH(QString, fileName); - QFETCH(WritingSystemList, writingSystems); + QFETCH(const WritingSystemList, writingSystems); QFETCH(QFont::HintingPreference, hintingPreference); QRawFont font(fileName, 10, hintingPreference); @@ -526,7 +501,7 @@ void tst_QRawFont::supportedWritingSystems() WritingSystemList actualWritingSystems = font.supportedWritingSystems(); QCOMPARE(actualWritingSystems.size(), writingSystems.size()); - foreach (QFontDatabase::WritingSystem writingSystem, writingSystems) + for (QFontDatabase::WritingSystem writingSystem : writingSystems) QVERIFY(actualWritingSystems.contains(writingSystem)); } @@ -654,6 +629,7 @@ void tst_QRawFont::fromFont_data() QTest::addColumn<QFont::HintingPreference>("hintingPreference"); QTest::addColumn<QString>("familyName"); QTest::addColumn<QFontDatabase::WritingSystem>("writingSystem"); + QTest::addColumn<QFont::StyleStrategy>("styleStrategy"); for (int i=QFont::PreferDefaultHinting; i<=QFont::PreferFullHinting; ++i) { QString titleBase = QString::fromLatin1("%2, hintingPreference=%1, writingSystem=%3") @@ -667,7 +643,8 @@ void tst_QRawFont::fromFont_data() << fileName << QFont::HintingPreference(i) << "QtBidiTestFont" - << writingSystem; + << writingSystem + << QFont::PreferDefault; } { @@ -679,7 +656,8 @@ void tst_QRawFont::fromFont_data() << fileName << QFont::HintingPreference(i) << "QtBidiTestFont" - << writingSystem; + << writingSystem + << QFont::PreferDefault; } { @@ -691,9 +669,24 @@ void tst_QRawFont::fromFont_data() << fileName << QFont::HintingPreference(i) << "QtBidiTestFont" - << writingSystem; + << writingSystem + << QFont::PreferDefault; } } + + { + QString fileName = testFont; + QFontDatabase::WritingSystem writingSystem = QFontDatabase::Arabic; + + QString title = QStringLiteral("No font merging + unsupported script"); + QTest::newRow(qPrintable(title)) + << fileName + << QFont::PreferDefaultHinting + << "QtBidiTestFont" + << writingSystem + << QFont::NoFontMerging; + } + } void tst_QRawFont::fromFont() @@ -702,14 +695,16 @@ void tst_QRawFont::fromFont() QFETCH(QFont::HintingPreference, hintingPreference); QFETCH(QString, familyName); QFETCH(QFontDatabase::WritingSystem, writingSystem); + QFETCH(QFont::StyleStrategy, styleStrategy); - QFontDatabase fontDatabase; - int id = fontDatabase.addApplicationFont(fileName); + int id = QFontDatabase::addApplicationFont(fileName); QVERIFY(id >= 0); QFont font(familyName); font.setHintingPreference(hintingPreference); font.setPixelSize(26.0); + if (styleStrategy != QFont::PreferDefault) + font.setStyleStrategy(styleStrategy); QRawFont rawFont = QRawFont::fromFont(font, writingSystem); QVERIFY(rawFont.isValid()); @@ -717,7 +712,7 @@ void tst_QRawFont::fromFont() QCOMPARE(rawFont.familyName(), familyName); QCOMPARE(rawFont.pixelSize(), 26.0); - QVERIFY(fontDatabase.removeApplicationFont(id)); + QVERIFY(QFontDatabase::removeApplicationFont(id)); } void tst_QRawFont::copyConstructor_data() @@ -878,8 +873,7 @@ void tst_QRawFont::unsupportedWritingSystem() { QFETCH(QFont::HintingPreference, hintingPreference); - QFontDatabase fontDatabase; - int id = fontDatabase.addApplicationFont(testFont); + int id = QFontDatabase::addApplicationFont(testFont); QFont font("QtBidiTestFont"); font.setHintingPreference(hintingPreference); @@ -915,7 +909,7 @@ void tst_QRawFont::unsupportedWritingSystem() QCOMPARE(rawFont.familyName(), layoutFont.familyName()); QCOMPARE(rawFont.pixelSize(), 12.0); - fontDatabase.removeApplicationFont(id); + QFontDatabase::removeApplicationFont(id); } void tst_QRawFont::rawFontSetPixelSize_data() @@ -1017,8 +1011,7 @@ void tst_QRawFont::kernedAdvances() void tst_QRawFont::fallbackFontsOrder() { - QFontDatabase fontDatabase; - int id = fontDatabase.addApplicationFont(testFont); + int id = QFontDatabase::addApplicationFont(testFont); QFont font("QtBidiTestFont"); font.setPixelSize(12.0); @@ -1047,7 +1040,7 @@ void tst_QRawFont::fallbackFontsOrder() // is not sorted by writing system support. QCOMPARE(glyphRuns.size(), 1); - fontDatabase.removeApplicationFont(id); + QFontDatabase::removeApplicationFont(id); } void tst_QRawFont::qtbug65923_partal_clone_data() @@ -1061,7 +1054,7 @@ void tst_QRawFont::qtbug65923_partal_clone_data() void tst_QRawFont::qtbug65923_partal_clone() { QFile file(testFont); - file.open(QIODevice::ReadOnly); + QVERIFY(file.open(QIODevice::ReadOnly)); QByteArray fontData = file.readAll(); QRawFont outerFont; |