Skip to content

Commit dce3f44

Browse files
committed
Extended testing version
See videos in youtube (link to videos is in options for testing)
1 parent bfec0ca commit dce3f44

File tree

12 files changed

+1474
-297
lines changed

12 files changed

+1474
-297
lines changed

data/app/openTestingLog.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<title>My Test</title>
4+
<script src="../../js/libs/jquery-1.11.0.js"></script>
5+
<script language="javascript" src="../../js/libs/flot/jquery.flot.js"></script>
6+
<script language="javascript" src="../../js/libs/flot/jquery.flot.time.js"></script>
7+
<script language="javascript" src="../../js/libs/flot/jquery.flot.selection.js"></script>
8+
<script language="javascript" src="openTestingLog.js"></script>
9+
</head>
10+
<body>
11+
<table>
12+
<tr><th><div id="logList"></div></th><th><button id="loadList">load data</button></th></tr>
13+
</table>
14+
<div id="placeholder" style="width:600px;height:300px;"></div>
15+
<div id="overview" style="width:600px; height:75px;"></div>
16+
</body>
17+
</html>

data/app/openTestingLog.js

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
var flotOptions = {
2+
legend:{noColumns:5,container:"#flotlegendholder"},grid:{hoverable:true},
3+
xaxis:{mode:"time",ticks:5},yaxes:[{},{min:0,max:1.05,show:false}]
4+
},
5+
flotDatasetOptions = {lines:{ show:true},clickable:false,hoverable:false},
6+
flotDatasetOptionsText = {points:{ show:true},yaxis:2,clickable:false,hoverable:true};
7+
var p; //plotobject
8+
function getEntry(){
9+
var pp,i,p,params = {};
10+
p = location.search.substr(1).split("&");
11+
for(i = 0; i < p.length; i++){
12+
pp = p[i].split("=");
13+
params[pp[0]] = pp[1];
14+
}
15+
return params.entry + ":" + params.directory;;
16+
}
17+
function checkEntry(entry,callback){
18+
chrome.fileSystem.isRestorable(entry, function(bIsRestorable){
19+
chrome.fileSystem.restoreEntry(entry, function(theEntry) {
20+
if(theEntry){ callback(theEntry);}
21+
else{console.log("Project not found");}
22+
});
23+
});
24+
}
25+
function getSubTree(entry,name,callback){
26+
var dirReader = entry.createReader();
27+
dirReader.readEntries (function(results) {
28+
for(var i = 0; i < results.length; i++){
29+
if(results[i].name === name){
30+
callback(results[i]);
31+
return;
32+
}
33+
}
34+
callback(false);
35+
});
36+
}
37+
function showLogTable(dirEntry,callback){
38+
var dirReader = dirEntry.createReader();
39+
dirReader.readEntries(function(results){
40+
var html = '<select id="logTable">';
41+
for(var i = 0; i < results.length; i++){
42+
html += '<option value="' + chrome.fileSystem.retainEntry(results[i]) + '">' + results[i].name + '\n';
43+
}
44+
html += '</select>';
45+
callback(html);
46+
});
47+
}
48+
function loadList(){
49+
var entry = $("#logTable").val();
50+
chrome.fileSystem.restoreEntry(entry, function(theEntry) {
51+
if(theEntry){
52+
var reader = new FileReader();
53+
reader.onload = function(e){ showChart(e.target.result);};
54+
theEntry.file(function(file){ reader.readAsText(file);});
55+
}
56+
else{console.log("File not found");}
57+
});
58+
}
59+
function showChart(data){
60+
var dt,dp,i,j,logData,flotTemp,flotData;
61+
dt = JSON.parse(data);
62+
logData = dt[0];
63+
dt.shift();
64+
flotTemp = {};
65+
for(i = 0; i < logData.dataPoints.length; i++){
66+
dp = logData.dataPoints[i];
67+
flotTemp[dp.label] = {data:[],label:dp.label,type:dp.type,lastValue:""};
68+
switch(dp.type){
69+
case "number":$.extend(flotTemp[dp.label],flotDatasetOptions);break;
70+
case "string":$.extend(flotTemp[dp.label],flotDatasetOptionsText);break;
71+
}
72+
}
73+
for(i = 0; i < dt.length; i++){
74+
for(j in dt[i].data){
75+
switch(flotTemp[j].type){
76+
case "number":flotTemp[j].data.push([dt[i].UTC,dt[i].data[j]]);break;
77+
case "string":
78+
if(dt[i].data[j] !== flotTemp[j].lastValue){
79+
flotTemp[j].lastValue = dt[i].data[j];
80+
flotTemp[j].data.push([dt[i].UTC,1,dt[i].data[j]]);
81+
}
82+
break;
83+
}
84+
}
85+
}
86+
flotData = [];
87+
for(i = 0; i < logData.dataPoints.length; i++){flotData.push(flotTemp[logData.dataPoints[i].label]);}
88+
p = $.plot($("#placeholder"),flotData,flotOptions);
89+
console.log(p.getData());
90+
$("#placeholder").unbind().on("plothover",function(event,pos,item){
91+
if(item){
92+
$("#flottooltip").html("changed to " + item.series.data[item.dataIndex][2])
93+
.css({top: item.pageY+5, left: item.pageX+5}).show();
94+
}
95+
else {$("#flottooltip").hide();}
96+
});
97+
$.plot($("#overview"),flotData,$.extend(flotOptions,
98+
{legend:{show:false},selection:{mode:"xy"},grid:{hoverable:false} } ));
99+
$("#overview").bind("plotselected",function (event, ranges) {p.setSelection(ranges);});
100+
$("#placeholder").bind("plotselected",function (event, ranges) {
101+
if (ranges.xaxis.to - ranges.xaxis.from < 0.00001) { ranges.xaxis.to = ranges.xaxis.from + 0.00001;}
102+
if (ranges.yaxis.to - ranges.yaxis.from < 0.00001) { ranges.yaxis.to = ranges.yaxis.from + 0.00001;}
103+
$.plot("#placeholder", flotData,
104+
$.extend(true, {}, flotOptions, {
105+
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
106+
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
107+
})
108+
);
109+
});
110+
}
111+
112+
$(document).ready(function(){
113+
$("<div id='flottooltip'></div>").css({
114+
position: "absolute",display: "none",border: "1px solid #fdd",
115+
padding: "2px","background-color": "#fee",opacity: 0.80
116+
}).appendTo("body");
117+
checkEntry(getEntry(),function(theEntry){
118+
getSubTree(theEntry,"testinglog",function(subDirEntry){
119+
showLogTable(subDirEntry,function(html){
120+
$("#logList").html(html);
121+
$("#loadList").unbind().click(loadList);
122+
});
123+
});
124+
});
125+
});

