Commit 93fefe5a authored by Kisslinger's avatar Kisslinger
Browse files

Added fields for integer lower/upper limit

Fixed UI bug on linux caused by missing borders
parent 515634b1
......@@ -13,12 +13,16 @@
package org.fortiss.af3.testing.ui.handler;
import static org.fortiss.af3.testing.model.coverage.CoveragePackage.Literals.COVERAGE_BASE__INT_LOWER_LIMIT;
import static org.fortiss.af3.testing.model.coverage.CoveragePackage.Literals.COVERAGE_BASE__INT_UPPER_LIMIT;
import static org.fortiss.af3.testing.model.coverage.CoveragePackage.Literals.COVERAGE_BASE__MAX_LENGTH;
import static org.fortiss.af3.testing.ui.Af3TestingUIActivator.getImageDescriptor;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
......@@ -31,7 +35,6 @@ import org.fortiss.af3.testing.model.coverage.StateCoverage;
import org.fortiss.af3.testing.ui.extension.ISpecificationPartHandler;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
/**
* {@link ISpecificationPartHandler} and {@link IModelElementHandler} for
......@@ -39,36 +42,52 @@ import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
*
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: FBAAC33119EA8405BF55B5D3639130D7
* @ConQAT.Rating YELLOW Hash: 197A8F516E246727059EDAF9D2540F87
*/
public class StateCoveragePartHandler extends
ModelElementHandlerBase<StateCoverage> implements
ISpecificationPartHandler<StateCoverage> {
/** single line input grid data factory */
private static GridDataFactory singleLineInputFactory = GridDataFactory
.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
/** {@inheritDoc} */
@Override
public void initSettingSection(Composite parent, FormToolkit toolkit,
DataBindingContext dbc, StateCoverage editedObject) {
parent.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().applyTo(parent);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, false).applyTo(parent);
// maximal length
toolkit.createLabel(parent,
"Maximal length of test cases(0 for unlimited): ");
Text lengthInput = toolkit.createText(parent, "");
DataBindingUtils.bind(dbc, lengthInput, editedObject,
COVERAGE_BASE__MAX_LENGTH);
Text lengthInput = toolkit.createText(parent, "", SWT.BORDER);
bind(dbc, lengthInput, editedObject, COVERAGE_BASE__MAX_LENGTH);
GridDataFactory.fillDefaults().applyTo(lengthInput);
// int lower limit
toolkit.createLabel(parent, "Integer lower limit: ", SWT.READ_ONLY);
Text intLowerLimitInput = toolkit.createText(parent, "", SWT.BORDER);
singleLineInputFactory.applyTo(intLowerLimitInput);
bind(dbc, intLowerLimitInput, editedObject,
COVERAGE_BASE__INT_LOWER_LIMIT);
// int upper limit
toolkit.createLabel(parent, "Integer upper limit: ", SWT.READ_ONLY);
Text intUpperLimitInput = toolkit.createText(parent, "", SWT.BORDER);
singleLineInputFactory.applyTo(intUpperLimitInput);
bind(dbc, intUpperLimitInput, editedObject,
COVERAGE_BASE__INT_UPPER_LIMIT);
}
/** {@inheritDoc} */
@Override
public ITestSuiteGenerator createGenerator(StateCoverage specPart) {
// TODO: Remove magic constants + such big default limits for integers
// are really big and thereby the MC will be slow - therefore, these
// should be some parameters
return new ModelCheckingTestSuiteGenerator(new StatesCoverageAnalyzer(
new ModelCheckerConfig(-10000, 10000), specPart));
new ModelCheckerConfig(specPart.getIntLowerLimit(),
specPart.getIntUpperLimit()), specPart));
}
/** {@inheritDoc} */
......
......@@ -13,12 +13,16 @@
package org.fortiss.af3.testing.ui.handler;
import static org.fortiss.af3.testing.model.coverage.CoveragePackage.Literals.COVERAGE_BASE__INT_LOWER_LIMIT;
import static org.fortiss.af3.testing.model.coverage.CoveragePackage.Literals.COVERAGE_BASE__INT_UPPER_LIMIT;
import static org.fortiss.af3.testing.model.coverage.CoveragePackage.Literals.COVERAGE_BASE__MAX_LENGTH;
import static org.fortiss.af3.testing.ui.Af3TestingUIActivator.getImageDescriptor;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
......@@ -32,37 +36,60 @@ import org.fortiss.af3.testing.model.coverage.TransitionCoverage;
import org.fortiss.af3.testing.ui.extension.ISpecificationPartHandler;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
/**
* {@link ISpecificationPartHandler} and {@link IModelElementHandler} for {@link StateCoverage}s.
* {@link ISpecificationPartHandler} and {@link IModelElementHandler} for
* {@link StateCoverage}s.
*
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 30709CC4E34140169FA73CB71C374F97
* @ConQAT.Rating YELLOW Hash: C4D579784C4B83BE9EE8246FDB709A88
*/
public class TransitionCoveragePartHandler extends ModelElementHandlerBase<TransitionCoverage>
implements ISpecificationPartHandler<TransitionCoverage> {
public class TransitionCoveragePartHandler extends
ModelElementHandlerBase<TransitionCoverage> implements
ISpecificationPartHandler<TransitionCoverage> {
/** single line input grid data factory */
private static GridDataFactory singleLineInputFactory = GridDataFactory
.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
/** {@inheritDoc} */
@Override
public void initSettingSection(Composite parent, FormToolkit toolkit, DataBindingContext dbc,
TransitionCoverage editedObject) {
public void initSettingSection(Composite parent, FormToolkit toolkit,
DataBindingContext dbc, TransitionCoverage editedObject) {
parent.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().applyTo(parent);
toolkit.createLabel(parent, "Maximal length of test cases(0 for unlimited): ");
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, false).applyTo(parent);
Text lengthInput = toolkit.createText(parent, "");
DataBindingUtils.bind(dbc, lengthInput, editedObject, COVERAGE_BASE__MAX_LENGTH);
// maximal length
toolkit.createLabel(parent,
"Maximal length of test cases(0 for unlimited): ");
Text lengthInput = toolkit.createText(parent, "", SWT.BORDER);
bind(dbc, lengthInput, editedObject, COVERAGE_BASE__MAX_LENGTH);
GridDataFactory.fillDefaults().applyTo(lengthInput);
// int lower limit
toolkit.createLabel(parent, "Integer lower limit: ", SWT.READ_ONLY);
Text intLowerLimitInput = toolkit.createText(parent, "", SWT.BORDER);
singleLineInputFactory.applyTo(intLowerLimitInput);
bind(dbc, intLowerLimitInput, editedObject,
COVERAGE_BASE__INT_LOWER_LIMIT);
// int upper limit
toolkit.createLabel(parent, "Integer upper limit: ", SWT.READ_ONLY);
Text intUpperLimitInput = toolkit.createText(parent, "", SWT.BORDER);
singleLineInputFactory.applyTo(intUpperLimitInput);
bind(dbc, intUpperLimitInput, editedObject,
COVERAGE_BASE__INT_UPPER_LIMIT);
}
/** {@inheritDoc} */
@Override
public ITestSuiteGenerator createGenerator(TransitionCoverage specPart) {
return new ModelCheckingTestSuiteGenerator(new TransitionCoverageAnalyzer(
new ModelCheckerConfig(-10000, 10000), specPart));
return new ModelCheckingTestSuiteGenerator(
new TransitionCoverageAnalyzer(new ModelCheckerConfig(
specPart.getIntLowerLimit(),
specPart.getIntUpperLimit()), specPart));
}
/** {@inheritDoc} */
......
......@@ -91,6 +91,8 @@
<eClassifiers xsi:type="ecore:EClass" name="CoverageBase" eSuperTypes="#//TestSuiteSpecificationPart">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="maxLength" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
defaultValueLiteral="0"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="intLowerLimit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="intUpperLimit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
</eSubpackages>
</ecore:EPackage>
......@@ -75,6 +75,8 @@
<genClasses ecoreClass="testing.ecore#//coverage/TransitionCoverage"/>
<genClasses ecoreClass="testing.ecore#//coverage/CoverageBase">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute testing.ecore#//coverage/CoverageBase/maxLength"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute testing.ecore#//coverage/CoverageBase/intLowerLimit"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute testing.ecore#//coverage/CoverageBase/intUpperLimit"/>
</genClasses>
</nestedGenPackages>
</genPackages>
......
......@@ -30,6 +30,12 @@
modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture">
</modelElementClass>
</modelElementCompositor>
<modelElementCompositor
compositor="org.fortiss.af3.testing.compose.TestSuiteSpecificationCompositor">
<modelElementClass
modelElementClass="org.fortiss.af3.testing.model.TestSuiteSpecification">
</modelElementClass>
</modelElementCompositor>
</extension>
<extension
point="org.fortiss.tooling.kernel.modelPrototypeProvider">
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.testing.compose;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.af3.testing.model.TestSuiteSpecification;
import org.fortiss.af3.testing.model.TestSuiteSpecificationPart;
import org.fortiss.af3.testing.model.coverage.StateCoverage;
import org.fortiss.af3.testing.model.coverage.TransitionCoverage;
import org.fortiss.tooling.kernel.extension.IElementCompositor;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.Prototype;
/**
* {@link IElementCompositor} for a {@link TestSuiteSpecification} to compose a
* {@link StateCoverage} or {@link TransitionCoverage} profile
*
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 2316144A48BF956BD9B87D998EF136EF
*/
public class TestSuiteSpecificationCompositor implements
IElementCompositor<TestSuiteSpecification> {
/** {@inheritDoc} */
@Override
public boolean canCompose(TestSuiteSpecification container,
EObject contained, IElementCompositionContext context) {
return (contained instanceof StateCoverage || contained instanceof TransitionCoverage)
// only one input profile of the same kind allowed per
// TestSuiteSpecification
&& null == pickFirstInstanceOf(
((TestSuiteSpecificationPart) contained).getClass(),
container.getSpecificationsList());
}
/** {@inheritDoc} */
@Override
public boolean canComposePrototype(Prototype prototype) {
return prototype.getPrototype() instanceof StateCoverage
|| prototype.getPrototype() instanceof TransitionCoverage;
}
/** {@inheritDoc} */
@Override
public boolean compose(TestSuiteSpecification container, EObject contained,
IElementCompositionContext context) {
TestSuiteSpecificationPart specPart = (TestSuiteSpecificationPart) EcoreUtil
.copy(contained);
if (!container.getSpecificationsList().add(specPart)) {
return false;
}
return true;
}
/** {@inheritDoc} */
@Override
public boolean canDecompose(EObject contained) {
return contained instanceof TestSuiteSpecificationPart;
}
/** {@inheritDoc} */
@Override
public boolean decompose(EObject contained) {
TestSuiteSpecificationPart spec = (TestSuiteSpecificationPart) contained;
return spec.getSpecificationOf().getSpecificationsList()
.remove(contained);
}
}
......@@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 65DBCF19B4950AEE30C3418B9C48E5E9
* @ConQAT.Rating YELLOW Hash: 0009FBDEAC02493995498F88CF9C0294
*/
public class TestSuiteSpecificationPrototypeProvider extends PrototypeProviderBase {
......@@ -39,9 +39,14 @@ public class TestSuiteSpecificationPrototypeProvider extends PrototypeProviderBa
@Override
public void registerPrototypes() {
TestSuiteSpecification specification = createTestSuiteSpecification();
createStateCoverage(specification);
createTransitionCoverage(specification);
// register test suite specification
registerPrimaryPrototype("Test Suite Specification", specification);
// register state coverage profile
registerPrimaryPrototype("State Coverage Profile", createStateCoverage());
// register transition coverage profile
registerPrimaryPrototype("Transition Coverage Profile", createTransitionCoverage());
}
}
......@@ -47,7 +47,7 @@ import org.fortiss.af3.testing.model.statistic.TransitionIntTupel;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 08906FAFBC56CC69084BFDAF4AB58E6E
* @ConQAT.Rating YELLOW Hash: C76F4C8CC17C3DE34261C8C814F9AF1F
*/
public class TestingModelElementFactory {
......@@ -56,9 +56,26 @@ public class TestingModelElementFactory {
return TestingModelFactory.eINSTANCE.createTestSuiteSpecification();
}
/** Creates a {@link StateCoverage} */
public static StateCoverage createStateCoverage() {
StateCoverage stateCoverage = CoverageFactory.eINSTANCE.createStateCoverage();
stateCoverage.setIntLowerLimit(-1000);
stateCoverage.setIntUpperLimit(1000);
return stateCoverage;
}
/** Creates a {@link TransitionCoverage} */
public static TransitionCoverage createTransitionCoverage() {
TransitionCoverage transitionCoverage =
CoverageFactory.eINSTANCE.createTransitionCoverage();
transitionCoverage.setIntLowerLimit(-1000);
transitionCoverage.setIntUpperLimit(1000);
return transitionCoverage;
}
/** Creates a {@link StateCoverage} and adds it to the {@link TestSuiteSpecification}. */
public static StateCoverage createStateCoverage(TestSuiteSpecification suiteSpecification) {
StateCoverage stateCoverage = CoverageFactory.eINSTANCE.createStateCoverage();
StateCoverage stateCoverage = createStateCoverage();
suiteSpecification.getSpecificationsList().add(stateCoverage);
return stateCoverage;
}
......@@ -66,8 +83,7 @@ public class TestingModelElementFactory {
/** Creates a {@link TransitionCoverage} and adds it to the {@link TestSuiteSpecification}. */
public static TransitionCoverage createTransitionCoverage(
TestSuiteSpecification suiteSpecification) {
TransitionCoverage transitionCoverage =
CoverageFactory.eINSTANCE.createTransitionCoverage();
TransitionCoverage transitionCoverage = createTransitionCoverage();
suiteSpecification.getSpecificationsList().add(transitionCoverage);
return transitionCoverage;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment