Exemplo n.º 1
0
    def checkDestination(self, inputContent):
        ###############################
        #Grab imge and imgeprocessing
        self.grabAndHandleImage(r"D:\Temp\TA\Mask\WaitDestinationCheck.xml",
                                inputContent)

        for i in range(25):
            waitDoneFlag = 0
            colorResult = self.handleImage.recognizeColor([20, 35], [20, 35],
                                                          [20, 30])
            if colorResult == 1:
                MyLog.debug("Please wait!!! Wait for information")
                print "Please wait"

                #Grab imge and imgeprocessing
                self.grabAndHandleImage(
                    r"D:\Temp\TA\Mask\WaitDestinationCheck.xml", inputContent)
                time.sleep(4)

            else:
                waitDoneFlag = 1
                break

        if waitDoneFlag == 1:

            recFlag = self.loopCheckDes(620, 680, 620, 320, 20, inputContent)
            if recFlag == 0:
                self.inputC.deleteEntry()
                return recFlag

        else:
            self.passFlag = 0
            self.msg = "Failed!!! Timeout"
            MyLog.error("Failed!!! Timeout")
            print "Failed!!! Timeout"
Exemplo n.º 2
0
    def desInPrecondition(self, coordX, coordY):
        #################################

        #Grab image to check what screen is
        #At first check if it is in navi
        self.grabAndHandleImage(r"D:\Temp\TA\Mask\NaviCheck.xml", None)
        colorResult = self.handleImage.recognizeColor([65, 75], [55, 65],
                                                      [15, 30])

        if colorResult == 1:
            MyLog.debug("It's in navi screen")
            print "It's in navi screen"
        else:
            self.touch.touchScreen(68, 619, 500, 1, 1)
            time.sleep(1)

        #Then we check if we are in search screen
        a = "搜索"
        MyLog.debug("Now check '搜索' mask")
        self.grabAndHandleImage(r"D:\Temp\TA\Mask\FreeSearch.xml",
                                a.decode('utf-8'))
        chResult, disL, flag, rect = self.handleImage.recognizeCharacters()

        print disL

        if disL > 0.87:
            self.touch.touchScreen(coordX, coordY, 500, 1, 1)
        else:
            self.touch.touchScreen(68, 619, 500, 1, 1)
            time.sleep(3)
            self.touch.touchScreen(coordX, coordY, 500, 1, 1)
Exemplo n.º 3
0
    def routeCalPrecondition(self):
        #################################

        #Grab image to check what screen is
        #At first check if it is in navi
        self.grabAndHandleImage(r"D:\Temp\TA\Mask\NaviCheck.xml", None)
        colorResult = self.handleImage.recognizeColor([65, 75], [55, 65],
                                                      [15, 30])

        if colorResult == 1:
            MyLog.debug("Now it's in the navi screen")
            print "It's in navi screen"
        else:
            self.touch.touchScreen(68, 619, 500, 1, 1)
            time.sleep(1)

        #Then we check if we are in search screen
        a = "搜索"
        MyLog.debug("Now check the '搜索' mask")
        self.grabAndHandleImage(r"D:\Temp\TA\Mask\FreeSearch.xml",
                                a.decode('utf-8'))
        chResult, disL, flag, rect = self.handleImage.recognizeCharacters()

        print disL

        if disL < 0.87:
            self.touch.touchScreen(68, 619, 500, 1, 1)  #Touch Navi Menu
            time.sleep(3)
            self.touch.touchScreen(1468, 140, 500, 1,
                                   1)  #Touch Navi Setting Button
            time.sleep(3)
        else:
            self.touch.touchScreen(1468, 140, 500, 1,
                                   1)  #Touch Navi Setting Button
            time.sleep(3)

        self.grabAndHandleImage(r"D:\Temp\TA\Mask\RouteInformation.xml", None)
        likelihood = self.handleImage.recognizeColor([25, 55], [25, 55],
                                                     [25, 55])

        if likelihood == 1:
            self.touch.touchScreen(265, 155, 500, 1, 1)  #Back up
            time.sleep(1)
        else:
            print "open setting"
            self.touch.touchScreen(1468, 140, 500, 1,
                                   1)  #Touch Navi Setting Button
            time.sleep(1)
            self.touch.touchScreen(1055, 530, 500, 1,
                                   1)  # Open the navi Setting
            time.sleep(1)
            self.touch.touchScreen(265, 155, 500, 1, 1)  #Back up
            time.sleep(1)
