Changeset 15333 in josm for trunk/test/unit
- Timestamp:
- 2019-09-02T22:35:07+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/ImageDataTest.java
r14615 r15333 33 33 34 34 @Test 35 public void testWith ullData() {35 public void testWithNullData() { 36 36 ImageData data = new ImageData(); 37 37 assertEquals(0, data.getImages().size()); … … 88 88 ImageData data = new ImageData(list); 89 89 data.selectFirstImage(); 90 assertEquals(list.get(0), data.getSelectedImage()); 90 assertEquals(1, data.getSelectedImages().size()); 91 assertEquals(list.get(0), data.getSelectedImages().get(0)); 91 92 } 92 93 … … 98 99 ImageData data = new ImageData(list); 99 100 data.selectLastImage(); 100 assertEquals(list.get(1), data.getSelectedImage()); 101 assertEquals(1, data.getSelectedImages().size()); 102 assertEquals(list.get(1), data.getSelectedImages().get(0)); 101 103 } 102 104 … … 108 110 assertTrue(data.hasNextImage()); 109 111 data.selectNextImage(); 110 assertEquals(list.get(0), data.getSelectedImage()); 112 assertEquals(1, data.getSelectedImages().size()); 113 assertEquals(list.get(0), data.getSelectedImages().get(0)); 111 114 assertFalse(data.hasNextImage()); 112 115 data.selectNextImage(); 113 assertEquals(list.get(0), data.getSelectedImage ());116 assertEquals(list.get(0), data.getSelectedImages().get(0)); 114 117 } 115 118 … … 124 127 assertTrue(data.hasPreviousImage()); 125 128 data.selectPreviousImage(); 126 assertEquals(list.get(0), data.getSelectedImage()); 129 assertEquals(1, data.getSelectedImages().size()); 130 assertEquals(list.get(0), data.getSelectedImages().get(0)); 127 131 data.selectPreviousImage(); 128 assertEquals(list.get(0), data.getSelectedImage ());132 assertEquals(list.get(0), data.getSelectedImages().get(0)); 129 133 } 130 134 … … 135 139 ImageData data = new ImageData(list); 136 140 data.setSelectedImage(list.get(0)); 137 assertEquals(list.get(0), data.getSelectedImage()); 138 } 139 140 @Test 141 public void testClearSelectedImage() { 141 assertEquals(1, data.getSelectedImages().size()); 142 assertEquals(list.get(0), data.getSelectedImages().get(0)); 143 } 144 145 @Test 146 public void testClearSelectedImages() { 142 147 List<ImageEntry> list = getOneImage(); 143 148 … … 145 150 data.setSelectedImage(list.get(0)); 146 151 data.clearSelectedImage(); 147 assert Null(data.getSelectedImage());152 assertTrue(data.getSelectedImages().isEmpty()); 148 153 } 149 154 … … 174 179 data.removeSelectedImage(); 175 180 assertEquals(0, data.getImages().size()); 176 assert Null(data.getSelectedImage());181 assertEquals(0, data.getSelectedImages().size()); 177 182 } 178 183 … … 238 243 data.mergeFrom(data2); 239 244 assertEquals(3, data.getImages().size()); 240 assertEquals(list1.get(0), data.getSelectedImage()); 245 assertEquals(1, data.getSelectedImages().size()); 246 assertEquals(list1.get(0), data.getSelectedImages().get(0)); 241 247 } 242 248 … … 254 260 data.mergeFrom(data2); 255 261 assertEquals(3, data.getImages().size()); 256 assertEquals(list2.get(0), data.getSelectedImage()); 262 assertEquals(1, data.getSelectedImages().size()); 263 assertEquals(list2.get(0), data.getSelectedImages().get(0)); 264 } 265 266 @Test 267 public void testAddImageToSelection() { 268 List<ImageEntry> list = getOneImage(); 269 list.add(new ImageEntry(new File("test2"))); 270 271 ImageData data = new ImageData(list); 272 data.addImageToSelection(list.get(0)); 273 data.addImageToSelection(list.get(0)); 274 assertEquals(1, data.getSelectedImages().size()); 275 data.addImageToSelection(list.get(1)); 276 assertEquals(2, data.getSelectedImages().size()); 277 } 278 279 @Test 280 public void testRemoveImageToSelection() { 281 List<ImageEntry> list = getOneImage(); 282 list.add(new ImageEntry()); 283 284 ImageData data = new ImageData(list); 285 data.selectLastImage(); 286 data.removeImageToSelection(list.get(1)); 287 assertEquals(0, data.getSelectedImages().size()); 288 data.selectFirstImage(); 289 assertEquals(1, data.getSelectedImages().size()); 290 291 } 292 293 @Test 294 public void testIsSelected() { 295 List<ImageEntry> list = getOneImage(); 296 list.add(new ImageEntry(new File("test2"))); 297 298 ImageData data = new ImageData(list); 299 assertFalse(data.isImageSelected(list.get(0))); 300 data.selectFirstImage(); 301 assertTrue(data.isImageSelected(list.get(0))); 302 data.addImageToSelection(list.get(1)); 303 assertTrue(data.isImageSelected(list.get(0))); 304 assertTrue(data.isImageSelected(list.get(1))); 305 assertFalse(data.isImageSelected(new ImageEntry())); 306 } 307 308 @Test 309 public void testActionsWithMultipleImagesSelected() { 310 List<ImageEntry> list = this.getOneImage(); 311 list.add(new ImageEntry(new File("test2"))); 312 list.add(new ImageEntry(new File("test3"))); 313 list.add(new ImageEntry(new File("test3"))); 314 315 ImageData data = new ImageData(list); 316 data.addImageToSelection(list.get(1)); 317 data.addImageToSelection(list.get(2)); 318 319 assertFalse(data.hasNextImage()); 320 assertFalse(data.hasPreviousImage()); 321 322 data.clearSelectedImage(); 323 assertEquals(0, data.getSelectedImages().size()); 324 data.addImageToSelection(list.get(1)); 325 data.selectFirstImage(); 326 assertEquals(1, data.getSelectedImages().size()); 327 } 328 329 @Test 330 public void testTriggerListenerWhenNewImageIsSelectedAndRemoved() { 331 List<ImageEntry> list = this.getOneImage(); 332 list.add(new ImageEntry()); 333 ImageData data = new ImageData(list); 334 ImageDataUpdateListener listener = new ImageDataUpdateListener() { 335 @Override 336 public void selectedImageChanged(ImageData data) {} 337 338 @Override 339 public void imageDataUpdated(ImageData data) {} 340 }; 341 new Expectations(listener) {{ 342 listener.selectedImageChanged(data); times = 3; 343 }}; 344 data.addImageDataUpdateListener(listener); 345 data.selectFirstImage(); 346 data.addImageToSelection(list.get(1)); 347 data.removeImageToSelection(list.get(0)); 257 348 } 258 349
Note:
See TracChangeset
for help on using the changeset viewer.