summaryrefslogtreecommitdiffstats
path: root/src/interpreter/imports/qtsystemtest/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/interpreter/imports/qtsystemtest/scripts')
-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
13 files changed, 1733 insertions, 0 deletions
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');