Ignore:
Timestamp:
12/05/05 11:49:55 (19 years ago)
Author:
boris
Message:
  • added a test on OMCProxy.getElementLocation()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestOMCProxy.java

    r171 r175  
    4545import java.util.Vector;
    4646
     47import org.eclipse.core.resources.IProject;
    4748import org.modelica.mdt.internal.omcproxy.CompilerException;
     49import org.modelica.mdt.internal.omcproxy.ConnectionException;
     50import org.modelica.mdt.internal.omcproxy.ElementLocation;
     51import org.modelica.mdt.internal.omcproxy.InvocationError;
    4852import org.modelica.mdt.internal.omcproxy.OMCProxy;
     53import org.modelica.mdt.internal.omcproxy.UnexpectedReplyException;
     54import org.modelica.mdt.test.util.Area51Projects;
     55import org.modelica.mdt.test.util.Utility;
    4956
    5057import junit.framework.TestCase;
     
    5663    protected void setUp()
    5764    {
     65        Area51Projects.createProjects();
     66
    5867        assertTrue(Collections.addAll(modelicaLibraryPackages,
    5968                "Mechanics",
     
    6675                "SIunits"));
    6776    }
     77   
     78    /**
     79     * test OMCProxy.getPackages()
     80     */
    6881    public void testGetPackages()
    6982    {
     
    88101        }
    89102    }
     103   
     104    /**
     105     * test OMCProxy.getElementLocation()
     106     */
     107    public void testGetElementLocation()
     108        throws ConnectionException, UnexpectedReplyException, InvocationError
     109    {
     110        /* load file nested_models.mo from Area51Projects modelica project */
     111        IProject proj = Utility.getProject(
     112                Area51Projects.MODELICA_PROJECT_NAME).getProject();
     113       
     114        OMCProxy.loadFileInteractive(proj.getFile("nested_models.mo"));
     115       
     116        /*
     117         * we are basicaly only interested in getting the right line number
     118         */
     119        ElementLocation loc = OMCProxy.getElementLocation("nested_models");     
     120        assertTrue(loc.getPath().endsWith("nested_models.mo"));
     121        assertEquals(loc.getLine(), 1);
     122       
     123        loc = OMCProxy.getElementLocation("nested_models.hepp");       
     124        assertEquals(loc.getLine(), 3);
     125
     126        loc = OMCProxy.getElementLocation("nested_models.foo");     
     127        assertEquals(loc.getLine(), 4);
     128       
     129        loc = OMCProxy.getElementLocation("nested_models.foo.bar");     
     130        assertEquals(loc.getLine(), 5);
     131       
     132        loc = OMCProxy.getElementLocation("muu");       
     133        assertEquals(loc.getLine(), 8);
     134       
     135        loc = OMCProxy.getElementLocation("foo");       
     136        assertEquals(loc.getLine(), 14);
     137
     138        loc = OMCProxy.getElementLocation("hej");       
     139        assertEquals(loc.getLine(), 19);
     140
     141        loc = OMCProxy.getElementLocation("hej.ine_paketen");       
     142        assertEquals(loc.getLine(), 20);
     143
     144        loc = OMCProxy.getElementLocation("hej.hejhej");       
     145        assertEquals(loc.getLine(), 22);
     146
     147        loc = OMCProxy.getElementLocation("hej.hejhej.foo");       
     148        assertEquals(loc.getLine(), 23);
     149
     150        loc = OMCProxy.getElementLocation("hepp");     
     151        assertEquals(loc.getLine(), 30);
     152
     153        loc = OMCProxy.getElementLocation("hepp.hopp");     
     154        assertEquals(loc.getLine(), 31);
     155
     156        loc = OMCProxy.getElementLocation("hepp.hehehe");       
     157        assertEquals(loc.getLine(), 33);
     158
     159    }
    90160}
Note: See TracChangeset for help on using the changeset viewer.