Skip to content

Commit

Permalink
js: Added new tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Lie <[email protected]>
  • Loading branch information
liealex committed Aug 21, 2024
1 parent 7772b2f commit f2bb68a
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 9 deletions.
94 changes: 86 additions & 8 deletions js/scopyDefaultTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,92 @@ function connectionTest(){
disconnect()
}

function switchToolTest(){
printToConsole("TEST SWITCH TOOL")
connect()
scopy.switchTool("Time")
scopy.switchTool("DataLogger 0")
scopy.switchTool("Debugger")
disconnect()
function switchAllToolsTest() {
printToConsole("TEST SWITCH ALL TOOLS")
connect()
let compatibleTools = scopy.getTools()
for (let i = 0; i < compatibleTools.length; i++){
let resultSwitch = scopy.switchTool(compatibleTools[i])
if (!resultSwitch) {
printToConsole("Switch all tools failed at " + compatibleTools[i])
}
}
disconnect()
}

function switchToolsPluginTest(plugin) {
printToConsole("TEST ALL TOOLS FROM PLUGIN")
connect()
let toolsFromPlugin = scopy.getToolsForPlugin(plugin)
for (let i = 0; i < toolsFromPlugin.length; i++){
let resultSwitch = scopy.switchTool(toolsFromPlugin[i])
if (!resultSwitch) {
printToConsole("Switch all tools for plugin failed at " + toolsFromPlugin[i])
}
}
disconnect()
}

function runAllToolsTest() {
printToConsole("TEST RUN ALL TOOLS")
connect()
let compatibleTools = scopy.getTools()
for (let i = 0; i < compatibleTools.length; i++){
let resultSwitch = scopy.switchTool(compatibleTools[i])
if (!resultSwitch) {
printToConsole("Test run all tools failed at " + compatibleTools[i])
}
if (scopy.getToolBtnState(compatibleTools[i]))
{
scopy.runTool(compatibleTools[i], true)
scopy.runTool(compatibleTools[i], false)
}
}
disconnect()
}

function runAllPluginToolsTest(plugin) {
printToConsole("TEST RUN ALL TOOLS FOR PLUGIN")
connect()
let compatibleTools = scopy.getToolsForPlugin(plugin)
for (let i = 0; i < compatibleTools.length; i++){
let resultSwitch = scopy.switchTool(compatibleTools[i])
if (!resultSwitch) {
printToConsole("Test run all tools for plugin failed at " + compatibleTools[i])
}
if (scopy.getToolBtn(compatibleTools[i]))
{
scopy.runTool(compatibleTools[i], true)
scopy.runTool(compatibleTools[i], false)
}
}
disconnect()
}

function saveTest(fileName) {
printToConsole("TEST SAVE")
connect()
let saveResult = scopy.saveSetup(fileName)
if (!saveResult) {
printToConsole("Save failed!")
}
disconnect()
}

function loadTest(fileName) {
printToConsole("TEST LOAD")
connect()
let loadResult = scopy.loadSetup(fileName)
if (!loadResult) {
printToConsole("Load failed!")
}
disconnect()
}

connectionTest()
switchToolTest()
switchAllToolsTest()
switchToolsPluginTest("DataLoggerPlugin")
runAllToolsTest()
runAllPluginToolsTest("DataLoggerPlugin")
saveTest("testFile")
loadTest("testFile")
2 changes: 1 addition & 1 deletion js/scopycommon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function connect(){
//TEST WITH EMU
var deviceID = scopy.addDevice("", "ip:127.0.0.0")
var deviceID = scopy.addDevice("127.0.0.0")
//CONNECT TO DEVICE
scopy.connectDevice(deviceID)
msleep(1000)
Expand Down

0 comments on commit f2bb68a

Please sign in to comment.