summaryrefslogtreecommitdiffstats
path: root/tests/auto/geometryloaders/objgeometryloader/tst_objgeometryloader.cpp
blob: f603005251cf681c14a6034c4cc8be2da3639693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include <QtTest/QTest>
#include <QtCore/private/qfactoryloader_p.h>
#include <Qt3DRender/private/qgeometryloaderinterface_p.h>
#include <Qt3DRender/private/qgeometryloaderfactory_p.h>

using namespace Qt3DRender;

class tst_ObjGeometryLoader : public QObject
{
    Q_OBJECT
private Q_SLOTS:

    void checkOutOfBoundFaceAccess_data()
    {
        QTest::addColumn<QString>("filePath");

        QTest::newRow("invalid position index") << ":invalid_vertex_position.obj";
    }


    void checkOutOfBoundFaceAccess()
    {
        // GIVEN
        QFETCH(QString, filePath);

        QFactoryLoader geometryLoader(QGeometryLoaderFactory_iid,
                                      QLatin1String("/geometryloaders"),
                                      Qt::CaseInsensitive);

        QScopedPointer<QGeometryLoaderInterface> loader;
        loader.reset(qLoadPlugin<QGeometryLoaderInterface, QGeometryLoaderFactory>(&geometryLoader, QLatin1String("obj")));

        if (!loader)
            QSKIP("ObjLoaderPlugin not deployed");

        QFile file(filePath);
        QVERIFY(file.open(QIODevice::ReadOnly));

        // WHEN
        loader->load(&file);

        // THEN
        // -> shouldn't crash
    }
};

QTEST_MAIN(tst_ObjGeometryLoader)

#include "tst_objgeometryloader.moc"