Changeset 8937 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2015-10-24T00:54:52+02:00 (9 years ago)
Author:
Don-vip
Message:

add unit tests to check validity of all map paint styles and tagging presets

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r8512 r8937  
    1111import java.util.Arrays;
    1212import java.util.Collection;
     13import java.util.Collections;
    1314import java.util.HashSet;
    1415import java.util.LinkedList;
     
    266267            }
    267268        }
    268         if (Main.isDebugEnabled()) {
     269        if (Main.isDebugEnabled() || !source.getErrors().isEmpty()) {
    269270            final long elapsedTime = System.currentTimeMillis() - startTime;
    270             Main.debug("Initializing map style " + source.url + " completed in " + Utils.getDurationString(elapsedTime));
     271            String message = "Initializing map style " + source.url + " completed in " + Utils.getDurationString(elapsedTime);
     272            if (!source.getErrors().isEmpty()) {
     273                Main.warn(message + " (" + source.getErrors().size() + " errors)");
     274            } else {
     275                Main.debug(message);
     276            }
    271277        }
    272278    }
     
    433439    }
    434440
    435     public static void addStyle(SourceEntry entry) {
     441    /**
     442     * Add a new map paint style.
     443     * @param entry map paint style
     444     * @return list of errors that occured during loading
     445     */
     446    public static Collection<Throwable> addStyle(SourceEntry entry) {
    436447        StyleSource source = fromSourceEntry(entry);
    437448        if (source != null) {
     
    441452            fireMapPaintSylesUpdated();
    442453            styles.clearCached();
    443             Main.map.mapView.repaint();
    444         }
     454            if (Main.isDisplayingMapView()) {
     455                Main.map.mapView.repaint();
     456            }
     457            return source.getErrors();
     458        }
     459        return Collections.emptyList();
    445460    }
    446461
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r8926 r8937  
    8383    public static final String OPTIONAL_TOOLTIP_TEXT = "Optional tooltip text";
    8484
     85    /** Prefix of preset icon loading failure error message */
     86    public static final String PRESET_ICON_ERROR_MSG_PREFIX = "Could not get presets icon ";
     87
    8588    public TaggingPresetMenu group;
    8689    public String name;
     
    166169     * Called from the XML parser to set the icon.
    167170     * The loading task is performed in the background in order to speedup startup.
     171     * @param iconName icon name
    168172     */
    169173    public void setIcon(final String iconName) {
     
    190194                    });
    191195                } else {
    192                     Main.warn("Could not get presets icon " + iconName);
     196                    Main.warn(PRESET_ICON_ERROR_MSG_PREFIX + iconName);
    193197                }
    194198            }
Note: See TracChangeset for help on using the changeset viewer.