-
diff --git a/src/org/openstreetmap/josm/actions/AddNodeAction.java b/src/org/openstreetmap/josm/actions/AddNodeAction.java
index 29373b9..5cc050f 100644
|
a
|
b
|
public final class AddNodeAction extends JosmAction {
|
| 65 | 65 | // add the node |
| 66 | 66 | Main.main.undoRedo.add(new AddCommand(nnew)); |
| 67 | 67 | getLayerManager().getEditDataSet().setSelected(nnew); |
| 68 | | if (Main.map.mapView.getRealBounds().contains(nnew.getCoor())) { |
| 69 | | Main.map.mapView.repaint(); |
| 70 | | } else { |
| 71 | | AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew)); |
| | 68 | if (Main.map.mapView != null) { |
| | 69 | if (Main.map.mapView.getRealBounds().contains(nnew.getCoor())) { |
| | 70 | Main.map.mapView.repaint(); |
| | 71 | } else { |
| | 72 | AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew)); |
| | 73 | } |
| 72 | 74 | } |
| 73 | 75 | } |
| 74 | 76 | |
-
diff --git a/src/org/openstreetmap/josm/actions/AlignInCircleAction.java b/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
index 192dd8e..a0a1302 100644
|
a
|
b
|
public final class AlignInCircleAction extends JosmAction {
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | Main.main.undoRedo.add(new SequenceCommand(tr("Align Nodes in Circle"), cmds)); |
| 286 | | Main.map.repaint(); |
| 287 | 286 | } |
| 288 | 287 | |
| 289 | 288 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/AlignInLineAction.java b/src/org/openstreetmap/josm/actions/AlignInLineAction.java
index 4c30ea4..daa848d 100644
|
a
|
b
|
public final class AlignInLineAction extends JosmAction {
|
| 204 | 204 | |
| 205 | 205 | // Do it! |
| 206 | 206 | Main.main.undoRedo.add(cmd); |
| 207 | | Main.map.repaint(); |
| 208 | 207 | |
| 209 | 208 | } catch (InvalidSelection except) { |
| 210 | 209 | Main.debug(except); |
-
diff --git a/src/org/openstreetmap/josm/actions/CreateCircleAction.java b/src/org/openstreetmap/josm/actions/CreateCircleAction.java
index 91d5bfc..2978476 100644
|
a
|
b
|
public final class CreateCircleAction extends JosmAction {
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | Main.main.undoRedo.add(new SequenceCommand(tr("Create Circle"), cmds)); |
| 243 | | Main.map.repaint(); |
| 244 | 243 | } |
| 245 | 244 | |
| 246 | 245 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/DistributeAction.java b/src/org/openstreetmap/josm/actions/DistributeAction.java
index aca100d..10945d7 100644
|
a
|
b
|
public final class DistributeAction extends JosmAction {
|
| 97 | 97 | |
| 98 | 98 | // Do it! |
| 99 | 99 | Main.main.undoRedo.add(new SequenceCommand(tr("Distribute Nodes"), cmds)); |
| 100 | | Main.map.repaint(); |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | 102 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java b/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
index d444d45..a35cac3 100644
|
a
|
b
|
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 136 | 136 | Main.debug(getClass().getName()+" consuming event "+kev); |
| 137 | 137 | } |
| 138 | 138 | kev.consume(); |
| 139 | | Main.map.repaint(); |
| 140 | 139 | } |
| 141 | 140 | } |
| 142 | 141 | |
| … |
… |
public class ImageryAdjustAction extends MapMode implements AWTEventListener {
|
| 163 | 162 | if (offsetDialog != null) { |
| 164 | 163 | offsetDialog.updateOffset(); |
| 165 | 164 | } |
| 166 | | Main.map.repaint(); |
| 167 | 165 | prevEastNorth = eastNorth; |
| 168 | 166 | } |
| 169 | 167 | |
-
diff --git a/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java b/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
index 5a0bcfd..ab3d135 100644
|
a
|
b
|
public class JoinNodeWayAction extends JosmAction {
|
| 159 | 159 | |
| 160 | 160 | if (cmds.isEmpty()) return; |
| 161 | 161 | Main.main.undoRedo.add(new SequenceCommand(getValue(NAME).toString(), cmds)); |
| 162 | | Main.map.repaint(); |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | 164 | private static SortedSet<Integer> pruneSuccs(Collection<Integer> is) { |
-
diff --git a/src/org/openstreetmap/josm/actions/MirrorAction.java b/src/org/openstreetmap/josm/actions/MirrorAction.java
index 36e4a8c..379afbd 100644
|
a
|
b
|
public final class MirrorAction extends JosmAction {
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | Main.main.undoRedo.add(new SequenceCommand(tr("Mirror"), cmds)); |
| 83 | | Main.map.repaint(); |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | @Override |
-
diff --git a/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java b/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
index 9afb758..973c492 100644
|
a
|
b
|
public final class OrthogonalizeAction extends JosmAction {
|
| 112 | 112 | } |
| 113 | 113 | if (!commands.isEmpty()) { |
| 114 | 114 | Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize / Undo"), commands)); |
| 115 | | Main.map.repaint(); |
| 116 | 115 | } else { |
| 117 | 116 | throw new InvalidUserInputException("Commands are empty"); |
| 118 | 117 | } |
| … |
… |
public final class OrthogonalizeAction extends JosmAction {
|
| 152 | 151 | try { |
| 153 | 152 | final SequenceCommand command = orthogonalize(sel); |
| 154 | 153 | Main.main.undoRedo.add(new SequenceCommand(tr("Orthogonalize"), command)); |
| 155 | | Main.map.repaint(); |
| 156 | 154 | } catch (InvalidUserInputException ex) { |
| 157 | 155 | Main.debug(ex); |
| 158 | 156 | String msg; |
-
diff --git a/src/org/openstreetmap/josm/actions/ReverseWayAction.java b/src/org/openstreetmap/josm/actions/ReverseWayAction.java
index 531a58f..831bcc3 100644
|
a
|
b
|
public final class ReverseWayAction extends JosmAction {
|
| 102 | 102 | propertiesUpdated |= !revResult.getTagCorrectionCommands().isEmpty(); |
| 103 | 103 | } |
| 104 | 104 | Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), c)); |
| | 105 | // FIXME: This should be handled by undoRedo. |
| 105 | 106 | if (propertiesUpdated) { |
| 106 | 107 | ds.fireSelectionChanged(); |
| 107 | 108 | } |
| 108 | | Main.map.repaint(); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/SimplifyWayAction.java b/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
index 076967c..8a979c3 100644
|
a
|
b
|
public class SimplifyWayAction extends JosmAction {
|
| 123 | 123 | } finally { |
| 124 | 124 | ds.endUpdate(); |
| 125 | 125 | } |
| 126 | | Main.map.repaint(); |
| 127 | 126 | } |
| 128 | 127 | |
| 129 | 128 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java b/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java
index 494c3f5..0e52890 100644
|
a
|
b
|
public class UnJoinNodeWayAction extends JosmAction {
|
| 90 | 90 | |
| 91 | 91 | // I'm sure there's a better way to handle this |
| 92 | 92 | Main.main.undoRedo.add(new RemoveNodesCommand(selectedWay, selectedNodes)); |
| 93 | | Main.map.repaint(); |
| 94 | 93 | } |
| 95 | 94 | |
| 96 | 95 | /** |
-
diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
index 3807238..41114c4 100644
|
a
|
b
|
public class DownloadReferrersTask extends PleaseWaitRunnable {
|
| 121 | 121 | @Override |
| 122 | 122 | public void run() { |
| 123 | 123 | targetLayer.onPostDownloadFromServer(); |
| 124 | | if (Main.map != null) |
| 125 | | Main.map.mapView.repaint(); |
| 126 | 124 | } |
| 127 | 125 | } |
| 128 | 126 | ); |
-
diff --git a/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java b/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
index dedbb84..05d267e 100644
|
a
|
b
|
public class DeleteAction extends MapMode implements ModifierListener {
|
| 133 | 133 | * @param e Action event |
| 134 | 134 | */ |
| 135 | 135 | public static void doActionPerformed(ActionEvent e) { |
| 136 | | if (!Main.map.mapView.isActiveLayerDrawable()) |
| | 136 | MainLayerManager lm = Main.getLayerManager(); |
| | 137 | OsmDataLayer editLayer = lm.getEditLayer(); |
| | 138 | if (editLayer == null) { |
| 137 | 139 | return; |
| | 140 | } |
| | 141 | |
| 138 | 142 | boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; |
| 139 | 143 | boolean alt = (e.getModifiers() & (ActionEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0; |
| 140 | 144 | |
| 141 | | MainLayerManager lm = Main.getLayerManager(); |
| 142 | 145 | Command c; |
| 143 | 146 | if (ctrl) { |
| 144 | | c = DeleteCommand.deleteWithReferences(lm.getEditLayer(), lm.getEditDataSet().getSelected()); |
| | 147 | c = DeleteCommand.deleteWithReferences(editLayer, lm.getEditDataSet().getSelected()); |
| 145 | 148 | } else { |
| 146 | | c = DeleteCommand.delete(lm.getEditLayer(), lm.getEditDataSet().getSelected(), !alt /* also delete nodes in way */); |
| | 149 | c = DeleteCommand.delete(editLayer, lm.getEditDataSet().getSelected(), !alt /* also delete nodes in way */); |
| 147 | 150 | } |
| 148 | 151 | // if c is null, an error occurred or the user aborted. Don't do anything in that case. |
| 149 | 152 | if (c != null) { |
| 150 | 153 | Main.main.undoRedo.add(c); |
| | 154 | //FIXME: This should not be required, DeleteCommand should update the selection, otherwise undo/redo won't work. |
| 151 | 155 | lm.getEditDataSet().setSelected(); |
| 152 | | Main.map.repaint(); |
| 153 | 156 | } |
| 154 | 157 | } |
| 155 | 158 | |
| … |
… |
public class DeleteAction extends MapMode implements ModifierListener {
|
| 212 | 215 | |
| 213 | 216 | private void repaintIfRequired(Set<OsmPrimitive> newHighlights, WaySegment newHighlightedWaySegment) { |
| 214 | 217 | boolean needsRepaint = false; |
| 215 | | DataSet ds = getLayerManager().getEditDataSet(); |
| | 218 | OsmDataLayer editLayer = getLayerManager().getEditLayer(); |
| 216 | 219 | |
| 217 | 220 | if (newHighlightedWaySegment == null && oldHighlightedWaySegment != null) { |
| 218 | | if (ds != null) { |
| 219 | | ds.clearHighlightedWaySegments(); |
| | 221 | if (editLayer != null) { |
| | 222 | editLayer.data.clearHighlightedWaySegments(); |
| 220 | 223 | needsRepaint = true; |
| 221 | 224 | } |
| 222 | 225 | oldHighlightedWaySegment = null; |
| 223 | 226 | } else if (newHighlightedWaySegment != null && !newHighlightedWaySegment.equals(oldHighlightedWaySegment)) { |
| 224 | | if (ds != null) { |
| 225 | | ds.setHighlightedWaySegments(Collections.singleton(newHighlightedWaySegment)); |
| | 227 | if (editLayer != null) { |
| | 228 | editLayer.data.setHighlightedWaySegments(Collections.singleton(newHighlightedWaySegment)); |
| 226 | 229 | needsRepaint = true; |
| 227 | 230 | } |
| 228 | 231 | oldHighlightedWaySegment = newHighlightedWaySegment; |
| 229 | 232 | } |
| 230 | 233 | needsRepaint |= highlightHelper.highlightOnly(newHighlights); |
| 231 | | if (needsRepaint) { |
| 232 | | Main.map.mapView.repaint(); |
| | 234 | if (needsRepaint && editLayer != null) { |
| | 235 | editLayer.invalidate(); |
| 233 | 236 | } |
| 234 | 237 | } |
| 235 | 238 | |
-
diff --git a/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java b/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
index 3226fe9..fba4f5f 100644
|
a
|
b
|
public class DrawAction extends MapMode implements MapViewPaintable, SelectionCh
|
| 184 | 184 | return false; |
| 185 | 185 | |
| 186 | 186 | // update selection to reflect which way being modified |
| 187 | | DataSet currentDataSet = getLayerManager().getEditDataSet(); |
| 188 | | if (getCurrentBaseNode() != null && currentDataSet != null && !currentDataSet.selectionEmpty()) { |
| | 187 | OsmDataLayer editLayer = getLayerManager().getEditLayer(); |
| | 188 | if (getCurrentBaseNode() != null && editLayer != null && !editLayer.data.selectionEmpty()) { |
| | 189 | DataSet currentDataSet = editLayer.data; |
| 189 | 190 | Way continueFrom = getWayForNode(getCurrentBaseNode()); |
| 190 | 191 | if (alt && continueFrom != null && (!getCurrentBaseNode().isSelected() || continueFrom.isSelected())) { |
| 191 | 192 | addRemoveSelection(currentDataSet, getCurrentBaseNode(), continueFrom); |
| … |
… |
public class DrawAction extends MapMode implements MapViewPaintable, SelectionCh
|
| 196 | 197 | } |
| 197 | 198 | } |
| 198 | 199 | |
| 199 | | if (needsRepaint) { |
| 200 | | Main.map.mapView.repaint(); |
| | 200 | if (needsRepaint && editLayer != null) { |
| | 201 | editLayer.invalidate(); |
| 201 | 202 | } |
| 202 | 203 | return needsRepaint; |
| 203 | 204 | } |
| … |
… |
public class DrawAction extends MapMode implements MapViewPaintable, SelectionCh
|
| 916 | 917 | */ |
| 917 | 918 | @Override |
| 918 | 919 | public void mouseExited(MouseEvent e) { |
| 919 | | if (!Main.map.mapView.isActiveLayerDrawable()) |
| | 920 | OsmDataLayer editLayer = Main.getLayerManager().getEditLayer(); |
| | 921 | if (editLayer == null) { |
| 920 | 922 | return; |
| | 923 | } |
| 921 | 924 | mousePos = e.getPoint(); |
| 922 | 925 | snapHelper.noSnapNow(); |
| 923 | 926 | boolean repaintIssued = removeHighlighting(); |
| 924 | 927 | // force repaint in case snapHelper needs one. If removeHighlighting |
| 925 | 928 | // caused one already, don’t do it again. |
| 926 | 929 | if (!repaintIssued) { |
| 927 | | Main.map.mapView.repaint(); |
| | 930 | editLayer.invalidate(); |
| 928 | 931 | } |
| 929 | 932 | } |
| 930 | 933 | |
-
diff --git a/src/org/openstreetmap/josm/command/AddCommand.java b/src/org/openstreetmap/josm/command/AddCommand.java
index f22603b..0ed62bb 100644
|
a
|
b
|
public class AddCommand extends Command {
|
| 58 | 58 | |
| 59 | 59 | @Override |
| 60 | 60 | public boolean executeCommand() { |
| 61 | | getLayer().data.addPrimitive(osm); |
| | 61 | getAffectedDataSet().addPrimitive(osm); |
| 62 | 62 | osm.setModified(true); |
| 63 | 63 | checkNodeStyles(osm); |
| 64 | 64 | return true; |
| … |
… |
public class AddCommand extends Command {
|
| 66 | 66 | |
| 67 | 67 | @Override |
| 68 | 68 | public void undoCommand() { |
| 69 | | getLayer().data.removePrimitive(osm); |
| | 69 | getAffectedDataSet().removePrimitive(osm); |
| 70 | 70 | checkNodeStyles(osm); |
| 71 | 71 | } |
| 72 | 72 | |
-
diff --git a/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java b/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
index 1c43060..c3a9ab7 100644
|
a
|
b
|
public class AddPrimitivesCommand extends Command {
|
| 77 | 77 | primitivesToSelect = new ArrayList<>(toSelect.size()); |
| 78 | 78 | |
| 79 | 79 | for (PrimitiveData pd : data) { |
| 80 | | OsmPrimitive primitive = getLayer().data.getPrimitiveById(pd); |
| | 80 | OsmPrimitive primitive = getAffectedDataSet().getPrimitiveById(pd); |
| 81 | 81 | boolean created = primitive == null; |
| 82 | 82 | if (created) { |
| 83 | 83 | primitive = pd.getType().newInstance(pd.getUniqueId(), true); |
| … |
… |
public class AddPrimitivesCommand extends Command {
|
| 86 | 86 | primitive.load(pd); |
| 87 | 87 | } |
| 88 | 88 | if (created) { |
| 89 | | getLayer().data.addPrimitive(primitive); |
| | 89 | getAffectedDataSet().addPrimitive(primitive); |
| 90 | 90 | } |
| 91 | 91 | newPrimitives.add(primitive); |
| 92 | 92 | if (toSelect.contains(pd)) { |
| … |
… |
public class AddPrimitivesCommand extends Command {
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | @Override public void undoCommand() { |
| 117 | | DataSet ds = getLayer().data; |
| | 117 | DataSet ds = getAffectedDataSet(); |
| 118 | 118 | |
| 119 | 119 | if (createdPrimitives == null) { |
| 120 | 120 | createdPrimitives = new ArrayList<>(data.size()); |
| … |
… |
public class AddPrimitivesCommand extends Command {
|
| 166 | 166 | |
| 167 | 167 | Collection<OsmPrimitive> prims = new HashSet<>(); |
| 168 | 168 | for (PrimitiveData d : data) { |
| 169 | | OsmPrimitive osm = getLayer().data.getPrimitiveById(d); |
| | 169 | OsmPrimitive osm = getAffectedDataSet().getPrimitiveById(d); |
| 170 | 170 | if (osm == null) |
| 171 | 171 | throw new RuntimeException(); |
| 172 | 172 | prims.add(osm); |
-
diff --git a/src/org/openstreetmap/josm/command/Command.java b/src/org/openstreetmap/josm/command/Command.java
index e6e3bfc..fadce1a 100644
|
a
|
b
|
import javax.swing.JPanel;
|
| 16 | 16 | import org.openstreetmap.josm.Main; |
| 17 | 17 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 18 | 18 | import org.openstreetmap.josm.data.coor.LatLon; |
| | 19 | import org.openstreetmap.josm.data.osm.DataSet; |
| 19 | 20 | import org.openstreetmap.josm.data.osm.Node; |
| 20 | 21 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| 21 | 22 | import org.openstreetmap.josm.data.osm.PrimitiveData; |
| … |
… |
public abstract class Command extends PseudoCommand {
|
| 212 | 213 | } |
| 213 | 214 | |
| 214 | 215 | /** |
| | 216 | * Gets the data set this command affects. |
| | 217 | * @return The data set. May be <code>null</code> if no layer was set and no edit layer was found. |
| | 218 | * @since xxx |
| | 219 | */ |
| | 220 | public DataSet getAffectedDataSet() { |
| | 221 | return layer == null ? null : layer.data; |
| | 222 | } |
| | 223 | |
| | 224 | /** |
| 215 | 225 | * Fill in the changed data this command operates on. |
| 216 | 226 | * Add to the lists, don't clear them. |
| 217 | 227 | * |
-
diff --git a/src/org/openstreetmap/josm/command/conflict/WayNodesConflictResolverCommand.java b/src/org/openstreetmap/josm/command/conflict/WayNodesConflictResolverCommand.java
index f94b18d..5d2e85b 100644
|
a
|
b
|
public class WayNodesConflictResolverCommand extends ConflictResolveCommand {
|
| 58 | 58 | // replace the list of nodes of 'my' way by the list of merged nodes |
| 59 | 59 | // |
| 60 | 60 | for (Node n:mergedNodeList) { |
| 61 | | if (!getLayer().data.getNodes().contains(n)) { |
| | 61 | if (!getAffectedDataSet().getNodes().contains(n)) { |
| 62 | 62 | Main.warn(tr("Main dataset does not include node {0}", n.toString())); |
| 63 | 63 | } |
| 64 | 64 | } |
-
diff --git a/src/org/openstreetmap/josm/data/UndoRedoHandler.java b/src/org/openstreetmap/josm/data/UndoRedoHandler.java
index bb39aae..6f77728 100644
|
a
|
b
|
public class UndoRedoHandler implements LayerChangeListener {
|
| 73 | 73 | * @param c The command to execute. Must not be {@code null}. |
| 74 | 74 | */ |
| 75 | 75 | public synchronized void add(final Command c) { |
| 76 | | DataSet ds = Main.getLayerManager().getEditDataSet(); |
| 77 | | Collection<? extends OsmPrimitive> oldSelection = ds.getSelected(); |
| | 76 | DataSet ds = c.getAffectedDataSet(); |
| | 77 | if (ds == null) { |
| | 78 | // old, legacy behaviour |
| | 79 | ds = Main.getLayerManager().getEditDataSet(); |
| | 80 | } |
| | 81 | Collection<? extends OsmPrimitive> oldSelection = null; |
| | 82 | if (ds != null) { |
| | 83 | oldSelection = ds.getSelected(); |
| | 84 | } |
| 78 | 85 | addNoRedraw(c); |
| 79 | 86 | afterAdd(); |
| 80 | 87 | |
| 81 | 88 | // the command may have changed the selection so tell the listeners about the current situation |
| 82 | | fireIfSelectionChanged(ds, oldSelection); |
| | 89 | if (ds != null) { |
| | 90 | fireIfSelectionChanged(ds, oldSelection); |
| | 91 | } |
| 83 | 92 | } |
| 84 | 93 | |
| 85 | 94 | /** |
-
diff --git a/src/org/openstreetmap/josm/data/gpx/GpxData.java b/src/org/openstreetmap/josm/data/gpx/GpxData.java
index 2d01218..da6d631 100644
|
a
|
b
|
public class GpxData extends WithAttributes implements Data {
|
| 202 | 202 | } else { |
| 203 | 203 | if (pnt.compareTo(earliest) < 0) { |
| 204 | 204 | earliest = pnt; |
| 205 | | } else { |
| | 205 | } else if (pnt.compareTo(latest) > 0) { |
| 206 | 206 | latest = pnt; |
| 207 | 207 | } |
| 208 | 208 | } |
-
diff --git a/src/org/openstreetmap/josm/data/gpx/WayPoint.java b/src/org/openstreetmap/josm/data/gpx/WayPoint.java
index 510f90f..7b85ee5 100644
|
a
|
b
|
import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
|
| 18 | 18 | public class WayPoint extends WithAttributes implements Comparable<WayPoint>, TemplateEngineDataProvider { |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | | * The seconds (not milliseconds!) since 1970-01-01. |
| | 21 | * The seconds (not milliseconds!) since 1970-01-01 00:00 UTC |
| 22 | 22 | */ |
| 23 | 23 | public double time; |
| 24 | 24 | public Color customColoring; |
-
diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
index 2d562c8..4abcbe5 100644
|
a
|
b
|
public class MainApplication extends Main {
|
| 100 | 100 | |
| 101 | 101 | @Override |
| 102 | 102 | protected void initializeMainWindow() { |
| | 103 | mainPanel.reAddListeners(); |
| 103 | 104 | if (mainFrame != null) { |
| 104 | 105 | mainFrame.initialize(); |
| 105 | 106 | |
| … |
… |
public class MainApplication extends Main {
|
| 409 | 410 | !args.containsKey(Option.NO_MAXIMIZE) && Main.pref.getBoolean("gui.maximized", false)); |
| 410 | 411 | final MainFrame mainFrame = new MainFrame(contentPanePrivate, mainPanel, geometry); |
| 411 | 412 | Main.parent = mainFrame; |
| 412 | | mainPanel.reAddListeners(); |
| 413 | 413 | |
| 414 | 414 | if (args.containsKey(Option.LOAD_PREFERENCES)) { |
| 415 | 415 | CustomConfigurator.XMLCommandProcessor config = new CustomConfigurator.XMLCommandProcessor(Main.pref); |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
index c7b9ade..22c2589 100644
|
a
|
b
|
public class LayerListDialog extends ToggleDialog {
|
| 175 | 175 | * Creates a layer list and attach it to the given mapView. |
| 176 | 176 | * @param layerManager The layer manager this list is for |
| 177 | 177 | */ |
| 178 | | private LayerListDialog(MainLayerManager layerManager) { |
| | 178 | public LayerListDialog(MainLayerManager layerManager) { |
| 179 | 179 | super(tr("Layers"), "layerlist", tr("Open a list of all loaded layers."), |
| 180 | 180 | Shortcut.registerShortcut("subwindow:layers", tr("Toggle: {0}", tr("Layers")), KeyEvent.VK_L, |
| 181 | 181 | Shortcut.ALT_SHIFT), 100, true); |
-
diff --git a/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java b/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
index 04eea4b..cc9997a 100644
|
a
|
b
|
public class ToggleDialog extends JPanel implements ShowHideButtonListener, Help
|
| 256 | 256 | Main.redirectToMainContentPane(this); |
| 257 | 257 | Main.pref.addPreferenceChangeListener(this); |
| 258 | 258 | |
| | 259 | registerInWindowMenu(); |
| | 260 | } |
| | 261 | |
| | 262 | /** |
| | 263 | * Registers this dialog in the window menu. Called in the constructor. |
| | 264 | */ |
| | 265 | protected void registerInWindowMenu() { |
| 259 | 266 | windowMenuItem = MainMenu.addWithCheckbox(Main.main.menu.windowMenu, |
| 260 | 267 | (JosmAction) getToggleAction(), |
| 261 | 268 | MainMenu.WINDOW_MENU_GROUP.TOGGLE_DIALOG); |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java b/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
index be0bcd5..4a6d290 100644
|
a
|
b
|
public abstract class ImageryLayer extends Layer {
|
| 116 | 116 | return dy; |
| 117 | 117 | } |
| 118 | 118 | |
| | 119 | /** |
| | 120 | * Sets the displacement offset of this layer. The layer is automatically invalidated. |
| | 121 | * @param dx The x offset |
| | 122 | * @param dy The y offset |
| | 123 | */ |
| 119 | 124 | public void setOffset(double dx, double dy) { |
| 120 | 125 | this.dx = dx; |
| 121 | 126 | this.dy = dy; |
| | 127 | invalidate(); |
| 122 | 128 | } |
| 123 | 129 | |
| 124 | 130 | public void displace(double dx, double dy) { |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/LayerManager.java b/src/org/openstreetmap/josm/gui/layer/LayerManager.java
index 352df56..e7ee59e 100644
|
a
|
b
|
import java.util.Collections;
|
| 6 | 6 | import java.util.List; |
| 7 | 7 | import java.util.concurrent.CopyOnWriteArrayList; |
| 8 | 8 | |
| | 9 | import org.openstreetmap.josm.Main; |
| 9 | 10 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| 10 | 11 | import org.openstreetmap.josm.tools.Utils; |
| 11 | 12 | import org.openstreetmap.josm.tools.bugreport.BugReport; |
| … |
… |
public class LayerManager {
|
| 174 | 175 | checkPosition(position); |
| 175 | 176 | insertLayerAt(layer, position); |
| 176 | 177 | fireLayerAdded(layer); |
| 177 | | layer.hookUpMapView(); // needs to be after fireLayerAdded |
| | 178 | if (Main.map != null) { |
| | 179 | layer.hookUpMapView(); // needs to be after fireLayerAdded |
| | 180 | } |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | 183 | /** |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java b/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
index 747df2b..6bcfb13 100644
|
a
|
b
|
public class OsmDataLayer extends AbstractModifiableLayer implements Listener, S
|
| 877 | 877 | public void onPostLoadFromFile() { |
| 878 | 878 | setRequiresSaveToFile(false); |
| 879 | 879 | setRequiresUploadToServer(isModified()); |
| | 880 | invalidate(); |
| 880 | 881 | } |
| 881 | 882 | |
| 882 | 883 | /** |
| … |
… |
public class OsmDataLayer extends AbstractModifiableLayer implements Listener, S
|
| 885 | 886 | public void onPostDownloadFromServer() { |
| 886 | 887 | setRequiresSaveToFile(true); |
| 887 | 888 | setRequiresUploadToServer(isModified()); |
| | 889 | invalidate(); |
| 888 | 890 | } |
| 889 | 891 | |
| 890 | 892 | @Override |
-
diff --git a/test/unit/org/openstreetmap/josm/JOSMFixture.java b/test/unit/org/openstreetmap/josm/JOSMFixture.java
index 51fb2dc..b8f3d28 100644
|
a
|
b
|
import java.nio.file.Paths;
|
| 11 | 11 | import java.security.GeneralSecurityException; |
| 12 | 12 | import java.text.MessageFormat; |
| 13 | 13 | import java.util.Locale; |
| | 14 | import java.util.TimeZone; |
| 14 | 15 | |
| 15 | 16 | import org.openstreetmap.josm.data.projection.Projections; |
| 16 | 17 | import org.openstreetmap.josm.gui.MainApplication; |
| | 18 | import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer; |
| 17 | 19 | import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; |
| 18 | 20 | import org.openstreetmap.josm.gui.util.GuiHelper; |
| 19 | 21 | import org.openstreetmap.josm.io.CertificateAmendment; |
| … |
… |
public class JOSMFixture {
|
| 87 | 89 | } |
| 88 | 90 | } |
| 89 | 91 | System.setProperty("josm.home", josmHome); |
| | 92 | TimeZone.setDefault(TimeZone.getTimeZone("UTC")); |
| 90 | 93 | Main.initApplicationPreferences(); |
| 91 | 94 | Main.pref.enableSaveOnPut(false); |
| 92 | 95 | I18n.init(); |
| … |
… |
public class JOSMFixture {
|
| 95 | 98 | // call the really early hook before we anything else |
| 96 | 99 | Main.platform.preStartupHook(); |
| 97 | 100 | |
| | 101 | Main.logLevel = 3; |
| 98 | 102 | Main.pref.init(false); |
| 99 | 103 | Main.pref.put("osm-server.url", "http://api06.dev.openstreetmap.org/api"); |
| 100 | 104 | I18n.set(Main.pref.get("language", "en")); |
| … |
… |
public class JOSMFixture {
|
| 127 | 131 | } |
| 128 | 132 | |
| 129 | 133 | private void setupGUI() { |
| | 134 | Main.getLayerManager().resetState(); |
| | 135 | assertTrue(Main.getLayerManager().getLayers().isEmpty()); |
| | 136 | assertNull(Main.getLayerManager().getEditLayer()); |
| | 137 | assertNull(Main.getLayerManager().getActiveLayer()); |
| | 138 | |
| 130 | 139 | if (Main.toolbar == null) { |
| 131 | 140 | Main.toolbar = new ToolbarPreferences(); |
| 132 | 141 | } |
| 133 | 142 | if (Main.main == null) { |
| 134 | 143 | new MainApplication().initialize(); |
| 135 | 144 | } |
| 136 | | Main.getLayerManager().resetState(); |
| 137 | | assertTrue(Main.getLayerManager().getLayers().isEmpty()); |
| 138 | | assertNull(Main.getLayerManager().getEditLayer()); |
| 139 | | assertNull(Main.getLayerManager().getActiveLayer()); |
| | 145 | // Add a test layer to the layer manager to get the MapFrame |
| | 146 | Main.getLayerManager().addLayer(new TestLayer()); |
| 140 | 147 | } |
| 141 | 148 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/data/AutosaveTaskTest.java b/test/unit/org/openstreetmap/josm/data/AutosaveTaskTest.java
index 28faf26..ce6b72c 100644
|
a
|
b
|
public class AutosaveTaskTest {
|
| 91 | 91 | cal.set(Calendar.MILLISECOND, 456); |
| 92 | 92 | Date fixed = cal.getTime(); |
| 93 | 93 | |
| 94 | | for (int i = 0; i <= AutosaveTask.PROP_INDEX_LIMIT.get() + 1; i++) { |
| | 94 | AutosaveTask.PROP_INDEX_LIMIT.put(5); |
| | 95 | for (int i = 0; i <= AutosaveTask.PROP_INDEX_LIMIT.get() + 2; i++) { |
| 95 | 96 | // Only retry 2 indexes to avoid 1000*1000 disk operations |
| 96 | 97 | File f = task.getNewLayerFile(info, fixed, Math.max(0, i - 2)); |
| 97 | 98 | if (i > AutosaveTask.PROP_INDEX_LIMIT.get()) { |
-
diff --git a/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy b/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy
index 7046cec..dcccb2e 100644
|
a
|
b
|
class PreferencesTest extends GroovyTestCase {
|
| 36 | 36 | " <tag key='jdk.Arrays.useLegacyMergeSort' value='false'/>%n" + |
| 37 | 37 | " <tag key='language' value='en'/>%n" + |
| 38 | 38 | " <tag key='osm-server.url' value='http://api06.dev.openstreetmap.org/api'/>%n" + |
| 39 | | " <tag key='osm-server.username' value='josm_test'/>%n" + |
| 40 | | "</preferences>%n", Version.getInstance().getVersion()) |
| | 39 | " <tag key='osm-server.username' value='%s'/>%n" + |
| | 40 | "</preferences>%n", Version.getInstance().getVersion(), Main.pref.get("osm-server.username")) |
| 41 | 41 | } |
| 42 | 42 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
index 0ccfab7..1b97917 100644
|
a
|
b
|
import java.util.List;
|
| 16 | 16 | import java.util.Set; |
| 17 | 17 | |
| 18 | 18 | import org.junit.Before; |
| | 19 | import org.junit.Rule; |
| 19 | 20 | import org.junit.Test; |
| 20 | | import org.openstreetmap.josm.JOSMFixture; |
| 21 | 21 | import org.openstreetmap.josm.data.osm.Tag; |
| 22 | 22 | import org.openstreetmap.josm.data.validation.Severity; |
| 23 | 23 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; |
| 24 | 24 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; |
| 25 | 25 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; |
| 26 | 26 | import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; |
| | 27 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 28 | |
| | 29 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 27 | 30 | |
| 28 | 31 | /** |
| 29 | 32 | * JUnit Test of "Opening hours" validation test. |
| | 33 | * @see OpeningHourTest |
| 30 | 34 | */ |
| 31 | 35 | public class OpeningHourTestTest { |
| | 36 | /** |
| | 37 | * We need prefs for this. We check strings so we need i18n. |
| | 38 | */ |
| | 39 | @Rule |
| | 40 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| | 41 | public JOSMTestRules test = new JOSMTestRules().preferences().i18n(); |
| 32 | 42 | |
| 33 | | private static final OpeningHourTest OPENING_HOUR_TEST = new OpeningHourTest(); |
| | 43 | private OpeningHourTest openingHourTest; |
| 34 | 44 | |
| 35 | 45 | /** |
| 36 | 46 | * Setup test. |
| … |
… |
public class OpeningHourTestTest {
|
| 38 | 48 | */ |
| 39 | 49 | @Before |
| 40 | 50 | public void setUp() throws Exception { |
| 41 | | JOSMFixture.createUnitTestFixture().init(); |
| 42 | | OPENING_HOUR_TEST.initialize(); |
| | 51 | openingHourTest = new OpeningHourTest(); |
| | 52 | openingHourTest.initialize(); |
| 43 | 53 | } |
| 44 | 54 | |
| 45 | 55 | /** |
| … |
… |
public class OpeningHourTestTest {
|
| 49 | 59 | public void testCheckOpeningHourSyntax1() { |
| 50 | 60 | final String key = "opening_hours"; |
| 51 | 61 | // frequently used tags according to https://taginfo.openstreetmap.org/keys/opening_hours#values |
| 52 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "24/7"), isEmpty()); |
| 53 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 08:30-20:00"), isEmpty()); |
| 54 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr sunrise-sunset"), isEmpty()); |
| 55 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "09:00-21:00"), isEmpty()); |
| 56 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise"), isEmpty()); |
| 57 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise"), hasSize(1)); |
| 58 | | assertEquals(Severity.OTHER, OPENING_HOUR_TEST.checkOpeningHourSyntax( |
| | 62 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "24/7"), isEmpty()); |
| | 63 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 08:30-20:00"), isEmpty()); |
| | 64 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr sunrise-sunset"), isEmpty()); |
| | 65 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "09:00-21:00"), isEmpty()); |
| | 66 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise"), isEmpty()); |
| | 67 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise"), hasSize(1)); |
| | 68 | assertEquals(Severity.OTHER, openingHourTest.checkOpeningHourSyntax( |
| 59 | 69 | key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise").get(0).getSeverity()); |
| 60 | | assertEquals("Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise", OPENING_HOUR_TEST.checkOpeningHourSyntax( |
| | 70 | assertEquals("Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise", openingHourTest.checkOpeningHourSyntax( |
| 61 | 71 | key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise").get(0).getPrettifiedValue()); |
| 62 | 72 | } |
| 63 | 73 | |
| 64 | 74 | @Test |
| 65 | 75 | public void testI18n() { |
| 66 | | assertTrue(OPENING_HOUR_TEST.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "de") |
| | 76 | assertTrue(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "de") |
| 67 | 77 | .get(0).toString().contains("Unerwartetes Zeichen")); |
| 68 | | assertFalse(OPENING_HOUR_TEST.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "en") |
| | 78 | assertFalse(openingHourTest.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "en") |
| 69 | 79 | .get(0).toString().contains("Unerwartetes Zeichen")); |
| 70 | 80 | } |
| 71 | 81 | |
| … |
… |
public class OpeningHourTestTest {
|
| 75 | 85 | @Test |
| 76 | 86 | public void testCheckOpeningHourSyntax2() { |
| 77 | 87 | final String key = "opening_hours"; |
| 78 | | final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Tue"); |
| | 88 | final List<OpeningHourTest.OpeningHoursTestError> errors = openingHourTest.checkOpeningHourSyntax(key, "Mo-Tue"); |
| 79 | 89 | assertThat(errors, hasSize(2)); |
| 80 | 90 | assertEquals(key + " - Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)", errors.get(0).getMessage()); |
| 81 | 91 | assertEquals(Severity.WARNING, errors.get(0).getSeverity()); |
| … |
… |
public class OpeningHourTestTest {
|
| 91 | 101 | @Test |
| 92 | 102 | public void testCheckOpeningHourSyntax3() { |
| 93 | 103 | final String key = "opening_hours"; |
| 94 | | final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00"); |
| | 104 | final List<OpeningHourTest.OpeningHoursTestError> errors = openingHourTest.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00"); |
| 95 | 105 | assertThat(errors, hasSize(2)); |
| 96 | 106 | assertEquals(key + " - Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)", errors.get(0).getMessage()); |
| 97 | 107 | assertEquals(Severity.WARNING, errors.get(0).getSeverity()); |
| … |
… |
public class OpeningHourTestTest {
|
| 105 | 115 | */ |
| 106 | 116 | @Test |
| 107 | 117 | public void testCheckOpeningHourSyntax4() { |
| 108 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, null), isEmpty()); |
| 109 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, ""), isEmpty()); |
| 110 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(null, " "), isEmpty()); |
| | 118 | assertThat(openingHourTest.checkOpeningHourSyntax(null, null), isEmpty()); |
| | 119 | assertThat(openingHourTest.checkOpeningHourSyntax(null, ""), isEmpty()); |
| | 120 | assertThat(openingHourTest.checkOpeningHourSyntax(null, " "), isEmpty()); |
| 111 | 121 | } |
| 112 | 122 | |
| 113 | 123 | /** |
| … |
… |
public class OpeningHourTestTest {
|
| 116 | 126 | @Test |
| 117 | 127 | public void testCheckOpeningHourSyntax5() { |
| 118 | 128 | final String key = "opening_hours"; |
| 119 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext"), hasSize(1)); |
| | 129 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "badtext"), hasSize(1)); |
| 120 | 130 | assertEquals(key + " - ba <--- (Unexpected token: \"b\" Invalid/unsupported syntax.)", |
| 121 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext").get(0).getMessage()); |
| 122 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1)); |
| | 131 | openingHourTest.checkOpeningHourSyntax(key, "badtext").get(0).getMessage()); |
| | 132 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1)); |
| 123 | 133 | assertEquals(key + " - 5.00 p <--- (hyphen (-) or open end (+) in time range expected. " |
| 124 | 134 | + "For working with points in time, the mode for opening_hours.js has to be altered. Maybe wrong tag?)", |
| 125 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getMessage()); |
| | 135 | openingHourTest.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getMessage()); |
| 126 | 136 | } |
| 127 | 137 | |
| 128 | 138 | /** |
| … |
… |
public class OpeningHourTestTest {
|
| 131 | 141 | @Test |
| 132 | 142 | public void testCheckOpeningHourSyntax6() { |
| 133 | 143 | final String key = "opening_hours"; |
| 134 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "PH open \"always open on public holidays\""), isEmpty()); |
| | 144 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "PH open \"always open on public holidays\""), isEmpty()); |
| 135 | 145 | } |
| 136 | 146 | |
| 137 | 147 | /** |
| … |
… |
public class OpeningHourTestTest {
|
| 140 | 150 | @Test |
| 141 | 151 | public void testCheckOpeningHourSyntax7() { |
| 142 | 152 | final String key = "opening_hours"; |
| 143 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00"), hasSize(1)); |
| 144 | | assertEquals(Severity.OTHER, OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getSeverity()); |
| 145 | | assertEquals("09:00-18:00", OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getPrettifiedValue()); |
| | 153 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "9:00-18:00"), hasSize(1)); |
| | 154 | assertEquals(Severity.OTHER, openingHourTest.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getSeverity()); |
| | 155 | assertEquals("09:00-18:00", openingHourTest.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getPrettifiedValue()); |
| 146 | 156 | } |
| 147 | 157 | |
| 148 | 158 | /** |
| … |
… |
public class OpeningHourTestTest {
|
| 151 | 161 | @Test |
| 152 | 162 | public void testCheckOpeningHourSyntaxTicket9367() { |
| 153 | 163 | final String key = "opening_hours"; |
| 154 | | assertEquals(Severity.WARNING, OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity()); |
| | 164 | assertEquals(Severity.WARNING, openingHourTest.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity()); |
| 155 | 165 | assertEquals(key + " - Mo,Tu 04-17 <--- (Time range without minutes specified. " |
| 156 | 166 | + "Not very explicit! Please use this syntax instead \"04:00-17:00\".)", |
| 157 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage()); |
| 158 | | assertEquals("Mo,Tu 04:00-17:00", OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue()); |
| | 167 | openingHourTest.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage()); |
| | 168 | assertEquals("Mo,Tu 04:00-17:00", openingHourTest.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue()); |
| 159 | 169 | } |
| 160 | 170 | |
| 161 | 171 | /** |
| … |
… |
public class OpeningHourTestTest {
|
| 165 | 175 | public void testCheckServiceTimeSyntax1() { |
| 166 | 176 | final String key = "service_times"; |
| 167 | 177 | // frequently used tags according to https://taginfo.openstreetmap.org/keys/service_times#values |
| 168 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su 10:00", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| 169 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "automatic", OpeningHourTest.CheckMode.BOTH), not(isEmpty())); |
| 170 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Sa 09:00-18:00", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| 171 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su 09:30; We 19:30", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| 172 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00", |
| | 178 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su 10:00", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| | 179 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "automatic", OpeningHourTest.CheckMode.BOTH), not(isEmpty())); |
| | 180 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Sa 09:00-18:00", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| | 181 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Su 09:30; We 19:30", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| | 182 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00", |
| 173 | 183 | OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| 174 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", |
| | 184 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", |
| 175 | 185 | OpeningHourTest.CheckMode.BOTH), hasSize(1)); |
| 176 | 186 | assertEquals("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00", |
| 177 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", |
| | 187 | openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", |
| 178 | 188 | OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue()); |
| 179 | 189 | assertEquals("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00", |
| 180 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", |
| | 190 | openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", |
| 181 | 191 | OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue()); |
| 182 | 192 | } |
| 183 | 193 | |
| … |
… |
public class OpeningHourTestTest {
|
| 188 | 198 | public void testCheckCollectionTimeSyntax1() { |
| 189 | 199 | final String key = "collection_times"; |
| 190 | 200 | // frequently used tags according to https://taginfo.openstreetmap.org/keys/collection_times#values |
| 191 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Sa 09:00", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| 192 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "fixme", OpeningHourTest.CheckMode.BOTH), not(isEmpty())); |
| 193 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "daily", OpeningHourTest.CheckMode.BOTH), not(isEmpty())); |
| 194 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00", |
| | 201 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Sa 09:00", OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| | 202 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "fixme", OpeningHourTest.CheckMode.BOTH), not(isEmpty())); |
| | 203 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "daily", OpeningHourTest.CheckMode.BOTH), not(isEmpty())); |
| | 204 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00", |
| 195 | 205 | OpeningHourTest.CheckMode.BOTH), isEmpty()); |
| 196 | | assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", |
| | 206 | assertThat(openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", |
| 197 | 207 | OpeningHourTest.CheckMode.BOTH), hasSize(1)); |
| 198 | 208 | assertEquals(Severity.OTHER, |
| 199 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", |
| | 209 | openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", |
| 200 | 210 | OpeningHourTest.CheckMode.BOTH).get(0).getSeverity()); |
| 201 | 211 | assertEquals("Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00", |
| 202 | | OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", |
| | 212 | openingHourTest.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", |
| 203 | 213 | OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue()); |
| 204 | 214 | } |
| 205 | 215 | |
| … |
… |
public class OpeningHourTestTest {
|
| 221 | 231 | } |
| 222 | 232 | } |
| 223 | 233 | for (final Tag t : values) { |
| 224 | | final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(t.getKey(), t.getValue()); |
| | 234 | final List<OpeningHourTest.OpeningHoursTestError> errors = openingHourTest.checkOpeningHourSyntax(t.getKey(), t.getValue()); |
| 225 | 235 | assertThat(t + " is valid", errors, isEmpty()); |
| 226 | 236 | } |
| 227 | 237 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java
index 8f94ad6..36ff653 100644
|
a
|
b
|
import static org.junit.Assert.assertEquals;
|
| 5 | 5 | import static org.junit.Assert.assertFalse; |
| 6 | 6 | import static org.junit.Assert.assertTrue; |
| 7 | 7 | |
| 8 | | import org.junit.BeforeClass; |
| | 8 | import org.junit.Rule; |
| 9 | 9 | import org.junit.Test; |
| 10 | | import org.openstreetmap.josm.JOSMFixture; |
| 11 | 10 | import org.openstreetmap.josm.Main; |
| 12 | 11 | import org.openstreetmap.josm.gui.dialogs.LayerListDialog; |
| 13 | 12 | import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel; |
| 14 | 13 | import org.openstreetmap.josm.gui.layer.TMSLayer; |
| 15 | 14 | import org.openstreetmap.josm.gui.layer.TMSLayerTest; |
| | 15 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 16 | |
| | 17 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 16 | 18 | |
| 17 | 19 | /** |
| 18 | 20 | * Unit tests of {@link LayerVisibilityAction} class. |
| 19 | 21 | */ |
| 20 | 22 | public class LayerVisibilityActionTest { |
| 21 | | |
| 22 | 23 | /** |
| 23 | | * Setup tests |
| | 24 | * TMS layer needs prefs. Platform for LayerListDialog shortcuts. |
| 24 | 25 | */ |
| 25 | | @BeforeClass |
| 26 | | public static void setUpBeforeClass() { |
| 27 | | JOSMFixture.createUnitTestFixture().init(true); |
| 28 | | } |
| | 26 | @Rule |
| | 27 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| | 28 | public JOSMTestRules test = new JOSMTestRules().preferences().projection().platform(); |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Unit test of {@link LayerVisibilityAction} class. |
| … |
… |
public class LayerVisibilityActionTest {
|
| 33 | 33 | @Test |
| 34 | 34 | public void testLayerVisibilityAction() { |
| 35 | 35 | TMSLayer layer = TMSLayerTest.createTmsLayer(); |
| 36 | | try { |
| 37 | | LayerListModel model = LayerListDialog.getInstance().getModel(); |
| 38 | | LayerVisibilityAction action = new LayerVisibilityAction(model); |
| 39 | | action.updateEnabledState(); |
| 40 | | assertFalse(action.isEnabled()); |
| 41 | | |
| 42 | | Main.getLayerManager().addLayer(layer); |
| 43 | | action.updateEnabledState(); |
| 44 | | assertTrue(action.isEnabled()); |
| 45 | | assertTrue(action.supportLayers(model.getSelectedLayers())); |
| | 36 | LayerListModel model = new LayerListDialog(Main.getLayerManager()) { |
| | 37 | @Override |
| | 38 | protected void registerInWindowMenu() { |
| | 39 | // ignore |
| | 40 | } |
| | 41 | }.getModel(); |
| | 42 | LayerVisibilityAction action = new LayerVisibilityAction(model); |
| | 43 | action.updateEnabledState(); |
| | 44 | assertFalse(action.isEnabled()); |
| 46 | 45 | |
| 47 | | // now check values |
| 48 | | action.updateValues(); |
| 49 | | assertEquals(1.0, action.opacitySlider.getRealValue(), 1e-15); |
| 50 | | assertEquals("OpacitySlider [getRealValue()=1.0]", action.opacitySlider.toString()); |
| | 46 | Main.getLayerManager().addLayer(layer); |
| | 47 | model.setSelectedLayer(layer); |
| | 48 | action.updateEnabledState(); |
| | 49 | assertTrue(action.isEnabled()); |
| | 50 | assertTrue(action.supportLayers(model.getSelectedLayers())); |
| 51 | 51 | |
| 52 | | action.opacitySlider.setRealValue(.5); |
| 53 | | action.updateValues(); |
| | 52 | // now check values |
| | 53 | action.updateValues(); |
| | 54 | assertEquals(1.0, action.opacitySlider.getRealValue(), 1e-15); |
| | 55 | assertEquals("OpacitySlider [getRealValue()=1.0]", action.opacitySlider.toString()); |
| 54 | 56 | |
| 55 | | assertEquals(0.5, action.opacitySlider.getRealValue(), 1e-15); |
| 56 | | assertEquals("OpacitySlider [getRealValue()=0.5]", action.opacitySlider.toString()); |
| | 57 | action.opacitySlider.setRealValue(.5); |
| | 58 | action.updateValues(); |
| 57 | 59 | |
| 58 | | action.setVisibleFlag(false); |
| 59 | | action.updateValues(); |
| 60 | | assertFalse(layer.isVisible()); |
| | 60 | assertEquals(0.5, action.opacitySlider.getRealValue(), 1e-15); |
| | 61 | assertEquals("OpacitySlider [getRealValue()=0.5]", action.opacitySlider.toString()); |
| 61 | 62 | |
| 62 | | action.setVisibleFlag(true); |
| 63 | | action.updateValues(); |
| 64 | | assertTrue(layer.isVisible()); |
| | 63 | action.setVisibleFlag(false); |
| | 64 | action.updateValues(); |
| | 65 | assertFalse(layer.isVisible()); |
| 65 | 66 | |
| 66 | | // layer stays visible during adjust |
| 67 | | action.opacitySlider.setValueIsAdjusting(true); |
| 68 | | action.opacitySlider.setRealValue(0); |
| 69 | | assertEquals(0, layer.getOpacity(), 1e-15); |
| 70 | | layer.setOpacity(.1); // to make layer.isVisible work |
| 71 | | assertTrue(layer.isVisible()); |
| 72 | | layer.setOpacity(0); |
| | 67 | action.setVisibleFlag(true); |
| | 68 | action.updateValues(); |
| | 69 | assertTrue(layer.isVisible()); |
| 73 | 70 | |
| 74 | | action.opacitySlider.setValueIsAdjusting(false); |
| 75 | | action.opacitySlider.setRealValue(0); |
| 76 | | assertEquals(0, layer.getOpacity(), 1e-15); |
| 77 | | layer.setOpacity(.1); // to make layer.isVisible work |
| 78 | | assertFalse(layer.isVisible()); |
| 79 | | layer.setOpacity(0); |
| 80 | | action.updateValues(); |
| | 71 | // layer stays visible during adjust |
| | 72 | action.opacitySlider.setValueIsAdjusting(true); |
| | 73 | action.opacitySlider.setRealValue(0); |
| | 74 | assertEquals(0, layer.getOpacity(), 1e-15); |
| | 75 | layer.setOpacity(.1); // to make layer.isVisible work |
| | 76 | assertTrue(layer.isVisible()); |
| | 77 | layer.setOpacity(0); |
| 81 | 78 | |
| 82 | | // Opacity reset when it was 0 and user set layer to visible. |
| 83 | | action.setVisibleFlag(true); |
| 84 | | action.updateValues(); |
| 85 | | assertEquals(1.0, action.opacitySlider.getRealValue(), 1e-15); |
| 86 | | assertEquals(1.0, layer.getOpacity(), 1e-15); |
| | 79 | action.opacitySlider.setValueIsAdjusting(false); |
| | 80 | action.opacitySlider.setRealValue(0); |
| | 81 | assertEquals(0, layer.getOpacity(), 1e-15); |
| | 82 | layer.setOpacity(.1); // to make layer.isVisible work |
| | 83 | assertFalse(layer.isVisible()); |
| | 84 | layer.setOpacity(0); |
| | 85 | action.updateValues(); |
| 87 | 86 | |
| 88 | | } finally { |
| 89 | | Main.getLayerManager().removeLayer(layer); |
| 90 | | } |
| | 87 | // Opacity reset when it was 0 and user set layer to visible. |
| | 88 | action.setVisibleFlag(true); |
| | 89 | action.updateValues(); |
| | 90 | assertEquals(1.0, action.opacitySlider.getRealValue(), 1e-15); |
| | 91 | assertEquals(1.0, layer.getOpacity(), 1e-15); |
| 91 | 92 | } |
| 92 | 93 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
index 4f7b522..1d8acb0 100644
|
a
|
b
|
import java.io.IOException;
|
| 10 | 10 | import java.util.ArrayList; |
| 11 | 11 | import java.util.Collection; |
| 12 | 12 | import java.util.HashMap; |
| | 13 | import java.util.TimeZone; |
| 13 | 14 | |
| 14 | 15 | import javax.swing.JScrollPane; |
| 15 | 16 | |
| … |
… |
public class GpxLayerTest {
|
| 170 | 171 | assertEquals("", GpxLayer.getTimespanForTrack( |
| 171 | 172 | new ImmutableGpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap<String, Object>()))); |
| 172 | 173 | |
| | 174 | assertEquals("1/3/16 11:59 AM - 12:00 PM (0:00)", GpxLayer.getTimespanForTrack(getMinimalGpxData().tracks.iterator().next())); |
| | 175 | |
| | 176 | TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); |
| 173 | 177 | assertEquals("1/3/16 12:59 PM - 1:00 PM (0:00)", GpxLayer.getTimespanForTrack(getMinimalGpxData().tracks.iterator().next())); |
| 174 | 178 | } |
| 175 | 179 | |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/LayerManagerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/LayerManagerTest.java
index 96c8be9..505b48b 100644
|
a
|
b
|
import static org.junit.Assert.assertSame;
|
| 10 | 10 | import static org.junit.Assert.assertTrue; |
| 11 | 11 | import static org.junit.Assert.fail; |
| 12 | 12 | |
| | 13 | import java.awt.Component; |
| | 14 | import java.awt.Graphics; |
| 13 | 15 | import java.awt.Graphics2D; |
| 14 | 16 | import java.lang.reflect.InvocationTargetException; |
| 15 | 17 | import java.util.ArrayList; |
| … |
… |
import org.openstreetmap.josm.tools.bugreport.ReportedException;
|
| 40 | 42 | */ |
| 41 | 43 | public class LayerManagerTest { |
| 42 | 44 | |
| 43 | | protected static class AbstractTestLayer extends Layer { |
| 44 | | protected AbstractTestLayer() { |
| | 45 | /** |
| | 46 | * This is a layer that can be used in tests. It does not do anything and provides a simple, fake implementation. |
| | 47 | * @author Michael Zangl |
| | 48 | * @since xxx |
| | 49 | */ |
| | 50 | public static class TestLayer extends Layer { |
| | 51 | /** |
| | 52 | * Create a new test layer. |
| | 53 | */ |
| | 54 | public TestLayer() { |
| 45 | 55 | super("Test Layer"); |
| 46 | 56 | } |
| 47 | 57 | |
| … |
… |
public class LayerManagerTest {
|
| 69 | 79 | |
| 70 | 80 | @Override |
| 71 | 81 | public Action[] getMenuEntries() { |
| 72 | | return null; |
| | 82 | return new Action[0]; |
| 73 | 83 | } |
| 74 | 84 | |
| 75 | 85 | @Override |
| … |
… |
public class LayerManagerTest {
|
| 79 | 89 | |
| 80 | 90 | @Override |
| 81 | 91 | public Icon getIcon() { |
| 82 | | return null; |
| | 92 | return new Icon() { |
| | 93 | @Override |
| | 94 | public void paintIcon(Component c, Graphics g, int x, int y) { |
| | 95 | // nop |
| | 96 | } |
| | 97 | |
| | 98 | @Override |
| | 99 | public int getIconWidth() { |
| | 100 | return 10; |
| | 101 | } |
| | 102 | |
| | 103 | @Override |
| | 104 | public int getIconHeight() { |
| | 105 | return 10; |
| | 106 | } |
| | 107 | }; |
| 83 | 108 | } |
| 84 | 109 | |
| 85 | 110 | @Override |
| … |
… |
public class LayerManagerTest {
|
| 88 | 113 | } |
| 89 | 114 | } |
| 90 | 115 | |
| 91 | | protected static class AbstractTestLayer2 extends AbstractTestLayer {} |
| | 116 | protected static class TestLayer2 extends TestLayer {} |
| 92 | 117 | |
| 93 | 118 | /** |
| 94 | 119 | * Intercepts the events for easier testing. |
| … |
… |
public class LayerManagerTest {
|
| 146 | 171 | */ |
| 147 | 172 | @Test |
| 148 | 173 | public void testAddLayer() { |
| 149 | | Layer layer1 = new AbstractTestLayer() { |
| | 174 | Layer layer1 = new TestLayer() { |
| 150 | 175 | @Override |
| 151 | 176 | public LayerPositionStrategy getDefaultLayerPosition() { |
| 152 | 177 | return LayerPositionStrategy.IN_FRONT; |
| … |
… |
public class LayerManagerTest {
|
| 157 | 182 | return true; |
| 158 | 183 | } |
| 159 | 184 | }; |
| 160 | | Layer layer2 = new AbstractTestLayer() { |
| | 185 | Layer layer2 = new TestLayer() { |
| 161 | 186 | @Override |
| 162 | 187 | public LayerPositionStrategy getDefaultLayerPosition() { |
| 163 | 188 | return LayerPositionStrategy.IN_FRONT; |
| 164 | 189 | } |
| 165 | 190 | }; |
| 166 | | Layer layer3 = new AbstractTestLayer() { |
| | 191 | Layer layer3 = new TestLayer() { |
| 167 | 192 | @Override |
| 168 | 193 | public LayerPositionStrategy getDefaultLayerPosition() { |
| 169 | 194 | return LayerPositionStrategy.BEFORE_FIRST_BACKGROUND_LAYER; |
| … |
… |
public class LayerManagerTest {
|
| 178 | 203 | assertEquals(layerManager.getLayers(), Arrays.asList(layer2, layer3, layer1)); |
| 179 | 204 | |
| 180 | 205 | // event |
| 181 | | AbstractTestLayer layer4 = new AbstractTestLayer(); |
| | 206 | TestLayer layer4 = new TestLayer(); |
| 182 | 207 | CapturingLayerChangeListener l = new CapturingLayerChangeListener(); |
| 183 | 208 | layerManager.addLayerChangeListener(l); |
| 184 | 209 | layerManager.addLayer(layer4); |
| … |
… |
public class LayerManagerTest {
|
| 197 | 222 | thrown.expectCause(any(InvocationTargetException.class)); |
| 198 | 223 | thrown.expectRootCause(any(IllegalArgumentException.class)); |
| 199 | 224 | |
| 200 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| | 225 | TestLayer layer1 = new TestLayer(); |
| 201 | 226 | layerManager.addLayer(layer1); |
| 202 | 227 | layerManager.addLayer(layer1); |
| 203 | 228 | } |
| … |
… |
public class LayerManagerTest {
|
| 211 | 236 | thrown.expectCause(any(InvocationTargetException.class)); |
| 212 | 237 | thrown.expectRootCause(any(IndexOutOfBoundsException.class)); |
| 213 | 238 | |
| 214 | | AbstractTestLayer layer1 = new AbstractTestLayer() { |
| | 239 | TestLayer layer1 = new TestLayer() { |
| 215 | 240 | @Override |
| 216 | 241 | public LayerPositionStrategy getDefaultLayerPosition() { |
| 217 | 242 | return new LayerPositionStrategy() { |
| … |
… |
public class LayerManagerTest {
|
| 230 | 255 | */ |
| 231 | 256 | @Test |
| 232 | 257 | public void testRemoveLayer() { |
| 233 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 234 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 258 | TestLayer layer1 = new TestLayer(); |
| | 259 | TestLayer layer2 = new TestLayer(); |
| 235 | 260 | layerManager.addLayer(layer1); |
| 236 | 261 | layerManager.addLayer(layer2); |
| 237 | 262 | assertEquals(layerManager.getLayers(), Arrays.asList(layer1, layer2)); |
| … |
… |
public class LayerManagerTest {
|
| 251 | 276 | */ |
| 252 | 277 | @Test |
| 253 | 278 | public void testMoveLayer() { |
| 254 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 255 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 279 | TestLayer layer1 = new TestLayer(); |
| | 280 | TestLayer layer2 = new TestLayer(); |
| 256 | 281 | layerManager.addLayer(layer1); |
| 257 | 282 | layerManager.addLayer(layer2); |
| 258 | 283 | assertEquals(layerManager.getLayers(), Arrays.asList(layer1, layer2)); |
| … |
… |
public class LayerManagerTest {
|
| 283 | 308 | thrown.expectCause(any(InvocationTargetException.class)); |
| 284 | 309 | thrown.expectRootCause(any(IndexOutOfBoundsException.class)); |
| 285 | 310 | |
| 286 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 287 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 311 | TestLayer layer1 = new TestLayer(); |
| | 312 | TestLayer layer2 = new TestLayer(); |
| 288 | 313 | layerManager.addLayer(layer1); |
| 289 | 314 | layerManager.addLayer(layer2); |
| 290 | 315 | layerManager.moveLayer(layer2, 2); |
| … |
… |
public class LayerManagerTest {
|
| 299 | 324 | thrown.expectCause(any(InvocationTargetException.class)); |
| 300 | 325 | thrown.expectRootCause(any(IllegalArgumentException.class)); |
| 301 | 326 | |
| 302 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 303 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 327 | TestLayer layer1 = new TestLayer(); |
| | 328 | TestLayer layer2 = new TestLayer(); |
| 304 | 329 | layerManager.addLayer(layer1); |
| 305 | 330 | layerManager.moveLayer(layer2, 0); |
| 306 | 331 | } |
| … |
… |
public class LayerManagerTest {
|
| 311 | 336 | @Test(expected = UnsupportedOperationException.class) |
| 312 | 337 | public void testGetLayers() { |
| 313 | 338 | // list should be immutable |
| 314 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 315 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 339 | TestLayer layer1 = new TestLayer(); |
| | 340 | TestLayer layer2 = new TestLayer(); |
| 316 | 341 | layerManager.addLayer(layer1); |
| 317 | 342 | layerManager.addLayer(layer2); |
| 318 | 343 | layerManager.getLayers().remove(0); |
| … |
… |
public class LayerManagerTest {
|
| 323 | 348 | */ |
| 324 | 349 | @Test |
| 325 | 350 | public void testGetLayersOfType() { |
| 326 | | AbstractTestLayer2 layer1 = new AbstractTestLayer2(); |
| 327 | | AbstractTestLayer2 layer2 = new AbstractTestLayer2(); |
| | 351 | TestLayer2 layer1 = new TestLayer2(); |
| | 352 | TestLayer2 layer2 = new TestLayer2(); |
| 328 | 353 | layerManager.addLayer(layer1); |
| 329 | | layerManager.addLayer(new AbstractTestLayer()); |
| | 354 | layerManager.addLayer(new TestLayer()); |
| 330 | 355 | layerManager.addLayer(layer2); |
| 331 | 356 | |
| 332 | | assertEquals(layerManager.getLayersOfType(AbstractTestLayer2.class), Arrays.asList(layer1, layer2)); |
| | 357 | assertEquals(layerManager.getLayersOfType(TestLayer2.class), Arrays.asList(layer1, layer2)); |
| 333 | 358 | } |
| 334 | 359 | |
| 335 | 360 | /** |
| … |
… |
public class LayerManagerTest {
|
| 337 | 362 | */ |
| 338 | 363 | @Test |
| 339 | 364 | public void testContainsLayer() { |
| 340 | | AbstractTestLayer layer = new AbstractTestLayer(); |
| | 365 | TestLayer layer = new TestLayer(); |
| 341 | 366 | layerManager.addLayer(layer); |
| 342 | | layerManager.addLayer(new AbstractTestLayer()); |
| | 367 | layerManager.addLayer(new TestLayer()); |
| 343 | 368 | |
| 344 | 369 | assertTrue(layerManager.containsLayer(layer)); |
| 345 | | assertFalse(layerManager.containsLayer(new AbstractTestLayer())); |
| | 370 | assertFalse(layerManager.containsLayer(new TestLayer())); |
| 346 | 371 | } |
| 347 | 372 | |
| 348 | 373 | /** |
| … |
… |
public class LayerManagerTest {
|
| 373 | 398 | @Test |
| 374 | 399 | public void testAddLayerChangeListenerFire() { |
| 375 | 400 | final ArrayList<Layer> fired = new ArrayList<>(); |
| 376 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 377 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 401 | TestLayer layer1 = new TestLayer(); |
| | 402 | TestLayer layer2 = new TestLayer(); |
| 378 | 403 | layerManager.addLayer(layer1); |
| 379 | 404 | layerManager.addLayer(layer2); |
| 380 | 405 | layerManager.addLayerChangeListener(new LayerChangeListener() { |
| … |
… |
public class LayerManagerTest {
|
| 404 | 429 | public void testRemoveLayerChangeListener() { |
| 405 | 430 | CapturingLayerChangeListener l = new CapturingLayerChangeListener(); |
| 406 | 431 | layerManager.addLayerChangeListener(l); |
| 407 | | layerManager.addLayer(new AbstractTestLayer()); |
| | 432 | layerManager.addLayer(new TestLayer()); |
| 408 | 433 | layerManager.removeLayerChangeListener(l); |
| 409 | | layerManager.addLayer(new AbstractTestLayer()); |
| | 434 | layerManager.addLayer(new TestLayer()); |
| 410 | 435 | // threw exception when fired twice. |
| 411 | 436 | assertNotNull(l.layerAdded); |
| 412 | 437 | assertNull(l.layerRemoved); |
| … |
… |
public class LayerManagerTest {
|
| 428 | 453 | @Test |
| 429 | 454 | public void testRemoveLayerChangeListenerFire() { |
| 430 | 455 | final ArrayList<Layer> fired = new ArrayList<>(); |
| 431 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 432 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 456 | TestLayer layer1 = new TestLayer(); |
| | 457 | TestLayer layer2 = new TestLayer(); |
| 433 | 458 | layerManager.addLayer(layer1); |
| 434 | 459 | layerManager.addLayer(layer2); |
| 435 | 460 | LayerChangeListener listener = new LayerChangeListener() { |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/MainLayerManagerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/MainLayerManagerTest.java
index afc1c2e..c1ee42f 100644
|
a
|
b
|
public class MainLayerManagerTest extends LayerManagerTest {
|
| 67 | 67 | |
| 68 | 68 | @Test |
| 69 | 69 | public void testAddLayerSetsActiveLayer() { |
| 70 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| | 70 | TestLayer layer1 = new TestLayer(); |
| 71 | 71 | AbstractTestOsmLayer layer2 = new AbstractTestOsmLayer(); |
| 72 | | AbstractTestLayer layer3 = new AbstractTestLayer(); |
| | 72 | TestLayer layer3 = new TestLayer(); |
| 73 | 73 | assertNull(layerManagerWithActive.getActiveLayer()); |
| 74 | 74 | assertNull(layerManagerWithActive.getEditLayer()); |
| 75 | 75 | layerManagerWithActive.addLayer(layer1); |
| … |
… |
public class MainLayerManagerTest extends LayerManagerTest {
|
| 85 | 85 | |
| 86 | 86 | @Test |
| 87 | 87 | public void testRemoveLayerUnsetsActiveLayer() { |
| 88 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| | 88 | TestLayer layer1 = new TestLayer(); |
| 89 | 89 | AbstractTestOsmLayer layer2 = new AbstractTestOsmLayer(); |
| 90 | | AbstractTestLayer layer3 = new AbstractTestLayer(); |
| | 90 | TestLayer layer3 = new TestLayer(); |
| 91 | 91 | AbstractTestOsmLayer layer4 = new AbstractTestOsmLayer(); |
| 92 | 92 | layerManagerWithActive.addLayer(layer1); |
| 93 | 93 | layerManagerWithActive.addLayer(layer2); |
| … |
… |
public class MainLayerManagerTest extends LayerManagerTest {
|
| 115 | 115 | */ |
| 116 | 116 | @Test |
| 117 | 117 | public void testAddActiveLayerChangeListener() { |
| 118 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| | 118 | TestLayer layer1 = new TestLayer(); |
| 119 | 119 | AbstractTestOsmLayer layer2 = new AbstractTestOsmLayer(); |
| 120 | 120 | layerManagerWithActive.addLayer(layer1); |
| 121 | 121 | layerManagerWithActive.addLayer(layer2); |
| … |
… |
public class MainLayerManagerTest extends LayerManagerTest {
|
| 153 | 153 | */ |
| 154 | 154 | @Test |
| 155 | 155 | public void testRemoveActiveLayerChangeListener() { |
| 156 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| | 156 | TestLayer layer1 = new TestLayer(); |
| 157 | 157 | AbstractTestOsmLayer layer2 = new AbstractTestOsmLayer(); |
| 158 | 158 | layerManagerWithActive.addLayer(layer1); |
| 159 | 159 | layerManagerWithActive.addLayer(layer2); |
| … |
… |
public class MainLayerManagerTest extends LayerManagerTest {
|
| 181 | 181 | */ |
| 182 | 182 | @Test |
| 183 | 183 | public void testSetGetActiveLayer() { |
| 184 | | AbstractTestLayer layer1 = new AbstractTestLayer(); |
| 185 | | AbstractTestLayer layer2 = new AbstractTestLayer(); |
| | 184 | TestLayer layer1 = new TestLayer(); |
| | 185 | TestLayer layer2 = new TestLayer(); |
| 186 | 186 | layerManagerWithActive.addLayer(layer1); |
| 187 | 187 | layerManagerWithActive.addLayer(layer2); |
| 188 | 188 | |
| … |
… |
public class MainLayerManagerTest extends LayerManagerTest {
|
| 199 | 199 | @Test |
| 200 | 200 | public void testGetEditDataSet() { |
| 201 | 201 | assertNull(layerManagerWithActive.getEditDataSet()); |
| 202 | | AbstractTestLayer layer0 = new AbstractTestLayer(); |
| | 202 | TestLayer layer0 = new TestLayer(); |
| 203 | 203 | layerManagerWithActive.addLayer(layer0); |
| 204 | 204 | assertNull(layerManagerWithActive.getEditDataSet()); |
| 205 | 205 | |
| … |
… |
public class MainLayerManagerTest extends LayerManagerTest {
|
| 222 | 222 | public void testGetVisibleLayersInZOrder() { |
| 223 | 223 | AbstractTestOsmLayer layer1 = new AbstractTestOsmLayer(); |
| 224 | 224 | AbstractTestOsmLayer layer2 = new AbstractTestOsmLayer(); |
| 225 | | AbstractTestLayer layer3 = new AbstractTestLayer(); |
| | 225 | TestLayer layer3 = new TestLayer(); |
| 226 | 226 | layer3.setVisible(false); |
| 227 | 227 | AbstractTestOsmLayer layer4 = new AbstractTestOsmLayer(); |
| 228 | | AbstractTestLayer layer5 = new AbstractTestLayer(); |
| | 228 | TestLayer layer5 = new TestLayer(); |
| 229 | 229 | AbstractTestOsmLayer layer6 = new AbstractTestOsmLayer(); |
| 230 | 230 | AbstractTestOsmLayer layer7 = new AbstractTestOsmLayer(); |
| 231 | 231 | layerManagerWithActive.addLayer(layer1); |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java
index a893981..eb90cac 100644
|
a
|
b
|
import java.io.InputStream;
|
| 9 | 9 | import java.util.Collections; |
| 10 | 10 | import java.util.List; |
| 11 | 11 | |
| 12 | | import org.junit.BeforeClass; |
| | 12 | import org.junit.Rule; |
| 13 | 13 | import org.junit.Test; |
| 14 | | import org.openstreetmap.josm.JOSMFixture; |
| 15 | 14 | import org.openstreetmap.josm.Main; |
| 16 | 15 | import org.openstreetmap.josm.TestUtils; |
| 17 | 16 | import org.openstreetmap.josm.gui.layer.GpxLayer; |
| 18 | 17 | import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer.Loader; |
| 19 | 18 | import org.openstreetmap.josm.io.GpxReader; |
| | 19 | import org.openstreetmap.josm.testutils.JOSMTestRules; |
| | 20 | |
| | 21 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 20 | 22 | |
| 21 | 23 | /** |
| 22 | 24 | * Unit tests of {@link GeoImageLayer} class. |
| 23 | 25 | */ |
| 24 | 26 | public class GeoImageLayerTest { |
| 25 | | |
| 26 | 27 | /** |
| 27 | | * Setup test. |
| | 28 | * We need prefs for this. |
| 28 | 29 | */ |
| 29 | | @BeforeClass |
| 30 | | public static void setUpBeforeClass() { |
| 31 | | JOSMFixture.createUnitTestFixture().init(true); |
| 32 | | } |
| | 30 | @Rule |
| | 31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") |
| | 32 | public JOSMTestRules test = new JOSMTestRules().preferences(); |
| | 33 | |
| 33 | 34 | |
| 34 | 35 | /** |
| 35 | 36 | * Unit test of {@link Loader} class. |
| … |
… |
public class GeoImageLayerTest {
|
| 41 | 42 | GpxReader reader = new GpxReader(in); |
| 42 | 43 | assertTrue(reader.parse(true)); |
| 43 | 44 | GpxLayer gpxLayer = new GpxLayer(reader.getGpxData()); |
| 44 | | try { |
| 45 | | Main.getLayerManager().addLayer(gpxLayer); |
| 46 | | assertEquals(1, Main.getLayerManager().getLayers().size()); |
| 47 | | new Loader( |
| 48 | | Collections.singleton(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG"))), |
| 49 | | gpxLayer).run(); |
| 50 | | assertEquals(2, Main.getLayerManager().getLayers().size()); |
| 51 | | GeoImageLayer layer = Main.getLayerManager().getLayersOfType(GeoImageLayer.class).iterator().next(); |
| 52 | | try { |
| 53 | | assertEquals(gpxLayer, layer.getGpxLayer()); |
| 54 | | List<ImageEntry> images = layer.getImages(); |
| 55 | | assertEquals(1, images.size()); |
| 56 | | assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getInfoComponent()); |
| 57 | | assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getToolTipText()); |
| 58 | | } finally { |
| 59 | | // Ensure we clean the place before leaving, even if test fails. |
| 60 | | Main.getLayerManager().removeLayer(layer); |
| 61 | | } |
| 62 | | } finally { |
| 63 | | // Ensure we clean the place before leaving, even if test fails. |
| 64 | | Main.getLayerManager().removeLayer(gpxLayer); |
| 65 | | } |
| | 45 | Main.getLayerManager().addLayer(gpxLayer); |
| | 46 | assertEquals(1, Main.getLayerManager().getLayers().size()); |
| | 47 | new Loader( |
| | 48 | Collections.singleton(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG"))), |
| | 49 | gpxLayer).run(); |
| | 50 | assertEquals(2, Main.getLayerManager().getLayers().size()); |
| | 51 | GeoImageLayer layer = Main.getLayerManager().getLayersOfType(GeoImageLayer.class).iterator().next(); |
| | 52 | assertEquals(gpxLayer, layer.getGpxLayer()); |
| | 53 | List<ImageEntry> images = layer.getImages(); |
| | 54 | assertEquals(1, images.size()); |
| | 55 | assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getInfoComponent()); |
| | 56 | assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getToolTipText()); |
| 66 | 57 | } |
| 67 | 58 | } |
| 68 | 59 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/io/NmeaReaderTest.java b/test/unit/org/openstreetmap/josm/io/NmeaReaderTest.java
index ed3f060..88f6ad7 100644
|
a
|
b
|
import java.io.FileInputStream;
|
| 7 | 7 | import java.text.SimpleDateFormat; |
| 8 | 8 | import java.util.ArrayList; |
| 9 | 9 | import java.util.List; |
| | 10 | import java.util.TimeZone; |
| 10 | 11 | |
| 11 | 12 | import org.junit.Test; |
| 12 | 13 | import org.openstreetmap.josm.data.coor.LatLon; |
| … |
… |
public class NmeaReaderTest {
|
| 39 | 40 | assertEquals(30, in.getNumberOfCoordinates()); |
| 40 | 41 | assertEquals(0, in.getParserMalformed()); |
| 41 | 42 | |
| | 43 | TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); |
| 42 | 44 | final List<WayPoint> wayPoints = new ArrayList<>(in.data.tracks.iterator().next().getSegments().iterator().next().getWayPoints()); |
| 43 | 45 | assertEquals("2016-01-25T04:05:09.200Z", wayPoints.get(0).get(GpxConstants.PT_TIME)); |
| 44 | 46 | assertEquals("2016-01-25T04:05:09.400Z", wayPoints.get(1).get(GpxConstants.PT_TIME)); |
-
diff --git a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
index 91b7082..a6033d0 100644
|
a
|
b
|
package org.openstreetmap.josm.testutils;
|
| 3 | 3 | |
| 4 | 4 | import java.io.File; |
| 5 | 5 | import java.io.IOException; |
| | 6 | import java.util.TimeZone; |
| 6 | 7 | |
| 7 | 8 | import org.junit.rules.DisableOnDebug; |
| 8 | 9 | import org.junit.rules.TemporaryFolder; |
| … |
… |
public class JOSMTestRules implements TestRule {
|
| 162 | 163 | |
| 163 | 164 | // Tests are running headless by default. |
| 164 | 165 | System.setProperty("java.awt.headless", "true"); |
| | 166 | // All tests use the same timezone. |
| | 167 | TimeZone.setDefault(TimeZone.getTimeZone("UTC")); |
| | 168 | // Set log level to info |
| | 169 | Main.logLevel = 3; |
| 165 | 170 | |
| 166 | 171 | // Set up i18n |
| 167 | 172 | if (i18n != null) { |