1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 #include <QDeclarativeEngine>
44 #include <QDeclarativeComponent>
47 class tst_typeimports : public QObject
58 QDeclarativeEngine engine;
61 class TestType1 : public QObject
64 Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources);
65 Q_CLASSINFO("DefaultProperty", "resources");
67 TestType1(QObject *parent = 0) : QObject(parent) {}
69 QDeclarativeListProperty<QObject> resources() {
70 return QDeclarativeListProperty<QObject>(this, 0, resources_append);
73 static void resources_append(QDeclarativeListProperty<QObject> *p, QObject *o) {
74 o->setParent(p->object);
78 class TestType2 : public TestType1
82 TestType2(QObject *parent = 0) : TestType1(parent) {}
86 class TestType3 : public TestType1
90 TestType3(QObject *parent = 0) : TestType1(parent) {}
93 class TestType4 : public TestType1
97 TestType4(QObject *parent = 0) : TestType1(parent) {}
101 tst_typeimports::tst_typeimports()
103 qmlRegisterType<TestType1>("Qt.test", 1, 0, "TestType1");
104 qmlRegisterType<TestType2>("Qt.test", 1, 0, "TestType2");
105 qmlRegisterType<TestType3>("Qt.test", 2, 0, "TestType3");
106 qmlRegisterType<TestType4>("Qt.test", 2, 0, "TestType4");
109 inline QUrl TEST_FILE(const QString &filename)
111 return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
114 void tst_typeimports::cpp()
117 QDeclarativeComponent component(&engine, TEST_FILE("cpp.qml"));
118 QVERIFY(component.isReady());
122 void tst_typeimports::qml()
124 //get rid of initialization effects
125 { QDeclarativeComponent component(&engine, TEST_FILE("qml.qml")); }
128 QDeclarativeComponent component(&engine, TEST_FILE("qml.qml"));
129 QVERIFY(component.isReady());
133 QTEST_MAIN(tst_typeimports)
135 #include "tst_typeimports.moc"