Skip to content

Commit

Permalink
cleaned up a few tests
Browse files Browse the repository at this point in the history
Change-Id: I5bef4bbba962e8dfb3ff17dbe7d765900bccdda2
  • Loading branch information
LorenzoBettini committed Oct 21, 2016
1 parent 4b5b58b commit 4105d5e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
Expand Up @@ -20,14 +20,14 @@ import org.eclipse.emf.parsley.composite.ProposalCreator
import org.eclipse.emf.parsley.junit4.util.LogAppenderTestRule
import org.eclipse.emf.parsley.tests.models.testmodels.BaseClass
import org.eclipse.emf.parsley.tests.util.CustomDialogControlFactoryForTests
import org.eclipse.emf.parsley.tests.util.CustomDialogControlFactoryForTestsWithCallToBindValude
import org.eclipse.emf.parsley.util.DatabindingUtil
import org.eclipse.swt.SWT
import org.eclipse.swt.layout.FillLayout
import org.junit.Rule
import org.junit.Test

import static extension org.junit.Assert.*
import org.eclipse.core.databinding.observable.value.IObservableValue

class CustomDialogControlFactoryTest extends AbstractControlFactoryTest {

Expand Down Expand Up @@ -176,17 +176,8 @@ class CustomDialogControlFactoryTest extends AbstractControlFactoryTest {
@Test
def void testCustomControlWithFeatureAndObservableValue() {
val o1 = createBaseClassObject
val factory = new DialogControlFactory {
@SuppressWarnings("rawtypes")
def control_BaseClass_baseClassFeature(IObservableValue observableValue, EStructuralFeature f) {
val text = createText("")
// by default the editable is true, thus setting it to false
// gives us evidence that this method was called
text.editable = false
bindValue(f, DatabindingUtil.observeText(text), observableValue)
return text
}
} => [initialize(o1)]
val factory = new CustomDialogControlFactoryForTestsWithCallToBindValude
=> [initialize(o1)]
val control = factory.createControl(testPackage.baseClass_BaseClassFeature)
control.assertTextEditable(false)
control.assertText("")
Expand Down
Expand Up @@ -22,7 +22,6 @@ import org.junit.Rule
import org.junit.Test

import static extension org.junit.Assert.*
import org.eclipse.emf.ecore.EObject

/**
* @author Lorenzo Bettini
Expand Down Expand Up @@ -78,26 +77,11 @@ class FormDetailCompositeTest extends AbstractEmfParsleyControlBasedTest {
formDetailComposite.dispose
}

@Test def void testFormDetailWithCustomInit() {
@Test def void testDisposeWhenInitIsNotCalled() {
val injector = getOrCreateInjector
val formDetailCompositeWithCustomInit=new TestableFormDetailWithCustomInitComposite(shell, SWT.NONE)
val formDetailCompositeWithCustomInit = new FormDetailComposite(shell, SWT.NONE)
injector.injectMembers(formDetailCompositeWithCustomInit)
val o = testFactory.createClassWithName => [ name = "Test" ]
formDetailCompositeWithCustomInit.init(o)
formDetailCompositeWithCustomInit.dispose
}

static class TestableFormDetailWithCustomInitComposite extends TestableFormDetailComposite {
/**
* public for tests
*/
new(Composite parent, int style) {
super(parent, style)
}

override init( EObject model, EditingDomain domain){
//It makes cool stuff and doesn't call super.initControlFactory
}

}
}
@@ -0,0 +1,28 @@
/**
*
*/
package org.eclipse.emf.parsley.tests.util;

import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.parsley.composite.DialogControlFactory;
import org.eclipse.emf.parsley.util.DatabindingUtil;
import org.eclipse.swt.widgets.Text;

/**
* Used for testing.
*
* @author Lorenzo Bettini
*
*/
public class CustomDialogControlFactoryForTestsWithCallToBindValude extends DialogControlFactory {
@SuppressWarnings("rawtypes")
public Text control_BaseClass_baseClassFeature(IObservableValue observableValue, EStructuralFeature f) {
final Text text = this.createText("");
// by default the editable is true, thus setting it to false
// gives us evidence that this method was called
text.setEditable(false);
bindValue(f, DatabindingUtil.observeText(text), observableValue);
return text;
}
}

0 comments on commit 4105d5e

Please sign in to comment.