diff options
Diffstat (limited to 'tests/auto/gui/util/qtexturefilereader')
-rw-r--r-- | tests/auto/gui/util/qtexturefilereader/CMakeLists.txt | 29 | ||||
-rw-r--r-- | tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc | 11 | ||||
-rw-r--r-- | tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx | bin | 0 -> 69 bytes | |||
-rw-r--r-- | tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp | 42 |
4 files changed, 31 insertions, 51 deletions
diff --git a/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt b/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt index de809f577d..70e2c02417 100644 --- a/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt +++ b/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt @@ -1,16 +1,15 @@ -# Generated from qtexturefilereader.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qtexturefilereader Test: ##################################################################### -qt_internal_add_test(tst_qtexturefilereader - SOURCES - tst_qtexturefilereader.cpp - PUBLIC_LIBRARIES - Qt::Gui - Qt::GuiPrivate -) +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qtexturefilereader LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() # Resources: set(qtexturefilereader_resource_files @@ -18,15 +17,19 @@ set(qtexturefilereader_resource_files "texturefiles/car_mips.ktx" "texturefiles/cubemap_float32_rgba.ktx" "texturefiles/cubemap_metadata.ktx" + "texturefiles/invalid.ktx" "texturefiles/newlogo.astc" "texturefiles/newlogo_srgb.astc" "texturefiles/pattern.pkm" ) -qt_internal_add_resource(tst_qtexturefilereader "qtexturefilereader" - PREFIX - "/" - FILES - ${qtexturefilereader_resource_files} +qt_internal_add_test(tst_qtexturefilereader + SOURCES + tst_qtexturefilereader.cpp + LIBRARIES + Qt::Gui + Qt::GuiPrivate + TESTDATA ${qtexturefilereader_resource_files} + BUILTIN_TESTDATA ) diff --git a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc deleted file mode 100644 index c4cef6cc44..0000000000 --- a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>texturefiles/car.ktx</file> - <file>texturefiles/cubemap_float32_rgba.ktx</file> - <file>texturefiles/cubemap_metadata.ktx</file> - <file>texturefiles/pattern.pkm</file> - <file>texturefiles/car_mips.ktx</file> - <file>texturefiles/newlogo_srgb.astc</file> - <file>texturefiles/newlogo.astc</file> - </qresource> -</RCC> diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx b/tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx Binary files differnew file mode 100644 index 0000000000..68a92221db --- /dev/null +++ b/tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx diff --git a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp index 89144eb245..62760e3844 100644 --- a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp +++ b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <private/qtexturefilereader_p.h> #include <QTest> @@ -36,6 +11,7 @@ class tst_qtexturefilereader : public QObject private slots: void checkHandlers_data(); void checkHandlers(); + void checkInvalid(); void checkMetadata(); }; @@ -165,6 +141,18 @@ void tst_qtexturefilereader::checkMetadata() QCOMPARE(kvs.value("test C"), QByteArrayLiteral("3\x0000")); } +void tst_qtexturefilereader::checkInvalid() +{ + QFile f(":/texturefiles/invalid.ktx"); + QVERIFY(f.open(QIODevice::ReadOnly)); + QTextureFileReader r(&f); + QTextureFileData d = r.read(); + auto kvs = d.keyValueMetadata(); + + // Basically just checking that we don't crash on and invalid file + QVERIFY(kvs.empty()); +} + QTEST_MAIN(tst_qtexturefilereader) #include "tst_qtexturefilereader.moc" |