1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** 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"