示例#1
0
def __setUpRealEnvironment(self):
    slotAllocated = StormTest.GetPhysicalAllocations()
    server = slotAllocated[0].split(':')[0]
    slot = slotAllocated[1]
    log.info("Test not running under daemon, using real environment")

    return server, slot
示例#2
0
def _getTestRunConfiguration():
    StormTest.BeginLogRegion('Open Connection')
    params = WarningCenter.GetTestRun()

    if params == None:
        return __getDeveloperModeParams()
    return params
    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
示例#4
0
    def test_tap_using_mapped_text(self):
        print "TEST TAP MAPPED TEXT"
        isPressed = self.device.tap(mappedText='openMenu')
        StormTest.WaitSec(4)
        self.device.tap(mappedText='closeMenu')

        self.assertEqual(isPressed, True, "Tap failed")
        pass
示例#5
0
 def start(self, appName=''):
     self._appName = appName
     self._appCommands = _loadAppCommands(self, appName, self._commandsModuleName)
                          
     self.connect('')
                       
     self._userActionLog.info("Started application %s" % self._appName)
     return StormTest.PressButton("START-ANDROID:" + self._appName)
示例#6
0
def stopVideo(device):
    StormTest.BeginLogRegion('Stop Video')
    device.tap(mappedText='closeVideo')
    device.tap(mappedText='closeVideo')
    device.tap(text='No')

    result = colorMatch(color=(50, 114, 167),
                        tolerances=(16, 16, 16),
                        flatness=90,
                        peakError=80,
                        includedAreas=[430, 80, 10, 10],
                        timeToWait=60,
                        imageName='StopVideo',
                        comment='Match color on closing the video')
    StormTest.EndLogRegion('Stop Video')
    checkCrash(device)
    return result
示例#7
0
def __logReserveSlotResult(slot, isReserved):
    if isReserved is 0:
        StormTest.EndLogRegion('Open Connection',
                               StormTest.LogRegionStyle.Fail,
                               comment='Failed to reserve slot %d' % slot)
        log.error('Failed to reserve slot %d' % slot)
    else:
        log.info("Slot %d reserved" % slot)
    pass
示例#8
0
def __logRemainingCharsResult(remainingChars):
    log.info("Remaining OCR chars in license: %d" % remainingChars)
    if remainingChars is 0:
        StormTest.EndLogRegion(
            'Open Connection',
            StormTest.LogRegionStyle.Fail,
            comment='OCR licenses has ran out. Not possible to run tests')
        log.error("OCR licenses has ran out. Not possible to run tests")
    pass
示例#9
0
def connectToTheNetwork(galaxyTab3, assistanceMenu):
    goToSettings(assistanceMenu)
    goToWiFi(galaxyTab3)
    galaxyTab3.tap(text='Vodafone-WIFI')
    enterPassword()
    galaxyTab3.tap(text='Connect')
    StormTest.WaitSec(5)
    closeSettings(assistanceMenu)
    pass
示例#10
0
    def connect(self, description=''):
        StormTest.BeginLogRegion('Open Connection')
        self._connectionLog.info(description)
        self._connectionLog.info("Started connection with the server")
        self._serviceInfo = _getTestRunConfiguration()['service']

        self._server, self._slot = _setUpEnvironment()
        self._connectionLog.debug("server:slot = {}:{}".format(
            self._server, self._slot))
        return _establishConnection(self._server, self._slot, description)
示例#11
0
def _videoMotionTest():
    """
    Checks if there is motion present in the video
    SDO only allows threshold of 1% minumum, so we run it repeatedly for 5s and if it fails
    we check the actual motion against a threshold of 0.1%
    Requires:
    - a Screen Definition file "DetectMotion.stscreen" 
    Returns:
    - result: boolean True or False
    - comment: a comment giving more details of the test result
    - image: a screenshot of the test
    """

    result = False
    repeat = 6
    count = 0
    SDO = StormTest.ScreenDefinition()
    try:
        SDO.Load('DetectMotion.stscreen')
        #we check every 5 seconds for motion > 0.1%
        while (result == False) and (count <= repeat):
            retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1]
            result = retSDO.VerifyStatus
            actualMotion = retSDO.Regions[0].ActualMotion
            StormTest.WriteDebugLine('Actual motion detected is ' +
                                     str(actualMotion))
            if actualMotion > 0.1:
                result = True
            count = count + 1

            StormTest.WriteDebugLine('Result of Motion Detection is ' +
                                     str(result))
            image = retSDO.Image
            image.Save('VideoMotion_%d_%t.jpeg')
            motionThreshold = 0.1
            comment = 'Motion Level = %0.3f, Motion Threshold = %0.3f' % (
                actualMotion, motionThreshold)
        SDO.Close()
        return [result, comment, image]
    except:
        print 'Could not load DetectMotion.stscreen - exiting test'
        SDO.Close()
        return [False, 'Could not load DetectMotion.stscreen - exiting test']
