forked from qt-creator/qt-creator
QmlPreview: Move test creation closer to test code
Change-Id: I7d44c332cd1fedf28854953d7bd649fbd6176fbf Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -249,8 +249,8 @@ void QmlPreviewPlugin::initialize()
|
|||||||
d = new QmlPreviewPluginPrivate(this);
|
d = new QmlPreviewPluginPrivate(this);
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
addTest<QmlPreviewClientTest>();
|
addTestCreator(createQmlPreviewClientTest);
|
||||||
addTest<QmlPreviewPluginTest>();
|
addTestCreator(createQmlPreviewPluginTest);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,6 +8,17 @@
|
|||||||
|
|
||||||
namespace QmlPreview {
|
namespace QmlPreview {
|
||||||
|
|
||||||
|
class QmlPreviewClientTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void testLoadFile();
|
||||||
|
void testAnnounceFile();
|
||||||
|
void testZoom();
|
||||||
|
void testMessageReceived();
|
||||||
|
};
|
||||||
|
|
||||||
class TestableQmlPreviewClient : public QmlPreviewClient
|
class TestableQmlPreviewClient : public QmlPreviewClient
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -116,6 +127,11 @@ void QmlPreviewClientTest::testMessageReceived()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject *createQmlPreviewClientTest()
|
||||||
|
{
|
||||||
|
return new QmlPreviewClientTest;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QmlPreview
|
} // namespace QmlPreview
|
||||||
|
|
||||||
#include "qmlpreviewclient_test.moc"
|
#include "qmlpreviewclient_test.moc"
|
||||||
|
@@ -5,15 +5,6 @@
|
|||||||
|
|
||||||
namespace QmlPreview {
|
namespace QmlPreview {
|
||||||
|
|
||||||
class QmlPreviewClientTest : public QObject
|
QObject *createQmlPreviewClientTest();
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void testLoadFile();
|
|
||||||
void testAnnounceFile();
|
|
||||||
void testZoom();
|
|
||||||
void testMessageReceived();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlPreview
|
} // namespace QmlPreview
|
||||||
|
@@ -9,13 +9,23 @@
|
|||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QmlPreview::TestFileLoader)
|
typedef QByteArray (*TestFileLoader)(const QString &, bool *);
|
||||||
Q_DECLARE_METATYPE(QmlPreview::TestFpsHandler)
|
typedef void (*TestFpsHandler)(quint16[8]);
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(TestFileLoader)
|
||||||
|
Q_DECLARE_METATYPE(TestFpsHandler)
|
||||||
|
|
||||||
namespace QmlPreview {
|
namespace QmlPreview {
|
||||||
|
|
||||||
QmlPreviewPluginTest::QmlPreviewPluginTest(QObject *parent) : QObject(parent)
|
class QmlPreviewPluginTest : public QObject
|
||||||
{ }
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void testFileLoaderProperty();
|
||||||
|
void testZoomFactorProperty();
|
||||||
|
void testFpsHandlerProperty();
|
||||||
|
};
|
||||||
|
|
||||||
static ExtensionSystem::IPlugin *getPlugin()
|
static ExtensionSystem::IPlugin *getPlugin()
|
||||||
{
|
{
|
||||||
@@ -66,4 +76,11 @@ void QmlPreviewPluginTest::testFpsHandlerProperty()
|
|||||||
handler(stats);
|
handler(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject *createQmlPreviewPluginTest()
|
||||||
|
{
|
||||||
|
return new QmlPreviewPluginTest;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QmlPreview
|
} // namespace QmlPreview
|
||||||
|
|
||||||
|
#include "qmlpreviewplugin_test.moc"
|
||||||
|
@@ -7,19 +7,6 @@
|
|||||||
|
|
||||||
namespace QmlPreview {
|
namespace QmlPreview {
|
||||||
|
|
||||||
typedef QByteArray (*TestFileLoader)(const QString &, bool *);
|
QObject *createQmlPreviewPluginTest();
|
||||||
typedef void (*TestFpsHandler)(quint16[8]);
|
|
||||||
|
|
||||||
class QmlPreviewPluginTest : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit QmlPreviewPluginTest(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void testFileLoaderProperty();
|
|
||||||
void testZoomFactorProperty();
|
|
||||||
void testFpsHandlerProperty();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace QmlPreview
|
} // namespace QmlPreview
|
||||||
|
Reference in New Issue
Block a user