Debian Codegraph @

tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp

raw symbols SCIP
1 // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #include <QtTest/QTest>
5
6 #include <Qt3DRender/private/qtextureimagedata_p.h>
7 #include <Qt3DRender/qtextureimagedata.h>
8
9 #include "testarbiter.h"
10
11 // We need to call QNode::clone which is protected
12 // So we sublcass QNode instead of QObject
13 class tst_QTextureImageData : public QObject
14 {
15 Q_OBJECT
16 public:
17 ~tst_QTextureImageData()
18 {
19 }
20
21 private Q_SLOTS:
22
23 void checkSaneDefaults()
24 {
25 Qt3DRender::QTextureImageData *tid = new Qt3DRender::QTextureImageData();
26
27 QCOMPARE(tid->width(), -1);
28 QCOMPARE(tid->height(), -1);
29 QCOMPARE(tid->depth(), -1);
30 QCOMPARE(tid->layers(), -1);
31 QCOMPARE(tid->mipLevels(), -1);
32 QCOMPARE(tid->target(), QOpenGLTexture::Target2D);
33 QCOMPARE(tid->format(), QOpenGLTexture::NoFormat);
34 QCOMPARE(tid->pixelFormat(), QOpenGLTexture::RGBA);
35 QCOMPARE(tid->pixelType(), QOpenGLTexture::UInt8);
36 QCOMPARE(tid->isCompressed(), false);
37 QCOMPARE(tid->alignment(), 1);
38 }
39
40 void checkTextureDataUsesFunctor() {
41 Qt3DRender::QTextureImageData *tid = new Qt3DRender::QTextureImageData();
42
43 tid->setLayers(1);
44 tid->setFaces(1);
45 tid->setMipLevels(1);
46 tid->setData({}, [](QByteArray, int, int, int) {
47 return QByteArray("a");
48 }, false);
49
50 QByteArray data = tid->data();
51 QCOMPARE(data.data()[0], 'a');
52 }
53 };
54
55 QTEST_MAIN(tst_QTextureImageData)
56
57 #include "tst_qtextureimagedata.moc"