src/asunit/printers/TextPrinter.as in asunit4-4.2.2.pre vs src/asunit/printers/TextPrinter.as in asunit4-4.2.3.pre

- old
+ new

@@ -15,69 +15,44 @@ import flash.system.Capabilities; import flash.text.TextField; import flash.text.TextFormat; import flash.utils.getQualifiedClassName; import flash.utils.getTimer; - import asunit.framework.CallbackBridge; public class TextPrinter extends Sprite implements IRunListener { - public static var LOCAL_PATH_PATTERN:RegExp = /([A-Z]:\\[^\/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^\/:\*\?<>\|]+\.\w{2,6})/g; - public static var BACKGROUND_COLOR:uint = 0x333333; - public static var DEFAULT_HEADER:String = "AsUnit 4.0 by Luke Bayes, Ali Mills and Robert Penner\n\nFlash Player version: " + Capabilities.version - public static var FONT_SIZE:int = 12; - public static var TEXT_COLOR:uint = 0xffffff; + public static const LOCAL_PATH_PATTERN:RegExp = /([A-Z]:\\[^\/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^\/:\*\?<>\|]+\.\w{2,6})/g; + public static const DEFAULT_BACKGROUND_COLOR:uint = 0x333333; + public static const DEFAULT_HEADER:String = "AsUnit 4.0 by Luke Bayes, Ali Mills and Robert Penner\n\nFlash Player version: " + Capabilities.version + public static const DEFAULT_FOOTER:String = ""; + public static const DEFAULT_FONT_SIZE:int = 12; + public static const DEFAULT_PERFORMANCE_COUNT:int = 10; + public static const DEFAULT_TEXT_COLOR:uint = 0xffffff; - public var backgroundColor:uint = BACKGROUND_COLOR; + public var header:String = DEFAULT_HEADER; + public var footer:String = DEFAULT_FOOTER; + public var backgroundColor:uint = DEFAULT_BACKGROUND_COLOR; + public var textColor:uint = DEFAULT_TEXT_COLOR; public var displayPerformanceDetails:Boolean = true; - public var localPathPattern:RegExp; - public var textColor:uint = TEXT_COLOR; public var traceOnComplete:Boolean = true; + public var hideLocalPaths:Boolean = false; + public var localPathPattern:RegExp = LOCAL_PATH_PATTERN; + public var performanceCount:int = DEFAULT_PERFORMANCE_COUNT; protected var textDisplay:TextField; private var backgroundFill:Shape; private var dots:Array; private var failures:Array; - private var footer:String; - private var header:String; private var ignores:Array; private var resultBar:Shape; private var resultBarHeight:uint = 3; private var runCompleted:Boolean; private var startTime:Number; private var successes:Array; private var testTimes:Array; private var warnings:Array; - /** - * The bridge provides the connection between the printer - * and the Runner(s) that it's interested in. - * - * Generally, a bridge can observe Runners, and build up - * state over the course of a test run. - * - * If you create a custom Runner, Printer and Bridge, - * you can decide to manage notifications however you wish. - * - */ - private var _bridge:CallbackBridge; - - [Inject] - public function set bridge(value:CallbackBridge):void - { - if (value !== _bridge) - { - _bridge = value; - _bridge.addObserver(this); - } - } - - public function get bridge():CallbackBridge - { - return _bridge; - } - public function TextPrinter() { initialize(); } private function initialize():void { @@ -86,14 +61,10 @@ ignores = []; successes = []; testTimes = []; warnings = []; - footer = ''; - header = DEFAULT_HEADER; - localPathPattern = LOCAL_PATH_PATTERN; - if(stage) { initializeDisplay(); } else { addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } @@ -115,11 +86,11 @@ } private function getFailureStackTrace(failure:ITestFailure):String { var stack:String = ""; stack = failure.thrownException.getStackTrace(); - //stack = stack.replace(localPathPattern, ''); + if (hideLocalPaths) stack = stack.replace(localPathPattern, ''); stack = stack.replace(/AssertionFailedError: /, ''); stack += "\n\n"; return stack; } @@ -216,11 +187,11 @@ testTimes.sortOn('duration', Array.NUMERIC | Array.DESCENDING); println(); println(); println('Time Summary:'); println(); - var len:Number = testTimes.length; + var len:Number = Math.min(performanceCount, testTimes.length); var total:Number = 0; var testTime:Object; for (var i:Number = 0; i < len; i++) { testTime = testTimes[i]; println(testTime.duration + ' ms : ' + getQualifiedClassName(testTime.test)); @@ -308,10 +279,10 @@ textDisplay.width = stage.stageWidth; textDisplay.height = stage.stageHeight; var format:TextFormat = textDisplay.getTextFormat(); format.font = '_sans'; - format.size = FONT_SIZE; + format.size = DEFAULT_FONT_SIZE; format.leftMargin = 5; format.rightMargin = 5; textDisplay.defaultTextFormat = format; addChild(textDisplay);