mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
de-duplicate code in tests and benchmarks
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
289cbb7dd1
commit
b438e6c37c
5 changed files with 13 additions and 23 deletions
|
@ -27,10 +27,7 @@
|
||||||
#include <qdeclarativebinding_p.h>
|
#include <qdeclarativebinding_p.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
|
|
||||||
inline QUrl TEST_FILE(const QString &filename)
|
#include "../../shared/util.h"
|
||||||
{
|
|
||||||
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyQmlObject : public QObject
|
class MyQmlObject : public QObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <qdeclarativetextinput_p.h>
|
#include <qdeclarativetextinput_p.h>
|
||||||
#include <qobject_p.h>
|
#include <qobject_p.h>
|
||||||
|
|
||||||
|
#include "../../../shared/util.h"
|
||||||
|
|
||||||
class tst_creation : public QObject
|
class tst_creation : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -89,11 +91,6 @@ tst_creation::tst_creation()
|
||||||
QDeclarativeTextInput te;
|
QDeclarativeTextInput te;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QUrl TEST_FILE(const QString &filename)
|
|
||||||
{
|
|
||||||
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_creation::qobject_cpp()
|
void tst_creation::qobject_cpp()
|
||||||
{
|
{
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
|
@ -286,7 +283,7 @@ void tst_creation::itemtree_data_cpp()
|
||||||
|
|
||||||
void tst_creation::itemtree_qml()
|
void tst_creation::itemtree_qml()
|
||||||
{
|
{
|
||||||
QDeclarativeComponent component(&engine, TEST_FILE(QLatin1String("item.qml")));
|
QDeclarativeComponent component(&engine, TEST_FILE("item.qml"));
|
||||||
QObject *obj = component.create();
|
QObject *obj = component.create();
|
||||||
delete obj;
|
delete obj;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
|
|
||||||
|
#include "../../../shared/util.h"
|
||||||
|
|
||||||
class tst_script : public QObject
|
class tst_script : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -78,11 +80,6 @@ private slots:
|
||||||
void scriptfile_property();
|
void scriptfile_property();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QUrl TEST_FILE(const char* filename)
|
|
||||||
{
|
|
||||||
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + QString::fromLatin1(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestObject : public QObject
|
class TestObject : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <QDeclarativeComponent>
|
#include <QDeclarativeComponent>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "../../../shared/util.h"
|
||||||
|
|
||||||
class tst_typeimports : public QObject
|
class tst_typeimports : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -86,15 +88,10 @@ tst_typeimports::tst_typeimports()
|
||||||
qmlRegisterType<TestType4>("Qt.test", 2, 0, "TestType4");
|
qmlRegisterType<TestType4>("Qt.test", 2, 0, "TestType4");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QUrl TEST_FILE(const QString &filename)
|
|
||||||
{
|
|
||||||
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_typeimports::cpp()
|
void tst_typeimports::cpp()
|
||||||
{
|
{
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
QDeclarativeComponent component(&engine, TEST_FILE(QLatin1String("cpp.qml")));
|
QDeclarativeComponent component(&engine, TEST_FILE("cpp.qml"));
|
||||||
QVERIFY(component.isReady());
|
QVERIFY(component.isReady());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,10 +99,10 @@ void tst_typeimports::cpp()
|
||||||
void tst_typeimports::qml()
|
void tst_typeimports::qml()
|
||||||
{
|
{
|
||||||
//get rid of initialization effects
|
//get rid of initialization effects
|
||||||
{ QDeclarativeComponent component(&engine, TEST_FILE(QLatin1String("qml.qml"))); }
|
{ QDeclarativeComponent component(&engine, TEST_FILE("qml.qml")); }
|
||||||
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
QDeclarativeComponent component(&engine, TEST_FILE(QLatin1String("qml.qml")));
|
QDeclarativeComponent component(&engine, TEST_FILE("qml.qml"));
|
||||||
QVERIFY(component.isReady());
|
QVERIFY(component.isReady());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,3 +48,5 @@
|
||||||
QCOMPARE(__expr, __expected); \
|
QCOMPARE(__expr, __expected); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#define TEST_FILE(__filename) \
|
||||||
|
QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(__filename))
|
||||||
|
|
Loading…
Add table
Reference in a new issue