Exemplo n.º 4
0
    def loopCheckDes(self, csX, csY, ceX, ceY, offset, inputContent):
        ##########################################
        '''
        When loopCheckDes is used csX,csY,ceX,ceY is equvilent to abt drag parameters
        The offset para is to recorrect the drag action. It is different with loopCheck
        You don't have to decide the number of loop
        '''

        MyLog.debug("Now in loopCheckDestinatons")
        print "Now we are in loopCheckDes"

        self.grabAndHandleImage(r"D:\Temp\TA\Mask\DestinationCheck.xml",
                                inputContent)
        chResult, disL, flag, rect, countNum = self.handleImage.recognizeCharacters_RC(
        )

        firstLine = chResult[0]
        print chResult[0]
        checkFlag = 1

        if countNum < 3:
            MyLog.error("Something wrong happens, please check Image " +
                        str(self.MGB.ImgFN))
            print "Something wrong happens, please check Image " + self.MGB.ImgFN
            checkFlag = 0

        while (1):
            self.touch.dragCoords(csX, csY, ceX, ceY)
            #time.sleep(1)
            self.touch.dragCoords(csX, csY, ceX, abs(csY - offset))
            time.sleep(1)

            self.grabAndHandleImage(r"D:\Temp\TA\Mask\DestinationCheck.xml",
                                    inputContent)
            chResult, disL, flag, rect, countNum = self.handleImage.recognizeCharacters_RC(
            )

            if chResult[0] == firstLine:
                break
            else:
                firstLine = chResult[0]

            if countNum < 3:
                #########################################################################
                #Here we should now in this cluster MIB2+ the destination always shows 3 result
                #So we can code like this
                #If not we should change our logic
                #########################################################################
                print "Something wrong happens, please check Image " + self.MGB.ImgFN
                checkFlag = 0

        return checkFlag
Exemplo n.º 5
0
    def runCases(self):
        ####################################
        #print self.InCasePath
        with open(self.InCasePath) as dataFile:
            self.recogCharacter = json.load(dataFile)

        #Check what the case is, destination input or
        #Route calculation
        try:
            if self.recogCharacter["DestinationInput"]:
                MyLog.debug("Now run Destination input case")
                self.runInputDestination()
        except Exception as e:
            MyLog.debug(e.message + " No Destination")
            print e.message + " No Destination"

        try:
            if self.recogCharacter["RouteCalculation"]:
                MyLog.debug("Now run route calculation case")
                self.runRouteCalculation()
        except Exception as e:
            MyLog.debug(e.message + " No RouteCalculation")
            print e.message + "No RouteCalculation"
