Debian Codegraph @

tests/auto/render/ktxtextures/tst_ktxtextures.cpp

raw symbols SCIP
1 // Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 // TODO Remove in Qt6
5 #include <QtCore/qcompilerdetection.h>
6 QT_WARNING_DISABLE_DEPRECATED
7
8 #include <QtTest/QTest>
9 #include <Qt3DRender/qtextureimagedata.h>
10 #include <Qt3DRender/private/qtexture_p.h>
11
12 class tst_KtxTextures : public QObject
13 {
14 Q_OBJECT
15
16 private slots:
17 void ktxImageData();
18 };
19
20 void tst_KtxTextures::ktxImageData()
21 {
22 const struct TextureInfo {
23 const char *source;
24 int width;
25 int height;
26 int depth;
27 int faces;
28 int mipmapLevels;
29 QOpenGLTexture::TextureFormat format;
30 } textures[] = {
31 { "data/16_16_PNG_ASTC_7.KTX", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_ASTC_4x4 },
32 { "data/16_16_PNG_ASTC_8.KTX", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_ASTC_4x4 },
33 { "data/16_16_PNG_ETC2_RGB_13.KTX", 16, 16, 1, 1, 1, QOpenGLTexture::RGB8_ETC2 },
34 { "data/16_16_PNG_ETC2_RGBA_11.KTX", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA8_ETC2_EAC },
35 { "data/16_16_PNG_ETC_RGB_12.KTX", 16, 16, 1, 1, 1, QOpenGLTexture::RGB8_ETC1 },
36 };
37
38 for (unsigned i = 0; i < sizeof(textures)/sizeof(*textures); i++) {
39 const TextureInfo *texture = &textures[i];
40
41 Qt3DRender::QTextureImageDataPtr data = Qt3DRender::TextureLoadingHelper::loadTextureData(QUrl::fromLocalFile(QFINDTESTDATA(texture->source)), true, false);
42
43 QVERIFY(data);
44 QCOMPARE(data->width(), texture->width);
45 QCOMPARE(data->height(), texture->height);
46 QCOMPARE(data->faces(), texture->faces);
47 QCOMPARE(data->mipLevels(), texture->mipmapLevels);
48 QCOMPARE(data->format(), texture->format);
49 }
50 }
51
52 QTEST_APPLESS_MAIN(tst_KtxTextures)
53
54 #include "tst_ktxtextures.moc"