aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertycache
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-02-16 14:43:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-24 04:51:31 +0100
commitb855240b782395f94315f43ea3e7e182299fac48 (patch)
treebc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /tests/auto/qml/qqmlpropertycache
parent6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff)
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache')
-rw-r--r--tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro8
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp281
2 files changed, 289 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro
new file mode 100644
index 0000000000..4beb961895
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qqmlpropertycache
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlpropertycache.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib v8-private
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
new file mode 100644
index 0000000000..b702623fee
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -0,0 +1,281 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <private/qqmlpropertycache_p.h>
+#include <QtQml/qqmlengine.h>
+#include "../../shared/util.h"
+
+class tst_qqmlpropertycache : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlpropertycache() {}
+
+private slots:
+ void properties();
+ void propertiesDerived();
+ void methods();
+ void methodsDerived();
+ void signalHandlers();
+ void signalHandlersDerived();
+
+private:
+ QQmlEngine engine;
+};
+
+class BaseObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyA READ propertyA NOTIFY propertyAChanged)
+ Q_PROPERTY(QString propertyB READ propertyB NOTIFY propertyBChanged)
+public:
+ BaseObject(QObject *parent = 0) : QObject(parent) {}
+
+ int propertyA() const { return 0; }
+ QString propertyB() const { return QString(); }
+
+public Q_SLOTS:
+ void slotA() {}
+
+Q_SIGNALS:
+ void propertyAChanged();
+ void propertyBChanged();
+ void signalA();
+};
+
+class DerivedObject : public BaseObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyC READ propertyC NOTIFY propertyCChanged)
+ Q_PROPERTY(QString propertyD READ propertyD NOTIFY propertyDChanged)
+public:
+ DerivedObject(QObject *parent = 0) : BaseObject(parent) {}
+
+ int propertyC() const { return 0; }
+ QString propertyD() const { return QString(); }
+
+public Q_SLOTS:
+ void slotB() {}
+
+Q_SIGNALS:
+ void propertyCChanged();
+ void propertyDChanged();
+ void signalB();
+};
+
+void tst_qqmlpropertycache::properties()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("propertyA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyC")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyD")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
+}
+
+void tst_qqmlpropertycache::propertiesDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("propertyA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyC")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyD")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
+}
+
+void tst_qqmlpropertycache::methods()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("slotA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("slotB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::methodsDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("slotA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("slotB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::signalHandlers()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::signalHandlersDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+QTEST_MAIN(tst_qqmlpropertycache)
+
+#include "tst_qqmlpropertycache.moc"