summaryrefslogtreecommitdiffstats
path: root/src/interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'src/interpreter')
-rw-r--r--src/interpreter/imports/imports.pro3
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/Application.qml162
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/ApplicationObjectsCache.js75
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/Js.qml49
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/Remote.qml168
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/Test.qml68
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/TestCollection.qml80
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/TestItem.qml83
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/TestMethod.qml80
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstObject.qml117
-rw-r--r--src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstWidget.qml49
-rw-r--r--src/interpreter/imports/qtsystemtest/qmldir11
-rw-r--r--src/interpreter/imports/qtsystemtest/qtsystemtest.json1
-rw-r--r--src/interpreter/imports/qtsystemtest/qtsystemtest.pro74
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/ApplicationRegistry.js68
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/Class.js121
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/ComponentCacher.js147
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/Console.js128
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/Datatype.js142
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/Exception.js105
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/Expect.js112
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/Functional.js298
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/ItemFactory.js117
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/JsCore.js215
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/QstCore.js52
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/SourceBuilder.js172
-rw-r--r--src/interpreter/imports/qtsystemtest/scripts/api.js56
-rw-r--r--src/interpreter/imports/qtsystemtest/src/imports.cpp66
-rw-r--r--src/interpreter/imports/qtsystemtest/src/imports.h58
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qstcoreapi.cpp56
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qstcoreapi.h71
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qstlocalprocess.cpp167
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qstlocalprocess.h131
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qstutils.cpp50
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qstutils.h61
-rw-r--r--src/interpreter/imports/qtsystemtest/src/qtuitestglobal.h84
-rw-r--r--src/interpreter/imports/runner/qml/Config.qml58
-rw-r--r--src/interpreter/imports/runner/qml/Logger.qml101
-rw-r--r--src/interpreter/imports/runner/qml/PlainTextLogger.qml162
-rw-r--r--src/interpreter/imports/runner/qml/XUnitLogger.qml172
-rw-r--r--src/interpreter/imports/runner/qml/XmlLogger.qml178
-rw-r--r--src/interpreter/imports/runner/qmldir7
-rw-r--r--src/interpreter/imports/runner/qtsystemtestrunner.json1
-rw-r--r--src/interpreter/imports/runner/runner.pro70
-rw-r--r--src/interpreter/imports/runner/src/imports.cpp60
-rw-r--r--src/interpreter/imports/runner/src/imports.h58
-rw-r--r--src/interpreter/imports/runner/src/qstlogwriter.cpp166
-rw-r--r--src/interpreter/imports/runner/src/qstlogwriter.h212
-rw-r--r--src/interpreter/imports/runner/src/qstxunitwriter.cpp189
-rw-r--r--src/interpreter/imports/runner/src/qstxunitwriter.h92
-rw-r--r--src/interpreter/interpreter.pro4
-rw-r--r--src/interpreter/runner/main.cpp66
-rw-r--r--src/interpreter/runner/qstjsengine.cpp49
-rw-r--r--src/interpreter/runner/qstjsengine.h59
-rw-r--r--src/interpreter/runner/qstrunnerbootstrap.cpp229
-rw-r--r--src/interpreter/runner/qstrunnerbootstrap.h81
-rw-r--r--src/interpreter/runner/qstrunnercore.cpp102
-rw-r--r--src/interpreter/runner/qstrunnercore.h71
-rw-r--r--src/interpreter/runner/runner.pro30
-rw-r--r--src/interpreter/runner/scripts/QstRunner.js358
-rw-r--r--src/interpreter/runner/scripts/QstRunner.qml138
61 files changed, 6210 insertions, 0 deletions
diff --git a/src/interpreter/imports/imports.pro b/src/interpreter/imports/imports.pro
new file mode 100644
index 0000000..dd43ea0
--- /dev/null
+++ b/src/interpreter/imports/imports.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS += qtsystemtest \
+ runner
diff --git a/src/interpreter/imports/qtsystemtest/qml/Application.qml b/src/interpreter/imports/qtsystemtest/qml/Application.qml
new file mode 100644
index 0000000..36c9cdb
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/Application.qml
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import "../scripts/QstCore.js" as Core
+
+QtObject {
+ id: app
+
+ property Remote remote
+ property variant pid: null
+ property variant __id
+
+ function item(query) {
+ var matches = __queryProperties(query);
+ if ( matches.length !== 1 ) {
+ throw new Core.Qtt.Fail('Error: ' + matches.length +
+ ' items match query, expected a single match', 1);
+ }
+ return __handlerForObject(matches[0]);
+ }
+
+ function items(query) {
+ var matches = __queryProperties(query);
+ var handlers = matches.map(function(obj) {
+ return __handlerForObject(obj);
+ });
+ return handlers;
+ }
+
+ function activeWidgetInfo() { return __sendQuery(arguments.callee.name); }
+
+ function applicationData() {
+ return __sendQuery(arguments.callee.name).applicationdata;
+ }
+
+
+ function keyPress(key) {
+ __sendQuery(arguments.callee.name, { key: key });
+ }
+
+ function keyRelease(key) {
+ __sendQuery(arguments.callee.name, { key: key });
+ }
+
+ function keyClick(key) {
+ __sendQuery(arguments.callee.name, { key: key });
+ }
+
+
+ function mousePress(pos, buttons) {
+ __inputEvent(arguments.callee.name, pos, buttons);
+ }
+
+ function mouseRelease(pos, buttons) {
+ __inputEvent(arguments.callee.name, pos, buttons);
+ }
+
+ function mouseClick(pos, buttons) {
+ __inputEvent(arguments.callee.name, pos, buttons);
+ }
+
+ function mouseDoubleClick(pos, buttons) {
+ __inputEvent(arguments.callee.name, pos, buttons);
+ }
+
+ function terminate() {
+ remote.runProcess( { program: "kill", arguments: [ pid ], timeout: 500 } );
+ }
+
+ function __queryProperties(query) {
+ // traverse the query object replacing any QstObject with its __internals
+ (function prepare(query) {
+ var prop, v;
+ for (prop in query) {
+ v = query[prop];
+ if ( typeof(v) !== 'object' ) { continue; }
+
+ if( v.__isQmlWrapper === true ) {
+ query[prop] = v.__internals;
+ } else {
+ prepare(v);
+ }
+ }
+ })(query);
+
+ var items = __sendQuery("queryProperties", {
+ searchvalues: query
+ }).queryproperties;
+ return items || [];
+ }
+
+ function __handlerForObject(obj) {
+ var ItemFactory = Core.ItemFactory;
+ var component = ItemFactory.handlerForObject(obj, {application: app});
+ return component.createObject(
+ __runner.currentTestItem, {
+ application: app,
+ __internals: obj,
+ }
+ );
+
+ }
+
+
+ function __inheritanceTree(o) {
+ return __sendQuery('inheritance',{}, o).inheritance;
+ }
+
+ function __inputEvent(event, pos, buttons) {
+ buttons = buttons || Qt.LeftButton;
+
+ if (pos.__isQmlWrapper === true) {
+ return __sendQuery(event, {buttons: buttons}, pos.__internals);
+ }
+
+ return remote.__sendPositionQuery(event, {buttons: buttons}, pos);
+ }
+
+
+ function __sendQuery() {
+ return remote.__sendQuery.apply(remote, arguments);
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/ApplicationObjectsCache.js b/src/interpreter/imports/qtsystemtest/qml/ApplicationObjectsCache.js
new file mode 100644
index 0000000..15fdc67
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/ApplicationObjectsCache.js
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+var __hosts = {};
+
+function host(address) {
+ if ( __hosts[address] === undefined) {
+ __hosts[address] = new Host(address);
+ }
+
+ return __hosts[address];
+}
+
+function Host(address) {
+ this.address = address;
+ this._store = {};
+}
+
+Host.prototype.store = function(appId, props) {
+ if ( !(appId in this._store) ){
+ this._store[appId] = props;
+ return;
+ }
+
+ var s = this._store[appId];
+ for (var x in props) {
+ s[x] = props[x];
+ }
+}
+
+Host.prototype.data = function(appId) {
+ return appId in this._store
+ ? this._store[appId]
+ : null;
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/Js.qml b/src/interpreter/imports/qtsystemtest/qml/Js.qml
new file mode 100644
index 0000000..703c564
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/Js.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import '../scripts/QstCore.js' as Core
+
+QtObject {
+ function core() {
+ return Core;
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/Remote.qml b/src/interpreter/imports/qtsystemtest/qml/Remote.qml
new file mode 100644
index 0000000..255a291
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/Remote.qml
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import '../scripts/QstCore.js' as Core
+import 'ApplicationObjectsCache.js' as Cache
+
+QtObject {
+ id: remote
+ property string host
+ property int port: 5656
+ property int applicationStartTimeout: 5000
+ property int appStartRefreshInterval: 250
+
+ property bool __needToReconnect: true
+ property bool __debug_showMessageReceived: false
+
+ onHostChanged: { __needToReconnect = true; }
+ onPortChanged: { __needToReconnect = true; }
+
+
+ function runProcess(params) {
+ return __sendQuery(arguments.callee.name, { cmd: params } );
+ }
+
+ function startApplication(app, args) {
+ args = args || []
+ args.push("-style", "qtuitestd");
+ var currentAppId = __currentAppId();
+ var output = runProcess({
+ program: app,
+ arguments: args,
+ detached: true
+ });
+
+ var timeout = 0;
+ while( __currentAppId() === currentAppId
+ && timeout < applicationStartTimeout) {
+ sleep(appStartRefreshInterval);
+ timeout += appStartRefreshInterval;
+ }
+
+ var newAppId = __currentAppId();
+ if (currentAppId === newAppId) {
+ throw new Core.Qtt.Fail('Application failed to start', 1);
+ }
+ Cache.host(host).store(newAppId, {
+ executable: app,
+ pid: output.pid,
+ });
+ return applicationForId(newAppId)
+ }
+
+
+
+ function currentApplication() {
+ var appId = __currentAppId();
+
+ if (appId === '') {
+ throw new Core.Qtt.Fail('No Current application', 1);
+ }
+
+ return applicationForId(appId);
+ }
+
+ function applicationForId(appId) {
+ // there should be data in the cache already
+ var cache = Cache.host(host);
+ var appData = cache.data(appId);
+ if (appData === null) {
+ throw new Core.Qtt.Fail('Application for Id not found', 1);
+ }
+
+ if (appData.application !== undefined) {
+ return appData.application;
+ }
+
+ var ApplicationRegistry = Core.ApplicationRegistry
+ var component = ApplicationRegistry.applicationForKey(appData.executable);
+ var app = component.createObject(__runner.currentTestItem, {
+ remote: remote,
+ __id: appId,
+ pid: appData.pid,
+ });
+ if (app === null) {
+ throw new Core.Qtt.Error('Failed to create an application object for : ' + appId);
+ }
+ cache.store(appId, {application: app});
+ return app;
+ }
+
+ function applications() {
+ }
+
+ function __connection() {
+ if (__needToReconnect == false) {
+ return __connection.object;
+ }
+ __connection.object = ConnectionManager.connectionForHost(host, port);
+ __connection.object.messageReceived.connect(__messageReceived);
+ var ok = __connection.object.connectToRemote();
+ if ( !ok ) {
+ var e = new Core.Qtt.Fail('Error: Connection to : \
+ host ' + host + 'port :' + port + ' failed', 2);
+ throw e;
+ }
+ __needToReconnect = false;
+ return __connection.object;
+ }
+
+ function __sendQuery(event, params, widgetSpecifier) {
+ return __connection().sendQuery(event, params, widgetSpecifier);
+ }
+
+ function __sendPositionQuery(event, params, position) {
+ return __connection().sendPositionQuery(event, params, position);
+ }
+
+ function __currentAppId() {
+ return __sendQuery('currentApplication').currentapplication;
+ }
+
+ function __messageReceived(event, context, data) {
+ if ( __debug_showMessageReceived ) {
+ console.log("Message received: ",
+ event, " context(" + context + ")",
+ 'data: ', Core.stringify(data));
+ }
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/Test.qml b/src/interpreter/imports/qtsystemtest/qml/Test.qml
new file mode 100644
index 0000000..df7f815
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/Test.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import "../scripts/QstCore.js" as Core
+
+TestItem {
+ id: root
+
+ property string __status: Core.Qtt.Status.Untested ///'' // passed, failed, skipped
+ property bool __isTest: true
+ property variant __mustHaves: ['name', 'description', 'run']
+
+ function __validate() {
+ var missingMustHave;
+ var allMustHaves = __mustHaves.every(function(k) {
+ missingMustHave =k;
+ return (k in root) && root[k] !== '';
+ });
+
+ if (!allMustHaves) {
+ return __error('Test Item: ', root.name, ' does not define property or function',
+ '\'', missingMustHave, '\' the must haves are: ', __mustHaves);
+ }
+
+ return __ok();
+ }
+
+}
+
diff --git a/src/interpreter/imports/qtsystemtest/qml/TestCollection.qml b/src/interpreter/imports/qtsystemtest/qml/TestCollection.qml
new file mode 100644
index 0000000..87e5b86
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/TestCollection.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import "../scripts/QstCore.js" as Core
+
+TestItem {
+ id: root
+ property list<TestItem> __subset
+ default property alias children: root.__subset
+
+ function __validate() {
+ var missingMustHave;
+ var allMustHaves = __mustHaves.every(function(k) {
+ missingMustHave =k;
+ return (k in root) && root[k] !== '';
+ });
+
+ if (!allMustHaves) {
+ return __error('Test Item: ', root.name, ' does not define property',
+ '\'', missingMustHave, '\' the must haves are: ', __mustHaves);
+ }
+
+ if( root.__subset.length > 0 && 'run' in root && typeof(root.run) === 'function' ) {
+ return __error('Invalid test: Cannot have sub test-sets and run() defined for ', root.name);
+ }
+
+ if(__subset === null) {
+ return __ok();
+ }
+
+ for( var i = 0; i < __subset.length; i++) {
+ var s = __subset[i];
+ var v = s.__validate();
+ if( v.valid === false) {
+ return v;
+ }
+ }
+
+ return __ok();
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/TestItem.qml b/src/interpreter/imports/qtsystemtest/qml/TestItem.qml
new file mode 100644
index 0000000..04fda39
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/TestItem.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import "../scripts/QstCore.js" as Core
+
+TestMethod {
+ id: root
+ property string name:''
+ property string description: ''
+ property bool enabled: true
+
+ property list<Remote> remotes
+
+ property variant __mustHaves: ['name', 'description']
+ property bool __isTest: false
+
+ function __ok() {
+ var path = Core.Js.__validationRoot__;
+ if ( path !== undefined) {
+ path.pop();
+ if (path.length === 0) {
+ delete Core.Js.__validationRoot__;
+ }
+ }
+ return {
+ valid: true,
+ };
+ }
+
+ function __error() {
+ var runner = __runner,
+ msg = Array.prototype.slice.call(arguments).join(' '),
+ e = new Core.Qtt.Error(msg),
+ loc = runner.locationOf(root),
+ err;
+
+ err = e.toString() + '\n'
+ + 'Location: ' + loc.url + '(' + loc.lineNumber + ')';
+ return {
+ valid: false,
+ error : err
+ };
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/TestMethod.qml b/src/interpreter/imports/qtsystemtest/qml/TestMethod.qml
new file mode 100644
index 0000000..55cb64d
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/TestMethod.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+import '../scripts/QstCore.js' as Core
+
+QtObject {
+ // make core c++ stuff internal
+ property variant __core: CoreApi {}
+ function core() { return Core; }
+
+ /*!
+ Causes the current test object to fail immediately
+ */
+ function fail(message) {
+ var msg = Core.stringify.apply(null, arguments);
+ var e = new Core.Qtt.Fail(msg);
+ e.discardCallSites();
+ throw e;
+ }
+
+ function skip(message) {
+ var msg = Core.stringify.apply(null, arguments);
+ var e = new Core.Qtt.Skip(msg);
+ e.discardCallSites();
+ throw e;
+ }
+
+ function log() {
+ __runner.log.apply(__runner, arguments);
+ }
+
+ function expect(o) {
+ return core().expect(o);
+ }
+
+ function sleep(ms) {
+ // calls cpp method
+ __core.sleep(ms);
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstObject.qml b/src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstObject.qml
new file mode 100644
index 0000000..6cbee20
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstObject.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import '..'
+import "../../scripts/QstCore.js" as Core
+
+QtObject {
+ id: me
+
+ property Application application
+ property variant __internals
+ property bool __isQmlWrapper: true
+ property string handles: 'QObject'
+
+ function property(name) {
+ return __sendQuery('getProperty', {property: name}).getproperty;
+ }
+
+ function setProperty(name, value) {
+ return __sendQuery('setProperty', {
+ property: name,
+ value: value,
+ });
+ }
+
+ function descendants(filter) {
+ filter = filter || {};
+ filter.descendant_of = me;
+ return application.items(filter);
+ }
+
+ function ancestors(filter) {
+ filter = filter || {};
+ filter.ancestor_of = me;
+ return application.items(filter);
+ }
+
+ function parent() {
+ return application.item({parent_of: me});
+ }
+
+ function isValid() {
+ try {
+ var x = type();
+ } catch(e) {
+ return false;
+ }
+ return true;
+
+ }
+
+ function type() {
+ return __sendQuery('typeOf')['typeof'];
+ }
+
+// method: function(methodSignature) {
+// return new QtUiTestMethod(this, methodSignature);
+// },
+
+// equals: function(other) {
+// // FIXME other should be checked if it is a QtUiTestObject
+// // but that test fails since for _prefetched_ objects the
+// // type is set as Object and not QtUiTestWidget or QtUiTestObject
+// // try: print(other.constructor.name)
+// return other._signature_ !== undefined
+// && this._signature_ === other._signature_;
+// },
+
+ function toString() {
+ return this._signature_;
+ }
+
+ function __sendQuery(event, params) {
+ params = params || {};
+ return application.__sendQuery(event, params, __internals);
+ }
+
+}
diff --git a/src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstWidget.qml b/src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstWidget.qml
new file mode 100644
index 0000000..4eaa33f
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qml/itemhandlers/QstWidget.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest 1.0
+import "../../scripts/QstCore.js" as Core
+
+QstObject {
+ id: me
+ handles: 'QWidget'
+}
diff --git a/src/interpreter/imports/qtsystemtest/qmldir b/src/interpreter/imports/qtsystemtest/qmldir
new file mode 100644
index 0000000..06f9958
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qmldir
@@ -0,0 +1,11 @@
+plugin qtsystemtest
+Application 1.0 qml/Application.qml
+Remote 1.0 qml/Remote.qml
+TestData 1.0 qml/TestData.qml
+TestItem 1.0 qml/TestItem.qml
+Test 1.0 qml/Test.qml
+TestCollection 1.0 qml/TestCollection.qml
+QstObject 1.0 qml/itemhandlers/QstObject.qml
+QstWidget 1.0 qml/itemhandlers/QstWidget.qml
+Js 1.0 qml/Js.qml
+Core 1.0 scripts/QstCore.js
diff --git a/src/interpreter/imports/qtsystemtest/qtsystemtest.json b/src/interpreter/imports/qtsystemtest/qtsystemtest.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qtsystemtest.json
@@ -0,0 +1 @@
+{}
diff --git a/src/interpreter/imports/qtsystemtest/qtsystemtest.pro b/src/interpreter/imports/qtsystemtest/qtsystemtest.pro
new file mode 100644
index 0000000..566a570
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/qtsystemtest.pro
@@ -0,0 +1,74 @@
+TARGET = qtsystemtest
+TARGETPATH = QtSystemTest
+
+
+TEMPLATE = lib
+CONFIG += no_clean qt plugin
+
+QT += declarative declarative-private testlib
+
+INCLUDEPATH += ../../../../include
+LIBS += -L../../../../lib
+LIBS += -lQstProtocol
+
+SOURCES += src/imports.cpp \
+ src/qstcoreapi.cpp \
+ src/qstutils.cpp \
+ src/qstlocalprocess.cpp
+
+HEADERS += src/imports.h \
+ src/qstcoreapi.h \
+ src/qstutils.h \
+ src/qstlocalprocess.h
+
+OTHER_FILES += \
+ qtsystemtest.json \
+
+target.path += $$[QT_INSTALL_IMPORTS]/QtSystemTest
+
+# public api
+QML_IMPORT_FILES = \
+ qml/TestMethod.qml \
+ qml/TestItem.qml \
+ qml/Test.qml \
+ qml/TestCollection.qml \
+ qml/Remote.qml \
+ qml/Application.qml \
+ qml/itemhandlers/QstObject.qml \
+ qml/Js.qml \
+
+qmlImportFiles.files += $$PWD/qml
+qmlImportFiles.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+# scripts
+SCRIPT_FILES = \
+ scripts/api.js \
+ scripts/Datatype.js \
+ scripts/Functional.js \
+ scripts/JsCore.js \
+ scripts/SourceBuilder.js \
+ scripts/Class.js \
+ scripts/QstCore.js \
+ scripts/Console.js \
+ scripts/Expect.js \
+ scripts/Exception.js \
+ scripts/ComponentCacher.js \
+ scripts/ApplicationRegistry.js \
+ scripts/ItemFactory.js \
+
+scriptFiles.files += $$SCRIPT_FILES
+scriptFiles.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/scripts
+
+# qmldir
+QMLDIR_FILE = qmldir
+qmldirFile.files += $$QMLDIR_FILE
+qmldirFile.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+# show in QtCreator
+OTHER_FILES += $$QML_IMPORT_FILES \
+ $$SCRIPT_FILES \
+ qmldir \
+
+
+INSTALLS += qmlImportFiles scriptFiles qmldirFile target
+
diff --git a/src/interpreter/imports/qtsystemtest/scripts/ApplicationRegistry.js b/src/interpreter/imports/qtsystemtest/scripts/ApplicationRegistry.js
new file mode 100644
index 0000000..9566179
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/ApplicationRegistry.js
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(ApplicationRegistry === undefined, 'ApplicationRegistry.js already included');
+
+Js.require('ComponentCacher.js');
+Js.require('Exception.js');
+
+// create a factory and make that singleton
+var ApplicationRegistry = function() {
+ var Factory = ComponentCacher.extend(function() {
+ this._super();
+ this.setDefaultItemFile('../qml/Application.qml');
+
+ function applicationForKey(key) {
+ var component = this.componentForKey(key);
+ if (component === null) {
+ throw new Qtt.Fail('Error creating an Application handler for: ' + key +
+ ' using file: ' + this.fileForKey(key) , 2);
+ }
+ return component;
+ }
+
+
+ return {
+ applicationForKey: applicationForKey
+ };
+ });
+ return new Factory();
+}();
diff --git a/src/interpreter/imports/qtsystemtest/scripts/Class.js b/src/interpreter/imports/qtsystemtest/scripts/Class.js
new file mode 100644
index 0000000..e59c7f7
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/Class.js
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(Class.isFn === undefined, 'Class.js already included');
+
+function Class(){ };
+
+Class.DebugEnabled = false;
+//Class.DebugEnabled = true;
+Class.debug = function debug() {
+ if (Class.DebugEnabled) {
+ var str = '';
+ for (var i=0; i<arguments.length; i++) {
+ str += arguments[i];
+ }
+ console.log(str);
+ }
+}
+
+Class.isFn = function(fn) { return typeof fn === 'function'; };
+Class.isBothFn = function (fn, superFn) {
+ var debug = Class.debug;
+ debug('\t is fn ', (fn ? fn.name: undefined), ', superFn: ', (superFn ? superFn.name : undefined) , ' is a function');
+ return Class.isFn(fn) && Class.isFn(superFn)
+};
+
+Class.create = function(superClass, constructor) {
+ // if 2 args are passed, then SuperClass is specified and else it is of the
+ // from X.extend(definition-of-y)
+ // SuperClass need not be specified in that case, SubClass definition will be
+ // in the SuperClass arg
+ var SuperClass, SubClass,
+ debug = Class.debug;
+ if( arguments.length == 1) {
+ SuperClass = this;
+ SubClass = superClass; // has the definition
+
+ }else {
+ SubClass = constructor;
+ SuperClass = superClass;
+ }
+ debug('Superclass is ', SuperClass.name);
+
+ // NOTE constructor.name for the object created using this is empty
+ var definition = function () {
+ // about to call the constructor of this object, so the super classes are already
+ // constructor and the prototype of this is already set.
+ var myProto = this;
+ debug('My Prototype already has : ', Object.keys(myProto));
+ // define _super before calling the construtor
+ this._super = SuperClass; // _super from constructor should work
+
+ // constructor returns the exported public members
+ var publicMembers = SubClass.apply(this, arguments); // returns the exported members
+ debug('Exported members are: ', Object.keys(publicMembers));
+
+ for (var name in publicMembers) {
+ debug('\t Testing if ', name, ' should be overridden');
+ (function(member, superMember) {
+ // overide the definition in my proto if required
+ if ( Class.isFn(member) ) {
+ var s = Class.isFn(superMember) ? superMember : undefined;
+ myProto[name] = function() {
+ var tmp = this._super;
+ this._super = s;
+ var ret = member.apply(this, arguments);
+ this._super = tmp;
+ return ret;
+ }
+ } else {
+ myProto[name] = member;
+ }
+
+ })(publicMembers[name], myProto[name]);
+ }
+ }; // definition
+ definition.prototype = new SuperClass; // establish prototype chain
+ definition.prototype.constructor = definition; // and the ctor
+ definition.extend = SuperClass.extend || Class.create
+ return definition;
+
+}; // Class.create
+
diff --git a/src/interpreter/imports/qtsystemtest/scripts/ComponentCacher.js b/src/interpreter/imports/qtsystemtest/scripts/ComponentCacher.js
new file mode 100644
index 0000000..781914f
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/ComponentCacher.js
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(ComponentCacher === undefined, 'ComponentCacher.js already included');
+Js.require('Exception.js');
+Js.require('Class.js');
+
+var OriginalCallerDepth = 5; // explaination below
+/*
+ the stack for factory.register(foo, bar) or this.setDefaultItemFile would lead to
+ 1. something.register()
+ 2. class.call (register)
+ 3. this.register
+ 3. absolutePathOf
+ 4. inside register
+ to get the file that called register, we would have to traverse back in stack 5 levels
+*/
+
+ function absolutePathOf(path) {
+ if ( !Qt.qst.isRelativePath(path) ) {
+ return path;
+ }
+ // get the filename that called applicaton.register
+ var stack = Js.Engine.callSite(OriginalCallerDepth);
+ var callerFilePath = stack.last().fileName;
+ var lastSlash = callerFilePath.lastIndexOf('/');
+ return callerFilePath.left(lastSlash + 1) + path;
+ }
+
+
+var ComponentCacher = Class.create(function() {
+ var __registry = {
+ //key: qmlFile
+ };
+
+ var __componentsCache = {
+ //key: Component
+ };
+ var __defaultItemFile;
+ var fallbackToDefault = true;
+
+ function setDefaultItemFile(qmlFilePath) {
+ __defaultItemFile = absolutePathOf(qmlFilePath);
+ }
+
+ function unregister(key) {
+ if (key in __registry) {
+ delete __registry[key];
+ }
+ if (key in __componentsCache) {
+ delete __componentsCache[key];
+ }
+ }
+
+ function register(key, qmlFilePath) {
+ __registry[key] = absolutePathOf(qmlFilePath);
+ }
+
+ function fileForKey(key) {
+ if (key in __registry) {
+ return __registry[key];
+ }
+ if ( !fallbackToDefault) {
+ return null;
+ }
+
+ if ( !__defaultItemFile) {
+ throw new Qtt.Error( 'Error: ComponentCacher - unable to find a file for ' + key);
+ }
+ return __defaultItemFile;
+ }
+
+ function componentForKey(key) {
+ var qmlFile = this.fileForKey(key);
+ if (qmlFile === null) {
+ return null;
+ }
+
+ var component = null;
+ if ( ! (qmlFile in __componentsCache)) {
+
+ component = Qt.createComponent(qmlFile)
+ // HACK ... 1 means Component.Ready I want to access Component.Ready here...
+ if (component.status !== 1) {
+ // fix me ... Change error to accept msg and formatted msg,
+ throw new Qtt.Error('Component creation failed : ' + component.errorString(), 2);
+ }
+ __componentsCache[qmlFile] = component;
+ } else {
+ component = __componentsCache[qmlFile];
+ }
+
+ return component;
+ }
+ function setFallbackToDefault(value) {
+ fallbackToDefault = value;
+ }
+
+ return {
+
+ setFallbackToDefault: setFallbackToDefault,
+ setDefaultItemFile: setDefaultItemFile,
+ fileForKey: fileForKey,
+ register: register,
+ unregister: unregister,
+ componentForKey: componentForKey,
+ keys: function() { return Object.keys(__registry); },
+ };
+});
diff --git a/src/interpreter/imports/qtsystemtest/scripts/Console.js b/src/interpreter/imports/qtsystemtest/scripts/Console.js
new file mode 100644
index 0000000..3ddb6f5
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/Console.js
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(Topic === undefined, 'Console.js already included');
+Js.require('Class.js');
+
+var Topic = Class.create(function(name, parent) {
+ parent = parent || null;
+ var _subtopic = {
+ // name: Topic
+ };
+ var loglevel = {
+ debug: {enabled: false, activate: false },
+ warn: {enabled: false, activate: false },
+ }
+
+ var DebugEnabled = false;
+ function stringify() {
+ stringify.sb = stringify.sb || new SourceBuilder();
+ var sb = stringify.sb;
+ var str = '';
+ for (var i =0; i<arguments.length; ++i) {
+ str += sb.sourceFor(arguments[i]);
+ }
+ return str;
+ }
+ function _debug() {
+ if (DebugEnabled) {
+ print('Console[Debug]: ', stringify.apply(null, arguments));
+ }
+ }
+
+ function path() {
+ var parents = [name];
+ for (var p = parent; p !== null; p = p.parent) {
+ _debug('....... type: ', typeof(p), ' ctor:', p.constructor.name );
+ parents.unshift(p.name);
+ }
+ return parents;
+ }
+
+ function debug(m) {
+ if ( loglevel.debug.activate) {
+ return;
+ }
+
+ if (arguments.length === 0) {
+ return;
+ }
+ _debug('..................', name);
+
+ function log() {
+ var parents = path();
+ var location = Js.Engine.callSite(4).last();
+ var filePath = location.fileName;
+ var file = filePath.right(filePath.length - filePath.lastIndexOf('/') -1);
+ console.log(' ', Date.timestamp(), ', ' // timestamp
+ + file + '(' + location.lineNumber + ') :', // file (linenumber)
+ parents.join('.'), ': ' + stringify.apply(null, arguments)); // topic.topic.... : msg
+ }
+// log.apply(null, arguments);
+ }
+
+ function topic(t) {
+ _debug('Already existing ones: ', Object.keys(_subtopic) );
+ if ( t in _subtopic ){
+ return _subtopic[t]
+ }
+ _debug('Creating a topic: ', name, '.' , t);
+ var sub = new Topic(t, this);
+ _subtopic[t] = sub;
+ _debug(Object.keys(_subtopic));
+ return sub;
+ }
+
+ function enable() {
+
+ }
+
+ return {
+ debug: debug,
+ topic: topic,
+ name: name,
+ parent: parent,
+ enable: enable,
+ };
+});
+
+
+var Console = new Topic('Console');
diff --git a/src/interpreter/imports/qtsystemtest/scripts/Datatype.js b/src/interpreter/imports/qtsystemtest/scripts/Datatype.js
new file mode 100644
index 0000000..1b2fa7a
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/Datatype.js
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+/// FIXME: Qt5, Error.stack can be enabled by calling prepareStack once
+Object.defineProperties(Error.prototype, {
+ __addStack: {
+ value: function(level) {
+ if (this.stack) {
+ return;
+ }
+
+ var stack = level === undefined ? Qt.qst.stack() : Qt.qst.stack(level);
+ // this function (top of the stack) with the right values from Error
+ stack[0] = {
+ fileName: this.fileName,
+ lineNumber: this.lineNumber,
+ functionName: '<unknown function>'
+ };
+ this.stack = stack;
+ }
+ }
+});
+
+
+Object.defineProperties(Array.prototype, {
+ isEmpty: {
+ value: function() { return this.length === 0; }
+ },
+
+ clear: {
+ value: function() { this.length = 0; }
+ },
+
+ last: {
+ value: function() { return this[this.length-1]; }
+ },
+
+ first: {
+ value: function() { return this[0]; }
+ },
+
+ contains: {
+ value: function(element) {
+ if (this === undefined || this === null) {
+ throw new TypeError();
+ }
+ return this.indexOf(element) !== -1;
+ }
+ },
+
+ remove: {
+ value: function(from, to) {
+ var rest = this.slice((to || from) + 1 || this.length);
+ this.length = from < 0 ? this.length + from : from;
+ return this.push.apply(this, rest);
+ }
+ }
+});
+
+
+Object.defineProperties(String.prototype, {
+ startsWith: {
+ value: function(prefix) { return this.indexOf(prefix) === 0; }
+ },
+
+ endsWith: {
+ value: function(suffix) {
+ return this.indexOf(suffix, this.length - suffix.length) !== -1; }
+ },
+
+ left: {
+ value: function(len) { return this.substring(0, len); }
+ },
+
+ right: {
+ value: function(len) { return this.substring(this.length- len); }
+ },
+
+ repeat: {
+ value: function( num ) { return new Array( num + 1 ).join(this); }
+ },
+ trim: {
+ value: function() { return this.replace(/^\s+|\s+$/g, ""); }
+ }
+});
+
+
+Date.timestamp = function() {
+ function pad(n, places) {
+ var str = ''+n;
+ if ( str.length >= places) {
+ return str;
+ }
+ return '0'.repeat(places - str.length) + str;
+ }
+ var now = new Date();
+ var timestamp = pad(now.getHours(), 2) + ':'
+ + pad( now.getMinutes(), 2) + ':'
+ + pad( now.getSeconds(), 2) + ' - '
+ + pad( now.getMilliseconds(), 3);
+ return timestamp;
+}
diff --git a/src/interpreter/imports/qtsystemtest/scripts/Exception.js b/src/interpreter/imports/qtsystemtest/scripts/Exception.js
new file mode 100644
index 0000000..25fdafb
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/Exception.js
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(Qtt === undefined, 'Exception.js already included');
+Js.require('Class.js');
+Js.require('Console.js');
+
+var Qtt = function(){
+ var QttDebug = Console.topic('Qtt');
+
+ var Status = {
+ Error: 'error',
+ Passed: 'passed',
+ Failed: 'failed',
+ Skipped: 'skipped',
+ Aborted: 'aborted',
+ Untested: 'untested',
+ };
+
+ var QttError = Class.create(function QttError(msg, discardLevel) {
+ discardLevel = (discardLevel || 0 ) + 2;
+ this.name = arguments.callee.name;
+ this.stack = Qt.qst.stack();
+ Js.discardCallSites.call(this, discardLevel);
+ return {
+ status : Status.Error,
+ type: 'QttError',
+ message: msg,
+ __addStack : function(){},
+ discardCallSites: Js.discardCallSites,
+ toString: function() { return this.message; }
+ };
+ });
+
+ var Skip = QttError.extend(function Skip(msg, discardLevel) {
+ discardLevel = (discardLevel || 0 ) + 2;
+ this._super(msg, discardLevel);
+ this.type = 'Skip';
+ this.status = Status.Skipped;
+ return { };
+ });
+
+ var Abort = QttError.extend(function Abort(msg, discardLevel) {
+ discardLevel = (discardLevel || 0 ) + 2;
+ this._super(msg, discardLevel);
+ this.type = 'Abort';
+ this.status = Status.Aborted;
+ return { };
+ });
+
+ var Fail = QttError.extend(function Fail(msg, discardLevel) {
+ discardLevel = (discardLevel || 0 ) + 2;
+ this._super(msg, discardLevel);
+ this.type = 'Fail';
+ this.status =Status.Failed;
+ return { };
+ });
+
+
+ return {
+ Error: QttError,
+ Skip: Skip,
+ Fail: Fail,
+ Abort: Abort,
+ Status: Status
+ };
+}();
diff --git a/src/interpreter/imports/qtsystemtest/scripts/Expect.js b/src/interpreter/imports/qtsystemtest/scripts/Expect.js
new file mode 100644
index 0000000..fc7cee0
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/Expect.js
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(Expectation === undefined, 'Expect.js already included');
+Js.require('Class.js');
+Js.require('Exception.js');
+
+var Expectation = Class.create(function(actual, value){
+ var ok = value === undefined ? true : value;
+
+ function _not_() {
+ return ok === true? ' ' : ' not ';
+ }
+
+ function toBeBetween(low, high){
+ if ( ( low < actual && actual < high) !== ok) {
+ var msg = 'Expected actual value to be' + _not_() + 'between low and high value.';
+ var formatted = 'Expected (' + actual + ') to be' + _not_()
+ + 'between (' + low + ', ' + high + ')';
+ var e = new Qtt.Fail(msg, formatted, 2);
+ e.meta = {
+ actual: actual,
+ low: low,
+ high: high
+ };
+ throw e;
+ }
+ }
+
+ function toBe(expectation){
+ if ( (actual === expectation) !== ok) {
+ var msg = 'Expected actual value to be' + _not_() + 'expected value.';
+ var e = new Qtt.Fail(msg, 2);
+ e.meta = {
+ actual: actual,
+ expected: expectation
+ };
+ e.formatted = 'Expected (' + actual + ') to be' + _not_()
+ + '(' + expectation + ')';
+ throw e;
+ }
+ }
+
+ function toThrow(expection){
+ }
+
+ function instanceOf(expectation){
+ if( (actual instanceof expectation) !== ok) {
+ var msg = 'Expected actual value to be' + _not_() + 'an instance of expected type.';
+ var e = new Qtt.Fail(msg, 2);
+ e.meta = {
+ actual: actual,
+ expected: expectation.name
+ };
+ e.formated = 'Expected (' + actual + ') to be' + _not_()
+ + 'instance of (' + expectation.name + ')';
+ throw e;
+ }
+ }
+
+
+ return {
+ toBe: toBe,
+ toBeBetween: toBeBetween,
+ instanceOf: instanceOf
+ }
+});
+
+
+function expect(actual) {
+ var x = new Expectation(actual);
+ x.not = new Expectation(actual, false)
+ return x;
+}
diff --git a/src/interpreter/imports/qtsystemtest/scripts/Functional.js b/src/interpreter/imports/qtsystemtest/scripts/Functional.js
new file mode 100644
index 0000000..ddce3f8
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/Functional.js
@@ -0,0 +1,298 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+/*!
+ Returns a function that suppresses throwing the expection when the
+ function \a being wrapped either fails or throws an exception.
+
+ The exception generated is stored in an exception property.
+ The failed property indicates if the function threw an exception.
+
+ Usage:
+ \code
+ var itemExists = findUniqueItem.nothrow();
+ var item = itemExists({QMLTYPE: 'QQuickItem'});
+
+ if (!itemExists.failed) {
+ print(item.property('x'));
+ } else {
+ // item is undefined
+ fail(itemExists.exception.message);
+ }
+ \endcode
+*/
+Function.prototype.nothrow = function nothrow() {
+ var fn = this;
+ function nothrow() {
+ try {
+ var result = fn.apply(this, arguments);
+ arguments.callee.failed = false;
+ return result;
+ } catch(e) {
+ arguments.callee.exception = e;
+ arguments.callee.failed = true;
+ }
+ return undefined;
+ }
+
+ // reduce nothrow().nothrow() to a single nothrow
+ return fn.toString() === nothrow.toString() ? fn : nothrow;
+}
+
+/*!
+ Returns a function that retries the \a fn after every \a interval milliseconds
+ until it doesn't result in a 'fail' or times out after \a timeout milliseconds.
+
+ Usage:
+ \code
+ var item = findUniqueItem.retry({timeout: 1000, interval: 250});
+ var obj = item({QMLTYPE: 'Button', QMLID: 'aButton'})
+ \endcode
+
+ is equal to writing
+
+ \code
+ var obj;
+ var excp;
+ var timeout = 1000;
+ var poll = 250;
+ try {
+ expect( function() {
+ try {
+ obj = findUniqueItem({QMLTYPE: 'Button', QMLID: 'aButton'})
+ return true;
+ }catch(e) {
+ excp = e;
+ }
+ return false;
+ }, timeout, Math.floor(timeout/poll));
+ } catch(e) {
+ fail(excp.message, ' after ', timeout, 'ms' );
+ }
+ \endcode
+
+*/
+//Function.prototype.retry = function(config) {
+// if (!config){
+// throw new Error('Missing args: no timeout and interval specified. \n'
+// + 'Usage retry({timeout: <timeout>, interval: <interval> })');
+// }
+
+// if (typeof(config.timeout) !== 'number') {
+// throw new TypeError('timeout: not a number \n'
+// + 'Usage retry({timeout: <timeout>, interval: <interval> })');
+// }
+// if (typeof(config.interval) !== 'number') {
+// throw new TypeError('interval: not a number \n'
+// + 'Usage retry({timeout: <timeout>, interval: <interval> })');
+// }
+
+// var method = this.nothrow();
+
+// function retry() {
+// // store the original method
+// retry.original = this;
+// var result;
+// var args = Private.Utils.makeArray(arguments) ;
+// var passes = Private.Utils.poll(function autoPoll() {
+// result = method.apply(this, args);
+// return method.failed === false;
+// }, config.timeout, config.interval);
+
+// if (!passes) {
+// fail(method.exception.message, ' after ', config.timeout, ' ms');
+// }
+// return result;
+// }
+
+// // error on retry().retry();
+// if (this.toString() === retry.toString()) {
+// var originalMethod = this.original.name === '' ? '[anonymous]'
+// : this.original.name;
+// return new Error('Cannot create a retry version of already retry version of method: '
+// + originalMethod);
+// }
+// return retry;
+//}
+
+/*!
+ Partially intialize first few arguments of a function
+
+ \code
+ function sum(a, b) { return a+b;};
+ var add5 = sum.curry(5);
+ var x = add5(10); // x = 15 now
+ \endcode
+
+*/
+Function.prototype.bind = function(scope) {
+ var fn = this;
+ var toArray = Array.prototype.slice;
+ var args = toArray.call(arguments);
+ var scope = args.shift();
+ return function() {
+ return fn.apply(scope, args.concat(toArray.call(arguments)));
+ };
+};
+
+Function.prototype.curry = function() {
+ var fn = this;
+ var toArray = Array.prototype.slice;
+ var args = toArray.call(arguments);
+ return function() {
+ return fn.apply(this, args.concat( toArray.call(arguments)));
+ };
+};
+
+
+/*!
+ Partially intialize arguments of a function, using undefined as placeholders for
+ arguments to be filled in later.
+
+ \code
+ function sum(a, b) { return a+b;};
+ var add5 = sum.partial(undefined, 5);
+
+ var x = add5(10); // x = 15 now
+ \endcode
+
+*/
+Function.prototype.partial = function(){
+ var fn = this;
+ var toArray = Array.prototype.slice;
+ var partialArgs = toArray.call(arguments);
+ return function(){
+ var args = partialArgs.slice(); // copy partial
+ var arg = 0;
+ for ( var i = 0; i < args.length && arg < arguments.length; i++ ) {
+ if ( args[i] === undefined ) {
+ args[i] = arguments[arg++];
+ }
+ }
+ return fn.apply(this, args);
+ };
+}
+
+var FunctionHelper = function() {
+ /*!
+ Validate number of the arguments passed to a function \a fn, throws an exception
+ if the number of args passed to the \a fn is less than the minArgsRequired.
+
+ if no minimumArgs is passed, uses the number of named arguments in \a fn
+
+ Usage:
+ \code
+ var findItems = FunctionHelper.validateArgs(function findItems( filter, fetch, mode) {
+ }, 1); // ensures 1 arg is passed when findItems
+ \endcode
+ */
+ function validateArgs(fn, minArgsRequired) {
+ if( typeof(fn) !== 'function' || fn.name === '' ) {
+ throw new Error('The first argument to validateArgs should be a named function');
+ }
+ minArgsRequired = minArgsRequired || fn.length;
+ return function() {
+ if (arguments.length < minArgsRequired) {
+ fail(fn.name, ' expects atleast ', minArgsRequired,
+ ' arguments, whereas only ', arguments.length, ' passed');
+ }
+ return fn.apply(this, arguments)
+ };
+ }
+
+ /*!
+ Deprecates a function with the name \a fnName and replaced by \a replacedBy. Would print of the
+ msg if one is passed or generates one.
+
+ Usage:
+ \code
+ var findWidget = FunctionHelper.deprecate('findWidget', findItems);
+ or
+ var findWidget = FunctionHelper.deprecate('findWidget', findItems,
+ 'Usage of findWidget is deprecated, use findItems instead')
+ var findWidget = FunctionHelper.deprecate('findWidget',
+ {replacedBy: findItems, name: 'findItems'});
+ \endcode
+ */
+ function deprecate(fnName, replacedBy, msg, config) {
+ msg = msg || 'Usage of deprecated function: ' + fnName + ', use ' + replacedBy.name + ' instead.';
+ config = config || {
+ FailOnInvoke : false
+ };
+ return function() {
+ if ( config.FailOnInvoke ) {
+ throw new Error('Error: ' + msg);
+ }
+ warn(msg);
+ // use the function if replacedBy is a Function else if it an object, then use the replacedBy property
+ var fn = replacedBy instanceof Function ? replacedBy : replacedBy.replacedBy;
+ return fn.apply(this, arguments);
+ };
+ }
+
+
+ /*!
+ Helper function that wraps an object of type anything other than function
+ inside an anonymous function, invoking which returns the object;
+
+ Usage:
+ \code
+ var x = 10;
+ x = FunctionHelper.toFunction(x);
+ var y = x(); // y is 10;
+ \endcode
+ */
+ function toFunction(x) {
+ return typeof(x) === 'function' ? x : function(){ return x;};
+ }
+
+ function isFunction(x) {
+ return typeof(x) === 'function';
+ }
+ return {
+ validateArgs: validateArgs,
+ deprecate: deprecate,
+ toFunction: toFunction,
+ isFunction: isFunction
+ };
+}
diff --git a/src/interpreter/imports/qtsystemtest/scripts/ItemFactory.js b/src/interpreter/imports/qtsystemtest/scripts/ItemFactory.js
new file mode 100644
index 0000000..93c2a2f
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/ItemFactory.js
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// create a factory and make that singleton
+var ItemFactory = function() {
+ /// FIXME: itemshandlers can be resitered or unregistered at run time
+ /// so, the keyForObject.cache would get invalidated
+ var Factory = ComponentCacher.extend(function() {
+ this._super();
+ this.setFallbackToDefault(false);
+ var _handlerForItemCache = {};
+
+ function keyForObject(obj, application) {
+ var key = obj._type_;
+
+ function handlerExists(k) {
+ if ( this.fileForKey(k) !== null ) {
+ handlerExists.key = k;
+ return true;
+ }
+ return false;
+ }
+
+ // perfect match
+ if ( handlerExists.call(this, key) ) {
+ return key;
+ }
+
+ if ( key in _handlerForItemCache) {
+ return _handlerForItemCache[key];
+ }
+
+ var tree = application.__inheritanceTree(obj);
+ tree.shift();
+ var ret = tree.some(handlerExists, this)
+ ? handlerExists.key
+ : null;
+ _handlerForItemCache[key] = ret;
+ return ret;
+ }
+
+ function itemForKey(obj, props) {
+ if ( !('_type_' in obj ) ) {
+ throw new Qtt.Fail('Invalid object passed to handlerForObject: _type_ does not exist ', 2);
+ }
+
+ var key = keyForObject.call(this, obj, props.application);
+ if (key === null) {
+ throw new Qtt.Fail('Error finding a Item handler for: ' + obj._type_ , 2);
+ }
+ var component = this.componentForKey(key);
+ if (component === null) {
+ throw new Qtt.Fail('Error creating an Item handler for: ' + obj._type_ , 2);
+ }
+ return component;
+ }
+
+ function register(k, path) {
+ path = absolutePathOf(path);
+ this._super(k, path);
+ _handlerForItemCache = {};
+ }
+
+ function unregister(key) {
+ this._super(key);
+ _handlerForItemCache = {};
+ }
+
+ return {
+ handlerForObject: itemForKey,
+ register: register,
+ unregister: unregister
+ };
+ });
+ var singleton = new Factory();
+ singleton.register('QObject', '../qml/itemhandlers/QstObject.qml');
+ singleton.register('QWidget', '../qml/itemhandlers/QstWidget.qml');
+ return singleton;
+}();
diff --git a/src/interpreter/imports/qtsystemtest/scripts/JsCore.js b/src/interpreter/imports/qtsystemtest/scripts/JsCore.js
new file mode 100644
index 0000000..30b3736
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/JsCore.js
@@ -0,0 +1,215 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+if( typeof(Js) !== 'undefined') {
+ Js.include_check(Js === undefined, 'JsCore.js already included');
+}
+
+Qt.include('Datatype.js')
+Qt.include('Functional.js');
+
+var Js = function() {
+
+ var Core = {
+ Error: {
+ maxStack: 17
+ }
+ };
+
+// var DebugEnabled = true;
+ var DebugEnabled = false;
+ function _debug() {
+ var str = '',
+ arg,
+ i,
+ now,
+ timestamp;
+
+ if (!DebugEnabled) {
+ return;
+ }
+
+ for (i =0; i<arguments.length; ++i) {
+ arg = arguments[i]
+ if (arg != null) {
+ str += arg.toString();
+ } else {
+ str += 'undefined'
+ }
+ }
+ console.log(Date.timestamp(), 'JsCore[Debug]:', str);
+ }
+
+ function discardCallSites(num) {
+ num = num || 1;
+ if (!this.stack) return;
+ var stack = this.stack;
+ if( stack.length < num ) {
+ _debug(' Error: insufficient stack depth');
+ throw new Error('Insufficient stack depth');
+ }
+ while ( num-- > 0 ) {
+ this.stack.shift();
+ }
+ }
+
+ var JsError = (function() {
+ function JsError(msg) {
+ Error.call(this);
+ this.message = msg;
+ this.name = arguments.callee.name;
+ this.stack = Qt.qst.stack();
+ this._discardCallSites();
+ }
+ JsError.prototype = new Error();
+ JsError.prototype._discardCallSites = discardCallSites;
+ return JsError;
+ })();
+
+ var IncludeError = (function() {
+ function IncludeError(msg) {
+ JsError.call(this, msg);
+ _debug(' Creating include error :', this.message);
+ this.name = arguments.callee.name;
+ this._discardCallSites();
+ }
+
+ IncludeError.prototype = new JsError();
+ IncludeError.prototype.constructor = IncludeError;
+ return IncludeError;
+ })();
+
+ function require(filename) {
+ require.level = require.level || 0;
+
+ function repeat(c, t){
+ var str = '';
+ for(var i=0; i< t; ++i){
+ str += c;
+ }
+ return str;
+ }
+ var spaces = repeat(' ', require.level*4);
+ _debug('including .... '+ spaces + (require.level !==0? '+--': '') + '[', filename, ']');
+
+ require.level++;
+ try {
+ var include = Qt.include(filename);
+ } catch(e) {
+ console.log('Exception caught loading', filename, e.message);
+ console.log('Stack', e.stack.join('\n'));
+ }
+
+ if( include && include.status === include.EXCEPTION) {
+ var ex = include.exception;
+ if (!(ex instanceof IncludeError) ) {
+ console.log('Exception including : ', filename, ': ', ex.message, ex.filename);
+ if ( ex.stack instanceof Array) {
+ ex.stack.forEach( function(cs) {
+ console.log( cs.fileName, ':', s.lineNumber);
+ });
+ }
+ throw ex;
+ } else {
+ _debug('Exception including : ', filename, " exception: ", ex);
+ }
+ }
+ // _debug('including .... [', filename, ']done');
+ require.level--;
+ }
+
+ function include_check(condition, msg) {
+ if(!condition) {
+ throw new IncludeError(msg);
+ }
+ }
+
+
+ var JsEngine = function() {
+ function callSite(depth) {
+ var stack = depth === undefined
+ ? Qt.qst.stack()
+ : Qt.qst.stack(depth++);
+ return stack;
+ }
+
+ function currentFile() {
+ var cs = callSite(3);
+ return cs.last().fileName;
+ }
+
+ function currentPath() {
+ var cs = callSite(3);
+ var filePath = cs.last().fileName;
+ var fileStart = filePath.lastIndexOf('/');
+ return filePath.substring(fileStart + 1);
+ }
+
+ function currentLine() {
+ var cs = callSite(3);
+ return cs.last().lineNumber;
+ }
+
+ return {
+ currentPath: currentPath,
+ currentFile: currentFile,
+ currentLine: currentLine,
+ callSite: callSite
+ }
+ }();
+
+ return {
+ require: require,
+ include_check: include_check,
+ Core: Core,
+ Error: JsError,
+ discardCallSites: discardCallSites,
+ Engine: JsEngine,
+ _debug: _debug,
+ }
+}();
+
+
+function assert(condition, msg) {
+ if (!condition) {
+ throw new JsError(msg);
+ }
+}
diff --git a/src/interpreter/imports/qtsystemtest/scripts/QstCore.js b/src/interpreter/imports/qtsystemtest/scripts/QstCore.js
new file mode 100644
index 0000000..da422be
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/QstCore.js
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+Qt.include('JsCore.js');
+Js.require('SourceBuilder.js');
+
+Js.require('Class.js');
+Js.require('Console.js');
+Js.require('Exception.js');
+Js.require('Expect.js');
+Js.require('ApplicationRegistry.js');
+Js.require('ItemFactory.js');
diff --git a/src/interpreter/imports/qtsystemtest/scripts/SourceBuilder.js b/src/interpreter/imports/qtsystemtest/scripts/SourceBuilder.js
new file mode 100644
index 0000000..014f118
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/SourceBuilder.js
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+Js.include_check(SourceBuilder === undefined, 'SourceBuilder.js already included');
+
+var SourceBuilder = function() {
+ var DebugEnabled = false;
+ function debug(enabled){
+ if (enabled && DebugEnabled) {
+ console.log( msg(Array.prototype.slice.call(arguments)) );
+ }
+ }
+
+ function msg() {
+ var str = '';
+ for (var i =0; i<arguments.length; i++) {
+ var arg = arguments[i];
+ str += arg;
+ }
+ return str;
+ }
+
+ // converters
+ function arrayToString(a, level) {
+ if (a.length === 0 ) {
+ return '[]';
+ }
+
+ var str = '[';
+ var quote;
+ for (var i =0; i < a.length; ++i) {
+ quote = typeOf(a[i]) === 'String' ? "'" : '';
+ str += quote + stringify(a[i]) + quote;
+ str += i < (a.length -1) ? ', ' : ']'
+ }
+ return str;
+ }
+
+ function objectToString(obj, level) {
+ debug(DebugEnabled && msg(arguments.callee.name));
+
+ // if toString for the object is overridden then, use that version
+ if ( obj.toString !== Object.prototype.toString) {
+ return obj.toString();
+ }
+
+ var indentation = indentText.repeat(level);
+ var propertyCount = Object.keys(obj).length;
+ var terminator = propertyCount > 1 ? '\n': ''
+ var propertyIndentation = propertyCount > 1 ? (indentation + indentText) : ''
+ var objectType = typeOf(obj)
+
+ function stripObject(o) {
+ return o === 'Object' ? '' : o;
+ }
+ // don't print 'Object', if the type is Object
+ var str = stripObject(objectType) + '{' + terminator;
+ var contents = '';
+ for (var prop in obj) {
+ // add a quote if the value is of type string
+ var quote = typeof(obj[prop]) == 'string' ? "'" : '';
+
+ contents += propertyIndentation + prop + ': '
+ + quote + stringify(obj[prop], level+1) + quote
+ + ',' + terminator;
+ }
+ str += contents.slice(0, -(1 + terminator.length)); // remove the , at the end of contents
+ str += terminator + indentation + '}' + terminator;
+ return str;
+ }
+
+ function typeOf(o) {
+ debug(DebugEnabled && msg(arguments.callee.name));
+ if ( o === undefined ) return 'undefined';
+ if ( o === null ) return 'null';
+
+ // we have a valid object
+ var ctor = o.constructor.name;
+ return ctor.length === 0 ? 'Object' // no Object for a generic object
+ : ctor;
+ }
+
+ function sameObject(x){ return x; }
+ function toString(x){ return x.toString(); }
+ function qtuitestWidget(x){ return 'QtUiTestWidget( ' + x.toString() + ' )'; }
+ function qtuitestObject(x){ return 'QtUiTestObject( ' + x.toString() + ' )'; }
+
+ // converts obj to string
+ function stringify(obj, level) {
+ debug(DebugEnabled && msg(arguments.callee.name));
+ debug(DebugEnabled && msg('Finding type of :', obj) );
+ level = level || 0;
+
+ var typeConverters = {
+ 'null': typeOf,
+ 'undefined': typeOf,
+ 'Number': toString,
+ 'Boolean': toString,
+ 'Function': toString,
+ 'String': sameObject,
+ 'Array': arrayToString,
+ 'QtUiTestWidget': qtuitestWidget,
+ 'QtUiTestObject': qtuitestObject,
+ 'Object': objectToString
+ };
+
+ var type = typeOf(obj);
+ if ( type in typeConverters) {
+ debug(DebugEnabled && msg('Found converter for type: ' + type
+ + ', using converter :' + typeConverters[type].name));
+ return typeConverters[type](obj, level);
+ }
+ debug(DebugEnabled && msg('No converters Found for type: ' + type) );
+ // if no converters are registered, treat the type as an object and print it
+ return objectToString(obj, level);
+ }
+
+ var indentText = ' ';// .repeat(4); // 4 spaces for each level
+ return {
+ sourceFor: function sourceFor(obj) {
+ return stringify(obj);
+ }
+ };
+
+}// SourceBuilder
+
+function stringify() {
+ stringify.sb = stringify.sb || new SourceBuilder();
+ var str = '';
+ for (var i =0; i< arguments.length; ++i) {
+ str += stringify.sb.sourceFor(arguments[i]);
+ }
+ return str;
+}
diff --git a/src/interpreter/imports/qtsystemtest/scripts/api.js b/src/interpreter/imports/qtsystemtest/scripts/api.js
new file mode 100644
index 0000000..f9cf7a1
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/scripts/api.js
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+Qt.include('JsCore.js');
+Js.include_check(Private === undefined, 'api.js already included');
+
+
+function api() {
+ var component = Qt.createQmlObject(
+ 'import QtQuick 2.0;'
+ + 'import QtUiTest 1.0;'
+ + 'TestMethod {}', Js.__testRoot);
+ return component;
+}
+
+Js._debug(' api.js ... loaded');
diff --git a/src/interpreter/imports/qtsystemtest/src/imports.cpp b/src/interpreter/imports/qtsystemtest/src/imports.cpp
new file mode 100644
index 0000000..e8f1529
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/imports.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imports.h"
+#include "qstcoreapi.h"
+#include "qstutils.h"
+#include "qstlocalprocess.h"
+#include <QtDeclarative>
+
+#include <QtSystemTest/QstConnection>
+#include <QtSystemTest/QstConnectionManager>
+
+void QtSystemTestQmlModule::registerTypes(const char *uri)
+{
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtSystemTest"));
+ qmlRegisterType<QstCoreApi>( uri, 1, 0, "CoreApi");
+ qmlRegisterType<QstConnection>( uri, 1, 0, "Connection");
+ qmlRegisterType<QstLocalProcess>( uri, 1, 0, "LocalProcess");
+}
+
+void QtSystemTestQmlModule::initializeEngine(QDeclarativeEngine *e, const char *uri)
+{
+ qDebug() << Q_FUNC_INFO << "Registering connection manager and Utils" << uri;
+ e->rootContext()->setContextProperty("ConnectionManager", new QstConnectionManager());
+ e->rootContext()->setContextProperty("Utils", new QstUtils());
+}
+
+Q_EXPORT_PLUGIN2(qtsystemtestplugin, QtSystemTestQmlModule);
diff --git a/src/interpreter/imports/qtsystemtest/src/imports.h b/src/interpreter/imports/qtsystemtest/src/imports.h
new file mode 100644
index 0000000..4a41b48
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/imports.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMPORTS_H
+#define IMPORTS_H
+
+#include <QDeclarativeExtensionPlugin>
+
+class QDeclarativeEngine;
+
+class QtSystemTestQmlModule : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+
+public:
+ virtual void registerTypes(const char *uri);
+ void initializeEngine(QDeclarativeEngine *, const char *);
+};
+
+#endif // IMPORTS_H
diff --git a/src/interpreter/imports/qtsystemtest/src/qstcoreapi.cpp b/src/interpreter/imports/qtsystemtest/src/qstcoreapi.cpp
new file mode 100644
index 0000000..979070d
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qstcoreapi.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstcoreapi.h"
+
+#include <QtCore/QDebug>
+#include <QtTest/QTest>
+
+QstCoreApi::QstCoreApi(QObject *parent) :
+ QObject(parent)
+{
+}
+
+void QstCoreApi::sleep(int ms)
+{
+ QTest::qSleep(ms);
+}
+
diff --git a/src/interpreter/imports/qtsystemtest/src/qstcoreapi.h b/src/interpreter/imports/qtsystemtest/src/qstcoreapi.h
new file mode 100644
index 0000000..4efc473
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qstcoreapi.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTCOREAPI_H
+#define QSTCOREAPI_H
+
+#include <QtCore/QObject>
+#include <QtCore/QVariantMap>
+
+class QSystemTestMaster;
+
+class QstCoreApi : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QstCoreApi(QObject *parent = 0);
+
+ static const QLatin1String signatureProperty;
+ static const QLatin1String appIdProperty;
+ static const QLatin1String widgetSpecifierProperty;
+
+signals:
+
+public slots:
+ void sleep(int ms);
+ bool connectApplication(const QString &host, int port);
+
+ private:
+
+ QSystemTestMaster *m_test_app;
+};
+
+#endif // QSTCOREAPI_H
diff --git a/src/interpreter/imports/qtsystemtest/src/qstlocalprocess.cpp b/src/interpreter/imports/qtsystemtest/src/qstlocalprocess.cpp
new file mode 100644
index 0000000..cf60379
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qstlocalprocess.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstlocalprocess.h"
+
+#include <QtCore/QTextCodec>
+
+QstLocalProcess::QstLocalProcess(QObject *parent) :
+ QProcess(parent),
+ m_inputCodec(0),
+ m_outputCodec(0),
+ m_outputDecoder(0),
+ m_errorDecoder(0),
+ m_outputMode(DeviceOutput)
+{
+ m_inputCodec = QTextCodec::codecForLocale();
+ m_outputCodec = QTextCodec::codecForLocale();
+
+ connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(forwardFinished(int, QProcess::ExitStatus)));
+}
+
+void QstLocalProcess::start(const QString &program, const QStringList &arguments)
+{
+ QProcess::start(program, arguments, QIODevice::ReadWrite);
+}
+
+bool QstLocalProcess::waitForStarted(int msecs)
+{
+ return QProcess::waitForStarted(msecs);
+}
+
+bool QstLocalProcess::waitForFinished(int msecs)
+{
+ return QProcess::waitForFinished(msecs);
+}
+
+bool QstLocalProcess::waitForReadyRead(int msecs)
+{
+ return QProcess::waitForReadyRead(msecs);
+}
+
+void QstLocalProcess::closeWriteChannel()
+{
+ QProcess::closeWriteChannel();
+}
+
+QProcess::ProcessState QstLocalProcess::state() const
+{
+ return QProcess::state();
+}
+
+QProcess::ExitStatus QstLocalProcess::exitStatus() const
+{
+ return QProcess::exitStatus();
+}
+
+int QstLocalProcess::exitCode() const
+{
+ return QProcess::exitCode();
+}
+
+QString QstLocalProcess::inputCodec() const
+{
+ return QString::fromLatin1(m_inputCodec->name());
+}
+
+void QstLocalProcess::setInputCodec(const QString &name)
+{
+ m_inputCodec = QTextCodec::codecForName(name.toLatin1().constData());
+}
+
+QString QstLocalProcess::outputCodec() const
+{
+ return QString::fromLatin1(m_outputCodec->name());
+}
+
+void QstLocalProcess::setOutputCodec(const QString &name)
+{
+ if (name == outputCodec())
+ return;
+ m_outputCodec = QTextCodec::codecForName(name.toLatin1().constData());
+ delete m_outputDecoder;
+ delete m_errorDecoder;
+ m_outputDecoder = 0;
+ m_errorDecoder = 0;
+}
+
+void QstLocalProcess::setOutputMode(OutputMode mode)
+{
+ if (mode == m_outputMode)
+ return;
+ m_outputMode = mode;
+ if (m_outputMode == DeviceOutput) {
+ disconnect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(updateOutputBuffer()));
+ disconnect(this, SIGNAL(readyReadStandardError()), this, SLOT(updateErrorBuffer()));
+ } else {
+ setProcessChannelMode(SeparateChannels);
+ connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(updateOutputBuffer()));
+ connect(this, SIGNAL(readyReadStandardError()), this, SLOT(updateErrorBuffer()));
+ updateOutputBuffer();
+ updateErrorBuffer();
+ }
+}
+void QstLocalProcess::updateOutputBuffer()
+{
+ QByteArray bytes = readAllStandardOutput();
+ if (!bytes.isEmpty()) {
+ if (!m_outputDecoder)
+ m_outputDecoder = m_outputCodec->makeDecoder();
+ m_stdoutBuffer.append(m_outputDecoder->toUnicode((bytes)));
+ emit standardOutputChanged(m_stdoutBuffer);
+ }
+}
+
+void QstLocalProcess::updateErrorBuffer()
+{
+ QByteArray bytes = readAllStandardOutput();
+ if (!bytes.isEmpty()) {
+ if (!m_errorDecoder)
+ m_errorDecoder = m_outputCodec->makeDecoder();
+ m_stderrBuffer.append(m_errorDecoder->toUnicode((bytes)));
+ emit standardErrorChanged(m_stderrBuffer);
+ }
+}
+
+void QstLocalProcess::write(const QString &input)
+{
+ QProcess::write(m_inputCodec->fromUnicode(input));
+}
diff --git a/src/interpreter/imports/qtsystemtest/src/qstlocalprocess.h b/src/interpreter/imports/qtsystemtest/src/qstlocalprocess.h
new file mode 100644
index 0000000..215ee36
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qstlocalprocess.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTLOCALPROCESS_H
+#define QSTLOCALPROCESS_H
+
+#include <QtCore/QProcess>
+
+class QTextCodec;
+class QTextDecoder;
+
+class QstLocalProcess : public QProcess
+{
+ Q_OBJECT
+ Q_ENUMS(ProcessState ExitStatus OutputMode)
+
+ Q_PROPERTY(ProcessState state READ state NOTIFY stateChanged)
+ Q_PROPERTY(ExitStatus exitStatus READ exitStatus NOTIFY exitStatusChanged)
+ Q_PROPERTY(int exitCode READ exitCode NOTIFY exitCodeChanged)
+
+ Q_PROPERTY(QString standardOutput READ standardOutput NOTIFY standardOutputChanged)
+ Q_PROPERTY(QString standardError READ standardError NOTIFY standardErrorChanged)
+
+ Q_PROPERTY(QString inputCodec READ inputCodec WRITE setInputCodec)
+ Q_PROPERTY(QString outputCodec READ outputCodec WRITE setOutputCodec)
+
+ Q_PROPERTY(OutputMode outputMode READ outputMode WRITE setOutputMode)
+
+public:
+ explicit QstLocalProcess(QObject *parent = 0);
+
+ enum OutputMode {
+ DeviceOutput,
+ PropertyOutput
+ };
+
+ Q_INVOKABLE void start(const QString &program, const QStringList &arguments = QStringList());
+ Q_INVOKABLE bool waitForStarted(int msecs);
+ Q_INVOKABLE bool waitForFinished(int msecs);
+ Q_INVOKABLE bool waitForReadyRead(int msecs);
+ Q_INVOKABLE void closeWriteChannel();
+
+ Q_INVOKABLE ProcessState state() const;
+ Q_INVOKABLE ExitStatus exitStatus() const;
+ Q_INVOKABLE int exitCode() const;
+
+ Q_INVOKABLE void write(const QString &input);
+
+ QString standardOutput() const { return m_stdoutBuffer; }
+ Q_INVOKABLE void clearStandardOutput()
+ { m_stdoutBuffer.clear(); emit standardOutputChanged(m_stdoutBuffer); }
+
+ QString standardError() const { return m_stderrBuffer; }
+ Q_INVOKABLE void clearStandardError()
+ { m_stderrBuffer.clear(); emit standardErrorChanged(m_stderrBuffer); }
+
+ QString inputCodec() const;
+ QString outputCodec() const;
+ void setInputCodec(const QString &);
+ void setOutputCodec(const QString &);
+
+ OutputMode outputMode() const { return m_outputMode; }
+ void setOutputMode(OutputMode mode);
+
+signals:
+ void stateChanged(QProcess::ProcessState state);
+ void exitStatusChanged(QProcess::ExitStatus status);
+ void exitCodeChanged(int);
+ void standardOutputChanged(const QString &);
+ void standardErrorChanged(const QString &);
+
+private slots:
+ void forwardFinished(int code, QProcess::ExitStatus status)
+ {
+ emit exitStatusChanged(status);
+ emit exitCodeChanged(code);
+ }
+
+ void updateOutputBuffer();
+ void updateErrorBuffer();
+
+private:
+ QTextCodec *m_inputCodec;
+ QTextCodec *m_outputCodec;
+ QTextDecoder *m_outputDecoder;
+ QTextDecoder *m_errorDecoder;
+ OutputMode m_outputMode;
+
+ QString m_stdoutBuffer;
+ QString m_stderrBuffer;
+};
+
+#endif // QSTLOCALPROCESS_H
diff --git a/src/interpreter/imports/qtsystemtest/src/qstutils.cpp b/src/interpreter/imports/qtsystemtest/src/qstutils.cpp
new file mode 100644
index 0000000..c826094
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qstutils.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstutils.h"
+#include <QtCore/QUrl>
+#include <QtCore/QDir>
+
+QstUtils::QstUtils(QObject *parent)
+ : QObject(parent)
+{
+}
+
diff --git a/src/interpreter/imports/qtsystemtest/src/qstutils.h b/src/interpreter/imports/qtsystemtest/src/qstutils.h
new file mode 100644
index 0000000..46f68b3
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qstutils.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTUTILS_H
+#define QSTUTILS_H
+
+#include <QObject>
+class QUrl;
+class QScriptValue;
+
+class QstUtils : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QstUtils(QObject *parent = 0);
+
+signals:
+
+public slots:
+
+};
+
+#endif // QSTUTILS_H
diff --git a/src/interpreter/imports/qtsystemtest/src/qtuitestglobal.h b/src/interpreter/imports/qtsystemtest/src/qtuitestglobal.h
new file mode 100644
index 0000000..66a0cef
--- /dev/null
+++ b/src/interpreter/imports/qtsystemtest/src/qtuitestglobal.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QTUITEST_GLOBAL_H
+#define QTUITEST_GLOBAL_H
+
+#include <QtGlobal>
+
+#if defined(Q_OS_WIN32)
+# if defined(QTUITEST_TARGET)
+# define QTUITEST_EXPORT Q_DECL_EXPORT
+# else
+# define QTUITEST_EXPORT Q_DECL_IMPORT
+# endif
+# if defined(QTSLAVE_TARGET)
+# define QTSLAVE_EXPORT Q_DECL_EXPORT
+# else
+# define QTSLAVE_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define QTUITEST_EXPORT Q_DECL_EXPORT
+# define QTSLAVE_EXPORT Q_DECL_EXPORT
+#endif
+
+#if defined(Q_OS_WIN32) || defined(Q_OS_SYMBIAN)
+# if defined(QSYSTEMTEST_TARGET)
+# define QSYSTEMTEST_EXPORT Q_DECL_EXPORT
+# else
+# define QSYSTEMTEST_EXPORT Q_DECL_IMPORT
+# endif
+# if defined(QTUITESTRUNNER_TARGET)
+# define QTUITESTRUNNER_EXPORT Q_DECL_EXPORT
+# else
+# define QTUITESTRUNNER_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define QSYSTEMTEST_EXPORT Q_DECL_EXPORT
+# define QTUITESTRUNNER_EXPORT Q_DECL_EXPORT
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+#define QTUITEST_VERSION_STR xstr(QTUITEST_VERSION)
+
+#endif
diff --git a/src/interpreter/imports/runner/qml/Config.qml b/src/interpreter/imports/runner/qml/Config.qml
new file mode 100644
index 0000000..9b5ae0e
--- /dev/null
+++ b/src/interpreter/imports/runner/qml/Config.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+
+QtObject {
+ property variant remotes: ({
+ localhost: {
+ address: 'localhost',
+ port: 5656
+ }
+ })
+
+ property list<Logger> loggers: [
+ PlainTextLogger{ },
+ XmlLogger {
+ path: 'result.xml'
+ }
+ ]
+}
diff --git a/src/interpreter/imports/runner/qml/Logger.qml b/src/interpreter/imports/runner/qml/Logger.qml
new file mode 100644
index 0000000..2ec66d9
--- /dev/null
+++ b/src/interpreter/imports/runner/qml/Logger.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+
+QtObject {
+ id: logger
+ property variant runner: null
+ property list<QtObject> __list
+ property string path
+ default property alias children : logger.__list
+
+ function setup() {
+ runner = __runner;
+ }
+
+ function locationOf(item) {
+ var ret = {
+ fileName : '',
+ lineNumber: 0
+ };
+
+ var loc = runner.locationOf(item);
+ if (loc.url === undefined) {
+ return ret;
+ }
+ var url = loc.url.toString();
+ ret.fileName = url.substr(url.lastIndexOf('/')+1);
+ ret.lineNumber = loc.lineNumber;
+ return ret;
+ }
+
+
+ onRunnerChanged: {
+ if (runner == undefined || runner == null) return;
+ runner.aboutToStartExecution.connect(aboutToStartExecution);
+ runner.finishedExecution.connect(finishedExecution);
+ runner.testCollectionStart.connect(testCollectionStart);
+ runner.testCollectionEnd.connect(testCollectionEnd);
+
+ runner.testStart.connect(testStart);
+ runner.testEnd.connect(testEnd);
+
+ runner.methodStart.connect(methodStart);
+ runner.methodEnd.connect(methodEnd);
+ }
+
+ function aboutToStartExecution() { }
+ function finishedExecution() { }
+
+ function testCollectionStart(testCollection) { }
+ function testCollectionEnd(testCollection) { }
+
+ function testStart(testCollection) { }
+ function testEnd(testCollection) { }
+
+ function methodStart(method) { }
+ function methodEnd(method) { }
+
+ function cleanup() { }
+
+ function log(type, event) { }
+}
diff --git a/src/interpreter/imports/runner/qml/PlainTextLogger.qml b/src/interpreter/imports/runner/qml/PlainTextLogger.qml
new file mode 100644
index 0000000..ab05906
--- /dev/null
+++ b/src/interpreter/imports/runner/qml/PlainTextLogger.qml
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+import QtSystemTest.Runner 1.0
+
+Logger {
+ id: plaintextLogger
+
+ property PlainTextWriter writer: PlainTextWriter {}
+
+ property int indentLevel : 0
+ property bool writeFinished : true
+ property string indentString: ' '
+ property int maxNameLen: 60
+
+ property variant status : ({
+ });
+
+ function aboutToStartExecution() {
+ writer.filePath = plaintextLogger.path;
+ }
+
+ function testCollectionStart(testCollection) {
+ var loc = locationOf(testCollection);
+ logString( 'Collection', pad("'"+ testCollection.name + "' ", maxNameLen - 2*indentLevel)
+ + ' : ' + loc.fileName + '('+ loc.lineNumber +')');
+ indentLevel++;
+ }
+
+ function testStart(test) { var loc = locationOf(test);
+ logString( 'Test', pad("'"+test.name + "' ", maxNameLen - 2*indentLevel)
+ + ' : ' + loc.fileName + '('+ loc.lineNumber +')');
+ indentLevel++;
+ }
+
+
+ function methodStart(method) {
+ logString('Running', method + '()');
+ writeFinished = false;
+ indentLevel++;
+ }
+
+ function methodEnd(method) {
+ indentLevel--;
+ if ( writeFinished ) {
+ logString('Finished', method + '()');
+ }
+ }
+
+ function testEnd(test) {
+ indentLevel--;
+ var statusMap = {
+ error: { text: 'ERROR', foreground: PlainTextWriter.White, background: PlainTextWriter.Red },
+ passed: { text: 'passed', foreground: PlainTextWriter.Green, background: PlainTextWriter.DefaultColor },
+ skipped: { text: 'skipped', foreground: PlainTextWriter.Yellow, background: PlainTextWriter.DefaultColor },
+ failed: { text: 'FAILED', foreground: PlainTextWriter.Red, background: PlainTextWriter.DefaultColor },
+ untested: { text: 'UNTESTED', foreground: PlainTextWriter.LightRed, background: PlainTextWriter.DefaultColor }
+ };
+
+ var result = test.__status.toLowerCase();
+ var status = statusMap[result];
+ logString( 'Result', pad("'"+test.name + "' ", maxNameLen - 2*indentLevel, '.')
+ + ' : [' + writer.colorize(status.text, status.foreground, status.background) + ']');
+ }
+
+ function testCollectionEnd(testCollection) {
+ indentLevel--;
+ logString( 'Collection', testCollection.name );
+ }
+
+
+ function finishedExecution() {
+ write('-'.repeat(80));
+ var report = runner.report;
+ var totalTests = 0;
+ var keys = ['error', 'passed', 'skipped', 'failed', 'untested'];
+ keys.forEach(function(s) {
+ totalTests += report[s];
+ });
+ write(pad('Total Tests', 15) + ' :' + totalTests);
+
+ keys.forEach(function(s) {
+ if (report[s] > 0 ) {
+ write(pad(s, 15) + ' :' + report[s]);
+ }
+ });
+ write('-'.repeat(80));
+ }
+
+
+ function log(type, event) {
+ var str = event.formatted || event.message;
+ if (event.stack) {
+ event.stack.forEach(function(callSite) {
+ var trace = Qt.qst.relativeToCurrentPath(callSite.fileName)
+ + '(' + callSite.lineNumber +') : '
+ + callSite.functionName;
+ str += '\n';
+ str += trace;
+ });
+ }
+ logString(type, str);
+ }
+
+ function logString(type, str) {
+ writeFinished = true;
+ write(pad(type, 10) + ' : ' + str);
+ }
+
+ function write(str) {
+ var strs = str.split('\n');
+ var prefix = '[' + Date.timestamp() + ']'+ indentString.repeat(indentLevel) + ' ';
+ for (var i = 0; i < strs.length; ++i) {
+ writer.writeLine(prefix + strs[i]);
+ }
+ }
+
+ function pad(text, len, using) {
+ using = using || ' '
+ var padding = text.length < len ? using.repeat(len - text.length) : '';
+ return text + padding;
+ }
+}
diff --git a/src/interpreter/imports/runner/qml/XUnitLogger.qml b/src/interpreter/imports/runner/qml/XUnitLogger.qml
new file mode 100644
index 0000000..fb66d3c
--- /dev/null
+++ b/src/interpreter/imports/runner/qml/XUnitLogger.qml
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtSystemTest 1.0
+import QtSystemTest.Runner 1.0
+
+Logger {
+ id: xunitLogger
+
+ property var writer: XUnitWriter {
+ filePath: xunitLogger.path
+ }
+
+ property var tests: []
+ property var currentTest
+ property var msecsMarker: 0
+ property var collectionStack: 0
+ property var lastCollection: '';
+
+ function aboutToStartExecution() {
+ writer.writeStartDocument();
+ writer.writeStartTestSuiteSet();
+ }
+
+ function finishedExecution() {
+ writer.writeEndTestSuiteSet();
+ writer.writeEndDocument();
+ }
+
+ function testCollectionStart(testCollection) {
+ if (!collectionStack) {
+ tests = [];
+ msecsMarker = new Date;
+ }
+ lastCollection = testCollection.name;
+ collectionStack++;
+ }
+
+ function testCollectionEnd(testCollection) {
+ collectionStack--;
+ if (collectionStack)
+ return;
+
+ var Status = Core.Qtt.Status;
+
+ var passed = 0;
+ var failed = 0;
+ var skipped = 0;
+ var errors = 0;
+ var i;
+ var test;
+ for (i = 0; i < tests.length; i++) {
+ test = tests[i];
+ switch(test.state) {
+ case Status.Passed:
+ passed++;
+ break;
+ case Status.Failed:
+ failed++;
+ break;
+ default:
+ case Status.Skipped:
+ case Status:Untested:
+ skipped++;
+ break;
+ case Status.Error:
+ errors++;
+ break;
+ }
+ }
+ writer.writeStartTestSuite(
+ testCollection.name,
+ msecsMarker,
+ 'localhost',
+ passed + failed + skipped + errors,
+ failed,
+ errors,
+ skipped,
+ (+(new Date()) - msecsMarker.getTime())/1000);
+ for (i = 0; i < tests.length; i++) {
+ test = tests[i];
+ writer.writeStartTestCase(test.classname, test.name, test.duration);
+ var message;
+ if (test.messages.length > 0) {
+ message = test.messages[test.messages.length-1];
+ var messageWritten;
+ switch(message.type) {
+ case Status.Error:
+ writer.writeError(message.type, message.message);
+ break;
+ case Status.Failed:
+ writer.writeFailure(message.type, message.message);
+ break;
+ case Status.Skipped:
+ case Status.Untested:
+ writer.writeSkipped(message.type, message.message);
+ break;
+ default:
+ break;
+ }
+ }
+
+ writer.writeEndTestCase();
+ }
+ writer.writeEndTestSuite();
+ }
+
+ function testStart(test) {
+ currentTest = {
+ state: Core.Qtt.Status.Passed,
+ time: +(new Date()),
+ classname: lastCollection,
+ name: test.name,
+ messages: []
+ };
+ }
+ function testEnd(test) {
+ currentTest.duration = (+(new Date()) - currentTest.time)/1000;
+ currentTest.state = test.__status
+ if (test.__status === Core.Qtt.Status.Untested) {
+ currentTest.messages.push({type: test.__status, message: 'No verifiable steps performed'});
+
+ }
+
+ tests.push(currentTest);
+
+ }
+
+ function cleanup() { }
+
+ function log(type, msg) {
+ currentTest.messages.push({type: type, message: msg});
+ }
+}
diff --git a/src/interpreter/imports/runner/qml/XmlLogger.qml b/src/interpreter/imports/runner/qml/XmlLogger.qml
new file mode 100644
index 0000000..951eb59
--- /dev/null
+++ b/src/interpreter/imports/runner/qml/XmlLogger.qml
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtSystemTest 1.0
+import QtSystemTest.Runner 1.0
+
+Logger {
+ id: xmlLogger
+ property XmlWriter writer: XmlWriter {}
+
+ property Js js : Js{}
+ function store(){}
+
+ function aboutToStartExecution() {
+ store.timerStack = [];
+ writer.filePath = xmlLogger.path;
+ writer.writeStartDocument();
+ writer.writeStartElement('systemtestrun');
+ store.timerStack.push(+new Date);
+ }
+
+ function finishedExecution() {
+ var duration = (+new Date) - store.timerStack.pop();
+
+ writer.writeStartElement('report');
+
+ var report = runner.report;
+ var totalTests = 0;
+ var keys = ['passed', 'skipped', 'untested', 'failed', 'error'];
+ keys.forEach(function(s) {
+ totalTests += report[s];
+ writer.writeTextElement(s, report[s].toString());
+ });
+ writer.writeTextElement('total', totalTests.toString());
+ writer.writeTextElement('duration', duration);
+ writer.writeEndElement(); // report
+ writer.writeEndElement(); // systemtestrun
+ writer.writeEndDocument();
+ }
+
+ function testCollectionStart(testCollection) {
+ var loc = locationOf(testCollection);
+ writer.writeStartElement('collection');
+ writer.writeAttribute('name', testCollection.name);
+ writer.writeAttribute('file', loc.fileName);
+ writer.writeAttribute('line', loc.lineNumber);
+ writer.writeAttribute('timestamp', (new Date).toISOString());
+ store.timerStack.push(+new Date);
+ }
+
+ function testCollectionEnd(testCollection) {
+ var duration = (+new Date) - store.timerStack.pop();
+ writer.writeStartElement('report');
+ writer.writeTextElement('duration', duration);
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ function testStart(test) {
+ var loc = locationOf(test);
+ writer.writeStartElement('test');
+ writer.writeAttribute('name', test.name);
+ writer.writeAttribute('file', loc.fileName);
+ writer.writeAttribute('line', loc.lineNumber);
+ writer.writeAttribute('timestamp', (new Date).toISOString());
+ store.timerStack.push(+new Date);
+ }
+
+ function testEnd(test) {
+ var duration = (+new Date) - store.timerStack.pop();
+ writer.writeStartElement('report');
+ writer.writeTextElement('status', test.__status.toLowerCase());
+ writer.writeTextElement('duration', duration);
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ function methodStart(method) {
+ writer.writeStartElement('method');
+ writer.writeAttribute('name', method);
+ }
+
+ function methodEnd(method) {
+ writer.writeEndElement();
+ }
+
+ function writeFrame(callSite) {
+ var path = Qt.qst.relativeToCurrentPath(callSite.fileName);
+ writer.writeStartElement('frame');
+ writer.writeAttribute('file', path);
+ writer.writeAttribute('line', callSite.lineNumber);
+ writer.writeCharacters(callSite.functionName);
+ writer.writeEndElement();
+ }
+
+ function writeEventContents(event)
+ {
+ var Core = js.core();
+ var stringify = Core.stringify.nothrow();
+ writer.writeTextElement('reason', event.message);
+ if (event.stack) {
+ writer.writeStartElement('stack');
+ event.stack.forEach(writeFrame.bind(this));
+ writer.writeEndElement();
+ }
+ if (event.meta) {
+ writer.writeStartElement('meta')
+ for(var part in event.meta) {
+ var asString = stringify(event.meta[part]);
+ writer.writeStartElement('property');
+ writer.writeAttribute('name', part);
+ writer.writeCharacters(stringify.failed ? 'opaque object' : asString);
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+ }
+ }
+
+ function log(type, event) {
+ var ltype = type.toLowerCase();
+ switch(ltype) {
+ case 'passed':
+ case 'skipped':
+ case 'failed':
+ case 'error':
+ case 'untested':
+ writer.writeStartElement(ltype);
+ writeEventContents(event);
+ writer.writeEndElement();
+ break;
+ default:
+ writer.writeStartElement('note');
+ writer.writeAttribute('type', ltype);
+ writeEventContents(event);
+ writer.writeEndElement();
+ break;
+ }
+ }
+
+}
diff --git a/src/interpreter/imports/runner/qmldir b/src/interpreter/imports/runner/qmldir
new file mode 100644
index 0000000..89362d2
--- /dev/null
+++ b/src/interpreter/imports/runner/qmldir
@@ -0,0 +1,7 @@
+plugin qtsystemtestrunner
+Logger 1.0 qml/Logger.qml
+PlainTextLogger 1.0 qml/PlainTextLogger.qml
+XUnitLogger 1.0 qml/XUnitLogger.qml
+XmlLogger 1.0 qml/XmlLogger.qml
+Config 1.0 qml/Config.qml
+
diff --git a/src/interpreter/imports/runner/qtsystemtestrunner.json b/src/interpreter/imports/runner/qtsystemtestrunner.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/src/interpreter/imports/runner/qtsystemtestrunner.json
@@ -0,0 +1 @@
+{}
diff --git a/src/interpreter/imports/runner/runner.pro b/src/interpreter/imports/runner/runner.pro
new file mode 100644
index 0000000..438c683
--- /dev/null
+++ b/src/interpreter/imports/runner/runner.pro
@@ -0,0 +1,70 @@
+TARGET = qtsystemtestrunner
+TARGETPATH = QtSystemTest/Runner
+
+TEMPLATE = lib
+CONFIG += no_clean qt plugin
+QT += declarative declarative-private
+
+
+SOURCES += src/imports.cpp \
+ src/qstxunitwriter.cpp \
+ src/qstlogwriter.cpp \
+
+HEADERS += src/imports.h \
+ src/qstxunitwriter.h \
+ src/qstlogwriter.h \
+
+OTHER_FILES += \
+ qtsystemtest.json \
+
+target.path += $$[QT_INSTALL_IMPORTS]/QtSystemTest/Runner
+
+# public api
+QML_IMPORT_FILES = \
+ qml/Config.qml \
+ qml/Logger.qml \
+ qml/PlainTextLogger.qml \
+ qml/XmlLogger.qml \
+ qml/XUnitLogger.qml
+
+qmlImportFiles.files += $$QML_IMPORT_FILES
+qmlImportFiles.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/qml
+
+# scripts
+#SCRIPT_FILES = \
+# scripts/api.js \
+# scripts/Datatype.js \
+# scripts/Functional.js \
+# scripts/JsCore.js \
+# scripts/SourceBuilder.js \
+# scripts/Class.js \
+# scripts/QstCore.js \
+# scripts/Console.js \
+# scripts/Expect.js \
+# scripts/Exception.js \
+# scripts/ApplicationRegistry.js \
+
+#scriptFiles.files += $$SCRIPT_FILES
+#scriptFiles.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH/scripts
+
+# qmldir
+QMLDIR_FILE = qmldir
+qmldirFile.files += $$QMLDIR_FILE
+qmldirFile.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+# show in QtCreator
+OTHER_FILES += $$QML_IMPORT_FILES \
+# $$SCRIPT_FILES \
+ qmldir \
+
+
+INSTALLS += qmlImportFiles qmldirFile target
+
+
+
+
+
+
+
+
+
diff --git a/src/interpreter/imports/runner/src/imports.cpp b/src/interpreter/imports/runner/src/imports.cpp
new file mode 100644
index 0000000..a2852d9
--- /dev/null
+++ b/src/interpreter/imports/runner/src/imports.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imports.h"
+#include "qstxunitwriter.h"
+#include <QtDebug>
+#include <QtDeclarative>
+
+void QtSystemTestRunnerModule::registerTypes(const char *uri)
+{
+ qDebug() << Q_FUNC_INFO << uri;
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtSystemTest.Runner"));
+ qmlRegisterType<QstPlainTextWriter>(uri, 1, 0, "PlainTextWriter");
+ qmlRegisterType<QstXmlStreamWriter>(uri, 1, 0, "XmlWriter");
+ qmlRegisterType<QstXUnitWriter>(uri, 1, 0, "XUnitWriter");
+}
+
+void QtSystemTestRunnerModule::initializeEngine(QDeclarativeEngine *, const char *)
+{
+}
+
+Q_EXPORT_PLUGIN2(qtsystemtestrunner, QtSystemTestRunnerModule);
diff --git a/src/interpreter/imports/runner/src/imports.h b/src/interpreter/imports/runner/src/imports.h
new file mode 100644
index 0000000..f424a95
--- /dev/null
+++ b/src/interpreter/imports/runner/src/imports.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMPORTS_H
+#define IMPORTS_H
+
+#include <QDeclarativeExtensionPlugin>
+
+class QDeclarativeEngine;
+
+class QtSystemTestRunnerModule : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+
+public:
+ virtual void registerTypes(const char *uri);
+ void initializeEngine(QDeclarativeEngine *, const char *);
+};
+
+#endif // IMPORTS_H
diff --git a/src/interpreter/imports/runner/src/qstlogwriter.cpp b/src/interpreter/imports/runner/src/qstlogwriter.cpp
new file mode 100644
index 0000000..8ef70de
--- /dev/null
+++ b/src/interpreter/imports/runner/src/qstlogwriter.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstlogwriter.h"
+
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QList>
+
+
+#include <QtCore/QDebug>
+
+static QIODevice *createDevice(const QString &path)
+{
+ QFile *file = new QFile;
+ if (path.isEmpty()) {
+ if (!file->open(stdout, QFile::WriteOnly)) {
+ qWarning("Error opening stdout: %s", qPrintable(file->errorString()));
+ delete file;
+ file = 0;
+ }
+ } else {
+ file->setFileName(path);
+ if (!file->open(QFile::WriteOnly)) {
+ qWarning("Error opening log file %s: %s", qPrintable(path), qPrintable(file->errorString()));
+ delete file;
+ file = 0;
+ }
+ }
+ return file;
+}
+
+
+void QstPlainTextWriter::setFilePath(const QString &path)
+{
+ QIODevice *dev = m_stream->device();
+ m_stream->setDevice(0);
+ dev->deleteLater();
+
+ dev = createDevice(path);
+ if (dev)
+ m_stream->setDevice(dev);
+}
+
+QString QstPlainTextWriter::filePath() const
+{
+ QFile *file = qobject_cast<QFile*>(m_stream->device());
+ if (file) {
+ QFileInfo info(*file);
+ return info.absoluteFilePath();
+ }
+ return QString();
+}
+
+void QstPlainTextWriter::writeLine(const QString &text)
+{
+ *m_stream << text << endl;
+ m_stream->flush();
+}
+
+static QList<int> color_codes(QstPlainTextWriter::Color color, bool foreground = true)
+{
+ QList<int> commands;
+ if (color == QstPlainTextWriter::DefaultColor)
+ return commands;
+ int distance = (int)color - (int)QstPlainTextWriter::Black;
+ commands.append(distance % 2);
+ commands.append((distance / 2) + (foreground ? 30 : 40));
+ return commands;
+}
+
+QString QstPlainTextWriter::colorize(const QString &text, Color foreground, Color background)
+{
+ if (m_colorSetting == NeverColor || (m_colorSetting == AutoColor && !isConsole()))
+ return text;
+
+ QList<int> commands;
+ commands << color_codes(foreground, true) << color_codes(background, false);
+ if (commands .isEmpty())
+ return text;
+ QString result = QString::fromLatin1("\033[");
+ QListIterator<int> it(commands);
+ while(it.hasNext()) {
+ result += QString::number(it.next());
+ if (it.hasNext())
+ result += QString::fromLatin1(";");
+ }
+ result += "m";
+ return result + text + "\033[0m";
+}
+
+bool QstPlainTextWriter::isConsole() const
+{
+ QFile *file = qobject_cast<QFile*>(m_stream->device());
+ if (file) {
+ // not sure, but may need to use _isatty on win
+ return isatty(file->handle());
+ }
+ return false;
+}
+
+void QstXmlStreamWriter::setFilePath(const QString &path)
+{
+ QIODevice *dev = m_writer->device();
+ m_writer->setDevice(0);
+ dev->deleteLater();
+
+ dev = createDevice(path);
+ if (dev)
+ m_writer->setDevice(dev);
+}
+
+QString QstXmlStreamWriter::filePath() const
+{
+ QFile *file = qobject_cast<QFile*>(m_writer->device());
+ if (file) {
+ QFileInfo info(*file);
+ return info.absoluteFilePath();
+ }
+ return QString();
+}
+
+void QstXmlStreamWriter::flush()
+{
+ QFile *file = qobject_cast<QFile *>(m_writer->device());
+ if (file)
+ file->flush();
+}
diff --git a/src/interpreter/imports/runner/src/qstlogwriter.h b/src/interpreter/imports/runner/src/qstlogwriter.h
new file mode 100644
index 0000000..8e87eac
--- /dev/null
+++ b/src/interpreter/imports/runner/src/qstlogwriter.h
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTLOGWRITER_H
+#define QSTLOGWRITER_H
+
+#include <QtCore/QTextStream>
+#include <QtCore/QXmlStreamWriter>
+
+
+class QstPlainTextWriter : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(ColorSetting Color)
+ Q_PROPERTY(QString filePath READ filePath WRITE setFilePath)
+ Q_PROPERTY(ColorSetting colorSetting READ colorSetting WRITE setColorSetting)
+public:
+ enum ColorSetting {
+ AutoColor,
+ AlwaysColor,
+ NeverColor
+ };
+
+ enum Color {
+ DefaultColor,
+ Black, // the order of these colors matters, see colorize
+ DarkGray,
+ Red,
+ LightRed,
+ Green,
+ LightGreen,
+ Brown,
+ Yellow,
+ Blue,
+ LightBlue,
+ Purple,
+ LightPurple,
+ Cyan,
+ LightCyan,
+ LightGray,
+ White
+ };
+
+ QstPlainTextWriter(QObject *parent = 0)
+ : QObject(parent),
+ m_colorSetting(AutoColor)
+ {
+ m_stream = new QTextStream;
+ m_stream->setCodec("UTF8");
+ }
+
+ ~QstPlainTextWriter() {
+ if (m_stream->device()) {
+ m_stream->device()->close();
+ m_stream->device()->deleteLater();
+ }
+ delete m_stream;
+ }
+
+ void setColorSetting(ColorSetting setting) { m_colorSetting = setting; }
+ ColorSetting colorSetting() const { return m_colorSetting; }
+
+ void setFilePath(const QString &);
+ QString filePath() const;
+
+ Q_INVOKABLE void writeLine(const QString &);
+
+ Q_INVOKABLE QString colorize(const QString &text, Color foreground = DefaultColor, Color background = DefaultColor);
+
+private:
+ Q_INVOKABLE bool isConsole() const;
+ QTextStream *m_stream;
+ ColorSetting m_colorSetting;
+};
+
+class QstXmlStreamWriter : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString filePath READ filePath WRITE setFilePath)
+ Q_PROPERTY(bool autoFormatting READ autoFormatting WRITE setAutoFormatting)
+ Q_PROPERTY(int autoFormattingIndent READ autoFormattingIndent WRITE setAutoFormattingIndent)
+
+public:
+ QstXmlStreamWriter(QObject *parent = 0)
+ : QObject(parent)
+ {
+ m_writer = new QXmlStreamWriter;
+ m_writer->setAutoFormatting(true);
+ }
+
+ ~QstXmlStreamWriter()
+ {
+ flush();
+ if (m_writer->device()) {
+ m_writer->device()->close();
+ m_writer->device()->deleteLater();
+ }
+ delete m_writer;
+ }
+
+ void setFilePath(const QString &);
+ QString filePath() const;
+
+ void setAutoFormatting(bool value)
+ { m_writer->setAutoFormatting(value); }
+ bool autoFormatting() const
+ { return m_writer->autoFormatting(); }
+
+ void setAutoFormattingIndent(int spacesOrTabs)
+ { m_writer->setAutoFormattingIndent(spacesOrTabs); }
+ int autoFormattingIndent() const
+ { return m_writer->autoFormattingIndent(); }
+
+ Q_INVOKABLE void writeAttribute(const QString &qualifiedName, const QString &value)
+ { m_writer->writeAttribute(qualifiedName, value); }
+ Q_INVOKABLE void writeAttribute(const QString &namespaceUri, const QString &name, const QString &value)
+ { m_writer->writeAttribute(namespaceUri, name, value); }
+
+ Q_INVOKABLE void writeCDATA(const QString &text)
+ { m_writer->writeCDATA(text); }
+ Q_INVOKABLE void writeCharacters(const QString &text)
+ { m_writer->writeCharacters(text); }
+ Q_INVOKABLE void writeComment(const QString &text)
+ { m_writer->writeComment(text); }
+
+ Q_INVOKABLE void writeDTD(const QString &dtd)
+ { m_writer->writeDTD(dtd); }
+
+ Q_INVOKABLE void writeEmptyElement(const QString &qualifiedName)
+ { m_writer->writeEmptyElement(qualifiedName); }
+ Q_INVOKABLE void writeEmptyElement(const QString &namespaceUri, const QString &name)
+ { m_writer->writeEmptyElement(namespaceUri, name); }
+
+ Q_INVOKABLE void writeTextElement(const QString &qualifiedName, const QString &text)
+ { m_writer->writeTextElement(qualifiedName, text); }
+ Q_INVOKABLE void writeTextElement(const QString &namespaceUri, const QString &name, const QString &text)
+ { m_writer->writeTextElement(namespaceUri, name, text); }
+
+ Q_INVOKABLE void writeEndDocument()
+ { m_writer->writeEndDocument(); flush(); }
+ Q_INVOKABLE void writeEndElement()
+ { m_writer->writeEndElement(); }
+
+ Q_INVOKABLE void writeEntityReference(const QString &name)
+ { m_writer->writeEntityReference(name); }
+ Q_INVOKABLE void writeNamespace(const QString &namespaceUri, const QString &prefix = QString())
+ { m_writer->writeNamespace(namespaceUri, prefix); }
+ Q_INVOKABLE void writeDefaultNamespace(const QString &namespaceUri)
+ { m_writer->writeDefaultNamespace(namespaceUri); }
+ Q_INVOKABLE void writeProcessingInstruction(const QString &target, const QString &data = QString())
+ { m_writer->writeProcessingInstruction(target, data); }
+
+ Q_INVOKABLE void writeStartDocument()
+ { m_writer->writeStartDocument(); }
+ Q_INVOKABLE void writeStartDocument(const QString &version)
+ { m_writer->writeStartDocument(version); }
+ Q_INVOKABLE void writeStartDocument(const QString &version, bool standalone)
+ { m_writer->writeStartDocument(version, standalone); }
+ Q_INVOKABLE void writeStartElement(const QString &qualifiedName)
+ { m_writer->writeStartElement(qualifiedName); }
+ Q_INVOKABLE void writeStartElement(const QString &namespaceUri, const QString &name)
+ { m_writer->writeStartElement(namespaceUri, name); }
+
+ Q_INVOKABLE bool hasError() const
+ { return m_writer->hasError(); }
+
+ void flush();
+private:
+
+ QXmlStreamWriter *m_writer;
+};
+
+
+#endif // QSTLOGWRITER_H
diff --git a/src/interpreter/imports/runner/src/qstxunitwriter.cpp b/src/interpreter/imports/runner/src/qstxunitwriter.cpp
new file mode 100644
index 0000000..976d98e
--- /dev/null
+++ b/src/interpreter/imports/runner/src/qstxunitwriter.cpp
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstxunitwriter.h"
+#include <QtCore/QDateTime>
+
+
+QstXUnitWriter::QstXUnitWriter()
+ : QstXmlStreamWriter(),
+ m_state(Document),
+ m_suiteId(1)
+{
+}
+
+QstXUnitWriter::~QstXUnitWriter()
+{
+}
+
+bool QstXUnitWriter::checkState(State state, const QString &element, bool start)
+{
+ if (m_state != state) {
+ if (m_state != Error) {
+ if (start)
+ qWarning("unexpected state when starting '%s'", element.toLocal8Bit().constData());
+ else
+ qWarning("unexpected state when ending '%s'", element.toLocal8Bit().constData());
+ m_state = Error;
+ }
+ return false;
+ }
+ if (hasError()) {
+ if (m_state != Error) {
+ qWarning("unexpected error with device");
+ m_state = Error;
+ }
+ return false;
+ }
+ return true;
+}
+
+static const QString s_suiteSet(QString::fromLatin1("testsuites"));
+static const QString s_suite(QString::fromLatin1("testsuite"));
+static const QString s_case(QString::fromLatin1("testcase"));
+static const QString s_error(QString::fromLatin1("error"));
+static const QString s_failure(QString::fromLatin1("failure"));
+static const QString s_skipped(QString::fromLatin1("skipped"));
+
+void QstXUnitWriter::writeStartTestSuiteSet()
+{
+ if (!checkState(Document, s_suiteSet, true))
+ return;
+ m_state = SuiteSet;
+
+ writeStartElement(s_suiteSet);
+}
+
+void QstXUnitWriter::writeEndTestSuiteSet()
+{
+ if (!checkState(SuiteSet, s_suiteSet, false))
+ return;
+ m_state = Document;
+
+ writeEndElement();
+ flush();
+}
+
+void QstXUnitWriter::writeStartTestSuite(
+ const QString &name,
+ const QDateTime &timestamp,
+ const QString &hostname,
+ int testTotal, int testFails, int testErrors, int testSkips,
+ int duration)
+{
+ if (!checkState(SuiteSet, s_suite, true))
+ return;
+ m_state = Suite;
+
+ writeStartElement(s_suite);
+ writeAttribute("name", name);
+ writeAttribute("package", QString::fromLatin1("none"));
+ writeAttribute("timestamp", timestamp.toLocalTime().toString("yyyy-MM-ddThh:mm:ss"));
+ writeAttribute("hostname", hostname.isEmpty() ? "localhost" : hostname);
+ writeAttribute("tests", QString::number(testTotal));
+ writeAttribute("failures", QString::number(testFails));
+ writeAttribute("errors", QString::number(testErrors));
+ writeAttribute("skipped", QString::number(testSkips));
+ writeAttribute("time", QString::number(duration));
+ writeAttribute("id", QString::number(m_suiteId++));
+}
+
+void QstXUnitWriter::writeEndTestSuite()
+{
+ if (!checkState(Suite, s_suite, false))
+ return;
+ m_state = SuiteSet;
+
+ writeEndElement();
+}
+
+
+void QstXUnitWriter::writeStartTestCase(const QString &classname, const QString &name, int duration)
+{
+ if (!checkState(Suite, s_case, true))
+ return;
+ m_state = Case;
+
+ writeStartElement(s_case);
+ writeAttribute("classname", classname);
+ writeAttribute("name", name);
+ writeAttribute("time", QString::number(duration));
+}
+
+void QstXUnitWriter::writeEndTestCase()
+{
+ if (!checkState(Case, s_case, false))
+ return;
+ m_state = Suite;
+
+ writeEndElement();
+}
+
+void QstXUnitWriter::writeError(const QString &type, const QString &message)
+{
+ if (!checkState(Case, s_error, true))
+ return;
+
+ writeStartElement(s_error);
+ writeAttribute("type", type);
+ writeCharacters(message);
+ writeEndElement();
+}
+void QstXUnitWriter::writeFailure(const QString &type, const QString &message)
+{
+ if (!checkState(Case, s_failure, true))
+ return;
+
+ writeStartElement(s_failure);
+ writeAttribute("type", type);
+ writeCharacters(message);
+ writeEndElement();
+}
+void QstXUnitWriter::writeSkipped(const QString &type, const QString &message)
+{
+ if (!checkState(Case, s_skipped, true))
+ return;
+
+ writeStartElement(s_skipped);
+ writeAttribute("type", type);
+ writeCharacters(message);
+ writeEndElement();
+}
diff --git a/src/interpreter/imports/runner/src/qstxunitwriter.h b/src/interpreter/imports/runner/src/qstxunitwriter.h
new file mode 100644
index 0000000..93904fc
--- /dev/null
+++ b/src/interpreter/imports/runner/src/qstxunitwriter.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTXUNITWRITER_H
+#define QSTXUNITWRITER_H
+
+#include "qstlogwriter.h"
+
+class QstXUnitWriter : public QstXmlStreamWriter
+{
+ Q_OBJECT
+public:
+ QstXUnitWriter();
+ ~QstXUnitWriter();
+
+ Q_INVOKABLE void writeStartTestSuiteSet();
+ Q_INVOKABLE void writeEndTestSuiteSet();
+
+ Q_INVOKABLE void writeStartTestSuite(
+ const QString &name,
+ const QDateTime &timestamp,
+ const QString &hostname,
+ int testTotal,
+ int testFails,
+ int testErrors,
+ int testSkips,
+ int duration);
+
+ Q_INVOKABLE void writeEndTestSuite();
+
+ Q_INVOKABLE void writeStartTestCase(const QString &classname, const QString &name, int duration);
+ Q_INVOKABLE void writeEndTestCase();
+
+ Q_INVOKABLE void writeError(const QString &type, const QString &message);
+ Q_INVOKABLE void writeFailure(const QString &type, const QString &message);
+ Q_INVOKABLE void writeSkipped(const QString &type, const QString &message);
+
+private:
+ enum State {
+ Document,
+ SuiteSet,
+ Suite,
+ Case,
+ Error
+ };
+
+ bool checkState(State, const QString &element, bool start = true);
+
+ State m_state;
+
+ int m_suiteId;
+};
+
+#endif // QSTXUNITWRITER_H
diff --git a/src/interpreter/interpreter.pro b/src/interpreter/interpreter.pro
new file mode 100644
index 0000000..a89fbfb
--- /dev/null
+++ b/src/interpreter/interpreter.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+
+SUBDIRS = imports runner
diff --git a/src/interpreter/runner/main.cpp b/src/interpreter/runner/main.cpp
new file mode 100644
index 0000000..f7f7ae1
--- /dev/null
+++ b/src/interpreter/runner/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include <qstrunnerbootstrap.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication *app = 0;
+
+ bool guiEnabled = false;
+ for (int i = 1; i < argc; ++i) {
+ if ( qstrcmp(argv[i], "--disable-manual-tests") == 0) {
+ guiEnabled = false;
+ break;
+ }
+ }
+
+ if (guiEnabled) {
+ app = new QApplication(argc, argv);
+ } else {
+ app = new QCoreApplication(argc, argv);
+ }
+
+ QstRunnerBootstrap runner(app);
+ int ret = runner.run();
+ return ret;
+}
diff --git a/src/interpreter/runner/qstjsengine.cpp b/src/interpreter/runner/qstjsengine.cpp
new file mode 100644
index 0000000..1e3b225
--- /dev/null
+++ b/src/interpreter/runner/qstjsengine.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstjsengine.h"
+
+
+QstJsEngine::QstJsEngine(QObject *parent) :
+ QObject(parent)
+{
+
+}
diff --git a/src/interpreter/runner/qstjsengine.h b/src/interpreter/runner/qstjsengine.h
new file mode 100644
index 0000000..14828a7
--- /dev/null
+++ b/src/interpreter/runner/qstjsengine.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTJSENGINE_H
+#define QSTJSENGINE_H
+
+#include <QObject>
+
+class QstJsEngine : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QstJsEngine(QObject *parent = 0);
+
+signals:
+
+public slots:
+
+};
+
+#endif // QSTJSENGINE_H
diff --git a/src/interpreter/runner/qstrunnerbootstrap.cpp b/src/interpreter/runner/qstrunnerbootstrap.cpp
new file mode 100644
index 0000000..0c44c56
--- /dev/null
+++ b/src/interpreter/runner/qstrunnerbootstrap.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstrunnerbootstrap.h"
+#include "qstrunnercore.h"
+#include <QtCore/QFileInfo>
+#include <QtCore/QStringList>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtScript/QScriptEngine>
+#include <QtScript/QScriptContext>
+#include <QtScript/QScriptValue>
+#include <QtScript/QScriptContextInfo>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+
+static const int InternalError = 1 << 6;
+
+
+static QScriptValue isRelativePath(QScriptContext *ctx, QScriptEngine *)
+{
+ QUrl url = ctx->argument(0).toString();
+ return url.isRelative();
+}
+
+static QScriptValue relativeToCurrentPath(QScriptContext *ctx, QScriptEngine *)
+{
+ QUrl url = ctx->argument(0).toString();
+ if (url.isLocalFile())
+ return QDir::current().relativeFilePath(url.toLocalFile());
+ return url.toString();
+}
+
+
+static QScriptValue qscriptengine_stack(QScriptContext *ctx, QScriptEngine *e)
+{
+ QVariantList stack;
+
+ qint32 frame = 0;
+ bool framesSpecified = ctx->argumentCount() > 0;
+ if (framesSpecified) {
+ frame = ctx->argument(0).toInt32();
+ }
+
+ while (ctx) {
+ // count down if user has requested for certain number of frames
+ if ( framesSpecified && frame-- <= 0 )
+ break;
+ ctx = ctx->parentContext();
+ QScriptContextInfo info(ctx);
+ QVariantMap callsite;
+ callsite["fileName"] = info.fileName();
+ callsite["lineNumber"] = info.lineNumber();
+ callsite["functionName"] = info.functionName();
+ stack << callsite;
+ }
+ return qScriptValueFromSequence(e, stack);
+}
+
+// Copied from qdeclarativedebughelper_p.h in Qt
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper
+{
+public:
+ static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine);
+};
+
+bool QstRunnerBootstrap::setupScriptEngine(QDeclarativeEngine *declarativeEngine)
+{
+ QScriptEngine *e = QDeclarativeDebugHelper::getScriptEngine(declarativeEngine);
+ QScriptValue qst = e->newObject();
+ qst.setProperty(QLatin1String("stack"), e->newFunction(qscriptengine_stack));
+ qst.setProperty(QLatin1String("isRelativePath"), e->newFunction(isRelativePath));
+ qst.setProperty(QLatin1String("relativeToCurrentPath"), e->newFunction(relativeToCurrentPath));
+
+ QScriptValue qtObject = e->globalObject().property(QLatin1String("Qt"));
+ qtObject.setProperty(QLatin1String("qst"), qst);
+ return true;
+}
+
+QstRunnerBootstrap::QstRunnerBootstrap(QCoreApplication *app)
+ : QObject(app)
+ , m_app(app)
+ , m_qmlRunner(0)
+{
+ QStringList args = app->arguments();
+ // Skips executable
+ args.removeAt(0);
+
+ if (args.count() == 0) {
+ qDebug() << "No arguments passed, failing back to qmlunit Test Suite (" << app->applicationDirPath() << ")\n";
+ args = QStringList(app->applicationDirPath() + "/test");
+ }
+
+ foreach (const QString &arg, args) {
+ findTests(arg);
+ }
+}
+
+
+bool QstRunnerBootstrap::setup()
+{
+ qmlRegisterType<QstRunnerCore>("QstRunner", 1, 0, "Runner");
+ QDeclarativeEngine *engine = new QDeclarativeEngine(this);
+ engine->setOfflineStoragePath(QDir::currentPath() + "/storage");
+ setupScriptEngine(engine);
+
+ qDebug()<< "Loading Runner";
+ QUrl runnerPath = QUrl::fromLocalFile(
+ m_app->applicationDirPath() + "/scripts/QstRunner.qml");
+
+ QDeclarativeComponent runnerCom(engine, runnerPath);
+ if (!runnerCom.errors().isEmpty()) {
+ qDebug() << "Internal error in Qml runner"
+ << runnerCom.errors();
+ return false; // may be exit 2
+ }
+ m_qmlRunner = qobject_cast<QstRunnerCore *>(runnerCom.create());
+ if (!m_qmlRunner) {
+ qDebug() << "Internal Error: qmlRunner creation failed"
+ << runnerCom.errors();
+ return false; // may be exit 2
+ }
+
+ if ( !m_qmlRunner->setup(engine, qApp->arguments()) ) {
+ return false;
+ }
+
+ qDebug()<< "Loading test file";
+ QDeclarativeComponent com(engine, QUrl::fromLocalFile(m_testFile.first()));
+ if (!com.errors().isEmpty()) {
+ qDebug() << "Errors in testcase \n"
+ << com.errors();
+ return false; // may be exit 1
+ }
+ QObject *test = com.create();
+ if (!test ) {
+ qDebug() << "Internal Error testcase object creation \n"
+ << com.errors();
+ return false; // may be exit 1
+ }
+ m_qmlRunner->setTest(test);
+ return true;
+}
+
+int QstRunnerBootstrap::run()
+{
+ if (!setup()) {
+ return InternalError;
+ }
+ qDebug() << Q_FUNC_INFO << "---------------[setup is ok]-------------------";
+ return m_qmlRunner->exec();
+}
+
+void QstRunnerBootstrap::findTests(const QString &path)
+{
+ if (isTest(path)) {
+ m_testFile << QDir(path).absolutePath();
+ return;
+ }
+
+ QStringList filters; filters << "*";
+ QDir dir = QDir(QDir(path).absolutePath());
+
+ QListIterator<QFileInfo> files(dir.entryInfoList(filters, QDir::AllEntries | QDir::NoDotAndDotDot));
+ while(files.hasNext()) {
+ QFileInfo file = files.next();
+ if (file.fileName() == "." || file.fileName() == "..") continue;
+
+ if (isTest(file))
+ m_testFile << file.absoluteFilePath();
+ else if (isDir(file))
+ findTests(file.absoluteFilePath());
+ }
+}
+
+bool QstRunnerBootstrap::isTest(const QFileInfo &file)
+{
+ return isTest(file.fileName());
+}
+
+bool QstRunnerBootstrap::isTest(const QString &filePath)
+{
+ return filePath.endsWith("Test.qml")
+ || filePath.endsWith("Tests.qml");
+}
+
+bool QstRunnerBootstrap::isDir(const QFileInfo &file)
+{
+ return QDir(file.absoluteFilePath()).exists();
+}
diff --git a/src/interpreter/runner/qstrunnerbootstrap.h b/src/interpreter/runner/qstrunnerbootstrap.h
new file mode 100644
index 0000000..a294306
--- /dev/null
+++ b/src/interpreter/runner/qstrunnerbootstrap.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTUITESTRUNNER_H
+#define QTUITESTRUNNER_H
+
+#include <QtCore/QObject>
+#include <QtCore/QStringList>
+
+class QDeclarativeEngine;
+class QCoreApplication;
+class QFileInfo;
+class QStringList;
+class QstRunnerCore;
+
+class QstRunnerBootstrap : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QstRunnerBootstrap(QCoreApplication *app);
+ int run();
+
+public slots:
+
+signals:
+
+private:
+ bool setup();
+ void findTests(const QString &path);
+ bool isDir(const QFileInfo &file);
+ bool isTest(const QFileInfo &file);
+ bool isTest(const QString &filePath);
+ bool setupScriptEngine(QDeclarativeEngine *declarativeEngine);
+
+
+private:
+ QCoreApplication *m_app;
+ QStringList m_testFile;
+ QstRunnerCore *m_qmlRunner;
+};
+
+#endif // QTUITESTRUNNER_H
diff --git a/src/interpreter/runner/qstrunnercore.cpp b/src/interpreter/runner/qstrunnercore.cpp
new file mode 100644
index 0000000..9116936
--- /dev/null
+++ b/src/interpreter/runner/qstrunnercore.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstrunnercore.h"
+#include <private/qdeclarativecontext_p.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
+#include <QtDebug>
+
+QstRunnerCore::QstRunnerCore(QObject *parent) :
+ QObject(parent)
+{
+}
+
+
+
+QVariant QstRunnerCore::locationOf(QObject *o)
+{
+ QVariantMap ret;
+ if (!o) {
+ return ret;
+ }
+ QDeclarativeData *d = QDeclarativeData::get(o, false);
+ if (d && d->outerContext && !d->outerContext->url.isEmpty()) {
+ ret["url"] = d->outerContext->url;
+ ret["lineNumber"] = d->lineNumber;
+ }
+ return ret;
+}
+
+
+void QstRunnerCore::setRootProperty(const QString &name, QObject *obj)
+{
+ m_engine->rootContext()->setContextProperty(name, obj);
+}
+
+bool QstRunnerCore::setup(QDeclarativeEngine *engine, const QStringList &args)
+{
+ m_engine = engine;
+ qDebug()<< "setting __runner : " << this;
+ m_engine->rootContext()->setContextProperty("__runner", this);
+
+ QVariant ret;
+ qDebug()<< "Invoking qml __setup";
+ QMetaObject::invokeMethod(this, "__setup",
+ Q_RETURN_ARG(QVariant, ret),
+ Q_ARG(QVariant, args) );
+ return ret.toBool();
+}
+
+void QstRunnerCore::setTest(QObject *test)
+{
+ setRootProperty("__testRoot", test);
+}
+
+
+int QstRunnerCore::exec()
+{
+ qDebug()<< "Validate test and exec";
+ QVariant ret;
+ QMetaObject::invokeMethod(this, "__exec",
+ Q_RETURN_ARG(QVariant, ret) );
+ return ret.toInt();
+}
diff --git a/src/interpreter/runner/qstrunnercore.h b/src/interpreter/runner/qstrunnercore.h
new file mode 100644
index 0000000..524260a
--- /dev/null
+++ b/src/interpreter/runner/qstrunnercore.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSYSTEMTESTRUNNERCORE_H
+#define QSYSTEMTESTRUNNERCORE_H
+
+#include <QtCore/QObject>
+#include <QtCore/QVariant>
+
+class QDeclarativeEngine;
+
+class QstRunnerCore : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QstRunnerCore(QObject *parent = 0);
+
+ bool setup(QDeclarativeEngine *engine, const QStringList &args);
+ void setTest(QObject *test);
+ int exec();
+
+signals:
+
+public slots:
+ QVariant locationOf(QObject *o);
+ void setRootProperty(const QString &name, QObject* obj);
+
+private:
+ QDeclarativeEngine *m_engine;
+
+};
+
+#endif // QSYSTEMTESTRUNNERCORE_H
diff --git a/src/interpreter/runner/runner.pro b/src/interpreter/runner/runner.pro
new file mode 100644
index 0000000..f5205b2
--- /dev/null
+++ b/src/interpreter/runner/runner.pro
@@ -0,0 +1,30 @@
+CONFIG += qt
+QT += declarative declarative-private script
+
+TARGET = qtsystemtestrunner
+TEMPLATE = app
+
+macx:CONFIG-=app_bundle
+
+SOURCES += main.cpp\
+ qstrunnercore.cpp \
+ qstrunnerbootstrap.cpp \
+ qstjsengine.cpp
+
+HEADERS += \
+ qstrunnercore.h \
+ qstrunnerbootstrap.h \
+ qstjsengine.h
+
+SCRIPTS += \
+ scripts/QstRunner.js \
+ scripts/QstRunner.qml
+
+DESTDIR = ../../../bin
+SCRIPTSDIR = $$OUT_PWD/../../../bin/scripts
+scripts.target = dummytarget
+scripts.commands = (mkdir -p $$SCRIPTSDIR && cd $$PWD && cp $$SCRIPTS $$SCRIPTSDIR/)
+
+QMAKE_EXTRA_TARGETS += scripts
+
+POST_TARGETDEPS += dummytarget
diff --git a/src/interpreter/runner/scripts/QstRunner.js b/src/interpreter/runner/scripts/QstRunner.js
new file mode 100644
index 0000000..da34bc6
--- /dev/null
+++ b/src/interpreter/runner/scripts/QstRunner.js
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+var create = function(Core){
+// import to this namespace
+var
+ InternalError = 1<<6,
+ Console = Core.Console,
+ Class = Core.Class,
+ Js = Core.Js,
+ Qtt = Core.Qtt,
+ runner,
+ Topic = Console.topic('Runner')
+;
+
+function relevantStack(e){
+ relevantStack.currentFile = relevantStack.currentFile
+ || Js.Engine.currentFile();
+
+ Topic.debug('Runner: file: ', relevantStack.currentFile);
+ var filtered = [];
+ e.stack.some(function(callSite) {
+ var hasReachedRunner = callSite.fileName === relevantStack.currentFile;
+ if (!hasReachedRunner) {
+ filtered.push(callSite);
+ }
+ return hasReachedRunner;
+ });
+ return (e instanceof Qtt.Error)
+ ? filtered
+ : filtered.length > 0 ? filtered
+ : e.stack;
+}
+
+var AbstractTestRunner = Class.create(function(item) {
+ var Topic = Console.topic('Runner').topic('AbstractTestRunner');
+
+ function validate(fnName, config){
+ config = config || { }
+ config.mustExist = config.mustExist === undefined ? true : config.mustExist;
+
+ if ( !(fnName in item) ) {
+ if (config.mustExist === true) {
+ throw new ReferenceError( 'Missing mandatory property or function "'
+ + fnName + '" in test item (Name:' + item.name + ')')
+ }
+ Topic.debug('Name: ', fnName, ' is missing, but ok to ignore' );
+ return {ok: true, exists : false};
+ }
+
+ var m = item[fnName];
+ if (typeof (m) !== 'function') {
+ throw new TypeError(fnName + ' not a function');
+ }
+ return {ok: true, exists : true};
+ }
+
+ function exec() {
+ var Topic = Console.topic('Runner').topic('exec');
+ Topic.debug( 'Running .............', item);
+
+ // skip disabled items
+ var result = true;
+ if (item.enabled === false) {
+ Topic.debug(item, 'is disabled ');
+ return result;
+ }
+
+ this.start();
+ runner.currentTestItem = item;
+ try {
+ var ok = invokeSetup.call(this);
+ if (ok) {
+ this.run();
+ }
+ } catch (e) {
+ /// FIXME: Qt5, remove this as e.stack *can be* enabled by default
+ e.__addStack(1);
+ this.setStatus(Qtt.Status.Failed);
+ console.log("Internal error: ", e.status || 'JsError', e.message);
+ ok = false;
+ e.stack.forEach( function(s) {
+ console.log(s.fileName, ': ', s.lineNumber, ' : ', s.functionName); });
+
+ var error = {
+ message: e.message,
+ stack: relevantStack(e),
+ formatted: e.formatted,
+ meta: e.meta
+ };
+ runner.logEvent(e.status || 'JsError', error);
+ throw e;
+ } finally {
+ invokeCleanup.call(this);
+ this.end();
+ }
+ }
+
+
+ function invokeSetup() {
+ var Topic = Console.topic('AbstractTestRunner').topic('invokeSetup');
+
+ Topic.debug( 'validating setup');
+ var setup = 'setup';
+ var result = validate(setup, {mustExist: false});
+ if ( result.ok && result.exists === false ) {
+ return true;
+ }
+
+ setup = item.setup;
+ var ok = true;
+ try {
+ runner.methodStart(setup.name);
+ runner.currentMethod = setup.name;
+ setup();
+ runner.methodEnd(setup.name);
+ } catch (e) {
+ /// FIXME: Qt5, remove this as e.stack *can be* enabled by default
+ e.__addStack(1);
+ Topic.debug('Exception caught: ', e);
+ ok = false;
+ var status = (e instanceof Qtt.Error)
+ ? Qtt.Status.Untested
+ : Qtt.Status.Failed;
+ var error = {
+ message: e.message,
+ stack: relevantStack(e),
+ formatted: e.formatted,
+ meta: e.meta
+ };
+ runner.logEvent(e.status || 'JsError', error);
+ runner.methodEnd(setup.name);
+ this.setStatus(status);
+ }
+ return ok;
+ }
+
+ // don't throw any errors, just report them and end the cleanup
+ function invokeCleanup() {
+ var Topic = Console.topic('TestRunner').topic('runCleanup');
+
+ var cleanup = 'cleanup';
+ var result = validate(cleanup, {mustExist: false});
+ if ( result.ok && result.exists === false ) {
+ return;
+ }
+
+ cleanup = item.cleanup;
+ runner.methodStart(cleanup.name);
+ runner.currentMethod = cleanup.name;
+
+ try {
+ cleanup();
+ } catch (e) {
+ /// FIXME: Qt5, remove this as e.stack *can be* enabled by default
+ e.__addStack(1);
+ Topic.debug('Exception in cleanup: ', e);
+
+ var error = {
+ message: e.message,
+ stack: e.stack,
+ formatted: e.formatted,
+ meta: e.meta
+ };
+
+ runner.logEvent('WARNING', error);
+ } finally {
+ Topic.debug('run finally - finishing method : cleanup ');
+ runner.methodEnd(cleanup.name);
+ }
+ }
+
+ return {
+ validate: validate,
+ item: function() { return item },
+ exec: exec,
+ start: function() { throw new Error('Must override start')},
+ run: function() { throw new Error('Must override run')},
+ end: function() { throw new Error('Must override end')},
+ setStatus: function() { throw new Error('Must override setStatus')},
+ };
+});
+
+var TestRunner = AbstractTestRunner.extend(function(item) {
+ this._super(item);
+ var Topic = Console.topic('TestRunner').topic('AbstractTestRunner');
+ Topic.debug(' Creating a Test runner for ', item.name);
+
+ function start() { runner.testStart(item); }
+
+ function end() { runner.testEnd(item); }
+
+ function setStatus(status) {
+ Topic.debug('Setting ... ', item.name , ' :', status)
+ item.__status = status;
+ /// FIXME Qt5: change report to var and runner.report[status]++
+ var report = runner.report;
+ report[status]++;
+ runner.report = report;
+ }
+
+ function run() {
+ var Topic = Console.topic('TestRunner').topic('runRun');
+
+ Topic.debug( 'validating run');
+ var run = 'run';
+ var status = Qtt.Status.Failed;
+ try {
+ this.validate(run);
+
+ run = item.run;
+ runner.methodStart(run.name);
+ runner.currentMethod = run.name;
+
+ Topic.debug('Going to run ... run');
+ run();
+ status = Qtt.Status.Passed;
+ } catch (e) {
+ /// FIXME: Qt5, remove this as e.stack *can be* enabled by default
+ e.__addStack(1);
+ status = (e instanceof Qtt.Error)
+ ? e.status
+ : Qtt.Status.Failed;
+ var error = {
+ message: e.message,
+ stack: relevantStack(e),
+ formatted: e.formatted,
+ meta: e.meta
+ };
+ Topic.debug(status, Core.stringify(error));
+ runner.logEvent(status, error);
+ } finally {
+ runner.methodEnd(run.name);
+ this.setStatus(status);
+ }
+ }
+
+ return {
+ start: start,
+ end: end,
+ run: run,
+ setStatus: setStatus
+ };
+});
+
+var TestCollectionRunner = AbstractTestRunner.extend(function(item) {
+ this._super(item);
+
+
+ function start() { runner.testCollectionStart(item); }
+
+ function end() { runner.testCollectionEnd(item); }
+
+
+ function setStatus(status) {
+ // recurse and run the subsets ...
+ var subset = item.children;
+ for (var i = 0; i< subset.length; ++i) {
+ var testItem = subset[i];
+ if ( !testItem.enabled ) {
+ continue;
+ }
+ var tr = runnerForItem(testItem);
+ tr.start();
+ tr.setStatus(status);
+ tr.end();
+ }
+ }
+
+ function run() {
+ // recurse and run the subsets ...
+ var subset = item.__subset;
+ for (var i = 0; i< subset.length; ++i) {
+ var tr = runnerForItem(subset[i]);
+ tr.exec();
+ }
+ }
+
+ return {
+ start: start,
+ end: end,
+ run: run,
+ setStatus: setStatus
+ };
+});
+
+
+function runnerForItem(item) {
+ var Runner = item.__isTest ? TestRunner : TestCollectionRunner;
+ return new Runner(item);
+}
+
+function exec(qmlRunner, item){
+ runner = qmlRunner
+ try {
+ runner.aboutToStartExecution();
+ var tr = runnerForItem(item);
+ tr.exec();
+ runner.finishedExecution();
+
+ var report = runner.report;
+ var result = (report.failed > 0)
+ | (report.skipped > 0) << 1
+ | (report.untested > 0) << 2
+ | (report.error > 0) << 3;
+ } catch (e) {
+ /// FIXME: Qt5, remove this as e.stack *can be* enabled by default
+ e.__addStack(1);
+ result = InternalError;
+ }
+ return result;
+}
+
+ return {
+ exec: exec
+ }
+
+};
diff --git a/src/interpreter/runner/scripts/QstRunner.qml b/src/interpreter/runner/scripts/QstRunner.qml
new file mode 100644
index 0000000..32aee06
--- /dev/null
+++ b/src/interpreter/runner/scripts/QstRunner.qml
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of QtSystemTest.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.1
+
+import QstRunner 1.0
+import QtSystemTest 1.0
+import QtSystemTest.Runner 1.0
+import "QstRunner.js" as JsRunner
+
+Runner {
+ id: runner
+
+ property variant currentTestItem
+ property string currentMethod
+
+ property variant report : ({
+ 'passed': 0,
+ 'failed': 0,
+ 'skipped': 0,
+ 'untested': 0,
+ 'error': 0,
+ });
+
+ property variant __loggers
+
+ signal aboutToStartExecution()
+ signal finishedExecution()
+ signal testCollectionStart(variant testCollection)
+ signal testCollectionEnd(variant testCollection)
+
+ signal testStart(variant test)
+ signal testEnd(variant test)
+
+ signal methodStart(string methodName)
+ signal methodEnd(string methodName)
+
+ property variant component: Component {
+ id: configComponent
+ Config { }
+ }
+
+
+
+ function __broadcast(fnName, args) {
+ for (var i =0; i < __loggers.length; ++i) {
+ var logger = __loggers[i];
+ if ( ! (fnName in logger) ) {
+ throw new Error('function ' + fnName + ' not in ' + logger);
+ }
+ var f = logger[fnName];
+ f.apply(logger, args);
+ };
+ }
+
+ function logEvent(type, error) {
+ __broadcast('log', [type, error]);
+ }
+
+
+ function log(messages) {
+ var str = js.core().stringify.apply(null, arguments);
+ __broadcast(arguments.callee.name, ['debug', { message: str }]);
+ }
+
+
+ function __setup(args) {
+ var x = configComponent.createObject(runner);
+ setRootProperty('config', x);
+ __loggers = x.loggers;
+ Array.prototype.forEach.call(__loggers, function(l) {
+ l.setup();
+ });
+ return true;
+ }
+
+ property Js js: Js { }
+
+ function __exec() {
+ var result = __testRoot.__validate();
+ if (!result.valid) {
+ __broadcast('log', ['Error', result.error]);
+ return JsRunner.InternalError;
+ }
+ console.log('Test validation - okay?: ', result.valid);
+
+ result = 1 << 6;
+ try {
+ var x = JsRunner.create(js.core());
+ result = x.exec(runner, __testRoot);
+ } catch (e) {
+ console.log('Error: internal: ', e.toString());
+ console.log('Details:')
+ for (var k in e) {
+ console.log(' ', k, ': ' , e[k]);
+ }
+ }
+ return result;
+ }
+}