summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp38
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp31
8 files changed, 89 insertions, 4 deletions
diff --git a/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h b/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h
index 57d8a3d2..a08d9b55 100644
--- a/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h
+++ b/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h
@@ -44,8 +44,6 @@
#include <QtCore/qglobal.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QScriptEngine;
@@ -66,6 +64,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QDECLARATIVEDEBUGHELPER_P_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml
new file mode 100644
index 00000000..4bf7eb2e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml
@@ -0,0 +1,2 @@
+import QtQuick 1.0
+MouseArea {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml
new file mode 100644
index 00000000..9ba0d612
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+Item {
+ property int test: 11
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml
new file mode 100644
index 00000000..d3b31a3d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+import org.qtproject.installedtest 1.0
+
+LocalLast2 {
+ property Item item: LocalLast {}
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml
new file mode 100644
index 00000000..532bc319
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml
@@ -0,0 +1,4 @@
+import QtQuick 1.0
+import Test 1.0
+
+MyComponentType {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
index ee01235b..f812110d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -69,7 +69,9 @@ void registerTypes()
qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser);
+#ifdef QT_BUILD_INTERNAL
qmlRegisterTypeNotAvailable("Test",1,0,"UnavailableType", "UnavailableType is unavailable for testing");
+#endif
}
QVariant myCustomVariantTypeConverter(const QString &data)
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index b37873b2..1574aa4a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -99,6 +99,7 @@ private slots:
void assignLiteralToVariant();
void customParserTypes();
void rootAsQmlComponent();
+ void qmlComponentType();
void inlineQmlComponents();
void idProperty();
void autoNotifyConnection();
@@ -132,6 +133,7 @@ private slots:
void reservedWords();
void inlineAssignmentsOverrideBindings();
void nestedComponentRoots();
+ void implicitImportsLast();
void basicRemote_data();
void basicRemote();
@@ -403,7 +405,9 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
+#ifdef QT_BUILD_INTERNAL
QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
+#endif
QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
QTest::newRow("incorrectCase") << "incorrectCase.qml"
@@ -627,6 +631,16 @@ void tst_qdeclarativelanguage::rootAsQmlComponent()
QCOMPARE(object->getChildren()->count(), 2);
}
+// Tests that types can be specified from a QML only component
+void tst_qdeclarativelanguage::qmlComponentType()
+{
+ QDeclarativeComponent component(&engine, testFileUrl("qmlComponentType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test"), QVariant(11));
+}
+
// Tests that components can be specified inline
void tst_qdeclarativelanguage::inlineQmlComponents()
{
@@ -1806,6 +1820,11 @@ void tst_qdeclarativelanguage::importsOrder_data()
"LocalLast {}"
<< (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml
<< (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory");
+ QTest::newRow("local last 3") <<
+ "import org.qtproject.installedtest 1.0\n"
+ "LocalLast {LocalLast2{}}"
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory");
}
void tst_qdeclarativelanguage::importsOrder()
@@ -1959,6 +1978,8 @@ void tst_qdeclarativelanguage::initTestCase()
{
QDeclarativeDataTest::initTestCase();
registerTypes();
+ // Registered here because it uses testFileUrl
+ qmlRegisterType(testFileUrl("MyComponentType.qml"), "Test", 1, 0, "MyComponentType");
// Registering the TestType class in other modules should have no adverse effects
qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test");
@@ -2021,6 +2042,23 @@ void tst_qdeclarativelanguage::compatibilitySemicolon()
QVERIFY(o != 0);
}
+// Tests that the implicit import has lowest precedence, in the case where
+// there are conflicting types and types only found in the local import.
+// Tests that just check one (or the root) type are in ::importsOrder
+void tst_qdeclarativelanguage::implicitImportsLast()
+{
+ if (qmlCheckTypes())
+ QSKIP("This test is about maintaining the same choice when type is ambiguous.");
+ QDeclarativeComponent component(&engine, testFileUrl("localOrderTest.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QDeclarativeMouseArea")));
+ QObject* object2 = object->property("item").value<QObject*>();
+ QVERIFY(object2 != 0);
+ QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QDeclarativeRectangle"));
+}
+
QTEST_MAIN(tst_qdeclarativelanguage)
#include "tst_qdeclarativelanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 5c00ac95..eb0e0948 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -85,6 +85,7 @@ private slots:
void enforceRange();
void spacing();
void sections();
+ void currentSection();
void sectionsDelegate();
void cacheBuffer();
void positionViewAtIndex();
@@ -1049,6 +1050,36 @@ void tst_QDeclarativeListView::sections()
delete canvas;
}
+void tst_QDeclarativeListView::currentSection()
+{
+ // QTBUG-29712
+ // update currentSection correctly if model modifications
+ // do not trigger a refill
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 5; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ // make sure the listView won't trigger refill when removing the first row
+ QTRY_VERIFY(listview->height() > model.count() * 40);
+
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
+ model.removeItem(0);
+ QTRY_COMPARE(listview->currentSection(), QString("1"));
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::sectionsDelegate()
{
QDeclarativeView *canvas = createView();