package jetbrains.mps.lang.editor.diagram.tests;
/*Generated by MPS */
import jetbrains.mps.MPSLaunch;
import jetbrains.mps.lang.test.runtime.BaseTransformationTest;
import org.junit.Test;
import jetbrains.mps.lang.test.runtime.BaseEditorTestBody;
import javax.swing.SwingUtilities;
import jetbrains.mps.smodel.ModelAccess;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.baseLanguage.closures.runtime.Wrappers;
import jetbrains.jetpad.mapper.Mapper;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.openapi.editor.cells.EditorCell;
import junit.framework.Assert;
import jetbrains.mps.nodeEditor.cells.jetpad.DiagramCell;
import jetbrains.mps.nodeEditor.cells.CellFinderUtil;
import jetbrains.jetpad.projectional.view.View;
@MPSLaunch
public class SelectAnotherNodeFromCode_Test extends BaseTransformationTest {
@Test
public void test_SelectAnotherNodeFromCode() throws Throwable {
initTest("${mps_home}", "r:e41d7e03-7ef3-4161-a48a-e48d8152e422(jetbrains.mps.lang.editor.diagram.tests@tests)");
runTest("jetbrains.mps.lang.editor.diagram.tests.SelectAnotherNodeFromCode_Test$TestBody", "testMethod", false);
}
@MPSLaunch
public static class TestBody extends BaseEditorTestBody {
@Override
public void testMethodImpl() throws Exception {
initEditorComponent("8041297453110598745", "8041297453110598749");
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
ModelAccess.instance().runReadAction(new Runnable() {
public void run() {
getEditorComponent().selectNode(SNodeOperations.cast(getNodeById("8041297453110598748"), SNodeOperations.asSConcept(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0x50560c9658e49c5L, 0xb8e79e4db4c7e97fL, "jetbrains.mps.lang.editor.diagram.testLanguage"), 0x7a0afda102e202aaL, "NodeWithSize"))));
}
});
}
});
final Wrappers._T<Mapper<? super SNode, ?>> descendantMapper = new Wrappers._T<Mapper<? super SNode, ?>>();
ModelAccess.instance().runReadAction(new Runnable() {
public void run() {
EditorCell selectedCell = getEditorComponent().getSelectedCell();
Assert.assertTrue(selectedCell != null);
DiagramCell diagramCell = CellFinderUtil.findChildByClass(getEditorComponent().getRootCell(), DiagramCell.class, true);
descendantMapper.value = diagramCell.getRootMapper().getDescendantMapper(selectedCell.getSNode());
}
});
Assert.assertTrue(descendantMapper.value != null && descendantMapper.value.getTarget() != null);
Assert.assertTrue(((View) descendantMapper.value.getTarget()).focused().get());
}
}
}