Changeset 12045 in josm


Ignore:
Timestamp:
2017-05-03T13:50:39+02:00 (21 months ago)
Author:
michael2402
Message:

PropertiesMergerTest: Test that buttons have been added.

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r11978 r12045  
    66
    77import java.awt.Component;
     8import java.awt.Container;
    89import java.awt.Graphics2D;
    910import java.io.File;
     
    1718import java.util.Collection;
    1819import java.util.Comparator;
     20import java.util.Objects;
     21import java.util.stream.Stream;
    1922
    2023import org.openstreetmap.josm.command.Command;
     
    307310        }
    308311    }
     312
     313    /**
     314     * Get a descendant component by name.
     315     * @param root The root component to start searching from.
     316     * @param name The component name
     317     * @return The component with that name or null if it does not exist.
     318     * @since 12045
     319     */
     320    public static Component getComponentByName(Component root, String name) {
     321        if (name.equals(root.getName())) {
     322            return root;
     323        } else if (root instanceof Container) {
     324            Container container = (Container) root;
     325            return Stream.of(container.getComponents())
     326                    .map(child -> getComponentByName(child, name))
     327                    .filter(Objects::nonNull)
     328                    .findFirst().orElse(null);
     329        } else {
     330            return null;
     331        }
     332    }
    309333}
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java

    r10962 r12045  
    66import org.junit.Rule;
    77import org.junit.Test;
     8import org.openstreetmap.josm.TestUtils;
    89import org.openstreetmap.josm.testutils.JOSMTestRules;
    910
     
    2728    @Test
    2829    public void testPropertiesMerger() {
    29         assertNotNull(new PropertiesMerger());
     30        PropertiesMerger merger = new PropertiesMerger();
     31        assertNotNull(TestUtils.getComponentByName(merger, "button.keepmycoordinates"));
     32        assertNotNull(TestUtils.getComponentByName(merger, "button.keeptheircoordinates"));
     33        assertNotNull(TestUtils.getComponentByName(merger, "button.undecidecoordinates"));
     34        assertNotNull(TestUtils.getComponentByName(merger, "button.keepmydeletedstate"));
     35        assertNotNull(TestUtils.getComponentByName(merger, "button.keeptheirdeletedstate"));
     36        assertNotNull(TestUtils.getComponentByName(merger, "button.undecidedeletedstate"));
    3037    }
    3138}
Note: See TracChangeset for help on using the changeset viewer.