# -*- coding: utf-8 -*- import names import time import subprocess import globals ################################################################################ # This test need to be changed when the Service screen has been implemented # # This is only checking the functionality exists and it's working # ################################################################################ def test_MainMenu_CurrentItem(vSRSUI = ""): #test.compare(waitForObjectExists(names.o_mainMenu).currentIndex, 0) test.compare(str(waitForObjectExists(names.o_mainMenu).currentTitle), "Treatment", globals.SRSUI(vSRSUI)) def gotoScreenNtest_Contains_PowerOffButton(vSRSUI = ""): mouseClick (waitForObjectExists(names.o_mainMenu_settings )) test.compare(waitForObjectExists(names.o_settingsHome ).visible, True, globals.SRSUI(vSRSUI)) def gotoScreenNtest_Contains_TreatmentHome(vSRSUI = ""): mouseClick (waitForObjectExists(names.o_mainMenu_treatment)) test.compare(waitForObjectExists(names.o_treatmentHome).visible, True, globals.SRSUI(vSRSUI)) def showNtest_PowerOffDialog_byCAN(vSRSUI = ""): subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.01.00.38']) test_PowerOffDialog(vSRSUI) def hideNtest_PowerOffDialog_byCAN(vSRSUI = ""): subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.01.01.09']) test_PowerOffButton(vSRSUI) def showNtest_PowerOffNotificationDialog_byCAN(vSRSUI = ""): mSRSUI = globals.SRSUI(vSRSUI) subprocess.call(['cansend', 'can0', '040#A5.01.00.0E.00.00.24.00']) test.compare(str(waitForObjectExists(names.o_poweroff_notification).baseUrl.path), "/dialogs/AutoHideInfo.qml", mSRSUI + " - Dialog") constantPartOfTheMessage = "System is shutting down" test.compare(str(waitForObjectExists(names.o_poweroff_notification).text)[0:len(constantPartOfTheMessage)], constantPartOfTheMessage, mSRSUI + " - Message Text") time.sleep(5) # dialog timeout time.sleep(1) # animation transition def showNtest_PowerOffRejectionDialog_byCAN(vSRSUI = ""): mSRSUI = globals.SRSUI(vSRSUI) subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.01.02.5A']) test.compare(str(waitForObjectExists(names.o_poweroff_rejection).baseUrl.path), "/dialogs/AutoHideInfo.qml", mSRSUI + " - Dialog") constantPartOfTheMessage = "Cannot shutdown during " # there might be the reason, concatenated at the end of the string. test.compare(str(waitForObjectExists(names.o_poweroff_rejection).text)[0:len(constantPartOfTheMessage)], constantPartOfTheMessage, mSRSUI + " - Message Text") time.sleep(2) # dialog timeout time.sleep(1) # animation transition def test_PowerOffButton(vSRSUI = ""): test.compare(waitForObjectExists(names.o_poweroffButton).visible, True, globals.SRSUI(vSRSUI)) def test_PowerOffDialog(vSRSUI = ""): test.compare(waitForObjectExists(names.o_modalDialog).visible, True, globals.SRSUI(vSRSUI)) def testNclick_ShutdownButton_onPowerOffConfirm(vSRSUI = ""): test.compare(waitForObjectExists(names.o_poweroff_shutdown).visible, True, globals.SRSUI(vSRSUI)) mouseClick (waitForObjectExists(names.o_poweroff_shutdown)) time.sleep (1) # Wait for the animation def testNclick_CancelButton_onPowerOffConfirm(vSRSUI = ""): test.compare(waitForObjectExists(names.o_poweroff_cancel).visible, True, globals.SRSUI(vSRSUI)) mouseClick (waitForObjectExists(names.o_poweroff_cancel)) time.sleep (1) # Wait for the animation def main(): # Start the Application startApplication("denaliSquish") # 535 : The "Treatment" button shall be selected by default on the Home Screen. test_MainMenu_CurrentItem(535) # 028 : The Home Screen shall display a "Settings" button. test.compare(str(waitForObjectExists(names.o_mainMenu_settings ).text.text), "Settings", globals.SRSUI(28)) # 029 : Upon "Settings" button depress on the Home Screen; the UI shall navigate the user to the Device Settings Screen. gotoScreenNtest_Contains_PowerOffButton(29) # 514 : The UI shall display a "Power Off Confirmation" screen when the HD Device requests power off. showNtest_PowerOffDialog_byCAN(514) # 556 : The UI shall hide the "Power Off Confirmation" screen after 1 minute inactivity, waiting for user interaction (upon HD Device messaging). hideNtest_PowerOffDialog_byCAN(556) # 015 : The "Power Off Confirmation" screen shall display a "CANCEL" button. showNtest_PowerOffDialog_byCAN(514) testNclick_CancelButton_onPowerOffConfirm(15) # 016 : Upon "CANCEL" button depress, the UI shall navigate the user to its previous screen. test_PowerOffButton(16) # 017 : The "Power Off Confirmation" screen shall display a "SHUTDOWN" button. showNtest_PowerOffDialog_byCAN(514) testNclick_ShutdownButton_onPowerOffConfirm(17) # 566 : The UI shall display the "Power Off Notification" Dialog when the HD Device confirms power off. showNtest_PowerOffNotificationDialog_byCAN(566) # 567 : The UI shall display the "Power Off Rejection" Dialog when the HD Device rejects power off. showNtest_PowerOffRejectionDialog_byCAN(567) # 534 : The "Treatment" button shall be selected by default on the Home Screen. gotoScreenNtest_Contains_TreatmentHome(534) print(0)