Changeset 10113 in josm for trunk/test
- Timestamp:
- 2016-04-06T23:06:38+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
r9669 r10113 7 7 import java.util.Collections; 8 8 9 import javax.swing.JPanel; 10 9 11 import org.junit.BeforeClass; 10 12 import org.junit.Test; 11 13 import org.openstreetmap.josm.JOSMFixture; 14 import org.openstreetmap.josm.data.osm.DataSet; 12 15 import org.openstreetmap.josm.data.osm.Node; 13 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 17 import org.openstreetmap.josm.data.osm.Relation; 15 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor.LeftButtonToolbar; 20 import org.openstreetmap.josm.gui.dialogs.relation.actions.ApplyAction; 21 import org.openstreetmap.josm.gui.dialogs.relation.actions.CancelAction; 22 import org.openstreetmap.josm.gui.dialogs.relation.actions.DeleteCurrentRelationAction; 23 import org.openstreetmap.josm.gui.dialogs.relation.actions.DuplicateRelationAction; 24 import org.openstreetmap.josm.gui.dialogs.relation.actions.OKAction; 25 import org.openstreetmap.josm.gui.dialogs.relation.actions.RefreshAction; 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 28 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 29 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 16 30 17 31 /** … … 25 39 @BeforeClass 26 40 public static void setUpBeforeClass() { 27 JOSMFixture.createUnitTestFixture().init(); 41 JOSMFixture.createUnitTestFixture().init(true); 42 } 43 44 /** 45 * Returns a new relation editor for unit tests. 46 * @param orig relation 47 * @param layer data layer 48 * @return new relation editor for unit tests 49 */ 50 public static IRelationEditor newRelationEditor(final Relation orig, final OsmDataLayer layer) { 51 return new IRelationEditor() { 52 private Relation r = orig; 53 54 @Override 55 public void setRelation(Relation relation) { 56 r = relation; 57 } 58 59 @Override 60 public boolean isDirtyRelation() { 61 return false; 62 } 63 64 @Override 65 public Relation getRelationSnapshot() { 66 return r; 67 } 68 69 @Override 70 public Relation getRelation() { 71 return r; 72 } 73 74 @Override 75 public void reloadDataFromRelation() { 76 // Do nothing 77 } 78 79 @Override 80 public OsmDataLayer getLayer() { 81 return layer; 82 } 83 }; 28 84 } 29 85 … … 41 97 } 42 98 99 /** 100 * Unit test of {@code GenericRelationEditor#build*} methods. 101 */ 102 @Test 103 public void testBuild() { 104 DataSet ds = new DataSet(); 105 Relation relation = new Relation(1); 106 ds.addPrimitive(relation); 107 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 108 IRelationEditor re = newRelationEditor(relation, layer); 109 110 MemberTableModel memberTableModel = new MemberTableModel(relation, layer, null); 111 MemberTable memberTable = new MemberTable(layer, relation, memberTableModel); 112 113 SelectionTableModel selectionTableModel = new SelectionTableModel(layer); 114 SelectionTable selectionTable = new SelectionTable(selectionTableModel, memberTableModel); 115 116 LeftButtonToolbar leftButtonToolbar = new LeftButtonToolbar(memberTable, memberTableModel, re); 117 assertNotNull(leftButtonToolbar.sortBelowButton); 118 119 AutoCompletingTextField tfRole = GenericRelationEditor.buildRoleTextField(re); 120 assertNotNull(tfRole); 121 122 TagEditorPanel tagEditorPanel = new TagEditorPanel(relation, null); 123 124 JPanel top = GenericRelationEditor.buildTagEditorPanel(tagEditorPanel); 125 JPanel bottom = GenericRelationEditor.buildMemberEditorPanel( 126 memberTable, memberTableModel, selectionTable, selectionTableModel, re, leftButtonToolbar, tfRole); 127 assertNotNull(top); 128 assertNotNull(bottom); 129 assertNotNull(GenericRelationEditor.buildSplitPane(top, bottom, re)); 130 131 TagEditorModel tagModel = tagEditorPanel.getModel(); 132 133 assertNotNull(GenericRelationEditor.buildOkCancelButtonPanel( 134 new OKAction(memberTable, memberTableModel, tagModel, layer, re, tfRole), 135 new CancelAction(memberTable, memberTableModel, tagModel, layer, re, tfRole))); 136 assertNotNull(GenericRelationEditor.buildSelectionControlButtonToolbar(memberTable, memberTableModel, selectionTableModel, re)); 137 assertNotNull(GenericRelationEditor.buildSelectionTablePanel(selectionTable)); 138 139 assertNotNull(GenericRelationEditor.buildToolBar( 140 new RefreshAction(memberTable, memberTableModel, tagModel, layer, re), 141 new ApplyAction(memberTable, memberTableModel, tagModel, layer, re), 142 new DuplicateRelationAction(memberTableModel, tagModel, layer), 143 new DeleteCurrentRelationAction(layer, re))); 144 } 43 145 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java
r9669 r10113 7 7 import org.openstreetmap.josm.data.osm.DataSet; 8 8 import org.openstreetmap.josm.data.osm.Relation; 9 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditorTest; 9 10 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 10 11 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; … … 36 37 final Relation orig = new Relation(1); 37 38 ds.addPrimitive(orig); 38 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null);39 final OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 39 40 MemberTableModel memberTableModel = new MemberTableModel(orig, layer, null); 40 41 SelectionTableModel selectionTableModel = new SelectionTableModel(layer); 41 42 42 IRelationEditor editor = new IRelationEditor() { 43 private Relation r = orig; 44 45 @Override 46 public void setRelation(Relation relation) { 47 r = relation; 48 } 49 50 @Override 51 public boolean isDirtyRelation() { 52 return false; 53 } 54 55 @Override 56 public Relation getRelationSnapshot() { 57 return r; 58 } 59 60 @Override 61 public Relation getRelation() { 62 return r; 63 } 64 65 @Override 66 public void reloadDataFromRelation() { 67 // Do nothing 68 } 69 }; 43 IRelationEditor editor = GenericRelationEditorTest.newRelationEditor(orig, layer); 70 44 71 45 MemberTable memberTable = new MemberTable(layer, editor.getRelation(), memberTableModel);
Note:
See TracChangeset
for help on using the changeset viewer.