1
16
17 import org.as2lib.core.BasicClass;
18 import org.as2lib.env.reflect.PackageInfo;
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 import org.as2lib.test.speed.layout.ClassLayout;
25
26
32 class org.as2lib.test.speed.layout.PackageLayout extends BasicClass implements TestResultLayout {
33
34
35 private var result:ConfigurableTestSuiteResult;
36
37
38 private var methodInvocations:Array;
39
40
43 public function PackageLayout(Void) {
44 }
45
46
54 public function layOut(testSuiteResult:TestSuiteResult):TestSuiteResult {
55 this.result = new SimpleTestSuiteResult(testSuiteResult.getName());
56 this.methodInvocations = testSuiteResult.getAllMethodInvocations();
57 for (var i:Number = 0; i < this.methodInvocations.length; i++) {
58 var methodInvocation:MethodInvocation = this.methodInvocations[i];
59 i -= addMethodInvocations(methodInvocation.getMethod().getDeclaringType().getPackage());
60 }
61 this.result.sort(SimpleTestSuiteResult.NAME);
62 return this.result;
63 }
64
65
72 private function addMethodInvocations(package:PackageInfo):Number {
73 var count:Number = 0;
74 var classResult:ConfigurableTestSuiteResult = new SimpleTestSuiteResult(package.getFullName());
75 for (var i:Number = 0; i < this.methodInvocations.length; i++) {
76 var methodInvocation:MethodInvocation = this.methodInvocations[i];
77 if (methodInvocation.getMethod().getDeclaringType().getPackage() == package) {
78 classResult.addTestResult(methodInvocation);
79 this.methodInvocations.splice(i, 1);
80 i--;
81 count++;
82 }
83 }
84 this.result.addTestResult((new ClassLayout()).layOut(classResult));
85 return count;
86 }
87
88 }