Changeset 32519 in osm for applications/editors/josm/plugins/turnrestrictions/test/unit/org
- Timestamp:
- 2016-07-02T01:10:44+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/AllUnitTests.java
r30365 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions; 2 3 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/AllEditorTests.java
r30365 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 import junit.framework.TestCase;4 3 5 4 import org.junit.runner.RunWith; 6 5 import org.junit.runners.Suite; 6 7 import junit.framework.TestCase; 7 8 8 9 @RunWith(Suite.class) -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/BasicEditorPanelTest.java
r30557 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 … … 11 12 12 13 /** 13 * Simple functional test for the layout / basic functionality of {@see BasicEditorPanel} 14 * 14 * Simple functional test for the layout / basic functionality of {@see BasicEditorPanel} 15 * 15 16 */ 16 17 @Ignore("no test") … … 19 20 private TurnRestrictionEditorModel model; 20 21 private DataSet ds; 21 22 22 23 public BasicEditorPanelTest() { 23 24 ds = new DataSet(); 24 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 25 // mock a controler 25 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 26 // mock a controler 26 27 NavigationControler controler = new NavigationControler() { 28 @Override 27 29 public void gotoAdvancedEditor() { 28 30 } 29 31 32 @Override 30 33 public void gotoBasicEditor() { 31 34 } 32 35 36 @Override 33 37 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 34 } 38 } 35 39 }; 36 40 model = new TurnRestrictionEditorModel(layer, controler); 37 41 38 42 BasicEditorPanel panel = new BasicEditorPanel(model); 39 43 40 44 Container c = getContentPane(); 41 45 c.setLayout(new BorderLayout()); 42 c.add(panel, BorderLayout.CENTER); 43 setSize(600,600); 46 c.add(panel, BorderLayout.CENTER); 47 setSize(600, 600); 44 48 setDefaultCloseOperation(EXIT_ON_CLOSE); 45 49 } 46 47 48 static public void main(String args[]) { 50 51 public static void main(String[] args) { 49 52 new BasicEditorPanelTest().setVisible(true); 50 53 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxTest.java
r30557 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 … … 12 13 13 14 /** 14 * This is a simple test application to test the functionality/layout of 15 * This is a simple test application to test the functionality/layout of 15 16 * the {@see TurnRestrictionComboBox} 16 * 17 * 17 18 */ 18 19 @Ignore("no test") 19 20 public class TurnRestrictionComboBoxTest extends JFrame { 20 21 21 22 private TurnRestrictionEditorModel model; 22 23 private DataSet ds = new DataSet(); 23 24 24 25 protected void build() { 25 26 ds = new DataSet(); 26 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 27 // mock a controler 27 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 28 // mock a controler 28 29 NavigationControler controler = new NavigationControler() { 30 @Override 29 31 public void gotoAdvancedEditor() { 30 32 } 31 33 34 @Override 32 35 public void gotoBasicEditor() { 33 36 } 34 37 38 @Override 35 39 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 36 } 40 } 37 41 }; 38 42 model = new TurnRestrictionEditorModel(layer, controler); 39 43 40 44 Container c = getContentPane(); 41 45 c.setLayout(new GridBagLayout()); … … 44 48 gc.fill = GridBagConstraints.HORIZONTAL; 45 49 gc.weightx = 1.0; 46 50 47 51 TurnRestrictionComboBox cb = new TurnRestrictionComboBox( 48 52 new TurnRestrictionComboBoxModel(model) 49 53 ); 50 add(cb, gc); 54 add(cb, gc); 51 55 } 52 56 53 57 public TurnRestrictionComboBoxTest() { 54 58 build(); 55 setSize(600,600); 59 setSize(600, 600); 56 60 setDefaultCloseOperation(EXIT_ON_CLOSE); 57 61 } 58 59 public static void main(String args[]) {62 63 public static void main(String[] args) { 60 64 new TurnRestrictionComboBoxTest().setVisible(true); 61 65 } 62 63 66 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorTest.java
r30557 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 … … 12 13 @Ignore("no test") 13 14 public class TurnRestrictionEditorTest extends JFrame { 14 15 15 16 public TurnRestrictionEditorTest() { 16 setSize(10,10); 17 setSize(10, 10); 17 18 TurnRestrictionEditor editor = new TurnRestrictionEditor(this, new OsmDataLayer(new DataSet(), "test", null)); 18 editor.setSize(600,600); 19 editor.setSize(600, 600); 19 20 editor.setVisible(true); 20 21 21 22 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 22 23 } 23 24 static public void main(Stringargs[]) {24 25 public static void main(String[] args) { 25 26 new TurnRestrictionEditorTest().setVisible(true); 26 27 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorTest.java
r31944 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 … … 30 31 31 32 /** 32 * Simple test application to test functionality and layout of the 33 * Simple test application to test functionality and layout of the 33 34 * {@see TurnRestrictionLegEditor} 34 35 */ 35 36 @Ignore("no test") 36 37 public class TurnRestrictionLegEditorTest extends JFrame { 37 38 38 39 private TurnRestrictionLegEditor editor; 39 40 private TurnRestrictionEditorModel model; … … 41 42 private DefaultListModel<OsmPrimitive> listModel; 42 43 private DataSet dataSet; 43 44 44 45 protected JPanel buildLegEditorPanel() { 45 46 DataSet ds = new DataSet(); 46 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 47 // mock a controler 47 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 48 // mock a controler 48 49 NavigationControler controler = new NavigationControler() { 50 @Override 49 51 public void gotoAdvancedEditor() { 50 52 } 51 53 54 @Override 52 55 public void gotoBasicEditor() { 53 56 } 54 57 58 @Override 55 59 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 56 } 60 } 57 61 }; 58 62 JPanel pnl = new JPanel(new GridBagLayout()); … … 60 64 gc.anchor = GridBagConstraints.NORTHWEST; 61 65 gc.fill = GridBagConstraints.HORIZONTAL; 62 gc.weightx = 0.0; 66 gc.weightx = 0.0; 63 67 pnl.add(new JLabel("From"), gc); 64 68 65 69 gc.weightx = 1.0; 66 70 gc.gridx = 1; … … 69 73 model.populate(new Relation()); 70 74 pnl.add(editor = new TurnRestrictionLegEditor(model, TurnRestrictionLegRole.FROM), gc); 71 75 72 76 return pnl; 73 77 } 74 78 75 79 protected JPanel buildObjectListPanel() { 76 80 JPanel pnl = new JPanel(new BorderLayout()); 77 81 listModel = new DefaultListModel<>(); 78 82 pnl.add(new JScrollPane(lstObjects = new JList<>(listModel)), BorderLayout.CENTER); 79 lstObjects.setCellRenderer(new OsmPrimitivRenderer()); 80 81 PrimitiveIdListProvider provider = new PrimitiveIdListProvider() { 83 lstObjects.setCellRenderer(new OsmPrimitivRenderer()); 84 85 PrimitiveIdListProvider provider = new PrimitiveIdListProvider() { 86 @Override 82 87 public List<PrimitiveId> getSelectedPrimitiveIds() { 83 88 List<PrimitiveId> ret = new ArrayList<>(); 84 int 85 for (int i: sel){ 89 int[] sel = lstObjects.getSelectedIndices(); 90 for (int i: sel) { 86 91 ret.add((lstObjects.getModel().getElementAt(i)).getPrimitiveId()); 87 92 } … … 89 94 } 90 95 }; 91 96 92 97 lstObjects.setTransferHandler(new PrimitiveIdListTransferHandler(provider)); 93 98 lstObjects.setDragEnabled(true); 94 99 return pnl; 95 100 } 96 101 97 102 protected void build() { 98 103 Container c = getContentPane(); 99 104 c.setLayout(new GridBagLayout()); 100 105 101 106 GridBagConstraints gc = new GridBagConstraints(); 102 107 gc.anchor = GridBagConstraints.NORTHWEST; 103 gc.fill = GridBagConstraints.HORIZONTAL; 108 gc.fill = GridBagConstraints.HORIZONTAL; 104 109 gc.insets = new Insets(20, 0, 20, 0); 105 gc.weightx = 1.0; 110 gc.weightx = 1.0; 106 111 gc.weighty = 0.0; 107 112 add(buildLegEditorPanel(), gc); 108 113 109 114 gc.gridy = 1; 110 115 gc.weightx = 1.0; … … 112 117 gc.fill = GridBagConstraints.BOTH; 113 118 add(buildObjectListPanel(), gc); 114 setSize(600, 600);119 setSize(600, 600); 115 120 } 116 121 117 122 protected void initForTest1() { 118 123 Way w = new Way(1); 119 124 w.put("name", "way-1"); 120 125 121 126 editor.getModel().setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, w); 122 127 } 123 128 124 129 protected void initForTest2() { 125 130 Way w = new Way(1); 126 w.put("name", "way-1"); 131 w.put("name", "way-1"); 127 132 dataSet.addPrimitive(w); 128 133 editor.getModel().setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, w); 129 130 Node n = new Node(new LatLon(1,1)); 134 135 Node n = new Node(new LatLon(1, 1)); 131 136 n.setOsmId(1, 1); 132 137 n.put("name", "node.1"); 133 138 dataSet.addPrimitive(n); 134 139 listModel.addElement(n); 135 140 136 141 w = new Way(); 137 w.setOsmId(2,1); 142 w.setOsmId(2, 1); 138 143 w.put("name", "way.1"); 139 144 dataSet.addPrimitive(w); 140 145 listModel.addElement(w); 141 146 142 147 Relation r = new Relation(); 143 r.setOsmId(3,1); 148 r.setOsmId(3, 1); 144 149 r.put("name", "relation.1"); 145 150 dataSet.addPrimitive(r); … … 147 152 } 148 153 149 public TurnRestrictionLegEditorTest(){ 154 public TurnRestrictionLegEditorTest() { 150 155 build(); 151 156 initForTest2(); 152 157 } 153 154 static public void main(Stringargs[]) {158 159 public static void main(String[] args) { 155 160 new TurnRestrictionLegEditorTest().setVisible(true); 156 161 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditorTest.java
r30557 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 … … 13 14 /** 14 15 * Simple test application to test the vehicle exception editor 15 * 16 * 16 17 */ 17 18 @Ignore("no test") … … 20 21 OsmDataLayer layer; 21 22 VehicleExceptionEditor editor; 22 23 23 24 protected void build() { 24 25 Container c = getContentPane(); … … 26 27 layer = new OsmDataLayer(new DataSet(), "test", null); 27 28 28 model = new TurnRestrictionEditorModel(layer, new MockNavigationControler()); 29 model = new TurnRestrictionEditorModel(layer, new MockNavigationControler()); 29 30 editor = new VehicleExceptionEditor(model); 30 31 c.add(editor, BorderLayout.CENTER); 31 32 32 33 model.getTagEditorModel().add(new TagModel("except", "non-standard-value")); 33 34 } 34 35 public VehicleExceptionEditorTest(){ 35 36 public VehicleExceptionEditorTest() { 36 37 build(); 37 38 setDefaultCloseOperation(EXIT_ON_CLOSE); 38 setSize(500, 500);39 setSize(500, 500); 39 40 } 40 41 public static void main(String args[]){41 42 public static void main(String[] args) { 42 43 new VehicleExceptionEditorTest().setVisible(true); 43 44 } 44 45 static private class MockNavigationControler implements NavigationControler{46 45 46 private static class MockNavigationControler implements NavigationControler { 47 48 @Override 47 49 public void gotoAdvancedEditor() { 48 50 // TODO Auto-generated method stub 49 51 50 52 } 51 53 54 @Override 52 55 public void gotoBasicEditor() { 53 56 // TODO Auto-generated method stub 54 57 55 58 } 56 59 60 @Override 57 61 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 58 62 // TODO Auto-generated method stub 59 63 60 64 } 61 65 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaListTest.java
r30557 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 2 3 … … 24 25 @Ignore("no test") 25 26 public class ViaListTest extends JFrame { 26 27 27 28 private TurnRestrictionEditorModel model; 28 29 29 30 protected void build() { 30 31 DataSet ds = new DataSet(); 31 OsmDataLayer layer =new OsmDataLayer(ds, "test", null); 32 // mock a controler 32 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 33 // mock a controler 33 34 NavigationControler controler = new NavigationControler() { 35 @Override 34 36 public void gotoAdvancedEditor() { 35 37 } 36 38 39 @Override 37 40 public void gotoBasicEditor() { 38 41 } 39 42 43 @Override 40 44 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 41 } 45 } 42 46 }; 43 47 model = new TurnRestrictionEditorModel(layer, controler); 44 48 Container c = getContentPane(); 45 49 46 50 c.setLayout(new GridBagLayout()); 47 51 GridBagConstraints gc = new GridBagConstraints(); 48 52 gc.anchor = GridBagConstraints.NORTHWEST; 49 gc.insets = new Insets(5, 5,5,20);53 gc.insets = new Insets(5, 5, 5, 20); 50 54 gc.fill = GridBagConstraints.BOTH; 51 55 gc.weightx = 0.5; 52 56 gc.weighty = 1.0; 53 57 54 58 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 55 59 c.add(new ViaList(new ViaListModel(model, selectionModel), selectionModel), gc); 56 60 57 61 gc.gridx = 1; 58 62 c.add(new JList<>(), gc); 59 60 setSize(600, 600);63 64 setSize(600, 600); 61 65 setDefaultCloseOperation(EXIT_ON_CLOSE); 62 66 } 63 67 64 68 protected void initTest1() { 65 69 DataSet ds = new DataSet(); 66 70 Relation r = new Relation(); 67 71 Node n; 68 for (int i = 1; i <10; i++){69 n = new Node(new LatLon(i, i));72 for (int i = 1; i < 10; i++) { 73 n = new Node(new LatLon(i, i)); 70 74 n.put("name", "node." + i); 71 75 ds.addPrimitive(n); 72 r.addMember(new RelationMember("via",n)); 73 } 76 r.addMember(new RelationMember("via", n)); 77 } 74 78 model.populate(r); 75 79 } 76 80 77 81 public ViaListTest() { 78 build(); 82 build(); 79 83 initTest1(); 80 84 } 81 82 static public void main(Stringargs[]) {85 86 public static void main(String[] args) { 83 87 new ViaListTest().setVisible(true); 84 88 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesViewTest.java
r30737 r32519 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.turnrestrictions.qa; 2 3 … … 22 23 public class IssuesViewTest extends JFrame { 23 24 private IssuesModel model; 24 25 25 26 protected void build() { 26 27 Container c = getContentPane(); 27 28 c.setLayout(new GridBagLayout()); 28 // mock a controler 29 // mock a controler 29 30 NavigationControler controler = new NavigationControler() { 31 @Override 30 32 public void gotoAdvancedEditor() { 31 33 } 32 34 35 @Override 33 36 public void gotoBasicEditor() { 34 37 } 35 38 39 @Override 36 40 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 37 } 41 } 38 42 }; 39 43 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null); … … 49 53 pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 50 54 c.add(pane, gc); 51 55 52 56 List<Issue> issues = new ArrayList<>(); 53 57 issues.add(new RequiredTagMissingError(model, "type", "restriction")); … … 55 59 model.populate(issues); 56 60 } 57 61 58 62 public IssuesViewTest() { 59 63 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 60 setSize(400,600); 64 setSize(400, 600); 61 65 build(); 62 66 } 63 64 public static void main(String args[]) {67 68 public static void main(String[] args) { 65 69 new IssuesViewTest().setVisible(true); 66 70 }
Note:
See TracChangeset
for help on using the changeset viewer.