Ignore:
Timestamp:
2017-04-23T19:14:12+02:00 (7 years ago)
Author:
Don-vip
Message:

add unit test for Main.postConstructorProcessCmdLine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r11531 r11986  
    5757     */
    5858    private static final BooleanProperty USE_NEW_LAYER = new BooleanProperty("download.newlayer", false);
     59    /**
     60     * the list of download tasks
     61     */
    5962    protected final transient List<Class<? extends DownloadTask>> downloadTasks;
    6063
     
    200203     * @param newLayer true if the URL needs to be opened in a new layer, false otherwise
    201204     * @param url The URL to open
    202      */
    203     public void openUrl(boolean newLayer, String url) {
    204         realOpenUrl(newLayer, url);
     205     * @return the list of tasks that have been started successfully (can be empty).
     206     * @since 11986 (return type)
     207     */
     208    public List<Future<?>> openUrl(boolean newLayer, String url) {
     209        return realOpenUrl(newLayer, url);
    205210    }
    206211
     
    208213     * Open the given URL. This class checks the {@link #USE_NEW_LAYER} preference to check if a new layer should be used.
    209214     * @param url The URL to open
    210      * @return <code>true</code> if at least one task was started successfully.
    211      * @since 11279
    212      */
    213     public boolean openUrl(String url) {
     215     * @return the list of tasks that have been started successfully (can be empty).
     216     * @since 11986 (return type)
     217     */
     218    public List<Future<?>> openUrl(String url) {
    214219        return realOpenUrl(USE_NEW_LAYER.get(), url);
    215220    }
    216221
    217     private boolean realOpenUrl(boolean newLayer, String url) {
     222    private List<Future<?>> realOpenUrl(boolean newLayer, String url) {
    218223        Collection<DownloadTask> tasks = findDownloadTasks(url, false);
    219224
     
    222227        } else if (tasks.isEmpty()) {
    223228            warnNoSuitableTasks(url);
    224             return false;
     229            return Collections.emptyList();
    225230        }
    226231
    227232        PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data"));
    228233
    229         boolean hadAnySuccess = false;
     234        List<Future<?>> result = new ArrayList<>();
    230235        for (final DownloadTask task : tasks) {
    231236            try {
    232                 Future<?> future = task.loadUrl(newLayer, url, monitor);
    233                 Main.worker.submit(new PostDownloadHandler(task, future));
    234                 hadAnySuccess = true;
     237                result.add(Main.worker.submit(new PostDownloadHandler(task, task.loadUrl(newLayer, url, monitor))));
    235238            } catch (IllegalArgumentException e) {
    236239                Main.error(e);
    237240            }
    238241        }
    239         return hadAnySuccess;
     242        return result;
    240243    }
    241244
Note: See TracChangeset for help on using the changeset viewer.