Changeset 17279 in josm for trunk/test/unit/org/openstreetmap/josm/gui
- Timestamp:
- 2020-10-29T00:51:28+01:00 (3 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/dialogs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r17275 r17279 3 3 4 4 import static java.util.concurrent.TimeUnit.MILLISECONDS; 5 import static org.junit. jupiter.api.Assertions.fail;6 import static org.junit. jupiter.api.Assertions.assertArrayEquals;7 import static org.junit. jupiter.api.Assertions.assertEquals;8 import static org.junit. jupiter.api.Assertions.assertFalse;9 import static org.junit. jupiter.api.Assertions.assertTrue;5 import static org.junit.Assert.assertArrayEquals; 6 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.assertFalse; 8 import static org.junit.Assert.assertTrue; 9 import static org.junit.Assert.fail; 10 10 import static org.openstreetmap.josm.tools.I18n.tr; 11 11 … … 28 28 29 29 import org.awaitility.Awaitility; 30 import org.junit. jupiter.api.Test;31 import org.junit. jupiter.api.extension.RegisterExtension;30 import org.junit.Rule; 31 import org.junit.Test; 32 32 import org.openstreetmap.josm.TestUtils; 33 33 import org.openstreetmap.josm.data.Bounds; … … 55 55 * Unit tests of {@link MinimapDialog} class. 56 56 */ 57 class MinimapDialogTest {57 public class MinimapDialogTest { 58 58 59 59 /** 60 60 * Setup tests 61 61 */ 62 @R egisterExtension62 @Rule 63 63 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 64 64 public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().fakeImagery(); … … 68 68 */ 69 69 @Test 70 void testMinimapDialog() {70 public void testMinimapDialog() { 71 71 MinimapDialog dlg = new MinimapDialog(); 72 72 dlg.showDialog(); … … 102 102 assertEquals(equalText, isSelected); 103 103 if (equalText) { 104 assertFalse( found, "Second selected source found");104 assertFalse("Second selected source found", found); 105 105 found = true; 106 106 } 107 107 } 108 108 } 109 assertTrue( found, "Selected source not found in menu");109 assertTrue("Selected source not found in menu", found); 110 110 } 111 111 … … 199 199 */ 200 200 @Test 201 void testSourceSwitching() throws Exception {201 public void testSourceSwitching() throws Exception { 202 202 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 203 203 // (not that there's a data layer for it to use) … … 246 246 */ 247 247 @Test 248 void testRefreshSourcesRetainsSelection() throws Exception {248 public void testRefreshSourcesRetainsSelection() throws Exception { 249 249 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 250 250 // (not that there's a data layer for it to use) … … 284 284 */ 285 285 @Test 286 void testRemovedSourceStillSelected() throws Exception {286 public void testRemovedSourceStillSelected() throws Exception { 287 287 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 288 288 // (not that there's a data layer for it to use) … … 317 317 */ 318 318 @Test 319 void testTileSourcesFromCurrentLayers() throws Exception {319 public void testTileSourcesFromCurrentLayers() throws Exception { 320 320 // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled 321 321 // (not that there's a data layer for it to use) … … 451 451 */ 452 452 @Test 453 void testSourcePrefObeyed() throws Exception {453 public void testSourcePrefObeyed() throws Exception { 454 454 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 455 455 … … 478 478 */ 479 479 @Test 480 void testSourcePrefInvalid() throws Exception {480 public void testSourcePrefInvalid() throws Exception { 481 481 Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles"); 482 482 … … 500 500 */ 501 501 @Test 502 void testViewportAspectRatio() throws Exception {502 public void testViewportAspectRatio() throws Exception { 503 503 // Add a test layer to the layer manager to get the MapFrame & MapView 504 504 MainApplication.getLayerManager().addLayer(new TestLayer()); … … 546 546 // should equal the number on the right 547 547 assertTrue( 548 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4,549 "Viewport marker not horizontally centered"548 "Viewport marker not horizontally centered", 549 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4 550 550 ); 551 551 … … 561 561 // should equal the number on the bottom 562 562 assertTrue( 563 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4,564 "Viewport marker not vertically centered"563 "Viewport marker not vertically centered", 564 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4 565 565 ); 566 566 567 567 // (within a tolerance for numerical error) the viewport marker should be square 568 568 assertTrue( 569 Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4,570 "Viewport marker not square"569 "Viewport marker not square", 570 Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4 571 571 ); 572 572 … … 591 591 ); 592 592 assertTrue( 593 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4,594 "Viewport marker not horizontally centered"593 "Viewport marker not horizontally centered", 594 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4 595 595 ); 596 596 … … 603 603 ); 604 604 assertTrue( 605 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4,606 "Viewport marker not vertically centered"605 "Viewport marker not vertically centered", 606 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4 607 607 ); 608 608 … … 614 614 615 615 assertTrue( 616 Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5,617 "Viewport marker not 2:1 aspect ratio"616 "Viewport marker not 2:1 aspect ratio", 617 Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5 618 618 ); 619 619 } … … 624 624 for (Component c: menu.getComponents()) { 625 625 if (JPopupMenu.Separator.class.isInstance(c)) { 626 assertFalse( afterSeparator, "More than one separator before target item");626 assertFalse("More than one separator before target item", afterSeparator); 627 627 afterSeparator = true; 628 628 } else if (((JMenuItem) c).getText().equals(tr("Show downloaded area"))) { 629 assertTrue( afterSeparator, "Separator not found before target item");630 assertTrue( JCheckBoxMenuItem.class.isInstance(c), "Target item doesn't appear to be a JCheckBoxMenuItem");629 assertTrue("Separator not found before target item", afterSeparator); 630 assertTrue("Target item doesn't appear to be a JCheckBoxMenuItem", JCheckBoxMenuItem.class.isInstance(c)); 631 631 return (JCheckBoxMenuItem) c; 632 632 } … … 641 641 */ 642 642 @Test 643 void testShowDownloadedArea() throws Exception {643 public void testShowDownloadedArea() throws Exception { 644 644 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 645 645 Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false); … … 800 800 */ 801 801 @Test 802 void testShowDownloadedAreaLayerSwitching() throws Exception {802 public void testShowDownloadedAreaLayerSwitching() throws Exception { 803 803 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 804 804 Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java
r17275 r17279 2 2 package org.openstreetmap.josm.gui.dialogs.layer; 3 3 4 import static org.junit. jupiter.api.Assertions.assertEquals;4 import static org.junit.Assert.assertEquals; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import org.junit. jupiter.api.BeforeEach;8 import org.junit. jupiter.api.Test;9 import org.junit. jupiter.api.extension.RegisterExtension;7 import org.junit.Before; 8 import org.junit.Rule; 9 import org.junit.Test; 10 10 import org.openstreetmap.josm.data.imagery.ImageryInfo; 11 11 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; … … 24 24 * @author Taylor Smock 25 25 */ 26 class CycleLayerActionTest {26 public class CycleLayerActionTest { 27 27 /** Layers need a projection */ 28 @R egisterExtension28 @Rule 29 29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 30 30 public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().fakeImagery(); … … 37 37 * Set up common items (make layers, etc.) 38 38 */ 39 @Before Each39 @Before 40 40 public void setUp() { 41 41 cycleDown = new CycleLayerDownAction(); … … 51 51 */ 52 52 @Test 53 void testDownBottom() {53 public void testDownBottom() { 54 54 manager.setActiveLayer(manager.getLayers().get(0)); 55 55 cycleDown.actionPerformed(null); … … 61 61 */ 62 62 @Test 63 void testUpTop() {63 public void testUpTop() { 64 64 manager.setActiveLayer(manager.getLayers().get(manager.getLayers().size() - 1)); 65 65 cycleUp.actionPerformed(null); … … 71 71 */ 72 72 @Test 73 void testDown() {73 public void testDown() { 74 74 manager.setActiveLayer(manager.getLayers().get(3)); 75 75 cycleDown.actionPerformed(null); … … 81 81 */ 82 82 @Test 83 void testUp() {83 public void testUp() { 84 84 manager.setActiveLayer(manager.getLayers().get(3)); 85 85 cycleUp.actionPerformed(null); … … 91 91 */ 92 92 @Test 93 void testNoLayers() {93 public void testNoLayers() { 94 94 manager.getLayers().forEach(manager::removeLayer); 95 95 cycleUp.actionPerformed(null); … … 102 102 */ 103 103 @Test 104 void testWithAerialImagery() {104 public void testWithAerialImagery() { 105 105 final ImageryInfo magentaTilesInfo = ImageryLayerInfo.instance.getLayers().stream() 106 106 .filter(i -> i.getName().equals("Magenta Tiles")).findAny().get();
Note:
See TracChangeset
for help on using the changeset viewer.