Changeset 84 for java/main/src/test


Ignore:
Timestamp:
06/22/13 21:51:33 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • simplification of entities management model
  • cleanup around params (improve hierarchy)
  • migrate from JUnit to TestNG
  • introduce FEST to automatically test GUI
  • improve slider control
  • loosen synchronization between gui tree and backend representation
  • and many other bug fixes

NOTICE:

  • a great many of lines is changed only because of substituting spaces with tabs

CHANGELOG (oldest changes at the bottom):

Some cleaning after fix found.

Fix bug with tree.

More changes with TreeNodes?.

Finally fix issue with tree.

Improve gui tree management.

Decouple update of values from fetch request in gui.

Minor changes.

Minor changes.

Minor change.

Change Path construction wording.

More fixes to SliderControl?.

Fix SliderControl?.

Fix SliderControl?.

Minor improvement.

Several changes.

Make NumberParam? a generic class.

Add robot to the gui test.

Setup common testing logging configuration.

Remove Parameters class.

Remove entityOwner from Parameters.

Move name out from Parameters class.

Move configuration to after the construction.

Simplify observers and endpoints.

Remove superfluous configureEntity overrides.

Add dependency on fest-swing-testng.

Use FEST for final print test.

Use FEST for more concise and readable assertions.

Divide test of F0Parser into multiple methods.

Migrate to TestNG

Minor change.

Change convention from LOGGER to log.

Fix reporting of errors during controls filling.

Bound maximal height of SliderControl?.

Minor improvements.

Improve tooltips for controls.

Also use Delimeted in more places.

Move static control utilities to Gui.

Rename package gui.components to controls.

Some cleaning in controls.

Improve Param classes placing.

Move ValueParam?, PrimitiveParam? and CompositeParam? one package up.

Improve ParamBuilder?.

Move getDef to ValueParam? and PrimitiveParam?.

Move getMax and getDef to ValueParam?.

Move getMin to ValueParam?.

Upgrade to laters apache commons versions.

Use filterInstanceof extensively.

Add instanceof filters.

Make ValueParam? in many places of Param.

Place assertions about ValueParam?.

Add ValueParam?

Rename ValueParam? to PrimitiveParam?

Minor changes.

Several improvements to params types.

Add NumberParam?.

Add TextControl? component.

Add .swp files to .gitignore

Greatly improved slider component.

Some improvements.

Make Param.reassign return also a state.

Add IterableIterator?.

Several changes.

  • Move util classes to better packages.
  • Remove warnings from eclim.

Several improvements.

Fix bug with BooleanParam?.

Some experiments with visualization.

Another fix to panel management.

Improve panel management.

Some refactorization around panels.

Add root class for panel.

