1
16
17 import org.as2lib.util.StringUtil;
18 import org.as2lib.test.speed.TestSuiteResult;
19 import org.as2lib.test.speed.ConfigurableTestSuiteResult;
20 import org.as2lib.test.speed.MethodInvocationHolder;
21 import org.as2lib.test.speed.AbstractTestSuiteResult;
22 import org.as2lib.test.speed.TestResult;
23 import org.as2lib.test.speed.MethodInvocation;
24
25
31 class org.as2lib.test.speed.MethodInvocationTestSuiteResult extends AbstractTestSuiteResult implements ConfigurableTestSuiteResult, MethodInvocationHolder {
32
33
34 private static var __proto__:Function = AbstractTestSuiteResult;
35
36
37 private var methodInvocation:MethodInvocation;
38
39
44 public function MethodInvocationTestSuiteResult(methodInvocation:MethodInvocation) {
45 this.methodInvocation = methodInvocation;
46 }
47
48
53 public function getMethodInvocation(Void):MethodInvocation {
54 return this.methodInvocation;
55 }
56
57
63 public function getName(Void):String {
64 return this.methodInvocation.getName();
65 }
66
67
72 public function getTime(Void):Number {
73 return this.methodInvocation.getTime();
74 }
75
76
84 public function toString():String {
85 var rootTestResult:TestSuiteResult = TestSuiteResult(arguments[0]);
86 if (!rootTestResult) rootTestResult = getThis();
87 var result:String = getTimePercentage(rootTestResult.getTime()) + "%";
88 result += ", " + getThis().getTime() + " ms";
89 result += " - " + getMethodInvocationPercentage(rootTestResult.getMethodInvocationCount()) + "%";
90 result += ", " + getMethodInvocationCount() + " inv.";
91 result += " - " + getAverageTime() + " ms/inv.";
92 result += " - " + getName();
93 if (hasTestResults()) {
94 var totalTime:Number = getThis().getTime();
95 for (var i:Number = 0; i < this.testResults.length; i++) {
96 var testResult:TestResult = this.testResults[i];
97 if (TestSuiteResult(testResult).hasMethodInvocations()
98 || !(testResult instanceof TestSuiteResult)
99 || testResult instanceof MethodInvocationHolder) {
100 result += "\n";
101 result += StringUtil.addSpaceIndent(testResult.toString(rootTestResult), 2);
102 }
103 }
104 }
105 return result;
106 }
107
108 }