Changeset 13112 in josm
- Timestamp:
- 2017-11-12T00:54:15+01:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.classpath
r13110 r13112 22 22 <classpathentry kind="lib" path="test/lib/unitils-core/unitils-core-3.4.6.jar"/> 23 23 <classpathentry kind="lib" path="test/lib/commons-testing/commons-testing-2.1.0.jar"/> 24 <classpathentry kind="lib" path="test/lib/wiremock-standalone-2.10.1.jar"/> 24 <classpathentry exported="true" kind="lib" path="test/lib/wiremock-standalone-2.10.1.jar"/> 25 <classpathentry exported="true" kind="lib" path="test/lib/awaitility-3.0.0.jar"/> 25 26 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 26 27 <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/> -
trunk/netbeans/nbproject/project.properties
r13110 r13112 59 59 file.reference.system-rules-1.16.1.jar=../test/lib/system-rules-1.16.1.jar 60 60 file.reference.wiremock-standalone-2.10.1.jar=../test/lib/wiremock-standalone-2.10.1.jar 61 file.reference.awaitility-3.0.0.jar=../test/lib/awaitility-3.0.0.jar 61 62 includes=**/*.java 62 63 jar.compress=false … … 94 95 ${file.reference.system-rules-1.16.1.jar}:\ 95 96 ${file.reference.wiremock-standalone-2.10.1.jar}:\ 97 ${file.reference.awaitility-3.0.0.jar}:\ 96 98 ${file.reference.spotbugs.jar}:\ 97 99 ${file.reference.commons-testing-2.1.0.jar} -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
r12539 r13112 127 127 } 128 128 129 @Override 130 public boolean hasOutstandingTasks() { 131 return downloadExecutor.getTaskCount() > downloadExecutor.getCompletedTaskCount(); 132 } 133 129 134 /** 130 135 * Sets the download executor that will be used to download tiles instead of default one. -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r13078 r13112 7 7 import static org.junit.Assert.fail; 8 8 9 import static java.util.concurrent.TimeUnit.MILLISECONDS; 10 9 11 import java.awt.Color; 10 12 import java.awt.Component; … … 15 17 import javax.swing.JPopupMenu; 16 18 19 import java.util.concurrent.Callable; 20 17 21 import org.junit.Rule; 18 22 import org.junit.Test; 23 import org.openstreetmap.josm.Main; 19 24 import org.openstreetmap.josm.TestUtils; 20 25 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; … … 23 28 24 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 30 31 import org.awaitility.Awaitility; 25 32 26 33 /** … … 79 86 } 80 87 88 protected MinimapDialog minimap; 89 protected SlippyMapBBoxChooser slippyMap; 90 protected SourceButton sourceButton; 91 92 protected static BufferedImage paintedSlippyMap; 93 94 protected void setUpMiniMap() throws Exception { 95 this.minimap = new MinimapDialog(); 96 this.minimap.setSize(300, 200); 97 this.minimap.showDialog(); 98 this.slippyMap = (SlippyMapBBoxChooser) TestUtils.getPrivateField(this.minimap, "slippyMap"); 99 this.sourceButton = (SourceButton) TestUtils.getPrivateField(this.slippyMap, "iSourceButton"); 100 101 // get dlg in a paintable state 102 this.minimap.addNotify(); 103 this.minimap.doLayout(); 104 } 105 106 protected void paintSlippyMap() { 107 if (paintedSlippyMap == null || 108 paintedSlippyMap.getWidth() != this.slippyMap.getSize().width || 109 paintedSlippyMap.getHeight() != this.slippyMap.getSize().height) { 110 paintedSlippyMap = new BufferedImage( 111 this.slippyMap.getSize().width, 112 this.slippyMap.getSize().height, 113 BufferedImage.TYPE_INT_RGB 114 ); 115 } // else reuse existing one - allocation is expensive 116 117 // clear background to a recognizably "wrong" color & dispose our Graphics2D so we don't risk carrying over 118 // any state 119 Graphics2D g = paintedSlippyMap.createGraphics(); 120 g.setBackground(Color.BLUE); 121 g.clearRect(0, 0, paintedSlippyMap.getWidth(), paintedSlippyMap.getHeight()); 122 g.dispose(); 123 124 g = paintedSlippyMap.createGraphics(); 125 this.slippyMap.paintAll(g); 126 } 127 128 protected Callable<Boolean> slippyMapTasksFinished() { 129 return () -> !this.slippyMap.getTileController().getTileLoader().hasOutstandingTasks(); 130 } 131 81 132 /** 82 133 * Tests to switch imagery source. … … 85 136 @Test 86 137 public void testSourceSwitching() throws Exception { 87 MinimapDialog dlg = new MinimapDialog(); 88 dlg.setSize(300, 200); 89 dlg.showDialog(); 90 SlippyMapBBoxChooser slippyMap = (SlippyMapBBoxChooser) TestUtils.getPrivateField(dlg, "slippyMap"); 91 SourceButton sourceButton = (SourceButton) TestUtils.getPrivateField(slippyMap, "iSourceButton"); 92 93 // get dlg in a paintable state 94 dlg.addNotify(); 95 dlg.doLayout(); 96 97 BufferedImage image = new BufferedImage( 98 slippyMap.getSize().width, 99 slippyMap.getSize().height, 100 BufferedImage.TYPE_INT_RGB 101 ); 102 103 Graphics2D g = image.createGraphics(); 138 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 139 // (not that there's a data layer for it to use) 140 141 this.setUpMiniMap(); 142 104 143 // an initial paint operation is required to trigger the tile fetches 105 slippyMap.paintAll(g); 106 g.setBackground(Color.BLUE); 107 g.clearRect(0, 0, image.getWidth(), image.getHeight()); 108 g.dispose(); 109 110 Thread.sleep(500); 111 112 g = image.createGraphics(); 113 slippyMap.paintAll(g); 114 115 assertEquals(0xffffffff, image.getRGB(0, 0)); 116 117 assertSingleSelectedSourceLabel(sourceButton.getPopupMenu(), "White Tiles"); 118 119 getSourceMenuItemByLabel(sourceButton.getPopupMenu(), "Magenta Tiles").doClick(); 120 assertSingleSelectedSourceLabel(sourceButton.getPopupMenu(), "Magenta Tiles"); 144 this.paintSlippyMap(); 145 146 Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished()); 147 148 this.paintSlippyMap(); 149 150 assertEquals(0xffffffff, paintedSlippyMap.getRGB(0, 0)); 151 152 assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "White Tiles"); 153 154 getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles").doClick(); 155 assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles"); 121 156 // call paint to trigger new tile fetch 122 slippyMap.paintAll(g); 123 124 // clear background to a recognizably "wrong" color & dispose our Graphics2D so we don't risk carrying over 125 // any state 126 g.setBackground(Color.BLUE); 127 g.clearRect(0, 0, image.getWidth(), image.getHeight()); 128 g.dispose(); 129 130 Thread.sleep(500); 131 132 g = image.createGraphics(); 133 slippyMap.paintAll(g); 134 135 assertEquals(0xffff00ff, image.getRGB(0, 0)); 136 137 getSourceMenuItemByLabel(sourceButton.getPopupMenu(), "Green Tiles").doClick(); 138 assertSingleSelectedSourceLabel(sourceButton.getPopupMenu(), "Green Tiles"); 157 this.paintSlippyMap(); 158 159 Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished()); 160 161 this.paintSlippyMap(); 162 163 assertEquals(0xffff00ff, paintedSlippyMap.getRGB(0, 0)); 164 165 getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Green Tiles").doClick(); 166 assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Green Tiles"); 139 167 // call paint to trigger new tile fetch 140 slippyMap.paintAll(g); 141 142 g.setBackground(Color.BLUE); 143 g.clearRect(0, 0, image.getWidth(), image.getHeight()); 144 g.dispose(); 145 146 Thread.sleep(500); 147 148 g = image.createGraphics(); 149 slippyMap.paintAll(g); 150 151 assertEquals(0xff00ff00, image.getRGB(0, 0)); 168 this.paintSlippyMap(); 169 170 Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished()); 171 172 this.paintSlippyMap(); 173 174 assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0)); 175 176 assertEquals("Green Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail")); 177 } 178 179 /** 180 * Tests minimap obeys a saved "mapstyle" preference on startup. 181 * @throws Exception if any error occurs 182 */ 183 @Test 184 public void testSourcePrefObeyed() throws Exception { 185 Main.pref.put("slippy_map_chooser.mapstyle", "Green Tiles"); 186 187 this.setUpMiniMap(); 188 189 assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Green Tiles"); 190 191 // an initial paint operation is required to trigger the tile fetches 192 this.paintSlippyMap(); 193 194 Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished()); 195 196 this.paintSlippyMap(); 197 198 assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0)); 199 200 getSourceMenuItemByLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles").doClick(); 201 assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "Magenta Tiles"); 202 203 assertEquals("Magenta Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail")); 204 } 205 206 /** 207 * Tests minimap handles an unrecognized "mapstyle" preference on startup 208 * @throws Exception if any error occurs 209 */ 210 @Test 211 public void testSourcePrefInvalid() throws Exception { 212 Main.pref.put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles"); 213 214 this.setUpMiniMap(); 215 216 assertSingleSelectedSourceLabel(this.sourceButton.getPopupMenu(), "White Tiles"); 217 218 // an initial paint operation is required to trigger the tile fetches 219 this.paintSlippyMap(); 220 221 Awaitility.await().atMost(1000, MILLISECONDS).until(this.slippyMapTasksFinished()); 222 223 this.paintSlippyMap(); 224 225 assertEquals(0xffffffff, paintedSlippyMap.getRGB(0, 0)); 152 226 } 153 227 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
r12636 r13112 29 29 @Rule 30 30 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 31 public JOSMTestRules test = new JOSMTestRules().platform().main().projection(); 31 public JOSMTestRules test = new JOSMTestRules().platform().main().projection().timeout(20000); 32 32 33 33 /**
Note:
See TracChangeset
for help on using the changeset viewer.