data/testing_form.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<table width="100%" height="100%">
2+
<tr height="350"><th>
3+
<table width="100%" height="100%" bgcolor="#dfd">
4+
<tr>
5+
<th>
6+
<button id="testingExpressionClear">Drop all expressions</button>
7+
</th>
8+
<th>
9+
<button id="testingExpressionReset">Reset Chart</button>
10+
</th>
11+
</tr>
12+
<tr>
13+
<th valign="top"><div id="testingTable"></div></th>
14+
<th valign="top">
15+
<div id="testingChart">
16+
<div id="flotlegendholder">hugo</div>
17+
<div id="flotplaceholder" style="width:380px;height:200px;"></div>
18+
</div>
19+
<div id="flottertooltip"
20+
style="position:absolute;display:none;border:1px solid #fdd;padding:2px;background-color:#fee;opacity:0.80;">
21+
</div>
22+
</th>
23+
</tr>
24+
<tr>
25+
<th colspan="2" valign="bottom">
26+
<input id="testingLabel" size="10" maxlength="20" value="newExpr">
27+
<input id="testingExpression" size="40" value="getTime()">
28+
<select id="testingType">
29+
<option value="number">Number</option>
30+
<option value="string">String</option>
31+
</select>
32+
<button id="testingAdd">new Expression</button>
33+
</th>
34+
</tr>
35+
</table>
36+
</th></tr>
37+
<tr><th>
38+
<table width="100%" height="100%" bgcolor="#ccf">
39+
<tr>
40+
<th colspan="2">
41+
<button id="testingSetClear">Clear</button>
42+
</th>
43+
</tr>
44+
<tr>
45+
<th valign="top"><div id="testingAction"></div></th>
46+
</tr>
47+
<tr>
48+
<th valign="bottom">
49+
<input id="actionName" size="10" maxlength="20" value="newAction">
50+
<input id="actionExpression" size="20" value="myVariable">
51+
<select id="actionType">
52+
<option value="number">Number</option>
53+
<option value="boolean">Boolean</option>
54+
<option value="string">String</option>
55+
<option value="command">Command</option>
56+
</select>
57+
<button id="testingAddAction">new Action</button>
58+
</th>
59+
</tr>
60+
</table>
61+
</th></tr>
62+
</table>
63+

