Index: suite_leahi/shared/scripts/configuration/application_init.py =================================================================== diff -u -r742f5ee77d1f59bf553700dd433779b4d0a22be0 -r53c5b62d1fbf9121df012d6c025f482bfd3826b0 --- suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 742f5ee77d1f59bf553700dd433779b4d0a22be0) +++ suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 53c5b62d1fbf9121df012d6c025f482bfd3826b0) @@ -1,10 +1,12 @@ import test import sys import os - +import glob +import subprocess +from pathlib import Path from leahi_dialin.ui import utils -from configuration import config -from configuration import utility +from configuration import config +from configuration import utility # WARNING: these variables has to match with the ones in the run.sh and in UI code POSTMSG_POSTFIX_PASSED = " passed" @@ -25,7 +27,35 @@ _devBluetooth = "hci0:" _yearMinimum = 2022 # The year to check for minimum + +def delete_existing_files_usb_folders(): + base_path = Path.home() / "Desktop/usb-disk" + + cleanup_targets = { + base_path / "log": ["*.log"], + base_path / "service": ["*.err"] + } + + for folder, extensions in cleanup_targets.items(): + if not folder.is_dir(): + test.log(f"Warning: Directory '{folder}' not found. Skipping.") + continue + + found = False + for ext in extensions: + for file_path in folder.glob(ext): + try: + os.remove(file_path) + found = True + except OSError as e: + test.log(f" Error deleting file {file_path}: {e}") + + if not found: + test.log("No matching files found.") + + test.log("Cleanup complete.") + def remove_mock_app_post_log_file(): if os.path.exists(config.APP_POST_LOG_LOCATION): os.remove(config.APP_POST_LOG_LOCATION) @@ -140,3 +170,20 @@ return True except: return False + +def get_aut_version(aut_path): + """ + Executes the AUT with the --version argument and captures the output. + """ + actual_aut_path = os.path.join(aut_path, "leahi") + command = [actual_aut_path, "--version"] + # Running the command and capturing the output. + result = subprocess.run( + command, + capture_output=True, + text=True, + ) + aut_name_and_version = result.stdout.strip() + aut_version = aut_name_and_version.split(" ") + aut_version_only = aut_version[1] + return aut_version_only Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rdf6668769f32a66a7a3ce7b5956726142b67cecf -r53c5b62d1fbf9121df012d6c025f482bfd3826b0 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision df6668769f32a66a7a3ce7b5956726142b67cecf) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 53c5b62d1fbf9121df012d6c025f482bfd3826b0) @@ -1,5 +1,6 @@ import squish import test +import object def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -11,4 +12,23 @@ return squish.waitForObject(names_dict, timeout_ms) except LookupError: test.fail("ERROR : " + error_message) - return None + return None + +def setObjectText(obj, text): + obj["text"] = text + return obj + +def findObjectById(parent, id): + """ + Recursively searches for a child object by its id. + Returns the found object or None if not found. + """ + if str(parent.id) == id: + return parent + + for child in object.children(parent): + found = findObjectById(child, id) + if found: + return found + + return None \ No newline at end of file Index: suite_leahi/tst_headerbar_information_popup/test.py =================================================================== diff -u -r4ae35475c883bf1b41279ffd753290ce2a2efc40 -r53c5b62d1fbf9121df012d6c025f482bfd3826b0 --- suite_leahi/tst_headerbar_information_popup/test.py (.../test.py) (revision 4ae35475c883bf1b41279ffd753290ce2a2efc40) +++ suite_leahi/tst_headerbar_information_popup/test.py (.../test.py) (revision 53c5b62d1fbf9121df012d6c025f482bfd3826b0) @@ -14,7 +14,7 @@ import os import names import subprocess -from configuration import config +from configuration import config, utility from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.ui import utils from leahi_dialin.ui.dd_messaging import DD_Messaging @@ -23,14 +23,6 @@ td_simulator = TD_Messaging() dd_simulator = DD_Messaging() -def information_parameters(text): - """ - Method to set custom object property for information pop screen. - @param text : (string) parameter text - """ - names.o_InformationParameters["text"] = text - return names.o_InformationParameters - def verify_parameters_under_information(): """ Method to verify the parameter under 'Information Popup' @@ -41,44 +33,13 @@ for info_parameter in config.INFORMATION_PARAMETERS: info_parameter_text = waitForObjectExists( - information_parameters(info_parameter)) + utility.setObjectText(names.o_InformationParameters, info_parameter) + ) test.compare(info_parameter_text.text, info_parameter, "{} should be available under 'Information'".format(info_parameter)) test.endSection() -def findObjectById(parent, id): - """ - Recursively searches for a child object by its id. - Returns the found object or None if not found. - """ - if str(parent.id) == id: - return parent - - for child in object.children(parent): - found = findObjectById(child, id) - if found: - return found - - return None - -def get_aut_version(aut_path): - """ - Executes the AUT with the --version argument and captures the output. - """ - actual_aut_path = os.path.join(aut_path, "leahi") - command = [actual_aut_path, "--version"] - # Running the command and capturing the output. - result = subprocess.run( - command, - capture_output=True, - text=True, - ) - aut_name_and_version = result.stdout.strip() - aut_version = aut_name_and_version.split(" ") - aut_version_only = aut_version[1] - return aut_version_only - def verify_td_and_dd_versions( td_major, td_minor, @@ -148,7 +109,7 @@ dd_simulator.dd_serial(dd_serial) aut_path = currentApplicationContext().cwd - ui_version = get_aut_version(aut_path) + ui_version = application_init.get_aut_version(aut_path) version_details = { "OS Version" : "123.123.123.20230628230011", @@ -186,7 +147,7 @@ # Using zip() to iterate through children and the dictionary's items for child, (key, expected_value) in zip(children, version_details.items()): - value = findObjectById(child, "_value") + value = utility.findObjectById(child, "_value") if value: test.compare(str(value.text), expected_value, " Comparison of Information Parameter '" + key + "'",