Location:
java/main
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • java/main

    • Property svn:ignore set to
      target
  • java/main/src/test/java/com/framsticks/parsers/F0ParserTest.java

    r79 r84  
    11package com.framsticks.parsers;
    22
     3import org.testng.annotations.*;
    34import com.framsticks.model.*;
    45import com.framsticks.model.Package;
    56import com.framsticks.params.*;
    67import com.framsticks.params.types.FloatParam;
    7 import com.framsticks.util.Point3d;
    8 import org.apache.log4j.PropertyConfigurator;
    9 import org.junit.Test;
     8import com.framsticks.test.TestConfiguration;
     9import com.framsticks.util.math.Point3d;
    1010
     11import java.io.IOException;
     12import java.text.ParseException;
    1113import java.util.List;
    12 
    13 import static org.junit.Assert.*;
     14import static org.fest.assertions.Assertions.*;
     15import static org.fest.assertions.Delta.*;
    1416
    1517/**
    1618 * Author: Piotr Śniegowski
    1719 */
    18 public class F0ParserTest {
     20public class F0ParserTest extends TestConfiguration {
     21
     22        private Schema schema;
     23        private List<AccessInterface> accesses;
     24        private List<Object> objects;
     25        private Model model;
     26
     27        @BeforeClass
     28        public void setUp() throws Exception {
     29                schema = new Schema(Schema.getDefaultDefinitionAsStream());
     30                Package.register(schema.getRegistry());
     31        }
    1932
    2033        @Test
    21         public void testParser() throws Exception {
    22                 PropertyConfigurator.configure(getClass().getResource("/log4j.properties"));
    23                 //testing schema
    24                 Schema schema = new Schema(Schema.getDefaultDefinitionAsStream());
     34        public void primitiveParam() {
     35                FramsClass joint = schema.getRegistry().getInfoFromCache("j");
     36                PrimitiveParam dx = joint.getParamEntry("dx", PrimitiveParam.class);
     37                assertThat(dx).isInstanceOf(FloatParam.class);
     38                assertThat(schema.getNeuroClasses().size()).isEqualTo(21);
     39                assertThat(dx.getName()).isEqualTo("delta.x");
     40                assertThat(dx.getMin(Double.class)).isEqualTo(-2.0, delta(0.0));
     41        }
    2542
    26                 {
    27                         FramsClass joint = schema.getRegistry().getInfoFromCache("j");
    28                         Param dx = joint.getParamEntry("dx");
    29                         assertEquals(FloatParam.class, dx.getClass());
    30                         assertEquals(21, schema.getNeuroClasses().size());
    31                         assertEquals("delta.x", dx.getName());
    32                         assertEquals(-2.0, dx.getMin(Double.class), 0.0);
    33                 }
     43        @Test
     44        public void readF0() throws IOException, ParseException {
     45                accesses = new F0Parser(schema, F0ParserTest.class.getResourceAsStream("/parsers/f0_example.txt")).parse();
    3446
    35                 Package.register(schema.getRegistry());
    36                 //testing parser
    37                 List<AccessInterface> accesses = new F0Parser(schema, F0ParserTest.class.getResourceAsStream("/parsers/f0_example.txt")).parse();
     47                assertThat(accesses.size()).isEqualTo(12);
     48                assertThat(accesses.get(0).getSelected()).isInstanceOf(Model.class);
     49                assertThat(accesses.get(5).get("i", String.class)).isEqualTo("1,2,3,\"dsadsa,,,,");
     50                assertThat(accesses.get(7).get("d", String.class)).isEqualTo("|:p=0.25,r=1");
     51                assertThat(accesses.get(10).get("d", String.class)).isEqualTo("@:p=0.25");
     52        }
    3853
    39                 {
    40                         assertEquals(12, accesses.size());
    41                         assertTrue(accesses.get(0).getSelected() instanceof Model);
    42                         assertEquals("1,2,3,\"dsadsa,,,,", accesses.get(5).get("i", String.class));
    43                         assertEquals("|:p=0.25,r=1", accesses.get(7).get("d", String.class));
    44                         assertEquals("@:p=0.25", accesses.get(10).get("d", String.class));
    45                 }
     54        @Test(dependsOnMethods = {"readF0"})
     55        public void stripAccessInterface() {
     56                objects = Util.stripAccessInterface(accesses);
    4657
    47                 List<Object> objects = Util.stripAccessInterface(accesses);
    48                 {
    49                         assertEquals(Part.class, objects.get(1).getClass());
    50                         assertEquals(Joint.class, objects.get(4).getClass());
    51                         assertEquals(NeuroDef.class, objects.get(6).getClass());
    52                 }
     58                assertThat(objects.get(1)).isInstanceOf(Part.class);
     59                assertThat(objects.get(4)).isInstanceOf(Joint.class);
     60                assertThat(objects.get(6)).isInstanceOf(NeuroDef.class);
     61        }
    5362
    54                 Model model = Model.build(objects);
    55                 {
    56                         assertEquals(3, model.getParts().size());
    57                         assertEquals(6, model.getNeuroDefs().size());
    58                         assertEquals(2, model.getJoints().size());
     63        @Test(dependsOnMethods = {"stripAccessInterface"})
     64        public void buildModel() {
     65                model = Model.build(objects);
    5966
    60                         assertEquals(new Integer(0), model.getJoints().get(0).part1);
    61                         assertEquals(new Integer(1), model.getJoints().get(0).part2);
    62                         assertEquals(new Integer(1), model.getNeuroDefs().get(0).part);
    63                         assertEquals(new Integer(-1), model.getNeuroDefs().get(0).joint);
    64                         assertEquals("|:p=0.25,r=1", model.getNeuroDefs().get(1).details);
    65                         assertEquals("N", model.getNeuroDefs().get(3).details);
    66                         assertEquals(new Integer(-1), model.getNeuroDefs().get(4).part);
     67                assertThat(model.getParts().size()).isEqualTo(3);
     68                assertThat(model.getNeuroDefs().size()).isEqualTo(6);
     69                assertThat(model.getJoints().size()).isEqualTo(2);
    6770
    68                         assertEquals(2.0, model.getParts().get(1).getPosition().x, 0.0);
    69                         assertTrue(model.getParts().get(2).getPosition().sub(new Point3d(2.27236, -0.0792596, -0.958924)).length() < 0.0001);
    70                         assertTrue(model.getParts().get(2).getOrientation().y.sub(new Point3d(0.870277, -0.404792, 0.280644)).length() < 0.0001);
    71                 }
     71                assertThat(model.getJoints().get(0).part1).isEqualTo(0);
     72                assertThat(model.getJoints().get(0).part2).isEqualTo(1);
     73                assertThat(model.getNeuroDefs().get(0).part).isEqualTo(1);
     74                assertThat(model.getNeuroDefs().get(0).joint).isEqualTo(-1);
     75                assertThat(model.getNeuroDefs().get(1).details).isEqualTo("|:p=0.25,r=1");
     76                assertThat(model.getNeuroDefs().get(3).details).isEqualTo("N");
     77                assertThat(model.getNeuroDefs().get(4).part).isEqualTo(-1);
    7278
     79                assertThat(model.getParts().get(1).getPosition().x).isEqualTo(2.0, delta(0.0));
     80                assertThat(model.getParts().get(2).getPosition().sub(new Point3d(2.27236, -0.0792596, -0.958924)).length()).isLessThan(0.0001);
     81                assertThat(model.getParts().get(2).getOrientation().y.sub(new Point3d(0.870277, -0.404792, 0.280644)).length()).isLessThan(0.0001);
     82        }
     83
     84        @Test(dependsOnMethods = {"buildModel"})
     85        public void print() throws Exception {
     86                ListSink sink = new ListSink();
     87                new F0Writer(schema, model, sink).write();
     88
     89                assertThat(sink.getOut()).containsExactly(
     90                        "p:",
     91                        "p:2.0,i=,Vstyle=",
     92                        "p:2.272364001928095,-0.07925961087140347,-0.9589242746631385,i=bla",
     93                        "j:0,1,dx=2.0",
     94                        "j:1,2,rx=8.0,5.0,6.0,dx=1.0,i=\"1,2,3,\\\"dsadsa,,,,\"",
     95                        "n:p=1",
     96                        "n:j=0,d=\"|:p=0.25,r=1\"",
     97                        "n:j=0,d=G",
     98                        "n:p=1",
     99                        "n:j=0,d=@:p=0.25",
     100                        "n:p=1,d=Nu",
     101                        "m:"
     102                );
    73103
    74104        }
  • java/main/src/test/resources/log4j.properties

    r78 r84  
    2727
    2828log4j.logger.com.framsticks=INFO
     29# log4j.logger.com.framsticks.gui.controls.SliderControl=TRACE
     30# log4j.logger.com.framsticks.communication.ClientConnection=DEBUG
Note: See TracChangeset for help on using the changeset viewer.