Revision: dd55c4695f3d
Author: Jussi Malinen
Date: Wed Jul 13 05:32:39 2011
Log: javascript side of suite teardown and setup splitting
http://code.google.com/p/robotframework/source/detail?r=dd55c4695f3d
Modified:
/src/robot/webcontent/fileloading.js
/src/robot/webcontent/model.js
/src/robot/webcontent/testdata.js
=======================================
--- /src/robot/webcontent/fileloading.js Wed Jul 6 02:18:23 2011
+++ /src/robot/webcontent/fileloading.js Wed Jul 13 05:32:39 2011
@@ -2,20 +2,39 @@
var fileLoadingCallbacks = {};
- function loadTestKeywordsFile(filename, callback) {
+ function loadKeywordsFile(filename, callback) {
fileLoadingCallbacks[filename] = callback;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = filename;
document.getElementsByTagName("head")[0].appendChild(script);
}
+
+ function getCallbackHandlerForKeywords(parent) {
+ var callableList = [];
+ return function (callable) {
+ if (!parent.isChildrenLoaded) {
+ callableList.push(callable);
+ if (callableList.length == 1) {
+ loadKeywordsFile(parent.childFileName, function () {
+ parent.isChildrenLoaded = true;
+ for (var i = 0; i < callableList.length; i++) {
+ callableList[i]();
+ }
+ });
+ }
+ } else {
+ callable();
+ }
+ }
+ }
function notifyFileLoaded(filename) {
fileLoadingCallbacks[filename]();
}
return {
- load: loadTestKeywordsFile,
+ getCallbackHandlerForKeywords: getCallbackHandlerForKeywords,
notify: notifyFileLoaded
}
}());
=======================================
--- /src/robot/webcontent/model.js Tue Jul 12 07:04:47 2011
+++ /src/robot/webcontent/model.js Wed Jul 13 05:32:39 2011
@@ -129,23 +129,7 @@
test.timeout = data.timeout;
test.populateKeywords = createIterablePopulator("Keyword");
test.isChildrenLoaded = data.isChildrenLoaded;
- // TODO: Should callable handling be in loadTestKeywordsFile
function?
- var callables = [];
- test.callWhenChildrenReady = function (callable) {
- if (!test.isChildrenLoaded) {
- callables.push(callable);
- if (callables.length == 1) {
- window.fileLoading.load(test.childFileName, function
() {
- test.isChildrenLoaded = true;
- for (var i = 0; i < callables.length; i++) {
- callables[i]();
- }
- });
- }
- } else {
- callable();
- }
- };
+ test.callWhenChildrenReady =
window.fileLoading.getCallbackHandlerForKeywords(test);
test.children = function () {
if (test.isChildrenLoaded)
return test.keywords();
@@ -164,10 +148,13 @@
kw.path = parentPath + "." + data.index;
kw.arguments = data.args;
kw.timeout = data.timeout;
- kw.populateKeywords = createIterablePopulator("Keyword");
kw.populateMessages = createIterablePopulator("Message");
+ kw.populateKeywords = createIterablePopulator("Keyword");
+ kw.isChildrenLoaded = data.isChildrenLoaded;
+ kw.callWhenChildrenReady =
window.fileLoading.getCallbackHandlerForKeywords(kw);
kw.children = function () {
- return kw.keywords();
+ if (kw.isChildrenLoaded)
+ return kw.keywords();
};
return kw;
}
=======================================
--- /src/robot/webcontent/testdata.js Tue Jul 12 07:04:47 2011
+++ /src/robot/webcontent/testdata.js Wed Jul 13 05:32:39 2011
@@ -71,12 +71,24 @@
status: parseStatus(element[5], strings),
times: model.Times(times(element[5])),
parent: parent,
- index: index
+ index: index,
+ isChildrenLoaded: typeof(element[6]) !== 'number'
});
- kw.populateKeywords(Populator(element[6], strings,
childCreator(kw, createKeyword)));
+ lazyPopulateKeywordsFromFile(kw, element[6], strings);
kw.populateMessages(Populator(element[7], strings, message));
return kw;
}
+
+ function lazyPopulateKeywordsFromFile(parent, keywordsOrIndex,
strings) {
+ if (parent.isChildrenLoaded) {
+ var keywords = keywordsOrIndex;
+ parent.populateKeywords(Populator(keywords, strings,
childCreator(parent, createKeyword)));
+ } else {
+ var index = keywordsOrIndex;
+ parent.childFileName = window.settings['splitLogBase'] + '-' +
index + '.js';
+ parent.populateKeywords(SplitLogPopulator(keywordsOrIndex,
childCreator(parent, createKeyword)));
+ }
+ }
function tags(taglist, strings) {
return util.map(taglist, strings.get);
@@ -105,12 +117,7 @@
tags: tags(element[4], strings),
isChildrenLoaded: typeof(element[6]) !== 'number'
});
- if (test.isChildrenLoaded) {
- test.populateKeywords(Populator(element[6], strings,
childCreator(test, createKeyword)));
- } else {
- test.childFileName = window.settings['splitLogBase']
+ '-'+element[6]+'.js';
- test.populateKeywords(SplitLogPopulator(element[6],
childCreator(test, createKeyword)));
- }
+ lazyPopulateKeywordsFromFile(test, element[6], strings);
return test;
}