示例#12
0
def _tapWithMappedText(commands, mappedText):
    log.info("Tap on mapped text {0}".format(commands[mappedText]))
    
    command = commands[mappedText]
    return StormTest.PressButton('TAP:{0}:{1}:{2}'.format(command['x'], command['y'], command['time']))





    
    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
示例#15
0
    def test_enter_email(self):
        print "TEST ENTER EMAIL"
        self.device.tap(mappedText='OpenMenu')
        self.device.tap(text='Indirizzo mail. Editing.')
        StormTest.WaitSec(2)
        isEmailEntered = self.device.enterText("*****@*****.**")
        self.device.tap(mappedText='OpenAssistantMenu')
        self.device.tap(mappedText='CloseAssistantMenu')
        self.device.tap(mappedText='CloseMenu')

        self.assertTrue(isEmailEntered, "Fail to enter text")
        pass
示例#16
0
    def enterText(self, text):
        specialChars = ['@']
        upperChars = ['A', 'B', 'C']

        for c in text:
            if c in specialChars:
                if not self.tap(mappedText='Sym'):
                    return False
                StormTest.WaitSec(1)
                if not self.tap(mappedText=c):
                    return False
                StormTest.WaitSec(1)
                if not self.tap(mappedText='Sym'):
                    return False
                StormTest.WaitSec(1)
                continue
            if c in upperChars:
                if not self.tap(mappedText='Shift'):
                    return False
                StormTest.WaitSec(1)
                if not self.tap(mappedText=c):
                    return False
                StormTest.WaitSec(1)
                continue
            if not self.tap(mappedText=c):
                return False
            StormTest.WaitSec(1)
        return True
示例#17
0
def exitmenus():
    StormTest.PressButton(EXIT)
    StormTest.WaitSec(3)
    StormTest.PressButton(SELECT)  #in case there is an error on screen
    StormTest.WaitSec(3)
    StormTest.PressButton(EXIT)
    StormTest.WaitSec(3)
示例#18
0
def createbuffer(minutes):
    maxbuffer = 90  #90 minutes
    try:
        if minutes > maxbuffer: minutes = maxbuffer  #change to minutes
        seconds = minutes * 60  #convert minutes to seconds, formula is minutes x 60s/min
        exitmenus(
        )  #make sure nothing is on screen preventing the buffer from being created
        StormTest.WaitSec(seconds)
    except:
        SThelperNew.takeScreenshot(
            'No Buffer',
            'No buffer was created, troubleshoot code createbuffer')
        return
示例#19
0
def _videoPresentTest():
    """
    Checks if video is present, by comparing screen colour against a black colour
    Requires:
    - a Screen Definition file called "DetectVideoPresence.stscreen"
    Returns:
    - result: boolean True or False
    - comment: a comment giving more details of the test result
    - image: a screenshot of the test
    """

    result = False
    repeat = 10
    count = 0
    SDO = StormTest.ScreenDefinition()
    try:
        SDO.Load('DetectVideoPresence.stscreen')
        while (result == False) and (count <= repeat):
            #note this SDO returns True when a match does *not* occur
            retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1]
            result = retSDO.VerifyStatus
            StormTest.WriteDebugLine(
                'Result of matching screen with black was ' + str(not result))
            count = count + 1
            if (result == False) and (count <= repeat):
                StormTest.WaitSec(4)
                StormTest.WriteDebugLine('Retry, count = ' + str(count))
        image = retSDO.Image
        image.Save('VideoPresent_%d_%t.jpeg')
        comment = 'Result of matching screen with black was ' + str(not result)
        SDO.Close()
        return [result, comment, image]
    except:
        print 'Could not load DetectVideoPresence.stscreen - exiting test'
        SDO.Close()
        return [
            False,
            'Could not load DetectVideoPresence.stscreen - exiting test', 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
示例#21
0
    def setUpClass(self):
        super(Test, self).setUpClass()
        self.device = AndroidDevice("samsung_galaxy_tab_3")
        self.device.start("it.sky.river")

        appLoaded = StormTest.WaitColorMatch((207, 209, 207),
                                             tolerances=(16, 16, 16),
                                             flatness=90,
                                             peakError=50,
                                             includedAreas=[1000, 750, 10, 10],
                                             timeToWait=15)
        if not appLoaded:
            return False
        pass
示例#22
0
def _audioPresentTest():
    #print StormTest.GetAudioLevel(1)
    SDO = StormTest.ScreenDefinition()
    try:
        SDO.Load('AudioDetect.stscreen')
        retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1]
        actualAudio = retSDO.Regions[0].ActualAudio
        audioThreshold = retSDO.Regions[0].AudioThreshold
        isPresent = StormTest.WaitAudioPresence(-110, 60)[0][1]
        StormTest.WriteDebugLine('Result of Audio Detection is ' +
                                 str(isPresent) + '. Actual audio level = ' +
                                 str(actualAudio))
        comment = 'Audio Level = %0.3f, Audio Threshold = %0.3f' % (
            actualAudio, audioThreshold)
        print comment
        SDO.Close()
    except:
        print 'Could not load AudioDetect.stscreen - exiting test'
        SDO.Close()

    if isPresent:
        return isPresent, 'Audio is present' + comment
    else:
        return isPresent, 'Audio not present' + comment
