From d322cc2ba371c70355243475911490379b0fc128 Mon Sep 17 00:00:00 2001 From: Alexandru Lie Date: Mon, 12 Aug 2024 19:39:00 +0300 Subject: [PATCH] js: Added new tests Signed-off-by: Alexandru Lie --- js/scopyDefaultTests.js | 76 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/js/scopyDefaultTests.js b/js/scopyDefaultTests.js index 1cabf1742b..24133a7b23 100644 --- a/js/scopyDefaultTests.js +++ b/js/scopyDefaultTests.js @@ -7,14 +7,74 @@ 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++){ + scopy.switchTool(compatibleTools[i]) + } + disconnect() +} + +function switchToolsPluginTest(plugin) { + printToConsole("TEST ALL TOOLS FROM PLUGIN") + connect() + let toolsFromPlugin = scopy.getToolsPlugin(plugin) + for (let i = 0; i < toolsFromPlugin.length; i++){ + scopy.switchTool(toolsFromPlugin[i]) + } + disconnect() +} + +function runAllToolsTest() { + printToConsole("TEST RUN ALL TOOLS") + connect() + let compatibleTools = scopy.getTools() + for (let i = 0; i < compatibleTools.length; i++){ + scopy.switchTool(compatibleTools[i]) + if (scopy.getToolBtn(compatibleTools[i])) + { + scopy.runTool(compatibleTools[i], true) + scopy.runTool(compatibleTools[i], false) + } + } + disconnect() +} + +function runAllPluginToolsTest(plugin) { + printToConsole("TEST RUN ALL PLUGIN TOOLS") + connect() + let compatibleTools = scopy.getToolsPlugin(plugin) + for (let i = 0; i < compatibleTools.length; i++){ + scopy.switchTool(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() + scopy.saveSetup(fileName) + disconnect() +} + +function loadTest(fileName) { + printToConsole("TEST LOAD") + connect() + scopy.loadSetup(fileName) + disconnect() } connectionTest() -switchToolTest() +switchAllToolsTest() +switchToolsPluginTest("DataLoggerPlugin") +runAllToolsTest() +runAllPluginToolsTest("DataLoggerPlugin") +saveTest("testFile") +loadTest("testFile")