def performTest( self, duration, width, testName ): self.a.getExecutionTimes().returns( ( 0., 1. * duration ) ) self.a.isSuccess().returns( True ) self.a.getPreview().returns( "self.a's preview" ) self.a.getPredecessors().returns( [] ) self.m.startTest() report = ExecutionReport( self.a, width ) img = cairo.ImageSurface( cairo.FORMAT_RGB24, 1, 1 ) ctx = cairo.Context( img ) report.draw( ctx ) graduations = [ report._ExecutionReport__graduationLabel( g ) for g in report._ExecutionReport__graduationPoints ] previousGraduation = None for graduation in graduations: self.assertNotEqual( graduation, previousGraduation ) previousGraduation = graduation
def performTest( self, duration, width, testName ): self.a.getExecutionTimes().returns( ( .7 * duration, 1. * duration ) ) self.a.isSuccess().returns( True ) self.a.getPreview().returns( "self.a's preview" ) self.a.getPredecessors().returns( [ self.b ] ) self.b.getExecutionTimes().returns( ( .3 * duration, .4 * duration ) ) self.b.isSuccess().returns( True ) self.b.getPreview().returns( "self.b's preview, a bit longer than others" ) self.b.getPredecessors().returns( [ self.c ] ) self.c.getExecutionTimes().returns( ( .0, .2 * duration ) ) self.c.isSuccess().returns( True ) self.c.getPreview().returns( "self.c's preview" ) self.c.getPredecessors().returns( [] ) self.m.startTest() report = ExecutionReport( self.a, width + 20 ) marginSize = 10 height = 100 img = cairo.ImageSurface( cairo.FORMAT_ARGB32, width + 2 * marginSize, height + 2 * marginSize ) ctx = cairo.Context( img ) ctx.set_source_rgb( 1, 1, 1 ) ctx.paint() ctx.translate( marginSize, marginSize ) report.draw( ctx ) leftMarginIsWhite, rightMarginIsWhite, drawingTouchesLeft, drawingTouchesRight = self.checkHorizontalMargins( img, marginSize, 0xFFFFFFFF ) reason = "" if not leftMarginIsWhite: reason += ".spreads_on_left_margin" if not rightMarginIsWhite: reason += ".spreads_on_right_margin" if not drawingTouchesLeft: reason += ".far_from_left" if not drawingTouchesRight: reason += ".far_from_right" if reason != "": img.write_to_png( "HorizontalMargins." + testName + reason + ".png" ) self.assertTrue( leftMarginIsWhite ) self.assertTrue( rightMarginIsWhite ) self.assertTrue( drawingTouchesLeft ) self.assertTrue( drawingTouchesRight )