Exemplo n.º 6
0
    def checkCharacters(self, inputContent):
        #################################
        if len(inputContent) > 1:

            self.grabAndHandleImage(r"D:\Temp\TA\Mask\CharactersCheck.xml",
                                    inputContent[0])
            chResult, disL, flag, rect = self.handleImage.recognizeCharacters()

            if disL > 0.87:
                print rect.left, rect.top, rect.right, rect.bottom
                self.touch.touchScreen(self.handleImage.mask[0] + rect.left + (rect.right-rect.left)/2,\
                                       self.handleImage.mask[1] + rect.top + (rect.bottom - rect.top)/2,\
                                       500, 1, 1)
                return 1

            else:
                recFlag = self.loopCheck(1070, 250, 300, 240, 3,
                                         inputContent[0])
                if recFlag == 0:
                    self.inputC.deleteEntry()
                    return recFlag

        else:
            #One by one check
            #Grab imge and imgeprocessing
            oneCharacter = inputContent[0].encode("utf-8")

            try:
                print oneCharacter
            except Exception as e:
                MyLog.error(e.message + " Can't print characters")
                print e.message + " Can't print characters"

            if oneCharacter.isalpha():
                #Touch OK button in the bottom screen.
                #a-z or A-Z only need to check if input is right after touch OK button
                MyLog.debug("Now input English characters")
                print "Now input English characters"
                self.inputC.touchCoords(1180, 580, 200, 2, 0)
                return 1

            elif oneCharacter.isdigit():

                #0-9 only need to check if input is right
                MyLog.debug("Now input numbers")
                print "Now input numbers"
                return 1

            else:
                #chinese characters you have to check carefully. Loopcheck if necessary

                self.grabAndHandleImage(r"D:\Temp\TA\Mask\CharactersCheck.xml",
                                        inputContent[0])
                chResult, disL, flag, rect = self.handleImage.recognizeCharacters(
                )

                if disL > 0.87:
                    print rect.left, rect.top, rect.right, rect.bottom
                    self.touch.touchScreen(self.handleImage.mask[0] + rect.left + (rect.right-rect.left)/2,\
                                           self.handleImage.mask[1] + rect.top + (rect.bottom - rect.top)/2,\
                                           500, 1, 1)
                    return 1

                else:
                    recFlag = self.loopCheck(1070, 250, 300, 240, 3,
                                             inputContent[0])
                    if recFlag == 0:
                        self.inputC.deleteEntry()
                        return recFlag
