summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-12 02:05:09 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-12 02:05:09 (GMT)
commit350d455677d928d5154ebf9e33328423c8aa012d (patch)
tree72bc36832aa07fcfe676bed3482766dc2071a8c7 /tests/auto
parent38c3d2d086d0e7fa07daf0d172d27747d6f95519 (diff)
downloadQt-350d455677d928d5154ebf9e33328423c8aa012d.zip
Qt-350d455677d928d5154ebf9e33328423c8aa012d.tar.gz
Qt-350d455677d928d5154ebf9e33328423c8aa012d.tar.bz2
Clean up qmlparser test
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmlparser/assignObjectToSignal.txt3
-rw-r--r--tests/auto/declarative/qmlparser/duplicateIDs.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/duplicateIDs.txt5
-rw-r--r--tests/auto/declarative/qmlparser/empty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/empty.txt0
-rw-r--r--tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/fakeDotProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/interfaceProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/interfaceQList.txt6
-rw-r--r--tests/auto/declarative/qmlparser/interfaceQmlList.txt6
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.txt3
-rw-r--r--tests/auto/declarative/qmlparser/missingObject.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/missingObject.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.1.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.3.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.4.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.5.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.6.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nullDotProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nullDotProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/qmlparser.pro1
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.1.txt3
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/simpleContainer.txt4
-rw-r--r--tests/auto/declarative/qmlparser/simpleObject.txt1
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp309
-rw-r--r--tests/auto/declarative/qmlparser/unregisteredObject.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/unregisteredObject.txt1
-rw-r--r--tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/unsupportedProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.1.txt3
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.3.txt3
46 files changed, 168 insertions, 234 deletions
diff --git a/tests/auto/declarative/qmlparser/assignObjectToSignal.txt b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt
new file mode 100644
index 0000000..0d6bc4e
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ onBasicSignal: MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt
new file mode 100644
index 0000000..b03f735
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt
@@ -0,0 +1 @@
+3:5:id is not unique
diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.txt b/tests/auto/declarative/qmlparser/duplicateIDs.txt
new file mode 100644
index 0000000..e76ee21
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/duplicateIDs.txt
@@ -0,0 +1,5 @@
+MyContainer {
+ MyQmlObject { id: MyID }
+ MyQmlObject { id: MyID }
+}
+
diff --git a/tests/auto/declarative/qmlparser/empty.errors.txt b/tests/auto/declarative/qmlparser/empty.errors.txt
new file mode 100644
index 0000000..101b6a2
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/empty.errors.txt
@@ -0,0 +1 @@
+0:0:Syntax error
diff --git a/tests/auto/declarative/qmlparser/empty.txt b/tests/auto/declarative/qmlparser/empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/empty.txt
diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt
new file mode 100644
index 0000000..6c42157
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot set properties on value as it is of unknown type
diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.txt
new file mode 100644
index 0000000..28eb9dc
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/fakeDotProperty.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ value.something: "hello"
+}
diff --git a/tests/auto/declarative/qmlparser/interfaceProperty.txt b/tests/auto/declarative/qmlparser/interfaceProperty.txt
new file mode 100644
index 0000000..cbad7f1
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/interfaceProperty.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ interface: MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/interfaceQList.txt b/tests/auto/declarative/qmlparser/interfaceQList.txt
new file mode 100644
index 0000000..6c6ab4b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/interfaceQList.txt
@@ -0,0 +1,6 @@
+MyContainer {
+ qlistInterfaces: [
+ MyQmlObject {},
+ MyQmlObject {}
+ ]
+}
diff --git a/tests/auto/declarative/qmlparser/interfaceQmlList.txt b/tests/auto/declarative/qmlparser/interfaceQmlList.txt
new file mode 100644
index 0000000..f41c105
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/interfaceQmlList.txt
@@ -0,0 +1,6 @@
+MyContainer {
+ qmllistInterfaces: [
+ MyQmlObject {},
+ MyQmlObject {}
+ ]
+}
diff --git a/tests/auto/declarative/qmlparser/invalidID.errors.txt b/tests/auto/declarative/qmlparser/invalidID.errors.txt
new file mode 100644
index 0000000..eed1869
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.errors.txt
@@ -0,0 +1 @@
+1:1:"1" is not a valid id
diff --git a/tests/auto/declarative/qmlparser/invalidID.txt b/tests/auto/declarative/qmlparser/invalidID.txt
new file mode 100644
index 0000000..f91e8c4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ id: 1
+}
diff --git a/tests/auto/declarative/qmlparser/missingObject.errors.txt b/tests/auto/declarative/qmlparser/missingObject.errors.txt
new file mode 100644
index 0000000..8438b9e
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/missingObject.errors.txt
@@ -0,0 +1 @@
+1:10:Syntax error
diff --git a/tests/auto/declarative/qmlparser/missingObject.txt b/tests/auto/declarative/qmlparser/missingObject.txt
new file mode 100644
index 0000000..2f17045
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/missingObject.txt
@@ -0,0 +1 @@
+something: 24
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt
new file mode 100644
index 0000000..406ad83
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt
@@ -0,0 +1 @@
+1:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt
new file mode 100644
index 0000000..5023b38
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt
@@ -0,0 +1 @@
+MyQmlObject { something: 24 }
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt
new file mode 100644
index 0000000..b371a0f
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt
@@ -0,0 +1 @@
+2:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt
new file mode 100644
index 0000000..3b6cfa6
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ something: 24
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt
new file mode 100644
index 0000000..b371a0f
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt
@@ -0,0 +1 @@
+2:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt
new file mode 100644
index 0000000..61f3625
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ something: 1 + 1
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt
new file mode 100644
index 0000000..b371a0f
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt
@@ -0,0 +1 @@
+2:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt
new file mode 100644
index 0000000..5ee1d3a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ something: ;
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt
new file mode 100644
index 0000000..4234fca4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt
@@ -0,0 +1 @@
+2:5:Unexpected token `numeric literal'
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt
new file mode 100644
index 0000000..1dc6985
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ 24
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt
new file mode 100644
index 0000000..3183b6d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot assign to default property
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt
new file mode 100644
index 0000000..4940833
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt
new file mode 100644
index 0000000..8482634
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot set properties on obj as it is null
diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.txt b/tests/auto/declarative/qmlparser/nullDotProperty.txt
new file mode 100644
index 0000000..5c60c5b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nullDotProperty.txt
@@ -0,0 +1,3 @@
+MyDotPropertyObject {
+ obj.value: 1
+}
diff --git a/tests/auto/declarative/qmlparser/qmlparser.pro b/tests/auto/declarative/qmlparser/qmlparser.pro
index 3e0b6ea..43e5309 100644
--- a/tests/auto/declarative/qmlparser/qmlparser.pro
+++ b/tests/auto/declarative/qmlparser/qmlparser.pro
@@ -1,3 +1,4 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
SOURCES += tst_qmlparser.cpp
+macx:CONFIG -= app_bundle
diff --git a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt
new file mode 100644
index 0000000..89009ce
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt
@@ -0,0 +1 @@
+2:21:Cannot assign value "Hello World" to the read-only property readOnlyString
diff --git a/tests/auto/declarative/qmlparser/readOnly.1.txt b/tests/auto/declarative/qmlparser/readOnly.1.txt
new file mode 100644
index 0000000..c47fdf3
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.1.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ readOnlyString: "Hello World"
+}
diff --git a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt
new file mode 100644
index 0000000..ab27946
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot assign a binding to read-only property "readOnlyString"
diff --git a/tests/auto/declarative/qmlparser/readOnly.2.txt b/tests/auto/declarative/qmlparser/readOnly.2.txt
new file mode 100644
index 0000000..2b6f733
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.2.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ readOnlyString: "Hello" + "World"
+}
diff --git a/tests/auto/declarative/qmlparser/simpleContainer.txt b/tests/auto/declarative/qmlparser/simpleContainer.txt
new file mode 100644
index 0000000..8b30ed9
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/simpleContainer.txt
@@ -0,0 +1,4 @@
+MyContainer {
+ MyQmlObject {}
+ MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/simpleObject.txt b/tests/auto/declarative/qmlparser/simpleObject.txt
new file mode 100644
index 0000000..05ed87a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/simpleObject.txt
@@ -0,0 +1 @@
+MyQmlObject {}
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index efd45d3..f17583a 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -1,6 +1,8 @@
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
class MyInterface
{
@@ -43,7 +45,7 @@ public:
MyInterface *interface() const { return m_interface; }
void setInterface(MyInterface *iface) { m_interface = iface; }
- Q_CLASSINFO("defaultMethod", "basicSlot()");
+ Q_CLASSINFO("DefaultMethod", "basicSlot()");
public slots:
void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
@@ -133,27 +135,16 @@ public:
tst_qmlparser() {}
private slots:
+
+ void errors_data();
+ void errors();
+
void simpleObject();
void simpleContainer();
- void unregisteredObject();
- void nonexistantProperty();
- void unsupportedProperty();
- //void setProperties();
- void wrongType();
- void readOnly();
- //void dotProperties();
- void nullDotProperty();
- void fakeDotProperty();
- //void readWriteDotProperty();
- void emptyInput();
- void missingObject();
- //void invalidXML();
- void duplicateIDs();
- void invalidID();
void interfaceProperty();
void interfaceQmlList();
void interfaceQList();
- //void cannotAssignBindingToSignal();
+
void assignObjectToSignal();
// regression tests for crashes
@@ -163,242 +154,101 @@ private:
QmlEngine engine;
};
-void tst_qmlparser::simpleObject()
-{
- QmlComponent component(&engine, "MyQmlObject {}");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QFile file(errorfile); \
+ QVERIFY(file.open(QIODevice::ReadOnly)); \
+ QByteArray data = file.readAll(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QmlError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "") \
+ qWarning() << expected << actual; \
+ QCOMPARE(expected, actual); \
+ }
-void tst_qmlparser::simpleContainer()
-{
- QmlComponent component(&engine, "MyContainer {\nMyQmlObject{}\nMyQmlObject{}\n}");
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QCOMPARE(container->children()->count(),2);
-}
+#define TEST_FILE(filename) \
+ QUrl::fromLocalFile(QApplication::applicationDirPath() + "/" + filename)
-void tst_qmlparser::unregisteredObject()
+void tst_qmlparser::errors_data()
{
- QmlComponent component(&engine, "UnRegisteredObject {}", QUrl("myprogram.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Unable to create object of type 'UnRegisteredObject' @myprogram.qml:1");
- QObject *object = component.create();
- QVERIFY(object == 0);
-}
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
-void tst_qmlparser::nonexistantProperty()
-{
- //NOTE: these first 3 should all have the same error message
- {
- QmlComponent component(&engine, "MyQmlObject { something: 24 }");
- QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QTest::newRow("nonExistantProperty.1") << "nonexistantProperty.1.txt" << "nonexistantProperty.1.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.2") << "nonexistantProperty.2.txt" << "nonexistantProperty.2.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.3") << "nonexistantProperty.3.txt" << "nonexistantProperty.3.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.4") << "nonexistantProperty.4.txt" << "nonexistantProperty.4.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false;
+ QTest::newRow("nonExistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << true;
- {
- QmlComponent component(&engine, "MyQmlObject {\n something: 24\n}");
- QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:2");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
- //non-existant using binding
- {
- QmlComponent component(&engine, "MyQmlObject { something: 1 + 1 }");
- QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QTest::newRow("wrongType (string for int)") << "wrongType.1.txt" << "wrongType.1.errors.txt" << false;
+ QTest::newRow("wrongType (int for bool)") << "wrongType.2.txt" << "wrongType.2.errors.txt" << false;
+ QTest::newRow("wrongType (bad rect)") << "wrongType.3.txt" << "wrongType.3.errors.txt" << false;
- {
- QmlComponent component(&engine, "MyQmlObject { something: }");
- QObject *object = component.create();
- QVERIFY(object != 0);
- }
- //non-existant value-type default property
- {
- QmlComponent component(&engine, "MyQmlObject {\n24\n}");
- QTest::ignoreMessage(QtWarningMsg, "Unable to resolve default property @<unspecified file>:3");
- // XXX would 2 be a better line number in this case? Message should also be improved.
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QTest::newRow("nonExistantProperty.1") << "readOnly.1.txt" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("nonExistantProperty.2") << "readOnly.2.txt" << "readOnly.2.errors.txt" << true;
- //non-existant object-type default property
- {
- QmlComponent component(&engine, "MyQmlObject {\nMyQmlObject{}\n}");
- QTest::ignoreMessage(QtWarningMsg, "Unable to assign to non-existant property @<unspecified file>:2");
- // XXX Message needs to be improved (and should be closer to value-type message).
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-}
-void tst_qmlparser::unsupportedProperty()
-{
- QTest::ignoreMessage(QtWarningMsg, "Property 'matrix' is of an unknown type @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { matrix: \"1,0,0,0,1,0,0,0,1\" }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
+ QTest::newRow("unsupportedProperty") << "unsupportedProperty.txt" << "unsupportedProperty.errors.txt" << true;
+ QTest::newRow("nullDotProperty") << "nullDotProperty.txt" << "nullDotProperty.errors.txt" << true;
+ QTest::newRow("fakeDotProperty") << "fakeDotProperty.txt" << "fakeDotProperty.errors.txt" << true;
+ QTest::newRow("duplicateIDs") << "duplicateIDs.txt" << "duplicateIDs.errors.txt" << false;
+ QTest::newRow("invalidID") << "invalidID.txt" << "invalidID.errors.txt" << false;
+ QTest::newRow("unregisteredObject") << "unregisteredObject.txt" << "unregisteredObject.errors.txt" << false;
+ QTest::newRow("empty") << "empty.txt" << "empty.errors.txt" << false;
+ QTest::newRow("missingObject") << "missingObject.txt" << "missingObject.errors.txt" << false;
}
-void tst_qmlparser::wrongType()
+void tst_qmlparser::errors()
{
- //string for int
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value 'hello' to property 'value' @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { value: \"hello\" }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
- }
-
- //int for bool
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5' to property 'enabled' @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { enabled: 5 }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
- }
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
- //bad format for rect
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5,5x10' to property 'rect' @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { rect: \"5,5x10\" }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
- }
-
- //TODO: more types (including float-to-int, complex types, etc)
-}
-
-void tst_qmlparser::readOnly()
-{
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value 'hello' to property 'readOnlyString' because 'readOnlyString' is read-only @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { readOnlyString: \"hello\" }");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QmlComponent component(&engine, TEST_FILE(file));
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign a binding to property 'readOnlyString' because 'readOnlyString' is read-only @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { readOnlyString: {'hello'} }");
+ if(create) {
QObject *object = component.create();
QVERIFY(object == 0);
}
-}
-void tst_qmlparser::nullDotProperty()
-{
- QTest::ignoreMessage(QtWarningMsg, "Can't set properties on 'obj' because it is null @<unspecified file>:1");
- QmlComponent component(&engine, "MyDotPropertyObject { obj.value: 1 }");
- QObject *object = component.create();
- QVERIFY(object == 0);
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
}
-void tst_qmlparser::fakeDotProperty()
+void tst_qmlparser::simpleObject()
{
- QTest::ignoreMessage(QtWarningMsg, "Can't set properties on 'value' because it isn't a known object type @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { value.something: \"hello\" }");
+ QmlComponent component(&engine, TEST_FILE("simpleObject.txt"));
+ VERIFY_ERRORS(0);
QObject *object = component.create();
- QVERIFY(object == 0);
-}
-
-//XXX need to define correct behavior first
-/*void tst_qmlparser::readWriteDotProperty()
-{
- QmlComponent component(&engine, "MyDotPropertyObject { readWriteObj.value: 1 }");
- MyDotPropertyObject *object = qobject_cast<MyDotPropertyObject*>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->readWriteObj()->value(),1);
-
- {
- QmlComponent component(&engine, "MyContainer { MyQmlObject { id: Obj value: 1 } MyDotPropertyObject { readWriteObj: Obj } }");
- MyContainer *object = qobject_cast<MyContainer*>(component.create());
- QVERIFY(object != 0);
- MyDotPropertyObject *dpo = qobject_cast<MyDotPropertyObject *>(object->children()->at(1));
- QCOMPARE(dpo->readWriteObj()->value(),1);
- }
-}*/
-
-void tst_qmlparser::emptyInput()
-{
- QTest::ignoreMessage(QtCriticalMsg, "No Qml was specified for parsing.");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @<unspecified file>:-1");
- QmlComponent component(&engine, "");
- QObject *object = component.create();
- QVERIFY(object == 0);
-}
-
-void tst_qmlparser::missingObject()
-{
- QTest::ignoreMessage(QtCriticalMsg, "Can't have a property with no object @<unspecified file>:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @<unspecified file>:-1");
- QmlComponent component(&engine, "something:");
- QObject *object = component.create();
- QVERIFY(object == 0);
-}
-
-
-/*void tst_qmlparser::invalidXML()
-{
- //extra stuff on end
- {
- QTest::ignoreMessage(QtCriticalMsg, "Extra content at end of document. @myprogram.qml:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject/><something/>", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- //mismatched tags
- {
- QTest::ignoreMessage(QtCriticalMsg, "Opening and ending tag mismatch. @myprogram.qml:2");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject>\n</MyContainer>", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- {
- QTest::ignoreMessage(QtCriticalMsg, "Expected '>' or '/', but got '<'. @myprogram.qml:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject < />", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- {
- QTest::ignoreMessage(QtCriticalMsg, "Premature end of document. @myprogram.qml:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject something=\" />", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
-}*/
-
-void tst_qmlparser::duplicateIDs()
-{
- QTest::ignoreMessage(QtWarningMsg, "An id (\"MyID\") is not unique within its scope. @<unspecified file>:3");
- QmlComponent component(&engine, "MyContainer {\nMyQmlObject { id: MyID }\nMyQmlObject { id: MyID }\n}");
- QObject *object = component.create();
- QVERIFY(object == 0);
}
-void tst_qmlparser::invalidID()
+void tst_qmlparser::simpleContainer()
{
- QTest::ignoreMessage(QtWarningMsg, "'1' is not a valid id @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { id: 1 }");
- QObject *object = component.create();
- QVERIFY(object == 0);
+ QmlComponent component(&engine, TEST_FILE("simpleContainer.txt"));
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QCOMPARE(container->children()->count(),2);
}
void tst_qmlparser::interfaceProperty()
{
- QmlComponent component(&engine, "MyQmlObject { interface: MyQmlObject }");
+ QmlComponent component(&engine, TEST_FILE("interfaceProperty.txt"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
QVERIFY(object->interface());
@@ -407,7 +257,7 @@ void tst_qmlparser::interfaceProperty()
void tst_qmlparser::interfaceQmlList()
{
- QmlComponent component(&engine, "MyContainer { qmllistInterfaces: MyQmlObject {} }");
+ QmlComponent component(&engine, TEST_FILE("interfaceQmlList.txt"));
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QVERIFY(container->qmllistAccessor().count() == 2);
@@ -417,7 +267,7 @@ void tst_qmlparser::interfaceQmlList()
void tst_qmlparser::interfaceQList()
{
- QmlComponent component(&engine, "MyContainer { qlistInterfaces: MyQmlObject {} }");
+ QmlComponent component(&engine, TEST_FILE("interfaceQList.txt"));
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QVERIFY(container->qlistInterfaces()->count() == 2);
@@ -425,17 +275,9 @@ void tst_qmlparser::interfaceQList()
QVERIFY(container->qlistInterfaces()->at(ii)->id == 913);
}
-/*void tst_qmlparser::cannotAssignBindingToSignal()
-{
- QTest::ignoreMessage(QtWarningMsg, "Cannot assign binding to signal property @<unspecified file>:1");
- QmlComponent component(&engine, "<MyQmlObject onBasicSignal=\"{print(1921)}\" />");
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container == 0);
-}*/
-
void tst_qmlparser::assignObjectToSignal()
{
- QmlComponent component(&engine, "MyQmlObject { onBasicSignal: MyQmlObject {} }");
+ QmlComponent component(&engine, TEST_FILE("assignObjectToSignal.txt"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
@@ -445,7 +287,6 @@ void tst_qmlparser::assignObjectToSignal()
void tst_qmlparser::crash1()
{
QmlComponent component(&engine, "Component {}");
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
}
QTEST_MAIN(tst_qmlparser)
diff --git a/tests/auto/declarative/qmlparser/unregisteredObject.errors.txt b/tests/auto/declarative/qmlparser/unregisteredObject.errors.txt
new file mode 100644
index 0000000..11e4e16
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unregisteredObject.errors.txt
@@ -0,0 +1 @@
+-1:-1:Type UnregisteredObject unavailable
diff --git a/tests/auto/declarative/qmlparser/unregisteredObject.txt b/tests/auto/declarative/qmlparser/unregisteredObject.txt
new file mode 100644
index 0000000..ff46457
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unregisteredObject.txt
@@ -0,0 +1 @@
+UnregisteredObject {}
diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt
new file mode 100644
index 0000000..f396e7e
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt
@@ -0,0 +1 @@
+2:-1:Property matrix is of an unknown type
diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.txt
new file mode 100644
index 0000000..bbbd31d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unsupportedProperty.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ matrix: "1,0,0,0,1,0,0,0,1"
+}
diff --git a/tests/auto/declarative/qmlparser/wrongType.1.errors.txt b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt
new file mode 100644
index 0000000..8976ee1
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt
@@ -0,0 +1 @@
+2:12:Cannot assign value "hello" to property value
diff --git a/tests/auto/declarative/qmlparser/wrongType.1.txt b/tests/auto/declarative/qmlparser/wrongType.1.txt
new file mode 100644
index 0000000..281a227
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.1.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ value: "hello"
+}
diff --git a/tests/auto/declarative/qmlparser/wrongType.2.errors.txt b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt
new file mode 100644
index 0000000..301d258
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt
@@ -0,0 +1 @@
+2:14:Cannot assign value "5" to property enabled
diff --git a/tests/auto/declarative/qmlparser/wrongType.2.txt b/tests/auto/declarative/qmlparser/wrongType.2.txt
new file mode 100644
index 0000000..cdedf8c
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.2.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ enabled: 5
+}
diff --git a/tests/auto/declarative/qmlparser/wrongType.3.errors.txt b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt
new file mode 100644
index 0000000..3afcc2b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt
@@ -0,0 +1 @@
+2:11:Cannot assign value "5,5x10" to property rect
diff --git a/tests/auto/declarative/qmlparser/wrongType.3.txt b/tests/auto/declarative/qmlparser/wrongType.3.txt
new file mode 100644
index 0000000..839e0c7
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.3.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ rect: "5,5x10"
+}