1 /* 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.mozilla.org/MPL/MPL-1.1.html 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import org.as2lib.core.BasicClass; 18 import org.as2lib.test.speed.TestResultLayout; 19 import org.as2lib.test.speed.TestSuiteResult; 20 import org.as2lib.test.speed.SimpleTestSuiteResult; 21 import org.as2lib.test.speed.MethodInvocation; 22 23 /** 24 * {@code MethodInvocationLayout} lays test results out with method invocations as root 25 * elements of the structure. 26 * 27 * @author Simon Wacker 28 */ 29 class org.as2lib.test.speed.layout.MethodInvocationLayout extends BasicClass implements TestResultLayout { 30 31 /** 32 * Constructs a new {@code MethodInvocationLayout} instance. 33 */ 34 public function MethodInvocationLayout(Void) { 35 } 36 37 /** 38 * Lays the passed-in {@code testSuiteResult} out with method invocations as root 39 * element of the structure and returns the new lay-outed test suite result. 40 * 41 * @param testSuiteResult the test suite result to lay-out 42 * @return the lay-outed test suite result 43 */ 44 public function layOut(testSuiteResult:TestSuiteResult):TestSuiteResult { 45 var result:SimpleTestSuiteResult = new SimpleTestSuiteResult(testSuiteResult.getName()); 46 var methodInvocations:Array = testSuiteResult.getAllMethodInvocations(); 47 for (var i:Number = 0; i < methodInvocations.length; i++) { 48 var methodInvocation:MethodInvocation = MethodInvocation(methodInvocations[i]); 49 if (methodInvocation) { 50 result.addTestResult(methodInvocation); 51 } 52 } 53 result.sort(SimpleTestSuiteResult.TIME, true); 54 return result; 55 } 56 57 }