aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
diff options
context:
space:
mode:
authorGlenn Watson <glenn.watson@nokia.com>2012-07-24 11:41:50 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-08 07:55:19 +0200
commit6ebf215fdaf2d757ab90ae4d46c4b938e978e2dc (patch)
tree515da352f1cc4d5567b6d93f0b19952b2e27d705 /tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
parent92562eacbc3c614a83a734f1108ed7df02415eae (diff)
Add type name to singleton (module api) implementations.
This change renames the previous module api implementation to singleton types. When a singleton type is registered, a type name must be provided that is used when accessing the API from QML. This makes the implementation more consistent with the rest of QML. Task-number: QTBUG-26549 Change-Id: Iab0bb1ccf516bd3ae20aee562a64d22976e0aecd Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qquickconnection/tst_qquickconnection.cpp')
-rw-r--r--tests/auto/qml/qquickconnection/tst_qquickconnection.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
index 1167281eb0..118d89e41e 100644
--- a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
+++ b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
@@ -62,7 +62,7 @@ private slots:
void unknownSignals();
void errors_data();
void errors();
- void moduleApiTarget();
+ void singletonTypeTarget();
private:
QQmlEngine engine;
@@ -225,14 +225,14 @@ void tst_qquickconnection::errors()
}
-class MyTestModuleApi : public QObject
+class MyTestSingletonType : public QObject
{
Q_OBJECT
Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged)
public:
- MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
- ~MyTestModuleApi() {}
+ MyTestSingletonType(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
+ ~MyTestSingletonType() {}
Q_INVOKABLE int otherMethod(int val) { return val + 4; }
@@ -256,15 +256,15 @@ static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
- MyTestModuleApi *api = new MyTestModuleApi();
+ MyTestSingletonType *api = new MyTestSingletonType();
return api;
}
// QTBUG-20937
-void tst_qquickconnection::moduleApiTarget()
+void tst_qquickconnection::singletonTypeTarget()
{
- qmlRegisterModuleApi<MyTestModuleApi>("MyTestModuleApi", 1, 0, module_api_factory);
- QQmlComponent component(&engine, testFileUrl("moduleapi-target.qml"));
+ qmlRegisterSingletonType<MyTestSingletonType>("MyTestSingletonType", 1, 0, "Api", module_api_factory);
+ QQmlComponent component(&engine, testFileUrl("singletontype-target.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -279,7 +279,7 @@ void tst_qquickconnection::moduleApiTarget()
QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2);
QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
- // the module API emits otherSignal every 3 times the int property changes.
+ // the singleton Type emits otherSignal every 3 times the int property changes.
QMetaObject::invokeMethod(object, "setModuleIntProp");
QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3);
QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1);