def _endTest(eventName, serviceInfo, result, video, comment=None, screenshot=None, sendEvent=True, displayName=""): """ For ending a specific test. Stores the result, and captures a screenshot if one was not passed in. Stops the video log. Sends an event to Warning Center. Completes the StormTest test step. Arguments: - eventName - the name of the Warning Center event generated for this specific test. This must be one of the event names from the data model - see programmer's guide. - result - the result (True or False) of the test - video - the name of the video log - comment - a comment to appear for this event - screenshot - a screenshot to appear for this event - sendEvent - boolean indicating whether to actually send an event to Warning Center - displayName - this can be used to send back a more detailed service name, different from the service name received from GetTestRun. It allows to differentiate between different events on the same service type. """ global results results[eventName] = result if screenshot is None: screenshot = StormTest.CaptureImageEx(None, eventName + '_%d_%t.jpeg')[0][3] StormTest.StopVideoLog() if result: testStepResult = StormTest.TM.PASS else: testStepResult = StormTest.TM.FAIL serviceInfoToSend = serviceInfo if displayName != "": serviceInfoToSend['name'] = displayName if sendEvent: origServiceName = serviceInfo['name'] if displayName != "": serviceInfo['name'] = displayName WarningCenter.SendEvent(name=eventName, value=result, service=serviceInfo, screenshot=screenshot, video=video) serviceInfo['name'] = origServiceName StormTest.EndTestStep(eventName, testStepResult, comment) pass
def doTest(): i = 0 for i in range(5): '''1st step: Go to DTT ch.031''' step_name = "Step" + str(5 * i + 1) + ": Go to DTT ch.031" StormTest.BeginTestStep(step_name) StormTest.PressButton('Stop') StormTest.PressDigits(031, waitSec=0.5) ret_motion = StormTest.DetectMotionEx((559, 179, 655, 301), 5) if ret_motion[0][1]: step_comment = "Go to DTT ch.31 is success" print ret_motion StormTest.EndTestStep(step_name, StormTest.TM.PASS, step_comment) else: step_comment = "Go to DTT ch.31 is failed" StormTest.EndTestStep(step_name, StormTest.TM.FAIL, step_comment) print step_comment StormTest.CaptureImageEx(None, "Step1.png") '''2st step: Go to DTT Duide''' step_name = "Step " + str(5 * i + 2) + ": Go to DTT Duide" StormTest.BeginTestStep(step_name) StormTest.PressButton('TV_Guide') StormTest.WaitSec(5) ret = [83, 34, 230, 58] ocr_result = StormTest.OCRSlot(ret) print ocr_result if ocr_result[4][0][1].strip() == 'DTT GUIDE': step_comment = "Go to DTT Guide success" print ocr_result StormTest.EndTestStep(step_name, StormTest.TM.PASS, step_comment) else: step_comment = "Go to DTT Guide is failed" StormTest.EndTestStep(step_name, StormTest.TM.FAIL, step_comment) print step_comment StormTest.CaptureImageEx(None, "Step2.png") '''3rd step: Check program name''' step_name = "Step" + str(5 * i + 3) + ": Check program name" StormTest.BeginTestStep(step_name) ret_name = [420, 643, 414, 37] ocr_result_name = StormTest.OCRSlot(ret_name) print ocr_result_name if ocr_result_name[4][0][1] != '': step_comment = "Program name is correct" print ocr_result_name StormTest.EndTestStep(step_name, StormTest.TM.PASS, step_comment) else: step_comment = "Program name is incorrect" StormTest.EndTestStep(step_name, StormTest.TM.FAIL, step_comment) print step_comment StormTest.CaptureImageEx(None, "Step3.png") '''4th step: Exit to Live''' step_name = "Step " + str(5 * i + 4) + ": Exit to Live" StormTest.BeginTestStep(step_name) StormTest.PressButton('Ok') ret_motion_live = StormTest.DetectMotionEx((359, 163, 1135, 371), 5) if ret_motion_live[0][1]: step_comment = "Exit to Live success" print ret_motion_live StormTest.EndTestStep(step_name, StormTest.TM.PASS, step_comment) else: step_comment = "Exit to Live is failed" StormTest.EndTestStep(step_name, StormTest.TM.FAIL, step_comment) print step_comment StormTest.CaptureImageEx(None, "Step4.png") '''5th step: Check program name on Mini-Guide''' step_name = "Step " + str(5 * i + 5) + ": Check program name on Mini-Guide" StormTest.BeginTestStep(step_name) ret_name = [222, 678, 448, 41] ocr_result_name_step_5 = StormTest.OCRSlot(ret_name) print ocr_result_name_step_5 if ocr_result[4][0][1].strip() == ocr_result_name[4][0][1]: step_comment = "Program name is correct" print ocr_result_name StormTest.EndTestStep(step_name, StormTest.TM.PASS, step_comment) else: step_comment = "Program name is incorrect" StormTest.EndTestStep(step_name, StormTest.TM.FAIL, step_comment) print step_comment StormTest.CaptureImageEx(None, "Step5.png") StormTest.PressButton('Channel+') return StormTest.TM.PASS