Changeset 9841 in josm for trunk/test


Ignore:
Timestamp:
2016-02-20T01:34:07+01:00 (4 years ago)
Author:
Don-vip
Message:

add unit test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java

    r9669 r9841  
    22package org.openstreetmap.josm.gui.io;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.Assert.assertEquals;
    55
    66import org.junit.BeforeClass;
    77import org.junit.Test;
    88import org.openstreetmap.josm.JOSMFixture;
     9import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.io.OsmApi;
     11import org.openstreetmap.josm.io.OsmApiInitializationException;
     12import org.openstreetmap.josm.io.OsmTransferCanceledException;
    913
    1014/**
     
    1923    public static void setUpBeforeClass() {
    2024        JOSMFixture.createUnitTestFixture().init();
     25        try {
     26            OsmApi.getOsmApi().initialize(null);
     27        } catch (OsmTransferCanceledException | OsmApiInitializationException e) {
     28            Main.error(e);
     29        }
    2130    }
    2231
     
    2635    @Test
    2736    public void testUploadStrategySelectionPanel() {
    28         assertNotNull(new UploadStrategySelectionPanel());
     37        UploadStrategySelectionPanel p = new UploadStrategySelectionPanel();
     38        p.setNumUploadedObjects(Integer.MAX_VALUE);
     39        p.rememberUserInput();
     40        p.initFromPreferences();
     41        p.initEditingOfChunkSize();
     42    }
     43
     44    /**
     45     * Test of {@link UploadStrategySelectionPanel#setUploadStrategySpecification}
     46     *       / {@link UploadStrategySelectionPanel#getUploadStrategySpecification}.
     47     */
     48    @Test
     49    public void testUploadStrategySpecification() {
     50        UploadStrategySelectionPanel p = new UploadStrategySelectionPanel();
     51
     52        UploadStrategySpecification def = new UploadStrategySpecification();
     53        assertEquals(def, p.getUploadStrategySpecification());
     54        p.setUploadStrategySpecification(null);
     55        assertEquals(def, p.getUploadStrategySpecification());
     56
     57        UploadStrategySpecification strat = new UploadStrategySpecification().setStrategy(UploadStrategy.INDIVIDUAL_OBJECTS_STRATEGY);
     58        p.setUploadStrategySpecification(strat);
     59        assertEquals(strat, p.getUploadStrategySpecification());
    2960    }
    3061}
Note: See TracChangeset for help on using the changeset viewer.