| 1 |
/* |
| 2 |
* Copyright 2014 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 |
|
| 17 |
/* |
| 18 |
* Test to prevent regressions for bug: https://bugs.launchpad.net/lomiri-ui-toolkit/+bug/1338602 |
| 19 |
* Activity Indicator crashes in QML/Widget mixed applications |
| 20 |
*/ |
| 21 |
|
| 22 |
#include <QtCore/QEventLoop> |
| 23 |
#include <QtCore/QObject> |
| 24 |
#include <QtCore/QScopedPointer> |
| 25 |
#include <QtCore/QTimer> |
| 26 |
#include <QtQuick/QQuickView> |
| 27 |
#include <QtTest/QTest> |
| 28 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 29 |
#include <LomiriToolkit-Qt6/private/uctheme_p.h> |
| 30 |
#else |
| 31 |
#include <LomiriToolkit/private/uctheme_p.h> |
| 32 |
#endif |
| 33 |
|
| 34 |
#include "uctestcase.h" |
| 35 |
|
| 36 |
UT_USE_NAMESPACE |
| 37 |
|
| 38 |
class Tst_Animator : public QObject |
| 39 |
{ |
| 40 |
Q_OBJECT |
| 41 |
|
| 42 |
private Q_SLOTS: |
| 43 |
void tst_animatorRegression_data() { |
| 44 |
QTest::addColumn<QString>("filename"); |
| 45 |
QTest::addColumn<QString>("suppressDeprecatedNote"); |
| 46 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 47 |
QTest::newRow("latest") << QString("tst_animator.qml") << QString("no"); |
| 48 |
#else |
| 49 |
QTest::newRow("1.1") << QString("tst_animator.qml") << QString("yes"); |
| 50 |
QTest::newRow("1.3") << QString("tst_animator13.qml") << QString("no"); |
| 51 |
#endif |
| 52 |
} |
| 53 |
|
| 54 |
void tst_animatorRegression () |
| 55 |
{ |
| 56 |
QFETCH(QString, filename); |
| 57 |
QFETCH(QString, suppressDeprecatedNote); |
| 58 |
|
| 59 |
UCTheme::previousVersion = 0; |
| 60 |
qputenv("SUPPRESS_DEPRECATED_NOTE", qPrintable(suppressDeprecatedNote)); |
| 61 |
QEventLoop l; |
| 62 |
QScopedPointer<LomiriTestCase> w(new LomiriTestCase(filename)); |
| 63 |
|
| 64 |
int countdown = 20; |
| 65 |
|
| 66 |
QTimer t; |
| 67 |
t.setInterval(100); |
| 68 |
connect(&t,&QTimer::timeout,[&]{ |
| 69 |
w->setVisible(!w->visibility()); |
| 70 |
|
| 71 |
if(--countdown == 0) |
| 72 |
l.exit(0); |
| 73 |
}); |
| 74 |
t.start(); |
| 75 |
l.exec(); |
| 76 |
} |
| 77 |
|
| 78 |
}; |
| 79 |
|
| 80 |
QTEST_MAIN(Tst_Animator) |
| 81 |
#include "tst_animator.moc" |
| 82 |
|