示例#23
0
def checkCrash(device):
    result = colorMatch(color=(48, 50, 48),
                        tolerances=(4, 4, 4),
                        flatness=99,
                        peakError=10,
                        includedAreas=(820, 590, 10, 10),
                        timeToWait=10,
                        imageName='Crash',
                        comment='Crash happened?')
    StormTest.WaitSec(5)
    if result[0]:
        log.error('CRASH!')
        device.tap(text='OK')
        return True
    return False
    def openMenu(self):
        self._device.tap(mappedText='OpenMenu')
        match = StormTest.WaitColorMatch((41, 100, 168),
                                         tolerances=(16, 16, 16),
                                         flatness=90,
                                         peakError=10,
                                         includedAreas=[400, 430, 10, 10],
                                         timeToWait=30)

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

        log.info(
            'Match color successful on opening the menu {0}'.format(match))
        return True
示例#25
0
def __isConnectionOk(isServerConnected, isSlotReserved):
    isConnectionOk = False
    if isServerConnected and isSlotReserved:
        isConnectionOk = __OCRCheckRemainingChars()

    log.info("Connection established and slot reserved"
             ) if isConnectionOk else log.info("Connection failed")
    if isConnectionOk:
        log.info("Connection established and slot reserved")
        StormTest.EndLogRegion(
            'Open Connection',
            StormTest.LogRegionStyle.Pass,
            comment='Connection with the server established')
    else:
        log.error("Connection failed")

    return isConnectionOk
示例#26
0
def enterPassword():
    StormTest.WaitSec(2)
    PressButton("TAP:55:680")
    StormTest.WaitSec(1)
    PressButton("TAP:55:680")
    StormTest.WaitSec(1)
    
    for i in range(3):
        PressButton("TAP:570:600:0")
        StormTest.WaitSec(1)
        PressButton("TAP:790:600:0")
        StormTest.WaitSec(1)
        PressButton("TAP:860:680:0")
        StormTest.WaitSec(1)
    pass
示例#27
0
 def disconnect(self):
     self._connectionLog.info("Closing connection with the server")
     logging.shutdown()
     return StormTest.ReleaseServerConnection()
示例#28
0
 def setUpClass(self):
     super(Test, self).setUpClass()
     self.device = AndroidDevice("samsung_galaxy_tab_3")
     self.device.start("it.sky.river")
     StormTest.WaitSec(4)
     pass
示例#29
0
 def swipe(self, coordinates=[0, 0, 0, 0], time=0):
     log.info("Swipe from ({0}, {1}) to ({2}, {3}) with time {4}".format(coordinates[0], coordinates[1], coordinates[2], coordinates[3], time))
     return StormTest.PressButton("SWIPE:{0}:{1}:{2}:{3}:{4}".format(coordinates[0], coordinates[1], coordinates[2], coordinates[3], time))
示例#30
0
 def stop(self):
     self._userActionLog.info("Stopped application %s" % self._appName)
     if not StormTest.PressButton("STOP-ANDROID"):
         self._userActionLog.error("Stop application failed. Disconnection will continue")
     pass