Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
494910: createDefaultControl in the AbstractControlFactory
Change-Id: Ia5c647d292cc01b6f3dee2a13fed75548a7a0c7a Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=494910 Signed-off-by: Lorenzo Bettini <lorenzo.bettini@gmail.com>
- Loading branch information
1 parent
8369e35
commit 4857548
Showing
2 changed files
with
114 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...lipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DefaultControlFactoryTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Lorenzo Bettini - Initial contribution and API | ||
*******************************************************************************/ | ||
package org.eclipse.emf.parsley.tests | ||
|
||
import org.eclipse.emf.ecore.EStructuralFeature | ||
import org.eclipse.emf.parsley.composite.DialogControlFactory | ||
import org.eclipse.swt.widgets.Text | ||
import org.eclipse.emf.parsley.tests.models.testmodels.BaseClass | ||
import org.junit.Test | ||
|
||
/** | ||
* Tests control creation without using polymorphic dispatch by default. | ||
* | ||
* @author Lorenzo Bettini | ||
*/ | ||
class DefaultControlFactoryTest extends DialogControlFactoryTest { | ||
|
||
def override protected createAndInitializeFactory() { | ||
new DialogControlFactory() { | ||
override create(EStructuralFeature feature) { | ||
super.createDefaultControl(feature) | ||
} | ||
} => [ | ||
initialize(classForControlsInstance) | ||
] | ||
} | ||
|
||
@Test | ||
def void testCustomControlPolymorphicUsingDefaultCreate() { | ||
val factory = new DialogControlFactory { | ||
def control_BaseClass_baseClassFeature(BaseClass e) { | ||
createDefaultControl(testPackage.baseClass_BaseClassFeature) => [ | ||
(it as Text).text = "Foo" | ||
] | ||
} | ||
} => [initialize(testFactory.createBaseClass)] | ||
val control = factory.createControl(testPackage.baseClass_BaseClassFeature) | ||
control.assertTextEditable(true) | ||
control.assertText("Foo") | ||
} | ||
} |