From 3184fbcd858244b5cd171fd0ab32c3ff565e579e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 6 Oct 2009 15:48:32 +1000 Subject: Add tst_qmlecmascript::scriptAccess testcase --- .../auto/declarative/qmlecmascript/data/scriptAccess.js | 7 +++++++ .../declarative/qmlecmascript/data/scriptAccess.qml | 17 +++++++++++++++++ .../declarative/qmlecmascript/tst_qmlecmascript.cpp | 15 +++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/auto/declarative/qmlecmascript/data/scriptAccess.js create mode 100644 tests/auto/declarative/qmlecmascript/data/scriptAccess.qml diff --git a/tests/auto/declarative/qmlecmascript/data/scriptAccess.js b/tests/auto/declarative/qmlecmascript/data/scriptAccess.js new file mode 100644 index 0000000..c00d285 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/scriptAccess.js @@ -0,0 +1,7 @@ +var extVariable = 19; + +function extMethod() +{ + return extVariable; +} + diff --git a/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml b/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml new file mode 100644 index 0000000..feb6d16 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml @@ -0,0 +1,17 @@ +import Qt 4.6 + +Item { + Script { + function method() { + return 10; + } + } + + Script { + source: "scriptAccess.js" + } + + property int test1: method() + property int test2: extMethod() + property int test3: extVariable +} diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index c69528a..15a7860 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -54,6 +54,7 @@ private slots: void scope(); void signalParameterTypes(); void objectsCompareAsEqual(); + void scriptAccess(); private: QmlEngine engine; @@ -600,6 +601,20 @@ void tst_qmlecmascript::aliasPropertyAndBinding() QCOMPARE(object->property("c3").toInt(), 19); } +/* +Tests that only methods of Script {} blocks are exposed. +*/ +void tst_qmlecmascript::scriptAccess() +{ + QmlComponent component(&engine, TEST_FILE("scriptAccess.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), 10); + QCOMPARE(object->property("test2").toInt(), 19); + QCOMPARE(object->property("test3").toInt(), 0); +} + QTEST_MAIN(tst_qmlecmascript) #include "tst_qmlecmascript.moc" -- cgit v0.12