Index: tst_serviceshutdown/test.py =================================================================== diff -u -r3a14d012ad33c25e386fa1df6f08613764ac8ae9 -rb8ec67700eef6b0581a997b75e2bf30460fba0f4 --- tst_serviceshutdown/test.py (.../test.py) (revision 3a14d012ad33c25e386fa1df6f08613764ac8ae9) +++ tst_serviceshutdown/test.py (.../test.py) (revision b8ec67700eef6b0581a997b75e2bf30460fba0f4) @@ -3,67 +3,106 @@ 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 main(): - startApplication("denaliSquish") +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)) - # Check the Home screen has the settings button on the Main Menu - test.compare(str(waitForObjectExists(names.o_mainMenu_settings ).text.text), "Settings" , "SRSUI 028") - - # Click on Settings button on the Main Menu +def gotoScreenNtest_Contains_PowerOffButton(vSRSUI = ""): mouseClick (waitForObjectExists(names.o_mainMenu_settings )) - # Upon depress the settings screen shall be visible - test.compare(waitForObjectExists(names.o_settingsHome ).visible, True , "SRSUI 029") + test.compare(waitForObjectExists(names.o_settingsHome ).visible, True, globals.SRSUI(vSRSUI)) - # Check the shutdown button exists - test.compare(waitForObjectExists(names.o_poweroffButton).visible, True) - # Click on shutdown button - mouseClick (waitForObjectExists(names.o_poweroffButton)) - # Sending can message to show Power off dialog - subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.6F.00.00']) - # The PowerOff screen shall have a shutdown button - test.compare(waitForObjectExists(names.o_poweroff_shutdown).visible, True) - # Click on the PowerOff Dialog's shutdown button +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.F0']) + 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(1) # 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)) - # Wait for the animation - time.sleep(1) + time.sleep (1) # Wait for the animation - # Going back to the screen which has the PowerOff screen - test.compare(waitForObjectExists(names.o_poweroffButton).visible, True) - # Click on shutdown button - mouseClick (waitForObjectExists(names.o_poweroffButton)) - # Sending can message to show Power off dialog - subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.6F.00.00']) - # The PowerOff screen shall have a Cancel button - test.compare(waitForObjectExists(names.o_poweroff_cancel).visible, True) - # Click on the PowerOff Dialog's Cancel button +def testNclick_CancelButton_onPowerOffConfirm(vSRSUI = ""): + test.compare(waitForObjectExists(names.o_poweroff_cancel).visible, True, globals.SRSUI(vSRSUI)) mouseClick (waitForObjectExists(names.o_poweroff_cancel)) - # Wait for the animation + time.sleep (1) # Wait for the animation - #SRSUI 556 - test.compare(waitForObjectExists(names.o_poweroffButton).visible, True) - # Sending can message to show Power off dialog - subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.6F.00.00']) - # Test the Power Off dialog is visible upon HD Request +def main(): + # Start the Application + startApplication("denaliSquish") + + # 535 : The "Treatment" button shall be selected by default on the Home Screen. + test_MainMenu_CurrentItem(535) - test.compare(waitForObjectExists(names.o_powerOffDialog).visible, True) - # wait for user reaction and if there is no reaction timeout - time.sleep(1) - # Sending can message to Hide Power off dialog - subprocess.call(['cansend', 'can0', '020#A5.01.00.01.01.5E.00.00']) - # Wait for the animation - time.sleep(1) - # Test the Power Off dialog is hidden upon HD Request after timeout, so the entry screen with power off button is visible again. - test.compare(waitForObjectExists(names.o_poweroffButton).visible, True , "SRSUI 556") + # 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) - # Go back to Home Screen - mouseClick (waitForObjectExists(names.o_mainMenu_treatment)) - test.compare(waitForObjectExists(names.o_treatmentHome).visible, True , "SRSUI 535") + # 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)