Index: suite_leahi/shared/scripts/configuration/application_init.py =================================================================== diff -u -r0bb330c1823aad987899f72b12c302551d575c5a -r4f71dc71ca95ab916947fafdc17c9e1e4f74c47e --- suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 0bb330c1823aad987899f72b12c302551d575c5a) +++ suite_leahi/shared/scripts/configuration/application_init.py (.../application_init.py) (revision 4f71dc71ca95ab916947fafdc17c9e1e4f74c47e) @@ -2,7 +2,7 @@ import sys import os import glob - +import subprocess from pathlib import Path from leahi_dialin.ui import utils from configuration import config @@ -170,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/navigation.py =================================================================== diff -u --- suite_leahi/shared/scripts/configuration/navigation.py (revision 0) +++ suite_leahi/shared/scripts/configuration/navigation.py (revision 4f71dc71ca95ab916947fafdc17c9e1e4f74c47e) @@ -0,0 +1,35 @@ +import names +import squish +import test +from leahi_dialin.ui.td_messaging import TD_Messaging +from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates +from configuration import config, utility + +td_simulator = TD_Messaging() + +def navigate_to_device_settings_screen(): + """ + Method to navigate to "Service" screen + """ + td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value, 0) + settings_menu_object = utility.get_object_from_names( + names.o_Settings_Menu, + error_message="Settings menu object missing", + timeout_ms=1000, + ) + if settings_menu_object is not None: + squish.mouseClick(settings_menu_object) + + device_setting_screen_title_text = utility.get_object_from_names( + names.o_DeviceSettingsTitleText, + error_message="Device Settings Screen title text object missing", + timeout_ms=2000, + ) + if device_setting_screen_title_text is not None: + test.compare( + device_setting_screen_title_text.text, + config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Device Settings Screen Title text".format( + config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT + ), + ) \ No newline at end of file Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -re2c906a7b5fde31d48d168f097fe6a5a2ab0afea -r4f71dc71ca95ab916947fafdc17c9e1e4f74c47e --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision e2c906a7b5fde31d48d168f097fe6a5a2ab0afea) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 4f71dc71ca95ab916947fafdc17c9e1e4f74c47e) @@ -1,5 +1,6 @@ import squish import test +import object def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -12,3 +13,22 @@ except LookupError: test.fail("ERROR : " + error_message) 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_device_settings_information_version/test.py =================================================================== diff -u -rb74559d74f32ce4e8e64650272ed849883a376af -r4f71dc71ca95ab916947fafdc17c9e1e4f74c47e --- suite_leahi/tst_device_settings_information_version/test.py (.../test.py) (revision b74559d74f32ce4e8e64650272ed849883a376af) +++ suite_leahi/tst_device_settings_information_version/test.py (.../test.py) (revision 4f71dc71ca95ab916947fafdc17c9e1e4f74c47e) @@ -15,7 +15,7 @@ import os import names import subprocess -from configuration import config, utility +from configuration import config, utility, navigation from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.ui import utils from leahi_dialin.ui.dd_messaging import DD_Messaging @@ -27,34 +27,6 @@ dd_simulator = DD_Messaging() -def navigate_to_device_settings_screen(): - """ - Method to navigate to "Service" screen - """ - td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value, 0) - settings_menu_object = utility.get_object_from_names( - names.o_Settings_Menu, - error_message="Settings menu object missing", - timeout_ms=1000, - ) - if settings_menu_object is not None: - mouseClick(settings_menu_object) - - device_setting_screen_title_text = utility.get_object_from_names( - names.o_DeviceSettingsTitleText, - error_message="Device Settings Screen title text object missing", - timeout_ms=2000, - ) - if device_setting_screen_title_text is not None: - test.compare( - device_setting_screen_title_text.text, - config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT, - "{} screen is displayed and Comparison of Device Settings Screen Title text".format( - config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT - ), - ) - - def navigate_to_information_screen(): infromation_subscreen_menu_element = utility.get_object_from_names( names.o_DeviceSettingsInformation, @@ -79,26 +51,20 @@ ) -def text_obj(text): - """ - Method to set custom object property for information screen. - @param text: (string) parameter text - """ - names.o_SettingsBase_Information_Text["text"] = text - return names.o_SettingsBase_Information_Text - - def verify_parameters_under_information(): """ Method to verify the parameter under 'Information' """ for title in config.INFORMATION_TITLES: - title_text = waitForObjectExists(text_obj(title)) - test.compare(title_text.text, title, - "{} should be available".format(title)) + title_text = waitForObjectExists( + utility.setObjectText(names.o_SettingsBase_Information_Text, title) + ) + test.compare(title_text.text, title, "{} should be available".format(title)) for info_parameter in config.VERSION_PARAMETERS: - info_parameter_text = waitForObjectExists(text_obj(info_parameter)) + info_parameter_text = waitForObjectExists( + utility.setObjectText(names.o_SettingsBase_Information_Text, info_parameter) + ) test.compare( info_parameter_text.text, info_parameter, @@ -107,15 +73,23 @@ ) test.log("Verifying services title and parameters") - services_text = waitForObjectExists(text_obj(config.SERIVCES_TITLE)) + services_text = waitForObjectExists( + utility.setObjectText( + names.o_SettingsBase_Information_Text, config.SERIVCES_TITLE + ) + ) test.compare( services_text.text, config.SERIVCES_TITLE, "Service title should be {}".format(config.SERIVCES_TITLE), ) for services_parameter in config.SERVICES_PARAMETERS: - services_par_text = waitForObjectExists(text_obj(services_parameter)) + services_par_text = waitForObjectExists( + utility.setObjectText( + names.o_SettingsBase_Information_Text, services_parameter + ) + ) test.compare( services_par_text.text, services_parameter, @@ -124,7 +98,11 @@ ) for water_parameter in config.WATER_PARAMETERS: - water_par_text = waitForObjectExists(text_obj(water_parameter)) + water_par_text = waitForObjectExists( + utility.setObjectText( + names.o_SettingsBase_Information_Text, water_parameter + ) + ) test.compare( water_par_text.text, water_parameter, @@ -133,24 +111,6 @@ ) -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, @@ -220,7 +180,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", @@ -253,7 +213,7 @@ count = 0 for child in children: - value = findObjectById(child, "_itemsValue") + value = utility.findObjectById(child, "_itemsValue") value_text = str(value.text) if value_text != "": @@ -270,22 +230,6 @@ break # Exit the loop after 8 items are processed -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 main(): utils.tstStart(__file__) # Set OS version @@ -296,7 +240,7 @@ ) startApplication(config.AUT_NAME + "-q") - navigate_to_device_settings_screen() + navigation.navigate_to_device_settings_screen() navigate_to_information_screen() test.endSection()