data/testing_image.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div id="divImage" style="position: relative;">
2+
<div id="divImage2" style="position: relative;width:100%;height:100%">
3+
<img id="testingImage" style="position:absolute;top:0;left:0;width:100%;height:100%">
4+
<canvas id="overlayCanvas" style="position:absolute;top:0px;left:0px;width:100%;height:100%"></canvas>
5+
</div>
6+
</div>
7+
8+

data/testing_initial.html

Lines changed: 15 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,20 @@
1-
<table width="100%" height="100%" border="1">
2-
<tr height="50">
3-
<th>
1+
<table width="100%" height="100%" border="1" bgcolor="#ffd">
2+
<tr>
3+
<th height="45px">
44
<button id="loadTesting">Load</button>
55
<span id="testingName"></span>
66
<button id="saveTesting">Save</button>
77
</th>
8+
<th>
9+
<button id="testingExpressionRun">Run</button>
10+
<button id="testingExpressionStop">Stop</button>
11+
<input type="checkbox" title="log data" id="testingLog">Log
12+
<button id="openTestingLog">Log Testing</button>
13+
</th>
14+
<th>
15+
<select id="testMode"><option>Form</option><option>Image</option></select>
16+
<button id="testProperties">Properties</button>
17+
</th>
818
</tr>
9-
<tr height="350"><th>
10-
<table width="100%" height="100%" bgcolor="#dfd">
11-
<tr>
12-
<th>
13-
<button id="testingExpressionClear">Drop all expressions</button>
14-
</th>
15-
<th>
16-
<button id="testingExpressionRun">Run</button>
17-
<button id="testingExpressionStop">Stop</button>
18-
<button id="testingExpressionReset">Reset Chart</button>
19-
</th>
20-
</tr>
21-
<tr>
22-
<th valign="top"><div id="testingTable"></div></th>
23-
<th valign="top">
24-
<div id="testingChart">
25-
<div id="flotlegendholder">hugo</div>
26-
<div id="flotplaceholder" style="width:380px;height:200px;"></div>
27-
</div>
28-
<div id="flottertooltip"
29-
style="position:absolute;display:none;border:1px solid #fdd;padding:2px;background-color:#fee;opacity:0.80;">
30-
</div>
31-
</th>
32-
</tr>
33-
<tr>
34-
<th colspan="2" valign="bottom">
35-
<input id="testingLabel" size="10" maxlength="20" value="newExpr">
36-
<input id="testingExpression" size="40" value="getTime()">
37-
<select id="testingType">
38-
<option value="number">Number</option>
39-
<option value="text">Text</option>
40-
</select>
41-
<button id="testingAdd">new Expression</button>
42-
</th>
43-
</tr>
44-
</table>
45-
</th></tr>
46-
<tr><th>
47-
<table width="100%" height="100%" bgcolor="#ccf">
48-
<tr>
49-
<th colspan="2">
50-
<button id="testingSetClear">Clear</button>
51-
</th>
52-
</tr>
53-
<tr>
54-
<th valign="top"><div id="testingAction"></div></th>
55-
</tr>
56-
<tr>
57-
<th valign="bottom">
58-
<input id="actionName" size="10" maxlength="20" value="newAction">
59-
<input id="actionExpression" size="20" value="myVariable">
60-
<button id="testingAddNumber">new Number</button>
61-
<button id="testingAddBoolean">new Boolean</button>
62-
<button id="testingAddString">new Text</button>
63-
<button id="testingAddCommand">new Command</button>
64-
</th>
65-
</tr>
66-
</table>
67-
</th></tr>
68-
</table>
69-
19+
<tr><td colspan="3" id="testingForm"></td></tr>
20+
</table>

