diff --git a/js/scopyDefaultTests.js b/js/scopyDefaultTests.js index 1cabf1742b..7f9fab88c9 100644 --- a/js/scopyDefaultTests.js +++ b/js/scopyDefaultTests.js @@ -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") diff --git a/js/scopycommon.js b/js/scopycommon.js index d4d987e7e6..7d43c7eee8 100644 --- a/js/scopycommon.js +++ b/js/scopycommon.js @@ -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)