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);
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
addTest<QmlPreviewClientTest>();
|
||||
addTest<QmlPreviewPluginTest>();
|
||||
addTestCreator(createQmlPreviewClientTest);
|
||||
addTestCreator(createQmlPreviewPluginTest);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,17 @@
|
||||
|
||||
namespace QmlPreview {
|
||||
|
||||
class QmlPreviewClientTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testLoadFile();
|
||||
void testAnnounceFile();
|
||||
void testZoom();
|
||||
void testMessageReceived();
|
||||
};
|
||||
|
||||
class TestableQmlPreviewClient : public QmlPreviewClient
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -116,6 +127,11 @@ void QmlPreviewClientTest::testMessageReceived()
|
||||
}
|
||||
}
|
||||
|
||||
QObject *createQmlPreviewClientTest()
|
||||
{
|
||||
return new QmlPreviewClientTest;
|
||||
}
|
||||
|
||||
} // namespace QmlPreview
|
||||
|
||||
#include "qmlpreviewclient_test.moc"
|
||||
|
@@ -5,15 +5,6 @@
|
||||
|
||||
namespace QmlPreview {
|
||||
|
||||
class QmlPreviewClientTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testLoadFile();
|
||||
void testAnnounceFile();
|
||||
void testZoom();
|
||||
void testMessageReceived();
|
||||
};
|
||||
QObject *createQmlPreviewClientTest();
|
||||
|
||||
} // namespace QmlPreview
|
||||
|
@@ -9,13 +9,23 @@
|
||||
#include <QtTest>
|
||||
#include <QVariant>
|
||||
|
||||
Q_DECLARE_METATYPE(QmlPreview::TestFileLoader)
|
||||
Q_DECLARE_METATYPE(QmlPreview::TestFpsHandler)
|
||||
typedef QByteArray (*TestFileLoader)(const QString &, bool *);
|
||||
typedef void (*TestFpsHandler)(quint16[8]);
|
||||
|
||||
Q_DECLARE_METATYPE(TestFileLoader)
|
||||
Q_DECLARE_METATYPE(TestFpsHandler)
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -66,4 +76,11 @@ void QmlPreviewPluginTest::testFpsHandlerProperty()
|
||||
handler(stats);
|
||||
}
|
||||
|
||||
QObject *createQmlPreviewPluginTest()
|
||||
{
|
||||
return new QmlPreviewPluginTest;
|
||||
}
|
||||
|
||||
} // namespace QmlPreview
|
||||
|
||||
#include "qmlpreviewplugin_test.moc"
|
||||
|
@@ -7,19 +7,6 @@
|
||||
|
||||
namespace QmlPreview {
|
||||
|
||||
typedef QByteArray (*TestFileLoader)(const QString &, bool *);
|
||||
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();
|
||||
};
|
||||
QObject *createQmlPreviewPluginTest();
|
||||
|
||||
} // namespace QmlPreview
|
||||
|
Reference in New Issue
Block a user