aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-14 16:08:01 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-14 16:08:01 +1000
commitdb9d54749f134495bd862ee901dd141d41fac291 (patch)
tree315075a46aa72b5cdec07a86a7cb29fa0342713d /tests
parent49cc32e6c91b0ebe935810f3d5d581e6e8dfcc46 (diff)
Update auto tests
Following merge, and after removing all QtScript usage from QDeclarativeEngine.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/declarative.pro2
-rw-r--r--tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp39
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp11
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml61
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp37
6 files changed, 69 insertions, 91 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 8859b83e9e..6067c70ad9 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -62,7 +62,7 @@ contains(QT_CONFIG, private_tests) {
qdeclarativeproperty \
qdeclarativepropertymap \
qdeclarativerepeater \
- qdeclarativescriptdebugging \
+# qdeclarativescriptdebugging \
qdeclarativesmoothedanimation \
qdeclarativespringanimation \
qdeclarativestyledtext \
diff --git a/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp b/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp
index 5fecd29c51..505361bc27 100644
--- a/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp
+++ b/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp
@@ -52,7 +52,6 @@
class tst_qdeclarativedebughelper : public QObject {
Q_OBJECT
private slots:
- void getScriptEngine();
void setAnimationSlowDownFactor();
void enableDebugging();
};
@@ -71,15 +70,6 @@ public:
}
};
-void tst_qdeclarativedebughelper::getScriptEngine()
-{
- QDeclarativeEngine engine;
-
- QScriptEngine *scriptEngine = QDeclarativeDebugHelper::getScriptEngine(&engine);
- QVERIFY(scriptEngine);
- QCOMPARE(scriptEngine, QDeclarativeEnginePrivate::getScriptEngine(&engine));
-}
-
void tst_qdeclarativedebughelper::setAnimationSlowDownFactor()
{
TestAnimation animation;
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 80701d52f2..81e54c0c5b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -178,7 +178,6 @@ private slots:
void aliasBindingsAssignCorrectly();
void aliasBindingsOverrideTarget();
void aliasWritesOverrideBindings();
- void pushCleanContext();
void realToInt();
void include();
@@ -3553,44 +3552,6 @@ void tst_qdeclarativeecmascript::revision()
}
}
-// Test for QScriptDeclarativeClass::pushCleanContext()
-void tst_qdeclarativeecmascript::pushCleanContext()
-{
- QScriptEngine engine;
- engine.globalObject().setProperty("a", 6);
- QCOMPARE(engine.evaluate("a").toInt32(), 6);
-
- // First confirm pushContext() behaves as we expect
- QScriptValue object = engine.newObject();
- object.setProperty("a", 15);
- QScriptContext *context1 = engine.pushContext();
- context1->pushScope(object);
- QCOMPARE(engine.evaluate("a").toInt32(), 15);
-
- QScriptContext *context2 = engine.pushContext();
- Q_UNUSED(context2);
- QCOMPARE(engine.evaluate("a").toInt32(), 15);
- QScriptValue func1 = engine.evaluate("(function() { return a; })");
-
- // Now check that pushCleanContext() works
- QScriptDeclarativeClass::pushCleanContext(&engine);
- QCOMPARE(engine.evaluate("a").toInt32(), 6);
- QScriptValue func2 = engine.evaluate("(function() { return a; })");
-
- engine.popContext();
- QCOMPARE(engine.evaluate("a").toInt32(), 15);
-
- engine.popContext();
- QCOMPARE(engine.evaluate("a").toInt32(), 15);
-
- engine.popContext();
- QCOMPARE(engine.evaluate("a").toInt32(), 6);
-
- // Check that function objects created in these contexts work
- QCOMPARE(func1.call().toInt32(), 15);
- QCOMPARE(func2.call().toInt32(), 6);
-}
-
void tst_qdeclarativeecmascript::realToInt()
{
QDeclarativeComponent component(&engine, TEST_FILE("realToInt.qml"));
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 0cd9df29b7..07a6d82752 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -69,7 +69,6 @@ public:
private:
int roleFromName(const QDeclarativeListModel *model, const QString &roleName);
- QScriptValue nestedListValue(QScriptEngine *eng) const;
QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model);
void waitForWorker(QDeclarativeItem *item);
@@ -119,16 +118,6 @@ int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model,
return -1;
}
-QScriptValue tst_qdeclarativelistmodel::nestedListValue(QScriptEngine *eng) const
-{
- QScriptValue list = eng->newArray();
- list.setProperty(0, eng->newObject());
- list.setProperty(1, eng->newObject());
- QScriptValue sv = eng->newObject();
- sv.setProperty("foo", list);
- return sv;
-}
-
QDeclarativeItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model)
{
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component->create());
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml
new file mode 100644
index 0000000000..4e03503f90
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml
@@ -0,0 +1,61 @@
+import QtQuick 1.0
+
+XmlListModel {
+ source: "model.xml"
+ query: "/Pets/Pet"
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "type"; query: "type/string()" }
+ XmlRole { name: "age"; query: "age/number()" }
+ XmlRole { name: "size"; query: "size/string()" }
+
+ id: root
+
+ property bool preTest: false
+ property bool postTest: false
+
+ function runPreTest() {
+ if (root.get(0) != undefined)
+ return;
+
+ preTest = true;
+ }
+
+ function runPostTest() {
+ if (root.get(-1) != undefined)
+ return;
+
+ var row = root.get(0);
+ if (row.name != "Polly" ||
+ row.type != "Parrot" ||
+ row.age != 12 ||
+ row.size != "Small")
+ return;
+
+ row = root.get(1);
+ if (row.name != "Penny" ||
+ row.type != "Turtle" ||
+ row.age != 4 ||
+ row.size != "Small")
+ return;
+
+ row = root.get(7);
+ if (row.name != "Rover" ||
+ row.type != "Dog" ||
+ row.age != 0 ||
+ row.size != "Large")
+ return;
+
+ row = root.get(8);
+ if (row.name != "Tiny" ||
+ row.type != "Elephant" ||
+ row.age != 15 ||
+ row.size != "Large")
+ return;
+
+ if (root.get(9) != undefined)
+ return;
+
+ postTest = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 7df2dc340d..37bafebdc4 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -520,40 +520,17 @@ void tst_qdeclarativexmllistmodel::data()
void tst_qdeclarativexmllistmodel::get()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/get.qml"));
QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
QVERIFY(model != 0);
- QVERIFY(model->get(0).isUndefined());
+
+ QVERIFY(QMetaObject::invokeMethod(model, "runPreTest"));
+ QCOMPARE(model->property("preTest").toBool(), true);
QTRY_COMPARE(model->count(), 9);
- QVERIFY(model->get(-1).isUndefined());
-
- QScriptValue sv = model->get(0);
- QCOMPARE(sv.property("name").toString(), QLatin1String("Polly"));
- QCOMPARE(sv.property("type").toString(), QLatin1String("Parrot"));
- QCOMPARE(sv.property("age").toNumber(), qsreal(12));
- QCOMPARE(sv.property("size").toString(), QLatin1String("Small"));
-
- sv = model->get(1);
- QCOMPARE(sv.property("name").toString(), QLatin1String("Penny"));
- QCOMPARE(sv.property("type").toString(), QLatin1String("Turtle"));
- QCOMPARE(sv.property("age").toNumber(), qsreal(4));
- QCOMPARE(sv.property("size").toString(), QLatin1String("Small"));
-
- sv = model->get(7);
- QCOMPARE(sv.property("name").toString(), QLatin1String("Rover"));
- QCOMPARE(sv.property("type").toString(), QLatin1String("Dog"));
- QCOMPARE(sv.property("age").toNumber(), qsreal(0));
- QCOMPARE(sv.property("size").toString(), QLatin1String("Large"));
-
- sv = model->get(8);
- QCOMPARE(sv.property("name").toString(), QLatin1String("Tiny"));
- QCOMPARE(sv.property("type").toString(), QLatin1String("Elephant"));
- QCOMPARE(sv.property("age").toNumber(), qsreal(15));
- QCOMPARE(sv.property("size").toString(), QLatin1String("Large"));
-
- sv = model->get(9);
- QVERIFY(sv.isUndefined());
+
+ QVERIFY(QMetaObject::invokeMethod(model, "runPostTest"));
+ QCOMPARE(model->property("postTest").toBool(), true);
delete model;
}