def compare_result(self, expected, detected): final = 'PASS' for item in expected.keys(): print("EXPECTED %s is %s and DETECTED %s is %s" % (item, expected[item], item, detected[item])) if item == 'vrat': if abs(float(expected['vrat']) - float(detected['vrat'])) <= 1: tcolor.cprint('PASS', 'GREEN') else: tcolor.cprint('FAIL', 'RED') final = 'FAIL' continue if expected[item] == detected[item]: tcolor.cprint('PASS', 'GREEN') else: tcolor.cprint('FAIL', 'RED') final = 'FAIL' return final
def checkPattern(qd, qdincode, qdoutcode, incode, outcode, aspectratio, incolor, outcolor, swcolorconfig, colorimetry='auto'): """ :param qd: Quantum obj :param incode: input paras dic :param outcode: output paras dic :param ar: AspectRatio, maintain, stretch :param colorspace: RGB/YCbCr444/YCbCr422/YCbCr420 :param swColorConfig: get colorspace expect paras :param colorimetry: set colorimetry under YCbCr mode(Auto BT601, BT709, BT2020) :return: Boolean """ expect_input = incode expect_output = outcode if 'stretch' == aspectratio: #check outcode h = int(expect_output['HRES']) #output hres v = int(expect_output['VRES']) #output vres #if 4K, 4K capture was not support by 780E if '2160p50' in qdincode or '2160p60' in qdincode: if '2160p50' in qdoutcode or '2160p60' in qdoutcode: log.logger.info("Both In/Out are 4K") desarea = calculateBox(1, 1, qd, h, v, h, v, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is: %s" % desarea) if compareArea(1, h, v, desarea): return True else: return False else: log.logger.info("In is 4K, Out not 4K") desarea = calculateBox(1, 0, qd, h, v, h, v, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is:") log.logger.info(desarea) if compareArea(0, h, v, desarea): tcolor.cprint('Pattern Test was Pass', 'GREEN') return True else: tcolor.cprint('Pattern Test was Fail', 'RED') return False else: if '2160p50' in qdoutcode or '2160p60' in qdoutcode: log.logger.info("In not 4K, Out is 4K") desarea = calculateBox(0, 1, qd, h, v, h, v, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is:") log.logger.info(desarea) if compareArea(1, h, v, desarea): tcolor.cprint('Pattern Test was Pass', 'GREEN') return True else: tcolor.cprint('Pattern Test was Fail', 'RED') return False else: log.logger.info("Both are not 4K") desarea = calculateBox(0, 0, qd, h, v, h, v, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is:") log.logger.info(desarea) if compareArea(0, h, v, desarea): tcolor.cprint('Pattern Test was Pass', 'GREEN') return True else: tcolor.cprint('Pattern Test was Fail', 'RED') return False elif 'maintain' == aspectratio: print("in maintain") #Get scale fators h1 = int(expect_input['HRES']) v1 = int(expect_input['VRES']) h2 = int(expect_output['HRES']) v2 = int(expect_output['VRES']) print(h1) print(v1) print(h2) print(v2) hsf = float("%.3f" % float(h2 / h1)) print(hsf) vsf = float("%.3f" % float(v2 / v1)) print(vsf) sf = min(hsf, vsf) print(sf) h3 = round(sf * h1) print("The Horizontal line is %d" % h3) v3 = round(sf * v1) print("The Vertical line is %d" % v3) if '2160p50' in qdincode or '2160p60' in qdincode: if '2160p50' in qdoutcode or '2160p60' in qdoutcode: log.logger.info("Both In/Out are 4K") desarea = calculateBox(1, 1, qd, h2, v2, h3, v3, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is: %s" % desarea) if compareArea(1, h3, v3, desarea): return True else: return False else: log.logger.info("In is 4K, Out not 4K") desarea = calculateBox(1, 0, qd, h2, v2, h3, v3, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is:") log.logger.info(desarea) if compareArea(0, h3, v3, desarea): tcolor.cprint('Pattern Test was Pass', 'GREEN') return True else: tcolor.cprint('Pattern Test was Fail', 'RED') return False else: if '2160p50' in qdoutcode or '2160p60' in qdoutcode: log.logger.info("In not 4K, Out is 4K") desarea = calculateBox(0, 1, qd, h2, v2, h3, v3, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is:") log.logger.info(desarea) if compareArea(1, h3, v3, desarea): tcolor.cprint('Pattern Test was Pass', 'GREEN') return True else: tcolor.cprint('Pattern Test was Fail', 'RED') return False else: log.logger.info("Both are not 4K") desarea = calculateBox(0, 0, qd, h2, v2, h3, v3, incolor, outcolor, swcolorconfig) log.logger.info("The dest area is:") log.logger.info(desarea) if compareArea(0, h3, v3, desarea): tcolor.cprint('Pattern Test was Pass', 'GREEN') return True else: tcolor.cprint('Pattern Test was Fail', 'RED') return False else: raise ("Unsupport aspectration was set.")
def checkPattern(qd, qdincode, qdoutcode, incode, outcode, patterntest, incolor, outcolor, swcolorconfig, colorimetry='auto'): """ :param qd: Quantum obj :param incode: input paras dic :param outcode: output paras dic :param patterntest: RED, GREEN, BLUE :param incolor: input colorspace :param outcolor: output colorspace :param swColorConfig: get colorspace expect paras :param colorimetry: set colorimetry under YCbCr mode(Auto BT601, BT709, BT2020) :return: Boolean """ expect_input = incode expect_output = outcode # check outcode h = int(expect_output['HRES']) # output hres v = int(expect_output['VRES']) # output vres #if 4K, 4K capture was not support by 780E if '2160p50' in qdincode or '2160p60' in qdincode: if '2160p50' in qdoutcode or '2160p60' in qdoutcode: log.logger.info("Both In/Out are 4K") res = calculatePixel(1, 1, qd, h, v, incolor, outcolor, swcolorconfig, patterntest) if res: tcolor.cprint('Pattern Test was PASS', 'GREEN') log.logger.info("Pattern Test was PASS!") return True else: tcolor.cprint('Pattern Test was FAIL', 'RED') log.logger.info("Pattern Test was FAIL!") return False else: log.logger.info("In is 4K, Out not 4K") res = calculatePixel(1, 0, qd, h,v, incolor, outcolor, swcolorconfig, patterntest) if res: tcolor.cprint('Pattern Test was PASS','GREEN') log.logger.info("Pattern Test was PASS!") return True else: tcolor.cprint('Pattern Test was FAIL', 'RED') log.logger.info("Pattern Test was FAIL!") return False else: if '2160p50' in qdoutcode or '2160p60' in qdoutcode: log.logger.info("In not 4K, Out is 4K") res = calculatePixel(0, 1, qd, h ,v, incolor, outcolor, swcolorconfig, patterntest) if res: tcolor.cprint('Pattern Test was PASS', 'GREEN') log.logger.info("Pattern Test was PASS!") return True else: tcolor.cprint('Pattern Test was FAIL', 'RED') log.logger.info("Pattern Test was FAIL!") return False else: log.logger.info("Both are not 4K") res = calculatePixel(0, 0, qd, h, v, incolor, outcolor, swcolorconfig, patterntest) if res: tcolor.cprint('Pattern Test was Pass', 'GREEN') log.logger.info("Pattern Test was PASS!") return True else: tcolor.cprint('Pattern Test was FAIL', 'RED') log.logger.info("Pattern Test was FAIL!") return False