Update auto tests
Following merge, and after removing all QtScript usage from QDeclarativeEngine.
This commit is contained in:
parent
49cc32e6c9
commit
db9d54749f
|
@ -62,7 +62,7 @@ contains(QT_CONFIG, private_tests) {
|
|||
qdeclarativeproperty \
|
||||
qdeclarativepropertymap \
|
||||
qdeclarativerepeater \
|
||||
qdeclarativescriptdebugging \
|
||||
# qdeclarativescriptdebugging \
|
||||
qdeclarativesmoothedanimation \
|
||||
qdeclarativespringanimation \
|
||||
qdeclarativestyledtext \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue