Example #1
0
    def test_tap_element_using_text(self):
        print "TEST TAP ELEMENT USING TEXT"
        self.device.tap(mappedText='OpenMenu')
        StormTest.WaitSec(4)

        isPressed = self.device.tap(text='Cinema')
        colorMatch = StormTest.WaitColorMatch((0, 0, 68),
                                              tolerances=(16, 16, 16),
                                              flatness=90,
                                              peakError=50,
                                              includedAreas=[600, 140, 10, 10],
                                              timeToWait=10)
        isCinema = colorMatch[0][1]
        print "Open cinema " + str(colorMatch)

        StormTest.WaitSec(1)

        self.device.tap(mappedText='Home')
        #colorNoMatch = StormTest.WaitColorNoMatch((0,0,68), tolerances=(16,16,16), flatness=90, peakError=50, includedAreas=[400,430,10,10], timeToWait=15)
        colorMatch = StormTest.WaitColorMatch(
            (40, 120, 178),
            tolerances=(16, 16, 16),
            flatness=90,
            peakError=50,
            includedAreas=[1000, 750, 10, 10],
            timeToWait=10)
        StormTest.CaptureImageEx((0, 0, 1920, 1080), "Screenshot")
        isHome = colorMatch[0][1]
        print "Return to Home " + str(colorMatch)
        #StormTest.WaitSec(6)

        self.assertTrue(isPressed, "Tap on Cinema failed")
        self.assertTrue(isCinema, "Tap on Cinema failed")
        pass
Example #2
0
def _checkLogin(device):
    image = StormTest.CaptureImageEx((0, 0, 1920, 1080), 'checkLogin')[0][2]
    resultString = StormTest.OCRImage(image, (237, 58, 140, 31))[4]
    log.debug("OCR result: {0}".format(resultString))
    if resultString != 'Benvenuto':
        login(device)
    log.info('App logged in')
    pass
    def openCatalog(self, catalogName):
        self._device.tap(text=catalogName)

        StormTest.WaitSec(5)

        match1 = StormTest.WaitColorNoMatch(color=(41, 116, 168),
                                            tolerances=(16, 16, 16),
                                            flatness=10,
                                            peakError=85,
                                            includedAreas=[495, 280, 663, 445],
                                            timeToWait=60)
        image = StormTest.CaptureImageEx(None, 'Catalog', slotNo=True)[2]

        if not match1[0][1]:
            comment = 'No match color of the poster failed on opening {0} catalog {1}'.format(
                catalogName, match1)
            log.error(comment)
            return False, comment, image

        comment = 'No match color of the poster successful on opening {0} catalog {1}'.format(
            catalogName, match1)
        log.info(comment)

        # match color sulla barra del menu blu
        match2 = StormTest.WaitColorMatch(color=(15, 15, 75),
                                          tolerances=(16, 16, 16),
                                          flatness=95,
                                          peakError=20,
                                          includedAreas=[1770, 140, 10, 10],
                                          timeToWait=60)
        image = StormTest.CaptureImageEx(None, 'Catalog2', slotNo=True)[2]

        if not match2[0][1]:
            comment = 'Match color of the dark blue menu failed on opening {0} catalog {1}'.format(
                catalogName, match2)
            log.error(comment)
            return False, comment, image

        comment = 'Match color of the dark blue menu successful on opening {0} catalog {1}'.format(
            catalogName, match2)
        log.info(comment)

        if match1 and match2:
            return True, comment, image
        else:
            return False, comment, image
Example #4
0
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
Example #5
0
def colorMatch(color, tolerances, flatness, peakError, includedAreas,
               timeToWait, imageName, comment):
    match = StormTest.WaitColorMatch(color=color,
                                     tolerances=tolerances,
                                     flatness=flatness,
                                     peakError=peakError,
                                     includedAreas=includedAreas,
                                     timeToWait=timeToWait)
    image = StormTest.CaptureImageEx(None, imageName, slotNo=True)[2]
    comment = comment + '{0}'.format(match)
    matched = match[0][1]

    _logColorMatch(matched, comment)
    return matched, comment, image
    def findSelectedVideo(self, videoName):
        self._device.enterText(videoName)
        self._device.tap(mappedText='Find')

        match = StormTest.WaitColorMatch((233, 235, 233), (16, 16, 16),
                                         flatness=95,
                                         peakError=50,
                                         includedAreas=[404, 633, 8, 7],
                                         timeToWait=60)
        StormTest.CaptureImageEx(None, 'PlayVideo', slotNo=True)[2]

        if not match[0][1]:
            comment = 'Match color failed on playing the video {0}'.format(
                match)
            log.error(comment)
            return False

        comment = 'Match color successful on playing the video {0}'.format(
            match)
        log.info(comment)
        return True
    def openSkyTG24(self, catalogName):
        self._device.tap(text=catalogName)

        match = StormTest.WaitColorMatch(color=(233, 235, 233),
                                         tolerances=(16, 16, 16),
                                         flatness=95,
                                         peakError=15,
                                         includedAreas=[322, 362, 7, 7],
                                         timeToWait=60)
        image = StormTest.CaptureImageEx(None, 'Catalog', slotNo=True)[2]

        if not match[0][1]:
            comment = 'Match color failed on opening {0} catalog {1}'.format(
                catalogName, match)
            log.error(comment)
            return False, comment, image

        comment = 'Match color successful on opening {0} catalog {1}'.format(
            catalogName, match)
        log.info(comment)
        return True, comment, image
    def openCatalogFind(self):
        self._device.tap(text="Cerca nel catalogo. Double tap to edit.")

        StormTest.WaitSec(5)

        match = StormTest.WaitColorMatch((197, 199, 200),
                                         tolerances=(16, 16, 16),
                                         flatness=80,
                                         peakError=85,
                                         includedAreas=[1200, 1000, 10, 10],
                                         timeToWait=60)
        StormTest.CaptureImageEx(None, 'Keyboard', slotNo=True)[2]

        if not match[0][1]:
            comment = 'Match color failed on opening the keyboard {0}'.format(
                match)
            log.error(comment)
            return False

        comment = 'Match color successful on opening the keyboard catalog {0}'.format(
            match)
        log.info(comment)
        return True
Example #9
0
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