Exemplo n.º 7
0
    def runRouteCalculation(self):
        ##################################

        def checkParkPop():
            popString = "驻车信息"
            for i in range(5):
                self.grabAndHandleImage(
                    r"D:\Temp\TA\Mask\NaviParkingInformation.xml",
                    popString.decode("utf-8"))
                chResult, disL, flag, rect = self.handleImage.recognizeCharacters(
                )

                if disL > 0.9:
                    time.sleep(5)
                else:
                    return 1
            return 0

        def setPOI(coordX, coordY):
            self.touch.touchScreen(coordX, coordY, 500, 1, 1)
            time.sleep(3)
            self.touch.touchScreen(260, 145, 500, 1, 1)
            time.sleep(10)

        if self.recogCharacter["RouteCalculation"]:
            for case in self.recogCharacter["RouteCalculation"]:
                MyLog.debug("Now run RouteCalculation case")
                print self.report

                self.routeCalPrecondition()

                if not self.recogCharacter["RouteCalculation"][case]["Map"]:

                    MyLog.debug("Now run " + case + ":" +\
                                self.recogCharacter["RouteCalculation"][case]["Name"])

                    coords = self.recogCharacter["RouteCalculation"][case][
                        "Coords"]

                    #Set POI
                    setPOI(coords[0], coords[1])
                    #Check parking
                    if not checkParkPop():  #timeout.

                        MyLog.error("Time out, Test Failed")

                        print "Time out, Test Failed!"

                    else:

                        self.grabAndHandleImage(
                            r"D:\Temp\TA\Mask\NaviRouteCalculationIconCheck.xml",
                            None)
                        likelihood = self.handleImage.recognizeImage(
                            r"D:\Temp\TA\MGB\RecogImage\Flag.png")

                        if likelihood > 0.60:
                            MyLog.debug(
                                "Get the flag Passed, and then check route information"
                            )
                            print "Get the flag Passed, and then check route information"

                            #After find the route flag then you should check the route info flag and get route mile info
                            #Then check the route info flag first
                            self.grabAndHandleImage(
                                r"D:\Temp\TA\Mask\RouteFlagInformation.xml",
                                None)
                            likelihood = self.handleImage.recognizeImage(
                                r"D:\Temp\TA\MGB\RecogImage\RouteCalFlag.PNG",
                                None)
                            if likelihood > 0.75:
                                MyLog.debug("Get the route info flag")

                                print "Get the route info flag"
                            else:

                                MyLog.error("Get the route info failed")
                                print "Get the route info failed"

                            #Get the route mile info
                            self.grabAndHandleImage(
                                r"D:\Temp\TA\Mask\RouteMilInformation.xml",
                                None)
                            result, disL, flag, rect, countNum = self.handleImage.recognizeCharacters_AIn(
                            )

                            print "#########################################"
                            print result
                            for i in range(countNum):
                                try:
                                    print result[i]
                                except Exception as e:
                                    MyLog.error("Return result is wrong " +
                                                e.message)
                                    print "return result is wrong " + e.message

                            self.touch.touchScreen(440, 135, 500, 1, 1)
                            time.sleep(3)

                        else:
                            MyLog.error("Failed, couldn't find the flag")
                            print "Failed, couldn't find the flag"

                            self.touch.touchScreen(440, 135, 500, 1, 1)
                            time.sleep(3)

                elif self.recogCharacter["RouteCalculation"][case]["Map"].get(
                        "drag"):

                    MyLog.debug("Now run " + case + ":" +\
                                self.recogCharacter["RouteCalculation"][case]["Name"])
                    coordsDrag = self.recogCharacter["RouteCalculation"][case][
                        "Map"]["drag"]
                    self.touch.dragCoords(coordsDrag[0], coordsDrag[1],
                                          coordsDrag[2], coordsDrag[3])

                    coords = self.recogCharacter["RouteCalculation"][case][
                        "Coords"]

                    #Set POI
                    setPOI(coords[0], coords[1])
                    #Check parking
                    if not checkParkPop():
                        MyLog.error("Time out, Test Failed")
                        print "Time out, Test Failed"

                    else:
                        #Need to drag the screen
                        self.touch.dragCoords(coordsDrag[0], coordsDrag[1],
                                              coordsDrag[2], coordsDrag[3])

                        time.sleep(3)
                        self.grabAndHandleImage(
                            r"D:\Temp\TA\Mask\NaviRouteCalculationIconCheck.xml",
                            None)
                        likelihood = self.handleImage.recognizeImage(
                            r"D:\Temp\TA\MGB\RecogImage\Flag.png")

                        if likelihood > 0.60:
                            MyLog.debug("Recognize image passed")
                            print "Passed"
                            self.touch.touchScreen(200, 650, 500, 1,
                                                   1)  #Touch navi deviation
                            time.sleep(3)

                            #After find the route flag then you should check the route info flag and get route mile info
                            #Check the route info flag first
                            self.grabAndHandleImage(
                                r"D:\Temp\TA\Mask\RouteFlagInformation.xml",
                                None)
                            likelihood = self.handleImage.recognizeImage(
                                r"D:\Temp\TA\MGB\RecogImage\RouteCalFlag.PNG",
                                None)
                            if likelihood > 0.75:

                                MyLog.debug("Get the route info flag")
                                print "Get the route info flag"
                            else:

                                MyLog.error("Get the route info failed")
                                print "Get the route info failed"

                            #Get the route mile info
                            self.grabAndHandleImage(
                                r"D:\Temp\TA\Mask\RouteMilInformation.xml",
                                None)
                            result, disL, flag, rect, countNum = self.handleImage.recognizeCharacters_AIn(
                            )

                            print "#########################################"
                            print result
                            for i in range(countNum):
                                try:
                                    print result[i]
                                except Exception as e:

                                    MyLog.error("return result is wrong " +
                                                e.message)
                                    print "return result is wrong " + e.message

                            self.touch.touchScreen(
                                440, 135, 500, 1,
                                1)  #Touch calc navi route calculation
                            time.sleep(3)

                        else:

                            MyLog.error("Failed, couldn't find the flag")
                            print "Failed, couldn't find the flag"

                            self.touch.touchScreen(200, 650, 500, 1,
                                                   1)  #Touch navi deviation
                            time.sleep(3)
                            self.touch.touchScreen(
                                440, 135, 500, 1,
                                1)  #Touch cancel navi route calculation
                            time.sleep(3)