| 1 | /* |
| 2 | * Copyright 2013 Canonical Ltd. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
| 6 | * the Free Software Foundation; version 3. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | * |
| 16 | * Author: Florian Boucault <[email protected]> |
| 17 | */ |
| 18 | |
| 19 | #include <QtQml/QQmlEngine> |
| 20 | #include <QtQuick/QQuickView> |
| 21 | #include <QtTest/QtTest> |
| 22 | |
| 23 | class tst_LomiriShape: public QObject |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | |
| 27 | private: |
| 28 | QQuickView *m_quickView; |
| 29 | |
| 30 | private Q_SLOTS: |
| 31 | |
| 32 | void initTestCase() |
| 33 | { |
| 34 | m_quickView = new QQuickView; |
| 35 | m_quickView->setGeometry(0, 0, 900, 500); |
| 36 | m_quickView->show(); |
| 37 | |
| 38 | // add modules folder so we have access to the plugin from QML |
| 39 | QQmlEngine *engine = m_quickView->engine(); |
| 40 | QString modules(LOMIRI_QML_IMPORT_PATH); |
| 41 | QStringList imports = engine->importPathList(); |
| 42 | imports.prepend(QDir(modules).absolutePath()); |
| 43 | engine->setImportPathList(imports); |
| 44 | } |
| 45 | |
| 46 | void noDistortion() { |
| 47 | QSKIP("This test passes on local machines but not in CI as it requires working OpenGL"); |
| 48 | m_quickView->setSource(QUrl::fromLocalFile("no_distortion.qml")); |
| 49 | QCoreApplication::processEvents(); |
| 50 | |
| 51 | QImage result = m_quickView->grabWindow(); |
| 52 | QVERIFY(!result.isNull()); |
| 53 | |
| 54 | QImage expected = QImage("no_distortion_expected.png"); |
| 55 | QVERIFY(!expected.isNull()); |
| 56 | |
| 57 | QCOMPARE(result, expected); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | QTEST_MAIN(tst_LomiriShape) |
| 62 | |
| 63 | #include "tst_lomiri_shape.moc" |