data/tours/testing.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
"attachTo": "[name='Testing']","position": "right","onHide": "clickAttached"},
1212
{ "title": "Enable Testing Plugin","description": "Click the Checkbox to enable Testing",
1313
"attachTo": "[name='ENABLE_Testing']","position": "left","source":true,"onHide": "sendAttached"},
14-
{ "title": "Set Timing","description": "Select how often you want data to be updated",
15-
"attachTo": "[name='FREQUENCY_Testing']","position": "left","onHide": "closePopup"},
14+
{ "title": "Close Popup","description": "Now you have to close the options dialog by clicking somewhere outside",
15+
"attachTo": ".v-split","position": "right","onHide": "closePopup"},
1616
{ "title": "Open Testing Window","description": "Click on &lt/&gt to the left of the terminal window.",
1717
"attachTo": "#icon-terminalTesting","position": "right","onHide": "clickAttached"},
1818
{ "title": "Set Name","description": "First assign a name that you will see in the chart",
19-
"attachTo": "#testingLabel","position": "top","source": "Time","onHide": "sendAttached"},
19+
"attachTo": "#testingLabel","position": "right","source": "Time","onHide": "sendAttached"},
2020
{ "title": "Set Expression","description": "Next assign an expression that you would like to observe",
2121
"attachTo": "#testingExpression","position": "top","source": "getTime()/2","onHide": "sendAttached"},
2222
{ "title": "Select type of variable","description": "Lastly, select the type of expression.<ul><li><b>Number</b> will shown as a line in the chart</li><li><b>Text</b> will show a point on each change, with data when you move the mouse over it.</li></ul>",
2323
"attachTo": "#testingType","position": "top","source":"number","onHide": "sendAttached"},
2424
{ "title": "Add to Expression List","description": "Finally click on this button to add the new expression.",
2525
"attachTo": "#testingAdd","position": "top","onHide": "clickAttached"},
2626
{ "title": "Remove Old Expressions","description": "Remove expressions that you don't need any more. Simply click on the `<b>-</b>` button to remove them from the list",
27-
"attachTo": ".dropDataPoint","position": "top","onHide":"clickAttached"},
27+
"attachTo": ".dropDataPoint","position": "7","onHide":"clickAttached"},
2828
{ "title": "Remove old expressions","description": "And remove one more...",
2929
"attachTo": ".dropDataPoint","position": "7","onHide":"clickAttached"},
3030
{ "title": "Start fetching expressions","description": "Click on the Start button to start testing. The refresh rate is set to 1 sample per second so you'll need to wait a few seconds to see anything.",
31-
"attachTo": "#testingExpressionRun","onHide": "clickAttached","position": "top"},
31+
"attachTo": "#testingExpressionRun","onHide": "clickAttached","position": "bottom"},
3232
{ "title": "Stop fetching expressions","description": "Click on the Stop button to Stop updating the chart",
33-
"attachTo": "#testingExpressionStop","onHide": "clickAttached","position": "top"},
33+
"attachTo": "#testingExpressionStop","onHide": "clickAttached","position": "bottom"},
3434
{ "title": "Clear Chart","description": "Click on the Reset button to clear the chart",
3535
"attachTo": "#testingExpressionReset","onHide": "clickAttached","position": "top"},
3636
{ "title": "Switch Back to terminal","description": "Switch back to terminal mode. You can switch between both whenever you want.",

data/tours/testingExt.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
"source":"var a=0;\nvar b=2;\nvar t1 = setInterval(function(){\n a+=b;\n if(a>25) {\n a = 0;\n b++;\n }\n},2000);\n","onHide":"sendEditor"},
1212
{ "title": "Open the Testing window","description": "Click on &lt/&gt to the left of the terminal window.",
1313
"attachTo": "#icon-terminalTesting","position": "right","onHide": "clickAttached"},
14+
{ "title": "Reset list of expressions","description":"Reset testing list to a startingpoint by dropping old entrys",
15+
"attachTo":"#testingExpressionClear","position":"right","onHide":"clickAttached"},
1416
{ "title": "Set Name","description": "First assign the name that you will see in chart",
1517
"attachTo": "#testingLabel","position": "7","source": "a-value","onHide": "sendAttached"},
1618
{ "title": "Set Expression","description": "Next assign an expression that you would like to observe",
1719
"attachTo": "#testingExpression","position": "7","source": "a","onHide": "sendAttached"},
1820
{ "title": "Select type of variable","description": "Lastly, select the type of expression.<br>Number will shown as a line in the chart",
1921
"attachTo": "#testingType","position": "6","source":"number","onHide": "sendAttached"},
2022
{ "title": "Add to expression list","description": "Click on this button to add the new expression.",
21-
"attachTo": "#testingAdd","position": "5","onHide": "clickAttached"},
23+
"attachTo": "#testingAdd","position": "bottom","onHide": "clickAttached"},
2224
{ "title": "Remove old expressions","description": "Any expressions that you don't need any more...",
2325
"attachTo": ".dropDataPoint","position": "7","onHide":"clickAttached"},
2426
{ "title": "Remove old expressions","description": "And remove one more...",
@@ -30,16 +32,18 @@
3032
{ "title": "Select type of variable","description": "Select the type of expression.<br>Text will show a point on each change, and will show data when you move the mouse over it",
3133
"attachTo": "#testingType","position": "6","source":"text","onHide": "sendAttached"},
3234
{ "title": "Add to expression list","description": "Click on this button to add the new expression.",
33-
"attachTo": "#testingAdd","position": "5","onHide": "clickAttached"},
35+
"attachTo": "#testingAdd","position": "bottom","onHide": "clickAttached"},
3436
{ "title": "Set Name","description": "Assign a name for a third value",
3537
"attachTo": "#testingLabel","position": "7","source": "b-value","onHide": "sendAttached"},
3638
{ "title": "Set Expression","description": "Assign an expression for a 3rd value",
3739
"attachTo": "#testingExpression","position": "7","source": "b","onHide": "sendAttached"},
3840
{ "title": "Select type of variable","description": "Select the type of expression...",
3941
"attachTo": "#testingType","position": "6","source":"number","onHide": "sendAttached"},
4042
{ "title": "Add to expression list","description": "Add the 3rd Expression...",
41-
"attachTo": "#testingAdd","position": "5","onHide": "clickAttached"},
43+
"attachTo": "#testingAdd","position": "bottom","onHide": "clickAttached"},
4244
{ "title": "Add action","description":"Now lets add an action"},
45+
{ "title": "Reset actionlist","description":"Reset action list to a startingpoint by dropping old entrys",
46+
"attachTo":"#testingSetClear","position":"right","onHide":"clickAttached"},
4347
{ "title": "Set Name","description":"Assign a name for the action",
4448
"attachTo":"#actionName","position":"11","source":"b-action","onHide": "sendAttached"},
4549
{ "title": "Set Expression","description":"Assign a JavaScript expression for the action",
@@ -49,15 +53,15 @@
4953
{ "title":"Send source","description":"Send the test application to the board",
5054
"attachTo":"#icon-deploy","position":"left","onHide":"clickAttached"},
5155
{ "title": "Start fetching expressions","description": "Click on the run button to start testing. Values update once a second so it'll take a few seconds to see the results.",
52-
"attachTo": "#testingExpressionRun","onHide": "clickAttached","position": "top"},
56+
"attachTo": "#testingExpressionRun","onHide": "clickAttached","position": "bottom"},
5357
{ "title": "Wait","description":"Watch the chart change for a few seconds..."},
5458
{ "title": "Action","description":"Assign a new value to the action expression...<br>Lets change the expression <b>b</b> to 1",
5559
"attachTo":"#b-action_input","position":"right","source":"1","onHide":"sendAttached"},
5660
{ "title": "Assign value", "description":"Assign the value to variable b on Espruino",
5761
"attachTo": ".executeActionPoint","position":"right","onHide":"clickAttached"},
5862
{ "title": "Wait","description":"Now you can see the changes in the chart..."},
5963
{ "title": "Stop fetching expressions","description": "Finally, click to stop refreshing the chart...",
60-
"attachTo": "#testingExpressionStop","onHide": "clickAttached","position": "top"},
64+
"attachTo": "#testingExpressionStop","onHide": "clickAttached","position": "bottom"},
6165
{ "title": "Switch back to the terminal","description": "And switch back to Terminal mode.",
6266
"attachTo": "#icon-terminalTesting","onHide": "clickAttached","position": "right"},
6367
{ "title": "All Done","description": "That's it!"}

0 commit comments

Comments
 (0)