Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed May 9, 2020
1 parent 01c80e4 commit be3e13f
Showing 1 changed file with 54 additions and 37 deletions.
91 changes: 54 additions & 37 deletions src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1>
<button onclick="runCode()" id="runButton" style="width:300px">E X E C U T E !</button>

<!--<a href="javascript:downloadZip()">Download Results</a>-->
<a href="javascript:SaveBlocks()" id="saveBlocks" >Save Blocks</a>
<a href="javascript:SaveBlocks()" id="saveBlocks">Save Blocks</a>
<a href="javascript:ShowInnerWorkings()">Show blocks</a>
</p>

Expand Down Expand Up @@ -102,10 +102,11 @@ <h1>

<script type="text/html" id="data_tmpl">
<% for ( var i = 0; i < data.length; i++ ) { %>
<li><%=(i+1)%>) <a href="javascript:Loadtesting('<%=data[i].name%>')"><%= data[i].name %></a></li>
<li><%=(i+1)%>) <a href="javascript:Loadtesting('<%=i%>')"><%= data[i].name %></a></li>
<% } %>

</script>
<button onclick="javascript:executeAll()" id="executeAll">Execute all testing</button>

</div>
<!--enddoNotCopyToFinal-->
Expand All @@ -132,17 +133,9 @@ <h1>

}

function Loadtesting(name) {
function Loadtesting(id) {
demoWorkspace.clear();
var content = '';

for (var i = 0; i < testBlocks.length; i++) {
if (testBlocks[i].name == name) {
//console.log(testBlocks[i]);
content = testBlocks[i].data;
break;
}
}
var content =testBlocks[id].data;
var dom = Blockly.Xml.textToDom(content);
Blockly.Xml.domToWorkspace(dom, demoWorkspace);
resetStepUi();
Expand All @@ -151,6 +144,32 @@ <h1>
/*doNotCopyToFinal*/
var results = document.getElementById("results");
results.innerHTML = tmpl("data_tmpl", { data: testBlocks });
var nrToExecute;
var runnerAll = function () {

nrToExecute = nrToExecute + 1;
console.log(nrToExecute);
var waitSecs = 1;
if (window.confirm(`execute ${testBlocks[nrToExecute].name} step ${nrToExecute + 1} from ${testBlocks.length}?`)) {
waitSecs = waitSecs * 5;
Loadtesting(nrToExecute);
}

waitSecs = waitSecs * 1000;
if (nrToExecute < testBlocks.length)
setTimeout(runnerAll, waitSecs);
else
document.getElementById('executeAll').disabled = '';
}

function executeAll() {
nrToExecute = -1;
document.getElementById('executeAll').disabled = 'disabled';
console.log('before');
runnerAll();


}
/*enddoNotCopyToFinal*/

</script>
Expand Down Expand Up @@ -517,8 +536,8 @@ <h1>
</block>
<block type="displayCurrentDate">
</block>
</category>
</category>

</category>
<category id="XHR" name="Request">
<block type="headersbeforehttp">
Expand All @@ -534,7 +553,7 @@ <h1>
</value>
<value name="HeaderValue">
<shadow type="text_join">

</shadow>
</value>
</block>
Expand Down Expand Up @@ -1024,7 +1043,7 @@ <h1>
outputArea.value = outputArea.value + '\n step' + step + ':' + text;
};





Expand Down Expand Up @@ -1090,14 +1109,14 @@ <h1>
interpreter.createNativeFunction(wrapper));

var wrapper = (href, callback) => {
var heads= interpreter.pseudoToNative(headersForDomain);
var heads = interpreter.pseudoToNative(headersForDomain);
var hostname = '(localSite)';
if (href.startsWith('http://') || href.startsWith('https://')) {
hostname = (new URL(href)).hostname;
}
var arrHeaders = [];
if (hostname in heads) {
arrHeaders = heads[hostname];
arrHeaders = heads[hostname];
}
return doGet(href, callback, arrHeaders);
}
Expand All @@ -1124,25 +1143,23 @@ <h1>
interpreter.setProperty(globalObject, 'postXhr',
interpreter.createAsyncFunction(wrapper));

var wrapper = (href, objectToPost, callback) =>

{
try {
var heads = interpreter.pseudoToNative(headersForDomain);
var hostname = '(localSite)';
if (href.startsWith('http://') || href.startsWith('https://')) {
hostname = (new URL(href)).hostname;
}
var arrHeaders = [];
if (hostname in heads) {
arrHeaders = heads[hostname];
}
doPut(href, objectToPost, callback);
var wrapper = (href, objectToPost, callback) => {
try {
var heads = interpreter.pseudoToNative(headersForDomain);
var hostname = '(localSite)';
if (href.startsWith('http://') || href.startsWith('https://')) {
hostname = (new URL(href)).hostname;
}
catch (e) {
alert("is an error" + e);
var arrHeaders = [];
if (hostname in heads) {
arrHeaders = heads[hostname];
}
};
doPut(href, objectToPost, callback);
}
catch (e) {
alert("is an error" + e);
}
};
interpreter.setProperty(globalObject, 'putXhr',
interpreter.createAsyncFunction(wrapper));

Expand All @@ -1166,7 +1183,7 @@ <h1>
};



interpreter.setProperty(globalObject, 'deleteXhr',
interpreter.createAsyncFunction(wrapper));

Expand Down Expand Up @@ -1358,7 +1375,7 @@ <h1>
}
/*doNotCopyToFinal*/
displayLinksSavedStorage();
/*enddoNotCopyToFinal*/
/*enddoNotCopyToFinal*/
</script>

</body>
Expand Down

0 comments on commit be3e13f

Please sign in to comment.