1
16
17 import org.as2lib.core.BasicClass;
18 import org.as2lib.env.reflect.MethodInfo;
19 import org.as2lib.test.speed.TestResultLayout;
20 import org.as2lib.test.speed.TestSuiteResult;
21 import org.as2lib.test.speed.MethodInvocation;
22 import org.as2lib.test.speed.ConfigurableTestSuiteResult;
23 import org.as2lib.test.speed.SimpleTestSuiteResult;
24
25
31 class org.as2lib.test.speed.layout.MethodLayout extends BasicClass implements TestResultLayout {
32
33
34 private var result:ConfigurableTestSuiteResult;
35
36
37 private var methodInvocations:Array;
38
39
42 public function MethodLayout(Void) {
43 }
44
45
52 public function layOut(testSuiteResult:TestSuiteResult):TestSuiteResult {
53 this.result = new SimpleTestSuiteResult(testSuiteResult.getName());
54 this.methodInvocations = testSuiteResult.getAllMethodInvocations();
55 for (var i:Number = 0; i < this.methodInvocations.length; i++) {
56 var methodInvocation:MethodInvocation = this.methodInvocations[i];
57 i -= addMethodInvocations(methodInvocation.getMethod());
58 }
59 this.result.sort(SimpleTestSuiteResult.TIME, true);
60 return this.result;
61 }
62
63
70 private function addMethodInvocations(method:MethodInfo):Number {
71 var count:Number = 0;
72 var methodResult:ConfigurableTestSuiteResult = new SimpleTestSuiteResult(method.getFullName());
73 for (var i:Number = 0; i < this.methodInvocations.length; i++) {
74 var methodInvocation:MethodInvocation = this.methodInvocations[i];
75 if (methodInvocation.getMethod() == method) {
76 methodResult.addTestResult(methodInvocation);
77 this.methodInvocations.splice(i, 1);
78 i--;
79 count++;
80 }
81 }
82 this.result.addTestResult(methodResult);
83 return count;
84 }
85
86 }